summaryrefslogtreecommitdiff
path: root/helm-eshell.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2017-08-10 20:08:27 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2017-08-10 20:13:11 +0200
commite21991b4c7d11981499c8d46ab7c0079e31fa835 (patch)
tree38f04dabf697e05f09bed7a2c72569ed6d17bc26 /helm-eshell.el
parent35149d27981f0d617ee84d05f7e91ced22b43302 (diff)
Continue fixing eshell completion according to #1832
* helm-eshell.el (helm-eshell--delete-space-flag): New flag. (helm-esh-pcomplete): Use it and fix completion against `../../`. (helm-eshell--delete-space): Used in helm-quit-hook. * helm.el (helm-internal): Add new hook. (helm-quit-hook): New.
Diffstat (limited to 'helm-eshell.el')
-rw-r--r--helm-eshell.el39
1 files changed, 27 insertions, 12 deletions
diff --git a/helm-eshell.el b/helm-eshell.el
index db13c08d..de15b475 100644
--- a/helm-eshell.el
+++ b/helm-eshell.el
@@ -202,6 +202,9 @@ The function that call this should set `helm-ec-target' to thing at point."
"Helm class to define source for Eshell history.")
+
+(defvar helm-eshell--delete-space-flag nil)
+
;;;###autoload
(defun helm-esh-pcomplete ()
"Preconfigured helm to provide helm completion in eshell."
@@ -241,18 +244,30 @@ The function that call this should set `helm-ec-target' to thing at point."
(car (last (ignore-errors
(pcomplete-parse-arguments))))))
(with-helm-show-completion beg end
- (or (helm :sources (helm-make-source "Eshell completions" 'helm-esh-source
- :fuzzy-match helm-eshell-fuzzy-match)
- :buffer "*helm pcomplete*"
- :keymap helm-esh-completion-map
- :resume 'noresume
- :input (if (and (stringp last)
- (not (string= last ""))
- (file-exists-p last))
- (expand-file-name last)
- last))
- (and del-space (looking-back "\\s-" (1- (point)))
- (delete-char -1))))))))
+ (add-hook 'helm-quit-hook 'helm-eshell--delete-space)
+ (unwind-protect
+ (or (helm :sources (helm-make-source "Eshell completions" 'helm-esh-source
+ :fuzzy-match helm-eshell-fuzzy-match)
+ :buffer "*helm pcomplete*"
+ :keymap helm-esh-completion-map
+ :resume 'noresume
+ :input (if (and (stringp last)
+ (not (string= last ""))
+ (or (file-exists-p last)
+ (helm-aand
+ (file-name-directory last)
+ (file-directory-p it))))
+ (expand-file-name last)
+ last))
+ (and del-space (looking-back "\\s-" (1- (point)))
+ (delete-char -1))
+ (unless helm-eshell--delete-space-flag
+ (insert " ")))
+ (remove-hook 'helm-quit-hook 'helm-eshell--delete-space)
+ (setq helm-eshell--delete-space-flag nil)))))))
+
+(defun helm-eshell--delete-space ()
+ (setq helm-eshell--delete-space-flag t))
;;;###autoload
(defun helm-eshell-history ()