Commit 71f16bda authored by Juri Linkov's avatar Juri Linkov
Browse files

* lisp/saveplace.el (toggle-save-place, save-place-to-alist)

(save-places-to-alist, save-place-dired-hook): Add (derived-mode-p
'dired-mode) before checking for dired-directory.

Fixes: debbugs:16477
parent 3c5a4839
2014-01-20 Juri Linkov <juri@jurta.org>
* saveplace.el (toggle-save-place, save-place-to-alist)
(save-places-to-alist, save-place-dired-hook): Add (derived-mode-p
'dired-mode) before checking for dired-directory. (Bug#16477)
2014-01-20 Juri Linkov <juri@jurta.org> 2014-01-20 Juri Linkov <juri@jurta.org>
* indent.el (indent-line-to): Use backward-to-indentation * indent.el (indent-line-to): Use backward-to-indentation
......
...@@ -152,7 +152,8 @@ file: ...@@ -152,7 +152,8 @@ file:
\(setq-default save-place t\)" \(setq-default save-place t\)"
(interactive "P") (interactive "P")
(if (not (or buffer-file-name dired-directory)) (if (not (or buffer-file-name (and (derived-mode-p 'dired-mode)
dired-directory)))
(message "Buffer `%s' not visiting a file or directory" (buffer-name)) (message "Buffer `%s' not visiting a file or directory" (buffer-name))
(if (and save-place (or (not parg) (<= parg 0))) (if (and save-place (or (not parg) (<= parg 0)))
(progn (progn
...@@ -172,10 +173,11 @@ file: ...@@ -172,10 +173,11 @@ file:
;; will be saved again when Emacs is killed. ;; will be saved again when Emacs is killed.
(or save-place-loaded (load-save-place-alist-from-file)) (or save-place-loaded (load-save-place-alist-from-file))
(let ((item (or buffer-file-name (let ((item (or buffer-file-name
(and dired-directory (and (derived-mode-p 'dired-mode)
(if (consp dired-directory) dired-directory
(expand-file-name (car dired-directory)) (expand-file-name (if (consp dired-directory)
(expand-file-name dired-directory)))))) (car dired-directory)
dired-directory))))))
(when (and item (when (and item
(or (not save-place-ignore-files-regexp) (or (not save-place-ignore-files-regexp)
(not (string-match save-place-ignore-files-regexp (not (string-match save-place-ignore-files-regexp
...@@ -184,7 +186,8 @@ file: ...@@ -184,7 +186,8 @@ file:
(position (cond ((eq major-mode 'hexl-mode) (position (cond ((eq major-mode 'hexl-mode)
(with-no-warnings (with-no-warnings
(1+ (hexl-current-address)))) (1+ (hexl-current-address))))
(dired-directory ((and (derived-mode-p 'dired-mode)
dired-directory)
(let ((filename (dired-get-filename nil t))) (let ((filename (dired-get-filename nil t)))
(if filename (if filename
`((dired-filename . ,filename)) `((dired-filename . ,filename))
...@@ -301,7 +304,8 @@ may have changed\) back to `save-place-alist'." ...@@ -301,7 +304,8 @@ may have changed\) back to `save-place-alist'."
(with-current-buffer (car buf-list) (with-current-buffer (car buf-list)
;; save-place checks buffer-file-name too, but we can avoid ;; save-place checks buffer-file-name too, but we can avoid
;; overhead of function call by checking here too. ;; overhead of function call by checking here too.
(and (or buffer-file-name dired-directory) (and (or buffer-file-name (and (derived-mode-p 'dired-mode)
dired-directory))
(save-place-to-alist)) (save-place-to-alist))
(setq buf-list (cdr buf-list)))))) (setq buf-list (cdr buf-list))))))
...@@ -321,9 +325,11 @@ may have changed\) back to `save-place-alist'." ...@@ -321,9 +325,11 @@ may have changed\) back to `save-place-alist'."
(defun save-place-dired-hook () (defun save-place-dired-hook ()
"Position the point in a dired buffer." "Position the point in a dired buffer."
(or save-place-loaded (load-save-place-alist-from-file)) (or save-place-loaded (load-save-place-alist-from-file))
(let ((cell (assoc (if (consp dired-directory) (let ((cell (assoc (and (derived-mode-p 'dired-mode)
(expand-file-name (car dired-directory)) dired-directory
(expand-file-name dired-directory)) (expand-file-name (if (consp dired-directory)
(car dired-directory)
dired-directory)))
save-place-alist))) save-place-alist)))
(if cell (if cell
(progn (progn
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment