[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] emacs-25 040e0d6: Fix 'toggle-save-place'
From: |
Stefan Monnier |
Subject: |
Re: [Emacs-diffs] emacs-25 040e0d6: Fix 'toggle-save-place' |
Date: |
Thu, 25 Feb 2016 12:05:06 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> It makes no sense not to autoload it, because then there's no way for
> users to turn save-place in a single buffer. Previously, users needed
> to load saveplace.el to have the feature, so an autoload was not
> needed.
But that still works "as well as before"
(i.e. as long as they (require 'saveplace)).
> But the changes which switched to save-place-mode invalidated
> that paradigm, and created a deficiency, which I fixed. (They also
> broke the command, which I also fixed.)
I think I'm beginning to understand, yes, thanks.
> I have nothing against having a local mode, but I don't have time to
> work on this now, so patches are very welcome.
I think I have something better, but I think some of the changes are too
late for 25.1, so I suggest we install the patch below (which against
forces users to use (require 'saveplace) before calling
toggle-save-place, like before: it's not ideal, but it's not
a regression).
Stefan
2016-02-25 Stefan Monnier <address@hidden>
* (toggle-save-place): Don't autoload yet (will do it in 26 when we
rename it and turn it into a minor mode). Avoid obsolete var
`save-place'. Don't remove hooks.
lisp/saveplace.el (save-place-mode): Remove global find-file-hook
since we also add it globally.
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index 0233a52..b7c77a4 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -136,14 +136,13 @@ save-place-mode
(add-hook 'kill-emacs-hook 'save-place-kill-emacs-hook))
(add-hook 'kill-buffer-hook 'save-place-to-alist))
(t
- (remove-hook 'find-file-hook 'save-place-find-file-hook t)
+ (remove-hook 'find-file-hook 'save-place-find-file-hook)
(remove-hook 'dired-initial-position-hook 'save-place-dired-hook)
(remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook)
(remove-hook 'kill-buffer-hook 'save-place-to-alist))))
(make-variable-buffer-local 'save-place-mode) ; Hysterical raisins.
-;;;###autoload
(defun toggle-save-place (&optional parg) ;FIXME: save-place-local-mode!
"Toggle whether to save your place in this file between sessions.
If this mode is enabled, point is recorded when you kill the buffer
@@ -167,17 +166,21 @@ toggle-save-place
(> (prefix-numeric-value parg) 0)
(not save-place)))
(cond
- (save-place
+ (save-place-mode
(add-hook 'find-file-hook 'save-place-find-file-hook t)
(add-hook 'dired-initial-position-hook 'save-place-dired-hook)
(unless noninteractive
(add-hook 'kill-emacs-hook 'save-place-kill-emacs-hook))
(add-hook 'kill-buffer-hook 'save-place-to-alist))
(t
- (remove-hook 'find-file-hook 'save-place-find-file-hook t)
- (remove-hook 'dired-initial-position-hook 'save-place-dired-hook)
- (remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook)
- (remove-hook 'kill-buffer-hook 'save-place-to-alist)))
+ ;; FIXME: We should remove the hooks, but only in case this was the last
+ ;; buffer using save-place-local-mode. Is it worth the trouble, tho?
+ ;; (unless (default-value 'save-place-mode)
+ ;; (remove-hook 'find-file-hook 'save-place-find-file-hook)
+ ;; (remove-hook 'dired-initial-position-hook 'save-place-dired-hook)
+ ;; (remove-hook 'kill-emacs-hook 'save-place-kill-emacs-hook)
+ ;; (remove-hook 'kill-buffer-hook 'save-place-to-alist))
+ ))
(message (if save-place
"Place will be saved"
"No place will be saved in this file"))))