From 403b6278226d765470c11d1ceb709c45cb4457c9 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 7 Nov 2022 17:52:29 +0800 Subject: eshell: j jumps immediately with only one match * eshell-conf.el (eshell-j): Previously this function does not filter the candidates according to the user-specified predicate, and presents the user with a `completing-read' that has only one candidate. I do not know why this was implemented like that, so I am trying the approach of jumping immediately when given a predicate that only matches one candidate. Let us see how this goes then. --- eshell-conf.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'eshell-conf.el') diff --git a/eshell-conf.el b/eshell-conf.el index 3ee8352..12a35b6 100644 --- a/eshell-conf.el +++ b/eshell-conf.el @@ -342,7 +342,15 @@ candidates." candidates :test #'string= ;; In Haskell this woule be a simple function composition. - :key (function (lambda (ls) (file-truename (cdr ls))))))) + :key (function (lambda (ls) (file-truename (cdr ls)))))) + ;; Delete non-matching ones + (candidates + (delq + nil + (mapcar + (lambda (cand) + (cond ((string-match-p short-cut (cdr cand)) cand))) + candidates)))) (cond ((null candidates) (user-error "No candidates matching %s found" short-cut)) @@ -354,7 +362,8 @@ candidates." (assoc (let ((completion-regexp-list (cons short-cut completion-regexp-list))) - (completing-read "Choose a link: " candidates nil t)) + (completing-read + "Choose a link: " candidates nil t)) candidates #'string=)))))))) ;;; convenient ls -- cgit v1.2.3-18-g5258