[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 08033db: New command icomplete-force-complete-and-e
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master 08033db: New command icomplete-force-complete-and-exit |
Date: |
Tue, 19 May 2015 12:53:46 +0000 |
branch: master
commit 08033db08bc2bc75221b0dde97257c987d4efa00
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
New command icomplete-force-complete-and-exit
* lisp/icomplete.el (icomplete-force-complete-and-exit):
New command
(http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00461.html)
(http://lists.gnu.org/archive/html/emacs-devel/2015-05/msg00516.html).
(icomplete-minibuffer-map): Bind C-j to it.
(icomplete-forward-completions, icomplete-backward-completions):
Mention the new command in the docstring.
* lisp/minibuffer.el (minibuffer-force-complete-and-exit): Revert
the previous fix for bug#17545.
---
lisp/icomplete.el | 16 +++++++++++++---
lisp/minibuffer.el | 16 ++++++----------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index ee28112..b1894ca 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -149,16 +149,26 @@ icompletion is occurring."
(defvar icomplete-minibuffer-map
(let ((map (make-sparse-keymap)))
(define-key map [?\M-\t] 'minibuffer-force-complete)
- (define-key map [?\C-j] 'minibuffer-force-complete-and-exit)
+ (define-key map [?\C-j] 'icomplete-force-complete-and-exit)
(define-key map [?\C-.] 'icomplete-forward-completions)
(define-key map [?\C-,] 'icomplete-backward-completions)
map)
"Keymap used by `icomplete-mode' in the minibuffer.")
+(defun icomplete-force-complete-and-exit ()
+ "Complete the minibuffer and exit.
+Use the first of the matches if there are any displayed, and use
+the default otherwise."
+ (interactive)
+ (if (or icomplete-show-matches-on-no-input
+ (> (icomplete--field-end) (icomplete--field-beg)))
+ (minibuffer-force-complete-and-exit)
+ (minibuffer-complete-and-exit)))
+
(defun icomplete-forward-completions ()
"Step forward completions by one entry.
Second entry becomes the first and can be selected with
-`minibuffer-force-complete-and-exit'."
+`icomplete-force-complete-and-exit'."
(interactive)
(let* ((beg (icomplete--field-beg))
(end (icomplete--field-end))
@@ -171,7 +181,7 @@ Second entry becomes the first and can be selected with
(defun icomplete-backward-completions ()
"Step backward completions by one entry.
Last entry becomes the first and can be selected with
-`minibuffer-force-complete-and-exit'."
+`icomplete-force-complete-and-exit'."
(interactive)
(let* ((beg (icomplete--field-beg))
(end (icomplete--field-end))
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 538bd97..60b89b6 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1241,16 +1241,12 @@ scroll the window of possible completions."
(defun minibuffer-force-complete-and-exit ()
"Complete the minibuffer with first of the matches and exit."
(interactive)
- (if (and (eq (minibuffer-prompt-end) (point-max))
- minibuffer-default)
- ;; Use the provided default if there's one (bug#17545).
- (minibuffer-complete-and-exit)
- (minibuffer-force-complete)
- (completion--complete-and-exit
- (minibuffer-prompt-end) (point-max) #'exit-minibuffer
- ;; If the previous completion completed to an element which fails
- ;; test-completion, then we shouldn't exit, but that should be rare.
- (lambda () (minibuffer-message "Incomplete")))))
+ (minibuffer-force-complete)
+ (completion--complete-and-exit
+ (minibuffer-prompt-end) (point-max) #'exit-minibuffer
+ ;; If the previous completion completed to an element which fails
+ ;; test-completion, then we shouldn't exit, but that should be rare.
+ (lambda () (minibuffer-message "Incomplete"))))
(defun minibuffer-force-complete (&optional start end)
"Complete the minibuffer to an exact match.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 08033db: New command icomplete-force-complete-and-exit,
Dmitry Gutov <=