mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-23 22:20:24 -08:00
(abbreviate-file-name): Add save-match-data.
This commit is contained in:
parent
d735cf50f7
commit
f663a1ce37
1 changed files with 42 additions and 41 deletions
|
|
@ -1275,48 +1275,49 @@ Choose the buffer's name using `generate-new-buffer-name'."
|
||||||
This also substitutes \"~\" for the user's home directory and
|
This also substitutes \"~\" for the user's home directory and
|
||||||
removes automounter prefixes (see the variable `automount-dir-prefix')."
|
removes automounter prefixes (see the variable `automount-dir-prefix')."
|
||||||
;; Get rid of the prefixes added by the automounter.
|
;; Get rid of the prefixes added by the automounter.
|
||||||
(if (and automount-dir-prefix
|
(save-match-data
|
||||||
(string-match automount-dir-prefix filename)
|
(if (and automount-dir-prefix
|
||||||
(file-exists-p (file-name-directory
|
(string-match automount-dir-prefix filename)
|
||||||
(substring filename (1- (match-end 0))))))
|
(file-exists-p (file-name-directory
|
||||||
(setq filename (substring filename (1- (match-end 0)))))
|
(substring filename (1- (match-end 0))))))
|
||||||
(let ((tail directory-abbrev-alist))
|
(setq filename (substring filename (1- (match-end 0)))))
|
||||||
;; If any elt of directory-abbrev-alist matches this name,
|
(let ((tail directory-abbrev-alist))
|
||||||
;; abbreviate accordingly.
|
;; If any elt of directory-abbrev-alist matches this name,
|
||||||
(while tail
|
;; abbreviate accordingly.
|
||||||
(if (string-match (car (car tail)) filename)
|
(while tail
|
||||||
(setq filename
|
(if (string-match (car (car tail)) filename)
|
||||||
(concat (cdr (car tail)) (substring filename (match-end 0)))))
|
(setq filename
|
||||||
(setq tail (cdr tail)))
|
(concat (cdr (car tail)) (substring filename (match-end 0)))))
|
||||||
;; Compute and save the abbreviated homedir name.
|
(setq tail (cdr tail)))
|
||||||
;; We defer computing this until the first time it's needed, to
|
;; Compute and save the abbreviated homedir name.
|
||||||
;; give time for directory-abbrev-alist to be set properly.
|
;; We defer computing this until the first time it's needed, to
|
||||||
;; We include a slash at the end, to avoid spurious matches
|
;; give time for directory-abbrev-alist to be set properly.
|
||||||
;; such as `/usr/foobar' when the home dir is `/usr/foo'.
|
;; We include a slash at the end, to avoid spurious matches
|
||||||
(or abbreviated-home-dir
|
;; such as `/usr/foobar' when the home dir is `/usr/foo'.
|
||||||
(setq abbreviated-home-dir
|
(or abbreviated-home-dir
|
||||||
(let ((abbreviated-home-dir "$foo"))
|
(setq abbreviated-home-dir
|
||||||
(concat "^" (abbreviate-file-name (expand-file-name "~"))
|
(let ((abbreviated-home-dir "$foo"))
|
||||||
"\\(/\\|$\\)"))))
|
(concat "^" (abbreviate-file-name (expand-file-name "~"))
|
||||||
|
"\\(/\\|$\\)"))))
|
||||||
|
|
||||||
;; If FILENAME starts with the abbreviated homedir,
|
;; If FILENAME starts with the abbreviated homedir,
|
||||||
;; make it start with `~' instead.
|
;; make it start with `~' instead.
|
||||||
(if (and (string-match abbreviated-home-dir filename)
|
(if (and (string-match abbreviated-home-dir filename)
|
||||||
;; If the home dir is just /, don't change it.
|
;; If the home dir is just /, don't change it.
|
||||||
(not (and (= (match-end 0) 1)
|
(not (and (= (match-end 0) 1)
|
||||||
(= (aref filename 0) ?/)))
|
(= (aref filename 0) ?/)))
|
||||||
;; MS-DOS root directories can come with a drive letter;
|
;; MS-DOS root directories can come with a drive letter;
|
||||||
;; Novell Netware allows drive letters beyond `Z:'.
|
;; Novell Netware allows drive letters beyond `Z:'.
|
||||||
(not (and (or (eq system-type 'ms-dos)
|
(not (and (or (eq system-type 'ms-dos)
|
||||||
(eq system-type 'cygwin)
|
(eq system-type 'cygwin)
|
||||||
(eq system-type 'windows-nt))
|
(eq system-type 'windows-nt))
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(string-match "^[a-zA-`]:/$" filename)))))
|
(string-match "^[a-zA-`]:/$" filename)))))
|
||||||
(setq filename
|
(setq filename
|
||||||
(concat "~"
|
(concat "~"
|
||||||
(match-string 1 filename)
|
(match-string 1 filename)
|
||||||
(substring filename (match-end 0)))))
|
(substring filename (match-end 0)))))
|
||||||
filename))
|
filename)))
|
||||||
|
|
||||||
(defcustom find-file-not-true-dirname-list nil
|
(defcustom find-file-not-true-dirname-list nil
|
||||||
"*List of logical names for which visiting shouldn't save the true dirname.
|
"*List of logical names for which visiting shouldn't save the true dirname.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue