[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19436: 24.4; dired-insert-subdir with saveplace
From: |
Juri Linkov |
Subject: |
bug#19436: 24.4; dired-insert-subdir with saveplace |
Date: |
Thu, 25 Dec 2014 21:31:28 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (x86_64-pc-linux-gnu) |
> On `dired-insert-subdir' with saveplace on, point goes to random place.
>
> 0. emacs -Q
> 1. (require 'saveplace)
> 2. (setq-default save-place t)
> 3. M-x dired
> 4. M-x dired-insert-subdir
> 5. I expect point goes to top of the new inserted directory.
> However, it goes to random place.
> 6. It seems that it has something to do with dired-initial-position-hook
> in dired-initial-position.
Thanks for the report. Subdir saving was not supported by
dired-initial-position until now. It's implemented by this patch:
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index a25dba2..a081794 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -153,7 +153,7 @@ (defun toggle-save-place (&optional parg)
\(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 @@ (defun save-place-to-alist ()
;; 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 @@ (defun save-place-to-alist ()
(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 @@ (defun save-places-to-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,12 +325,13 @@ (declare-function dired-goto-file "dired" (file))
(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