summaryrefslogtreecommitdiff
path: root/helm-eshell.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2012-03-22 13:07:55 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2012-03-22 13:07:55 +0100
commit18fc764471685e2722e78354fe3b26cf5701286d (patch)
tree5b1ed522e251ccd557970e49063d12d9058ade31 /helm-eshell.el
parent00184513fe985b05965ce51ebf4156c6815e783e (diff)
* helm-config.el: Move helm-esh-pcomplete, helm-eshell-history.
* helm-eshell.el: (helm-esh-pcomplete, helm-eshell-history): Moved from helm-config.el.
Diffstat (limited to 'helm-eshell.el')
-rw-r--r--helm-eshell.el40
1 files changed, 40 insertions, 0 deletions
diff --git a/helm-eshell.el b/helm-eshell.el
index bd38781f..9b362160 100644
--- a/helm-eshell.el
+++ b/helm-eshell.el
@@ -123,6 +123,46 @@ The function that call this should set `helm-ec-target' to thing at point."
(insert candidate))))
"Helm source for Eshell history.")
+;;;###autoload
+(defun helm-esh-pcomplete ()
+ "Preconfigured helm to provide helm completion in eshell."
+ (interactive)
+ (let* ((helm-quit-if-no-candidate t)
+ (helm-execute-action-at-once-if-one t)
+ (target (thing-at-point 'symbol))
+ (end (point))
+ (beg (or (and target (- end (length target)))
+ ;; Nothing at point.
+ (progn (insert " ") (point)))))
+ (setq helm-ec-target (or target " "))
+ (with-helm-show-completion beg end
+ (helm :sources 'helm-c-source-esh
+ :buffer "*helm pcomplete*"
+ :input (helm-ff-set-pattern ; Handle tramp filenames.
+ (car (last (ignore-errors ; Needed in lisp symbols completion.
+ (pcomplete-parse-arguments)))))))))
+
+;;;###autoload
+(defun helm-eshell-history ()
+ "Preconfigured helm for eshell history."
+ (interactive)
+ (let* ((end (point))
+ (beg (save-excursion (eshell-bol) (point)))
+ (input (buffer-substring beg end))
+ flag-empty)
+ (when (eq beg end)
+ (insert " ")
+ (setq flag-empty t)
+ (setq end (point)))
+ (unwind-protect
+ (with-helm-show-completion beg end
+ (helm :sources 'helm-c-source-eshell-history
+ :buffer "*Eshell history*"
+ :input input))
+ (when (and flag-empty
+ (looking-back " "))
+ (delete-char -1)))))
+
(provide 'helm-eshell)
;;; helm-eshell ends here