]> git.eshelyaron.com Git - emacs.git/commitdiff
Support subdirectories when saving places in dired.
authorJuri Linkov <juri@linkov.net>
Sat, 27 Dec 2014 00:38:34 +0000 (02:38 +0200)
committerJuri Linkov <juri@linkov.net>
Sat, 27 Dec 2014 00:38:34 +0000 (02:38 +0200)
* 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
lisp/ChangeLog
lisp/saveplace.el

index 52146e4bf8a579dc927640e0cae47a531b4947c6..0c321732918a41b677f282344e05d1b95e61fe35 100644 (file)
@@ -1,3 +1,12 @@
+2014-12-27  Juri Linkov  <juri@linkov.net>
+
+       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  <fgallina@gnu.org>
 
        python.el: Generate clearer shell buffer names.
index a25dba2e39ecf6d658f60233401d747ba6953985..18e34cfcaa3949d2dd04aeda66490047b0eab043 100644 (file)
@@ -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)))))