Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
ffb3a4db
Commit
ffb3a4db
authored
Dec 26, 1992
by
Richard M. Stallman
Browse files
(abbreviated-home-dir): New variable.
(abbreviate-file-name): Properly convert abbreviated homedir to ~.
parent
21ccfb5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
lisp/files.el
lisp/files.el
+15
-1
No files found.
lisp/files.el
View file @
ffb3a4db
...
...
@@ -395,6 +395,9 @@ Choose the buffer's name using `generate-new-buffer-name'."
(defconst automount-dir-prefix "^/tmp_mnt/"
"Regexp to match the automounter prefix in a directory name.")
(defvar abbreviated-home-dir nil
"The the user's homedir abbreviated according to `directory-abbrev-list'.")
(defun abbreviate-file-name (filename)
"Return a version of FILENAME shortened using `directory-abbrev-alist'.
This also substitutes \"~\" for the user's home directory.
...
...
@@ -405,12 +408,23 @@ Type \\[describe-variable] directory-abbrev-alist RET for more information."
(substring filename (1- (match-end 0))))))
(setq filename (substring filename (1- (match-end 0)))))
(let ((tail directory-abbrev-alist))
;; If any elt of directory-abbrev-alist matches this name,
;; abbreviate accordingly.
(while tail
(if (string-match (car (car tail)) filename)
(setq filename
(concat (cdr (car tail)) (substring filename (match-end 0)))))
(setq tail (cdr tail)))
(if (string-match (concat "^" (expand-file-name "~")) filename)
;; Compute and save the abbreviated homedir name.
;; We defer computing this until the first time it's needed, to
;; give time for directory-abbrev-alist to be set properly.
(or abbreviated-home-dir
(setq abbreviated-home-dir
(let ((abbreviated-home-dir "$foo"))
(concat "^" (abbreviate-file-name (expand-file-name "~"))))))
;; If FILENAME starts with the abbreviated homedir,
;; make it start with `~' instead.
(if (string-match abbreviated-home-dir filename)
(setq filename
(concat "~" (substring filename (match-end 0)))))
filename))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment