[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/some-more-icomplete-hacks 0943c81 2/2: Add new ico
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/some-more-icomplete-hacks 0943c81 2/2: Add new icomplete-force-complete-and-exit-unless-directory command |
Date: |
Mon, 4 Feb 2019 11:07:11 -0500 (EST) |
branch: scratch/some-more-icomplete-hacks
commit 0943c81ecd08252e521e841e2614a1516dc64c9e
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Add new icomplete-force-complete-and-exit-unless-directory command
Useful if you want icomplete to behave a little more like Ido.
(define-key icomplete-minibuffer-map (kbd "RET")
'icomplete-force-complete-and-exit-unless-directory)
* lisp/icomplete.el
(icomplete-force-complete-and-exit-unless-directory): New command.
---
lisp/icomplete.el | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 102ebb9..67c8ef6 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -167,6 +167,19 @@ the default otherwise."
(minibuffer-force-complete-and-exit)
(minibuffer-complete-and-exit)))
+(defun icomplete-force-complete-and-exit-unless-directory ()
+ "Complete minibuffer, don't exit if completing a directory."
+ (interactive)
+ (minibuffer-force-complete nil nil 'dont-cycle)
+ (let* ((meta (cdr (funcall minibuffer-completion-table
+ nil nil 'metadata)))
+ (category (cdr (assq 'category meta))))
+ (unless (and (eq 'file category)
+ (file-directory-p
+ (buffer-substring-no-properties (icomplete--field-beg)
+ (icomplete--field-end))))
+ (minibuffer-complete-and-exit))))
+
(defun icomplete-force-complete-and-kill ()
"Complete minibuffer, kill current prospect, don't exit.
Killing the current prospect has different meanings according to