aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2019-12-23 23:43:30 +0000
committerJoão Távora2019-12-23 23:44:12 +0000
commitee914051fbb4fbff9073a23b5ea7668bf48b5c6a (patch)
tree51ccc0d2d4d2b33600c302561df4accebfb3c8b9
parent24a1f520f91c278cb8cc57325ea80285a3b252cf (diff)
downloademacs-ee914051fbb4fbff9073a23b5ea7668bf48b5c6a.tar.gz
emacs-ee914051fbb4fbff9073a23b5ea7668bf48b5c6a.zip
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.
-rw-r--r--lisp/icomplete.el21
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 4d6dfcd18a1..bf7e2ea7cb4 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -442,6 +442,24 @@ Usually run by inclusion in `minibuffer-setup-hook'."
442 (cdr tem))))) 442 (cdr tem)))))
443 (add-hook 'pre-command-hook 'icomplete-pre-command-hook nil t) 443 (add-hook 'pre-command-hook 'icomplete-pre-command-hook nil t)
444 (add-hook 'post-command-hook 'icomplete-post-command-hook nil t))) 444 (add-hook 'post-command-hook 'icomplete-post-command-hook nil t)))
445
446(defun icomplete--sorted-completions ()
447 (let ((all (completion-all-sorted-completions
448 (icomplete--field-beg) (icomplete--field-end))))
449 (if (and fido-mode
450 (window-minibuffer-p)
451 (not minibuffer-default)
452 (eq (icomplete--category) 'file))
453 (cl-loop for l on all
454 while (listp (cdr l))
455 for comp = (cadr l)
456 when (string= comp "./")
457 do (setf (cdr l) (cddr l))
458 and return
459 (setq completion-all-sorted-completions (cons comp all))
460 finally return all)
461 all)))
462
445 463
446 464
447 465
@@ -550,8 +568,7 @@ matches exist."
550 (funcall predicate cand)))) 568 (funcall predicate cand))))
551 predicate)) 569 predicate))
552 (md (completion--field-metadata (icomplete--field-beg))) 570 (md (completion--field-metadata (icomplete--field-beg)))
553 (comps (completion-all-sorted-completions 571 (comps (icomplete--sorted-completions))
554 (icomplete--field-beg) (icomplete--field-end)))
555 (last (if (consp comps) (last comps))) 572 (last (if (consp comps) (last comps)))
556 (base-size (cdr last)) 573 (base-size (cdr last))
557 (open-bracket (if require-match "(" "[")) 574 (open-bracket (if require-match "(" "["))