[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-27 e3276f3 3/7: Make fido-mode behave more like ido-mode when find
From: |
Jo�o T�vora |
Subject: |
emacs-27 e3276f3 3/7: Make fido-mode behave more like ido-mode when finding directories |
Date: |
Tue, 31 Dec 2019 08:32:04 -0500 (EST) |
branch: emacs-27
commit e3276f36c08691d6789b8eb49923735dc9565642
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Make fido-mode behave more like ido-mode when finding directories
Notably C-x d (M-x dired) and C-x v d (M-x vc-dir) behaved quite
differently, having regular files as the default instead of ido's
usual "./".
* lisp/icomplete.el (icomplete--sorted-completions): New helper.
(icomplete-completions): Use it.
(cherry picked from commit ee914051fbb4fbff9073a23b5ea7668bf48b5c6a)
---
lisp/icomplete.el | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 4d6dfcd..bf7e2ea 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -442,6 +442,24 @@ Usually run by inclusion in `minibuffer-setup-hook'."
(cdr tem)))))
(add-hook 'pre-command-hook 'icomplete-pre-command-hook nil t)
(add-hook 'post-command-hook 'icomplete-post-command-hook nil t)))
+
+(defun icomplete--sorted-completions ()
+ (let ((all (completion-all-sorted-completions
+ (icomplete--field-beg) (icomplete--field-end))))
+ (if (and fido-mode
+ (window-minibuffer-p)
+ (not minibuffer-default)
+ (eq (icomplete--category) 'file))
+ (cl-loop for l on all
+ while (listp (cdr l))
+ for comp = (cadr l)
+ when (string= comp "./")
+ do (setf (cdr l) (cddr l))
+ and return
+ (setq completion-all-sorted-completions (cons comp all))
+ finally return all)
+ all)))
+
@@ -550,8 +568,7 @@ matches exist."
(funcall predicate cand))))
predicate))
(md (completion--field-metadata (icomplete--field-beg)))
- (comps (completion-all-sorted-completions
- (icomplete--field-beg) (icomplete--field-end)))
+ (comps (icomplete--sorted-completions))
(last (if (consp comps) (last comps)))
(base-size (cdr last))
(open-bracket (if require-match "(" "["))
- emacs-27 updated (9b6872b -> 195bde9), Jo�o T�vora, 2019/12/31
- emacs-27 5352947 1/7: Another adjustment to flex completion style's sorting function, Jo�o T�vora, 2019/12/31
- emacs-27 e3276f3 3/7: Make fido-mode behave more like ido-mode when finding directories,
Jo�o T�vora <=
- emacs-27 b1c3ed9 4/7: Move flex style's minibuffer-default-aware sorting to lisp/icomplete.el, Jo�o T�vora, 2019/12/31
- emacs-27 9b1053b 5/7: Correctly cache sorted completions in icomplete--sorted-completions, Jo�o T�vora, 2019/12/31
- emacs-27 fe0ed17 2/7: Slightly simplify lisp/icomplete.el with new icomplete--category helper, Jo�o T�vora, 2019/12/31
- emacs-27 f2a349b 6/7: Don't force completion recalculation in icomplete-fido-ret, Jo�o T�vora, 2019/12/31
- emacs-27 195bde9 7/7: Don't always resort in recently introduced icomplete--sorted-completions, Jo�o T�vora, 2019/12/31