Function: eshell-expand-multiple-dots

eshell-expand-multiple-dots is a byte-compiled function defined in em-dirs.el.gz.

Signature

(eshell-expand-multiple-dots FILENAME)

Documentation

Convert ... to ../.., .... to ../../.., etc..

With the following piece of advice, you can make this functionality available in most of Emacs, with the exception of filename completion in the minibuffer:

    (advice-add 'expand-file-name :around #'my-expand-multiple-dots)
    (defun my-expand-multiple-dots (orig-fun filename &rest args)
      (apply orig-fun (eshell-expand-multiple-dots filename) args))

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/em-dirs.el.gz
(defun eshell-expand-multiple-dots (filename)
  ;; FIXME: This advice recommendation is rather odd: it's somewhat
  ;; dangerous and it claims not to work with minibuffer-completion, which
  ;; makes it much less interesting.
  "Convert `...' to `../..', `....' to `../../..', etc..

With the following piece of advice, you can make this functionality
available in most of Emacs, with the exception of filename completion
in the minibuffer:

    (advice-add 'expand-file-name :around #'my-expand-multiple-dots)
    (defun my-expand-multiple-dots (orig-fun filename &rest args)
      (apply orig-fun (eshell-expand-multiple-dots filename) args))"
  (while (string-match "\\(?:\\`\\|/\\)\\.\\.\\(\\.+\\)\\(?:\\'\\|/\\)"
                       filename)
    (let* ((extra-dots (match-string 1 filename))
	   (len (length extra-dots))
	   replace-text)
      (while (> len 0)
	(setq replace-text (concat replace-text "/..")
	      len (1- len)))
      (setq filename
	    (replace-match replace-text t t filename 1))))
  filename)