diff options
| author | Paul Eggert | 2016-05-22 17:29:58 -0700 |
|---|---|---|
| committer | Paul Eggert | 2016-05-22 17:30:34 -0700 |
| commit | 18a9bc1152452fecfa09e6f2f3a5d6677a564977 (patch) | |
| tree | b711a60aeab9ba2b9719fbb5dfdf9d14abf1d288 | |
| parent | 2671179b11a9423792aaf2439a26a2562679c086 (diff) | |
| download | emacs-18a9bc1152452fecfa09e6f2f3a5d6677a564977.tar.gz 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).
| -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." | |||
| 1869 | (file-readable-p user-init-file) | 1869 | (file-readable-p user-init-file) |
| 1870 | (file-writable-p user-init-file)) | 1870 | (file-writable-p user-init-file)) |
| 1871 | (let* ((buffer (find-buffer-visiting user-init-file)) | 1871 | (let* ((buffer (find-buffer-visiting user-init-file)) |
| 1872 | buffer-name | ||
| 1872 | (contains-init | 1873 | (contains-init |
| 1873 | (if buffer | 1874 | (if buffer |
| 1874 | (with-current-buffer buffer | 1875 | (with-current-buffer buffer |
| @@ -1884,8 +1885,12 @@ add a call to it along with some explanatory comments." | |||
| 1884 | (re-search-forward "(package-initialize\\_>" nil 'noerror))))) | 1885 | (re-search-forward "(package-initialize\\_>" nil 'noerror))))) |
| 1885 | (unless contains-init | 1886 | (unless contains-init |
| 1886 | (with-current-buffer (or buffer | 1887 | (with-current-buffer (or buffer |
| 1887 | (let ((delay-mode-hooks t)) | 1888 | (let ((delay-mode-hooks t) |
| 1889 | (find-file-visit-truename t)) | ||
| 1888 | (find-file-noselect user-init-file))) | 1890 | (find-file-noselect user-init-file))) |
| 1891 | (when buffer | ||
| 1892 | (setq buffer-name (buffer-file-name)) | ||
| 1893 | (set-visited-file-name (file-chase-links user-init-file))) | ||
| 1889 | (save-excursion | 1894 | (save-excursion |
| 1890 | (save-restriction | 1895 | (save-restriction |
| 1891 | (widen) | 1896 | (widen) |
| @@ -1904,7 +1909,10 @@ add a call to it along with some explanatory comments." | |||
| 1904 | (insert "\n")) | 1909 | (insert "\n")) |
| 1905 | (let ((file-precious-flag t)) | 1910 | (let ((file-precious-flag t)) |
| 1906 | (save-buffer)) | 1911 | (save-buffer)) |
| 1907 | (unless buffer | 1912 | (if buffer |
| 1913 | (progn | ||
| 1914 | (set-visited-file-name buffer-name) | ||
| 1915 | (set-buffer-modified-p nil)) | ||
| 1908 | (kill-buffer (current-buffer))))))))) | 1916 | (kill-buffer (current-buffer))))))))) |
| 1909 | (setq package--init-file-ensured t)) | 1917 | (setq package--init-file-ensured t)) |
| 1910 | 1918 | ||