summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eshell-conf.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/eshell-conf.el b/eshell-conf.el
index ebadfda..f4c8a23 100644
--- a/eshell-conf.el
+++ b/eshell-conf.el
@@ -451,6 +451,39 @@ other value means 1."
(add-to-list 'eshell-expand-input-functions
#'eshell-expand-history-references)
+;;; Expand multiple dots
+
+(defun durand-eshell-expand-dots (beg end)
+ "Expand multiple dots in BEG and END.
+For example, \"...\" expands into \"../..\"."
+ (save-excursion
+ (save-match-data
+ (let ((str (buffer-substring beg end))
+ (start 0))
+ (while (string-match (rx ".." (1+ ".")) str start)
+ (let* ((matched (match-string 0 str))
+ (len (length matched)))
+ (setq
+ str
+ (replace-match
+ (let ((result "..")
+ (index 2))
+ (while (< index len)
+ (setq index (1+ index))
+ (setq
+ result
+ (concat result "/..")))
+ result)
+ nil nil str))
+ (setq start (+ (match-end 0)
+ (lsh (- len 2) 1)))))
+ (goto-char beg)
+ (delete-region beg end)
+ (insert str)))))
+
+(add-to-list 'eshell-expand-input-functions
+ #'durand-eshell-expand-dots)
+
;;; Visual commands
(add-to-list 'eshell-visual-commands