diff options
author | JSDurand <mmemmew@gmail.com> | 2022-11-07 17:52:29 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2022-11-07 17:52:29 +0800 |
commit | 403b6278226d765470c11d1ceb709c45cb4457c9 (patch) | |
tree | 58ca90515185229cc755214fe2bc314d7aabde6f /eshell-conf.el | |
parent | 5651f68e259a006ae588b34917f13d7c91707ab0 (diff) |
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.
Diffstat (limited to 'eshell-conf.el')
-rw-r--r-- | eshell-conf.el | 13 |
1 files changed, 11 insertions, 2 deletions
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 |