From: Juri Linkov Date: Sat, 27 Dec 2014 00:38:34 +0000 (+0200) Subject: Support subdirectories when saving places in dired. X-Git-Tag: emacs-25.0.90~2631^2~15^2~25 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d51459246bf54316f3a22694bf9eda0bfcc18a6a;p=emacs.git Support subdirectories when saving places in dired. * lisp/saveplace.el (toggle-save-place, save-place-to-alist) (save-places-to-alist, save-place-dired-hook): Use dired-current-directory instead of dired-directory. (save-place-dired-hook): Add check for alist to make the new format future-proof to allow other possible formats. Fixes: debbugs:19436 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 52146e4bf8a..0c321732918 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,12 @@ +2014-12-27 Juri Linkov + + Support subdirectories when saving places in dired. + * saveplace.el (toggle-save-place, save-place-to-alist) + (save-places-to-alist, save-place-dired-hook): + Use dired-current-directory instead of dired-directory (bug#19436). + (save-place-dired-hook): Add check for alist to make the new + format future-proof to allow other possible formats. + 2014-12-26 Fabián Ezequiel Gallina python.el: Generate clearer shell buffer names. diff --git a/lisp/saveplace.el b/lisp/saveplace.el index a25dba2e39e..18e34cfcaa3 100644 --- a/lisp/saveplace.el +++ b/lisp/saveplace.el @@ -153,7 +153,7 @@ file: \(setq-default save-place t)" (interactive "P") (if (not (or buffer-file-name (and (derived-mode-p 'dired-mode) - dired-directory))) + (dired-current-directory)))) (message "Buffer `%s' not visiting a file or directory" (buffer-name)) (setq save-place (if parg (> (prefix-numeric-value parg) 0) @@ -172,12 +172,13 @@ file: ;; file. If not, do so, then feel free to modify the alist. It ;; will be saved again when Emacs is killed. (or save-place-loaded (load-save-place-alist-from-file)) - (let ((item (or buffer-file-name - (and (derived-mode-p 'dired-mode) - dired-directory - (expand-file-name (if (consp dired-directory) - (car dired-directory) - dired-directory)))))) + (let* ((directory (and (derived-mode-p 'dired-mode) + (dired-current-directory))) + (item (or buffer-file-name + (and directory + (expand-file-name (if (consp directory) + (car directory) + directory)))))) (when (and item (or (not save-place-ignore-files-regexp) (not (string-match save-place-ignore-files-regexp @@ -186,8 +187,7 @@ file: (position (cond ((eq major-mode 'hexl-mode) (with-no-warnings (1+ (hexl-current-address)))) - ((and (derived-mode-p 'dired-mode) - dired-directory) + ((and (derived-mode-p 'dired-mode) directory) (let ((filename (dired-get-filename nil t))) (if filename `((dired-filename . ,filename)) @@ -305,7 +305,7 @@ may have changed) back to `save-place-alist'." ;; save-place checks buffer-file-name too, but we can avoid ;; overhead of function call by checking here too. (and (or buffer-file-name (and (derived-mode-p 'dired-mode) - dired-directory)) + (dired-current-directory))) (save-place-to-alist)) (setq buf-list (cdr buf-list)))))) @@ -325,19 +325,21 @@ may have changed) back to `save-place-alist'." (defun save-place-dired-hook () "Position the point in a Dired buffer." (or save-place-loaded (load-save-place-alist-from-file)) - (let ((cell (assoc (and (derived-mode-p 'dired-mode) - dired-directory - (expand-file-name (if (consp dired-directory) - (car dired-directory) - dired-directory))) - save-place-alist))) + (let* ((directory (and (derived-mode-p 'dired-mode) + (dired-current-directory))) + (cell (assoc (and directory + (expand-file-name (if (consp directory) + (car directory) + directory))) + save-place-alist))) (if cell (progn (or revert-buffer-in-progress-p - (if (integerp (cdr cell)) - (goto-char (cdr cell)) - (and (assq 'dired-filename (cdr cell)) - (dired-goto-file (cdr (assq 'dired-filename (cdr cell))))))) + (cond + ((integerp (cdr cell)) + (goto-char (cdr cell))) + ((and (listp (cdr cell)) (assq 'dired-filename (cdr cell))) + (dired-goto-file (cdr (assq 'dired-filename (cdr cell))))))) ;; and make sure it will be saved again for later (setq save-place t)))))