From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Slawomir Nowaczyk <Slawomir.Nowaczyk@hh.se>,
Dan McKinley <mcfunley@gmail.com>,
emacs-devel <emacs-devel@gnu.org>
Subject: Re: bug#17545: 24.4.50; icomplete conflicts with minibuffer default
Date: Tue, 19 May 2015 02:20:47 +0300 [thread overview]
Message-ID: <555A73CF.8000204@yandex.ru> (raw)
In-Reply-To: <jwvpp5xx2b9.fsf-monnier+emacsbugs@gnu.org>
On 05/18/2015 07:45 PM, Stefan Monnier wrote:
> AFAIK the issue is that we should return the entry that icomplete
> display(s|ed).
Well, minibuffer.el doesn't have the necessary information. How about this?
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.
next prev parent reply other threads:[~2015-05-18 23:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 15:40 bug#17545: 24.4.50; icomplete conflicts with minibuffer default Dan McKinley
2014-05-21 17:52 ` Stefan Monnier
2014-06-01 2:25 ` Stefan Monnier
[not found] ` <86zj5439za.fsf@yandex.ru>
[not found] ` <jwv4mncr48h.fsf-monnier+emacsbugs@gnu.org>
2015-05-17 1:07 ` Dmitry Gutov
2015-05-18 8:51 ` Slawomir Nowaczyk
2015-05-18 19:41 ` Stephen Leake
2015-05-18 23:30 ` Dmitry Gutov
2015-05-18 16:45 ` Stefan Monnier
2015-05-18 23:20 ` Dmitry Gutov [this message]
2015-05-19 1:38 ` Stefan Monnier
2015-05-19 13:06 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=555A73CF.8000204@yandex.ru \
--to=dgutov@yandex.ru \
--cc=Slawomir.Nowaczyk@hh.se \
--cc=emacs-devel@gnu.org \
--cc=mcfunley@gmail.com \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.