diff options
author | Glenn Morris <rgm@gnu.org> | 2015-06-11 20:34:54 -0400 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2015-06-11 20:34:54 -0400 |
commit | ebbc6a4782c279527c52d6b1d8b379517aeec2d5 (patch) | |
tree | 13294b8212776555f38defad43d82c8e0020510f /lisp | |
parent | 32e53667a91ed479743175d5698a89b163c8be94 (diff) | |
download | emacs-ebbc6a4782c279527c52d6b1d8b379517aeec2d5.tar.gz |
Some progress towards starting with PWD deleted. (Bug#18851)
* src/buffer.c (init_buffer): Handle get_current_dir_name failures.
* lisp/startup.el (normal-top-level, command-line-1):
* lisp/minibuffer.el (read-file-name-default):
Handle default-directory being nil.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/minibuffer.el | 2 | ||||
-rw-r--r-- | lisp/startup.el | 47 |
2 files changed, 32 insertions, 17 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 60b89b6d521..bf18adf361b 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2572,7 +2572,7 @@ and `read-file-name-function'." (defun read-file-name-default (prompt &optional dir default-filename mustmatch initial predicate) "Default method for reading file names. See `read-file-name' for the meaning of the arguments." - (unless dir (setq dir default-directory)) + (unless dir (setq dir (or default-directory "~/"))) (unless (file-name-absolute-p dir) (setq dir (expand-file-name dir))) (unless default-filename (setq default-filename (if initial (expand-file-name initial dir) diff --git a/lisp/startup.el b/lisp/startup.el index 3c9ada682d3..b638ed50cc6 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -592,9 +592,10 @@ It is the default value of the variable `top-level'." ;; describes the directory linked to, not FOO itself. (or (equal (file-attributes (concat (file-name-as-directory pwd) ".")) - (file-attributes - (concat (file-name-as-directory default-directory) - "."))) + (if default-directory + (file-attributes + (concat (file-name-as-directory default-directory) + ".")))) (setq process-environment (delete (concat "PWD=" pwd) process-environment))))) @@ -609,12 +610,19 @@ It is the default value of the variable `top-level'." (mapcar (lambda (dir) (decode-coding-string dir coding t)) charset-map-path)))) - (setq default-directory (abbreviate-file-name default-directory)) + (if default-directory + (setq default-directory (abbreviate-file-name default-directory)) + ;; FIXME this does not get shown. + ;; If after (command-line), it is shown, but if command-line + ;; changed the buffer (eg found a file), it applies to that + ;; buffer, not *scratch*. + (display-warning 'initialization "Error setting default-directory")) (let ((old-face-font-rescale-alist face-font-rescale-alist)) (unwind-protect (command-line) ;; Do this again, in case .emacs defined more abbreviations. - (setq default-directory (abbreviate-file-name default-directory)) + (if default-directory + (setq default-directory (abbreviate-file-name default-directory))) ;; Specify the file for recording all the auto save files of this session. ;; This is used by recover-session. (or auto-save-list-file-name @@ -2193,19 +2201,26 @@ A fancy display is used on graphic displays, normal otherwise." ;; to zero when `process-file-arg' returns. (process-file-arg (lambda (name) - (let* ((file (expand-file-name + ;; If a relative filename was specified and + ;; command-line-default-directory is nil, + ;; silently drop that argument. + ;; This can only happen if PWD is deleted. + ;; The warning about setting default-directory will + ;; clue you in. + (when (and (or dir (file-name-absolute-p name)) + (let* ((file (expand-file-name (command-line-normalize-file-name name) dir)) - (buf (find-file-noselect file))) - (setq displayable-buffers (cons buf displayable-buffers)) - (with-current-buffer buf - (unless (zerop line) - (goto-char (point-min)) - (forward-line (1- line))) - (setq line 0) - (unless (< column 1) - (move-to-column (1- column))) - (setq column 0)))))) + (buf (find-file-noselect file))) + (setq displayable-buffers (cons buf displayable-buffers)) + (with-current-buffer buf + (unless (zerop line) + (goto-char (point-min)) + (forward-line (1- line))) + (setq line 0) + (unless (< column 1) + (move-to-column (1- column))) + (setq column 0)))))))) ;; Add the long X options to longopts. (dolist (tem command-line-x-option-alist) |