]> git.eshelyaron.com Git - emacs.git/commitdiff
remember-data-file: Don't unconditionally call set-visited-file-name
authorSean Whitton <spwhitton@spwhitton.name>
Wed, 25 Sep 2024 15:02:53 +0000 (16:02 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 30 Sep 2024 19:39:32 +0000 (21:39 +0200)
* lisp/textmodes/remember.el (remember-data-file): Don't
unconditionally call set-visited-file-name.

(cherry picked from commit 794bb2a2e31f3027e1db9e027af28151f11a32ed)

lisp/textmodes/remember.el

index c75a9b758e7168295d0f1edd4493a5054cf78816..cc3496da33caad3ce8fece9f89b2c613d27816fe 100644 (file)
@@ -378,8 +378,15 @@ exists) might be changed."
            (set-default symbol value)
            (when (buffer-live-p buf)
              (with-current-buffer buf
-               (set-visited-file-name
-                (expand-file-name remember-data-file))))))
+               ;; Don't unconditionally call `set-visited-file-name'
+               ;; because that will probably change the major mode and
+               ;; rename the buffer.
+               ;; These must be avoided in the case where
+               ;; `remember-notes-buffer-name' is "*scratch*", a
+               ;; supported configuration.
+               (let ((value (expand-file-name value)))
+                 (unless (string= buffer-file-name value)
+                   (set-visited-file-name value)))))))
   :initialize #'custom-initialize-default)
 
 (defcustom remember-leader-text "** "