diff options
| -rw-r--r-- | lisp/eshell/em-dirs.el | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el index 5180a0700db..b7d13ee27b7 100644 --- a/lisp/eshell/em-dirs.el +++ b/lisp/eshell/em-dirs.el | |||
| @@ -314,16 +314,18 @@ Thus, this does not include the current directory.") | |||
| 314 | path))) | 314 | path))) |
| 315 | 315 | ||
| 316 | (defun eshell-expand-multiple-dots (path) | 316 | (defun eshell-expand-multiple-dots (path) |
| 317 | ;; FIXME: This advice recommendation is rather odd: it's somewhat | ||
| 318 | ;; dangerous and it claims not to work with minibuffer-completion, which | ||
| 319 | ;; makes it much less interesting. | ||
| 317 | "Convert `...' to `../..', `....' to `../../..', etc.. | 320 | "Convert `...' to `../..', `....' to `../../..', etc.. |
| 318 | 321 | ||
| 319 | With the following piece of advice, you can make this functionality | 322 | With the following piece of advice, you can make this functionality |
| 320 | available in most of Emacs, with the exception of filename completion | 323 | available in most of Emacs, with the exception of filename completion |
| 321 | in the minibuffer: | 324 | in the minibuffer: |
| 322 | 325 | ||
| 323 | (defadvice expand-file-name | 326 | (advice-add 'expand-file-name :around #'my-expand-multiple-dots) |
| 324 | (before translate-multiple-dots | 327 | (defun my-expand-multiple-dots (orig-fun filename &rest args) |
| 325 | (filename &optional directory) activate) | 328 | (apply orig-fun (eshell-expand-multiple-dots filename) args))" |
| 326 | (setq filename (eshell-expand-multiple-dots filename)))" | ||
| 327 | (while (string-match "\\(?:^\\|/\\)\\.\\.\\(\\.+\\)\\(?:$\\|/\\)" path) | 329 | (while (string-match "\\(?:^\\|/\\)\\.\\.\\(\\.+\\)\\(?:$\\|/\\)" path) |
| 328 | (let* ((extra-dots (match-string 1 path)) | 330 | (let* ((extra-dots (match-string 1 path)) |
| 329 | (len (length extra-dots)) | 331 | (len (length extra-dots)) |