aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2016-02-24 22:56:32 +0200
committerEli Zaretskii2016-02-24 22:56:32 +0200
commit040e0d6b3b9e7222707ba96a57f3abeef1f5fe88 (patch)
treedb3175a320e0519b4753b81124c26ae1f29e139d
parent5244db29158aed4b3430329cbc48c1c925e1c36a (diff)
downloademacs-040e0d6b3b9e7222707ba96a57f3abeef1f5fe88.tar.gz
emacs-040e0d6b3b9e7222707ba96a57f3abeef1f5fe88.zip
Fix 'toggle-save-place'
* lisp/saveplace.el (toggle-save-place): Set up hooks necessary to support save-place in the buffer. Autoload the command.
-rw-r--r--lisp/saveplace.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index c27df150248..0233a5259a0 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -143,6 +143,7 @@ where it was when you previously visited the same file."
143 143
144(make-variable-buffer-local 'save-place-mode) ; Hysterical raisins. 144(make-variable-buffer-local 'save-place-mode) ; Hysterical raisins.
145 145
146;;;###autoload
146(defun toggle-save-place (&optional parg) ;FIXME: save-place-local-mode! 147(defun toggle-save-place (&optional parg) ;FIXME: save-place-local-mode!
147 "Toggle whether to save your place in this file between sessions. 148 "Toggle whether to save your place in this file between sessions.
148If this mode is enabled, point is recorded when you kill the buffer 149If this mode is enabled, point is recorded when you kill the buffer
@@ -165,6 +166,18 @@ file:
165 (setq save-place (if parg 166 (setq save-place (if parg
166 (> (prefix-numeric-value parg) 0) 167 (> (prefix-numeric-value parg) 0)
167 (not save-place))) 168 (not save-place)))
169 (cond
170 (save-place
171 (add-hook 'find-file-hook 'save-place-find-file-hook t)
172 (add-hook 'dired-initial-position-hook 'save-place-dired-hook)
173 (unless noninteractive
174 (add-hook 'kill-emacs-hook 'save-place-kill-emacs-hook))
175 (add-hook 'kill-buffer-hook 'save-place-to-alist))
176 (t
177 (remove-hook 'find-file-hook 'save-place-find-file-hook t)
178 (remove-hook 'dired-initial-position-hook 'save-place-dired-hook)
179 (remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook)
180 (remove-hook 'kill-buffer-hook 'save-place-to-alist)))
168 (message (if save-place 181 (message (if save-place
169 "Place will be saved" 182 "Place will be saved"
170 "No place will be saved in this file")))) 183 "No place will be saved in this file"))))