]> git.eshelyaron.com Git - emacs.git/commitdiff
(custom-save-all): Avoid destrying symlink if already visiting the
authorChong Yidong <cyd@stupidchicken.com>
Sat, 2 Aug 2008 21:10:05 +0000 (21:10 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Sat, 2 Aug 2008 21:10:05 +0000 (21:10 +0000)
custom file.

lisp/cus-edit.el

index 0446102eb09d260dd1b8bf6acb3a46643c2aed7a..5201256bcabe02c215b9380dc6bdd797e1cb5836 100644 (file)
@@ -4207,9 +4207,17 @@ if only the first line of the docstring is shown."))
                             (recentf-expand-file-name (custom-file)))
                            "\\'")
                    recentf-exclude)))
-        (old-buffer (find-buffer-visiting filename)))
+        (old-buffer (find-buffer-visiting filename))
+        old-buffer-name)
     (with-current-buffer (let ((find-file-visit-truename t))
                           (or old-buffer (find-file-noselect filename)))
+      ;; We'll save using file-precious-flag, so avoid destroying
+      ;; symlinks.  (If we're not already visiting the buffer, this is
+      ;; handled by find-file-visit-truename, above.)
+      (when old-buffer
+       (setq old-buffer-name (buffer-file-name))
+       (set-visited-file-name (file-chase-links filename)))
+
       (unless (eq major-mode 'emacs-lisp-mode)
        (emacs-lisp-mode))
       (let ((inhibit-read-only t))
@@ -4217,7 +4225,10 @@ if only the first line of the docstring is shown."))
        (custom-save-faces))
       (let ((file-precious-flag t))
        (save-buffer))
-      (unless old-buffer
+      (if old-buffer
+         (progn
+           (set-visited-file-name old-buffer-name)
+           (set-buffer-modified-p nil))
        (kill-buffer (current-buffer))))))
 
 ;;;###autoload