diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-22 17:29:58 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-05-22 17:30:34 -0700 |
commit | 18a9bc1152452fecfa09e6f2f3a5d6677a564977 (patch) | |
tree | b711a60aeab9ba2b9719fbb5dfdf9d14abf1d288 /lisp/emacs-lisp | |
parent | 2671179b11a9423792aaf2439a26a2562679c086 (diff) | |
download | emacs-18a9bc1152452fecfa09e6f2f3a5d6677a564977.tar.gz emacs-18a9bc1152452fecfa09e6f2f3a5d6677a564977.tar.bz2 emacs-18a9bc1152452fecfa09e6f2f3a5d6677a564977.zip |
Do not trash symlinks to init file
If the user’s init file is a symbolic link, do not break the link
when initializing the package system. Problem reported by Jackson
Hamilton (Bug#23050).
* lisp/emacs-lisp/package.el (package--ensure-init-file):
Bind find-file-visit-truename when visiting the init file, and
save and restore the buffer name the way cus-edit does in a
similar situation (Bug#454).
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/package.el | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index b0a6db087ba..14626e2f28f 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1869,6 +1869,7 @@ add a call to it along with some explanatory comments." (file-readable-p user-init-file) (file-writable-p user-init-file)) (let* ((buffer (find-buffer-visiting user-init-file)) + buffer-name (contains-init (if buffer (with-current-buffer buffer @@ -1884,8 +1885,12 @@ add a call to it along with some explanatory comments." (re-search-forward "(package-initialize\\_>" nil 'noerror))))) (unless contains-init (with-current-buffer (or buffer - (let ((delay-mode-hooks t)) + (let ((delay-mode-hooks t) + (find-file-visit-truename t)) (find-file-noselect user-init-file))) + (when buffer + (setq buffer-name (buffer-file-name)) + (set-visited-file-name (file-chase-links user-init-file))) (save-excursion (save-restriction (widen) @@ -1904,7 +1909,10 @@ add a call to it along with some explanatory comments." (insert "\n")) (let ((file-precious-flag t)) (save-buffer)) - (unless buffer + (if buffer + (progn + (set-visited-file-name buffer-name) + (set-buffer-modified-p nil)) (kill-buffer (current-buffer))))))))) (setq package--init-file-ensured t)) |