From: Juri Linkov <juri@linkov.net>
To: Tak Kunihiro <tak.kunihiro@gmail.com>
Cc: 19436@debbugs.gnu.org
Subject: bug#19436: 24.4; dired-insert-subdir with saveplace
Date: Thu, 25 Dec 2014 21:31:28 +0200 [thread overview]
Message-ID: <87mw6bh7uf.fsf@mail.linkov.net> (raw)
In-Reply-To: <20141224.232401.279982387.tak.kunihiro@gmail.com> (Tak Kunihiro's message of "Wed, 24 Dec 2014 23:24:01 +0900 (JST)")
> 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
next prev parent reply other threads:[~2014-12-25 19:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-24 14:24 bug#19436: 24.4; dired-insert-subdir with saveplace Tak Kunihiro
2014-12-25 19:31 ` Juri Linkov [this message]
2014-12-27 0:40 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mw6bh7uf.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=19436@debbugs.gnu.org \
--cc=tak.kunihiro@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).