summaryrefslogtreecommitdiff
path: root/lisp/files.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-11-25 22:55:35 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2017-11-25 22:55:35 -0800
commitd20161b25e9cd184d841ba9e36ee5141c01fd75f (patch)
tree6026fea9d48e641bf63b23209970efd1f8024e2c /lisp/files.el
parente27004c5fe3c227476ea210ff5bee2efb783ae17 (diff)
parenta89f0b6f33f9eb8910a1fceda9028d76ef50b05d (diff)
downloademacs-d20161b25e9cd184d841ba9e36ee5141c01fd75f.tar.gz
Merge from origin/emacs-26
a89f0b6f33 maint: shorten https://lists.gnu.org/archive/html/... links 8be3aee281 Merge from Gnulib 265cee553f Work around GCC bug 80776 on Fedora 27 x86 dc7a97fb84 Tweak copy-file, rename-file doc cfa2a944d4 Change font-lock-extend-region-multiline handling in mhtml... a8664cc998 Minor cleanup in tramp-gvfs-handle-file-local-copy 55c5b12fa0 Add test for Bug#29423 in Tramp. 3198a1646e Avoid jumbled order in HTML rendered by shr.el 23bfc2d2db Make sure 'dired-filename' property is always put by ls-lisp f7fdaea4c0 A better solution for bug#29347 86e6ed8521 ; * src/thread.c (acquire_global_lock): Fix thinko in last... f300852037 Avoid a hang after C-g while sit-for on a Unix TTY d7fc719ff1 Improve the doc string of 'list-packages' b4f67ebb92 Improve discoverability of 'defvar' for suppressing warnings 8a2b204e64 Improve discoverability of 'read-buffer-completion-ignore-... eea4e9194c Improve documentation of self-insert-uses-region-functions e6e41dac87 Reflect changes in copy-file and rename-file in doc strings 0ec534070f * lisp/progmodes/cc-vars.el (c-offsets-alist): Doc fix. (... 1d0dbdff6c Reorder type predicates in ELisp manual b081ec9dd7 Fix backward scrolling in buffers with header-line 8e40429c96 ; Fix some doc typos ed2c542920 * lisp/bindings.el (buffer-file-coding-system): Add explic... d82474e452 * src/fns.c (syms_of_fns) <overriding-plist-environment>: ... 292c09ff6d Fix incorrect interaction of drag/drop and double click (b... d6fadb1d26 * lisp/menu-bar.el (menu-bar-options-save): Add display-li... daa959efbc * lisp/menu-bar.el (menu-bar-options-save): Add global-dis... 17fc74d1b9 * lisp/follow.el (follow-mode): Restore mode line lighter.... f20c2e2f3d ; Compare process status against 127 exactly 2d203ffb7e Extract the common part of ruby-flymake-simple and ruby-fl... 09944d499a Add Rubocop Flymake backend c65a0ae7c4 ; Fix a typo 7ab7603125 Update nt/INSTALL.W64 (Bug#28601) 11db253c08 Remove incorrect NEWS item about VC state indicator (Bug#2... 2fdc01c036 * lisp/emacs-lisp/byte-run.el (defsubst): Doc fix. 735c8b516e Make c-defun-name analyze more thoroughly a function type ... 92f0c4cd56 Avoid bogus abbreviated file names if HOME changes 8d450453fa * lisp/emacs-lisp/byte-run.el (inline): Give it a doc. 37a3b4ea40 Fix erc keep-place module with new defaults (Bug#29111) 6c312605bf Add window divider faces to NS (bug#29353) # Conflicts: # etc/NEWS # lisp/ruler-mode.el
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el58
1 files changed, 34 insertions, 24 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 63dd509eab8..5d78cd07b6e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1859,9 +1859,9 @@ home directory is a root directory) and removes automounter prefixes
When this function is first called, it caches the user's home
directory as a regexp in `abbreviated-home-dir', and reuses it
-afterwards. Lisp programs that temporarily set the home directory
-to a different value should let-bind `abbreviated-home-dir' for
-the modified home directory to take effect."
+afterwards (so long as the home directory does not change;
+if you want to permanently change your home directory after having
+started Emacs, set `abbreviated-home-dir' to nil so it will be recalculated)."
;; Get rid of the prefixes added by the automounter.
(save-match-data
(if (and automount-dir-prefix
@@ -1883,29 +1883,37 @@ the modified home directory to take effect."
;; give time for directory-abbrev-alist to be set properly.
;; We include a slash at the end, to avoid spurious matches
;; such as `/usr/foobar' when the home dir is `/usr/foo'.
- (or abbreviated-home-dir
- (setq abbreviated-home-dir
- (let ((abbreviated-home-dir "$foo"))
- (setq abbreviated-home-dir
- (concat "\\`"
- (abbreviate-file-name (expand-file-name "~"))
- "\\(/\\|\\'\\)"))
- ;; Depending on whether default-directory does or
- ;; doesn't include non-ASCII characters, the value
- ;; of abbreviated-home-dir could be multibyte or
- ;; unibyte. In the latter case, we need to decode
- ;; it. Note that this function is called for the
- ;; first time (from startup.el) when
- ;; locale-coding-system is already set up.
- (if (multibyte-string-p abbreviated-home-dir)
- abbreviated-home-dir
- (decode-coding-string abbreviated-home-dir
- (if (eq system-type 'windows-nt)
- 'utf-8
- locale-coding-system))))))
+ (unless abbreviated-home-dir
+ (put 'abbreviated-home-dir 'home (expand-file-name "~"))
+ (setq abbreviated-home-dir
+ (let ((abbreviated-home-dir "$foo"))
+ (setq abbreviated-home-dir
+ (concat "\\`"
+ (abbreviate-file-name
+ (get 'abbreviated-home-dir 'home))
+ "\\(/\\|\\'\\)"))
+ ;; Depending on whether default-directory does or
+ ;; doesn't include non-ASCII characters, the value
+ ;; of abbreviated-home-dir could be multibyte or
+ ;; unibyte. In the latter case, we need to decode
+ ;; it. Note that this function is called for the
+ ;; first time (from startup.el) when
+ ;; locale-coding-system is already set up.
+ (if (multibyte-string-p abbreviated-home-dir)
+ abbreviated-home-dir
+ (decode-coding-string abbreviated-home-dir
+ (if (eq system-type 'windows-nt)
+ 'utf-8
+ locale-coding-system))))))
;; If FILENAME starts with the abbreviated homedir,
+ ;; and ~ hasn't changed since abbreviated-home-dir was set,
;; make it start with `~' instead.
+ ;; If ~ has changed, we ignore abbreviated-home-dir rather than
+ ;; invalidating it, on the assumption that a change in HOME
+ ;; is likely temporary (eg for testing).
+ ;; FIXME Is it even worth caching abbreviated-home-dir?
+ ;; Ref: https://debbugs.gnu.org/19657#20
(if (and (string-match abbreviated-home-dir filename)
;; If the home dir is just /, don't change it.
(not (and (= (match-end 0) 1)
@@ -1914,7 +1922,9 @@ the modified home directory to take effect."
;; Novell Netware allows drive letters beyond `Z:'.
(not (and (memq system-type '(ms-dos windows-nt cygwin))
(save-match-data
- (string-match "^[a-zA-`]:/$" filename)))))
+ (string-match "^[a-zA-`]:/$" filename))))
+ (equal (get 'abbreviated-home-dir 'home)
+ (expand-file-name "~")))
(setq filename
(concat "~"
(match-string 1 filename)