From: Chong Yidong Date: Sat, 2 Aug 2008 21:07:20 +0000 (+0000) Subject: (custom-save-all): Avoid destrying symlink if already visiting the X-Git-Tag: emacs-pretest-23.0.90~3685 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ac1831635bc3132f02e10cc855665a67e5085529;p=emacs.git (custom-save-all): Avoid destrying symlink if already visiting the custom file. --- diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index e39a50f3a8e..918f43a9da0 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el @@ -4265,9 +4265,18 @@ 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)) @@ -4275,7 +4284,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