branch: elpa/helm commit 452dd1baebb765bf633f37818cd63c6f085f89b9 Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
Try to fix issue #2504 in eshell completion This fix the default eshell completion based on completion-at-point which fails to complete a filename not preceded by a meaningful command like cd or ls. Pcomplete and helm-eshell are working properly in this case. Problem is that the base-size returned by completion-all-completions in this case is always zero (seems it assume we are trying to complete a command even if the metadata specify a file completion) To fix it we try here to recalculate the base-size from the last / found. --- helm-mode.el | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/helm-mode.el b/helm-mode.el index 6f5bb0e834..fbc4c99a8c 100644 --- a/helm-mode.el +++ b/helm-mode.el @@ -1957,7 +1957,11 @@ Can be used for `completion-in-region-function' by advicing it with an (string= input "")) " ")) (file-comp-p (or (eq (completion-metadata-get metadata 'category) 'file) - (helm-mode--in-file-completion-p) + (and (helm-mode--in-file-completion-p) + ;; Probably unneeded at this + ;; point but never know. + (setq metadata (append metadata '((category . file)))) + t) ;; Assume that when `afun' and `predicate' are null ;; we are in filename completion. (and (null afun) (null predicate)))) @@ -1978,7 +1982,23 @@ Can be used for `completion-in-region-function' by advicing it with an metadata)) (last-data (last comps)) (bs (helm-aif (cdr last-data) - (prog1 it + ;; Try to fix eshell completion + ;; which fails to complete a + ;; filename not preceded by + ;; a meaningful + ;; command like cd or ls + ;; (bug #2504) so + ;; try to find the last + ;; leading / and set + ;; base-size from it. + (prog1 (if (and (zerop it) file-comp-p) + (or (helm-aand + (save-excursion + (re-search-backward + "/" start t)) + (- (1+ it) start)) + it) + it) ;; Remove the last element of ;; comps by side-effect. (setcdr last-data nil))