From: Oleh Krehel <ohwoeowho@gmail.com>
To: "Ryan C. Thompson" <rct@thompsonclan.org>
Cc: 21644@debbugs.gnu.org
Subject: bug#21644: 24.4; completing-read acts differently on functional collection
Date: Thu, 08 Oct 2015 12:13:22 +0200 [thread overview]
Message-ID: <87vbahmzwd.fsf@gmail.com> (raw)
In-Reply-To: <5615A2EA.4@thompsonclan.org> (Ryan C. Thompson's message of "Wed, 7 Oct 2015 15:55:38 -0700")
[-- Attachment #1: Type: text/plain, Size: 532 bytes --]
> Try typing "g" followed by RET for both of the above. In the first
> case (collection is a list), it returns "green". In the second case
> (collection is a function), it returns just "g". This is reproducible
> in emacs -Q.
I can reproduce this as well, although "TAB RET" works where "RET"
doesn't. I attach a patch with a fix. If someone can check it I can push
it. The patch doesn't solve all the intricacies of
`completion-ignore-case' that were mentioned in that function's
comments, just this specific use case.
Oleh
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-minibuffer.el-completion-complete-and-exit-Fix-.patch --]
[-- Type: text/x-diff, Size: 6224 bytes --]
From 6eca5cbbe328bc035fff41d33b47f03ac5b6ca81 Mon Sep 17 00:00:00 2001
From: Oleh Krehel <ohwoeowho@gmail.com>
Date: Thu, 8 Oct 2015 12:05:20 +0200
Subject: [PATCH] lisp/minibuffer.el (completion--complete-and-exit): Fix
(bug#21644)
When `test-completion' returns a string and `completion-ignore-case'
is nil, the result was not used at all and only the minibuffer text
was returned. This change makes it use that returned string.
---
lisp/minibuffer.el | 96 ++++++++++++++++++++++++++++--------------------------
1 file changed, 49 insertions(+), 47 deletions(-)
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 2814d02..f684164 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1342,56 +1342,58 @@ completion-complete-and-exit
(_ nil)))))
(defun completion--complete-and-exit (beg end
- exit-function completion-function)
+ exit-function completion-function)
"Exit from `require-match' minibuffer.
COMPLETION-FUNCTION is called if the current buffer's content does not
appear to be a match."
- (cond
- ;; Allow user to specify null string
- ((= beg end) (funcall exit-function))
- ((test-completion (buffer-substring beg end)
- minibuffer-completion-table
- minibuffer-completion-predicate)
- ;; FIXME: completion-ignore-case has various slightly
- ;; incompatible meanings. E.g. it can reflect whether the user
- ;; wants completion to pay attention to case, or whether the
- ;; string will be used in a context where case is significant.
- ;; E.g. usually try-completion should obey the first, whereas
- ;; test-completion should obey the second.
- (when completion-ignore-case
- ;; Fixup case of the field, if necessary.
- (let* ((string (buffer-substring beg end))
- (compl (try-completion
- string
- minibuffer-completion-table
- minibuffer-completion-predicate)))
- (when (and (stringp compl) (not (equal string compl))
- ;; If it weren't for this piece of paranoia, I'd replace
- ;; the whole thing with a call to do-completion.
- ;; This is important, e.g. when the current minibuffer's
- ;; content is a directory which only contains a single
- ;; file, so `try-completion' actually completes to
- ;; that file.
- (= (length string) (length compl)))
- (completion--replace beg end compl))))
- (funcall exit-function))
-
- ((memq minibuffer-completion-confirm '(confirm confirm-after-completion))
- ;; The user is permitted to exit with an input that's rejected
- ;; by test-completion, after confirming her choice.
- (if (or (eq last-command this-command)
- ;; For `confirm-after-completion' we only ask for confirmation
- ;; if trying to exit immediately after typing TAB (this
- ;; catches most minibuffer typos).
- (and (eq minibuffer-completion-confirm 'confirm-after-completion)
- (not (memq last-command minibuffer-confirm-exit-commands))))
- (funcall exit-function)
- (minibuffer-message "Confirm")
- nil))
-
- (t
- ;; Call do-completion, but ignore errors.
- (funcall completion-function))))
+ (cond
+ ;; Allow user to specify null string
+ ((= beg end) (funcall exit-function))
+ ((test-completion (buffer-substring beg end)
+ minibuffer-completion-table
+ minibuffer-completion-predicate)
+ (let* ((string (buffer-substring beg end))
+ (compl (try-completion
+ string
+ minibuffer-completion-table
+ minibuffer-completion-predicate)))
+ (when (and (stringp compl)
+ (or (not completion-ignore-case)
+ ;; FIXME: completion-ignore-case has various slightly
+ ;; incompatible meanings. E.g. it can reflect whether the user
+ ;; wants completion to pay attention to case, or whether the
+ ;; string will be used in a context where case is significant.
+ ;; E.g. usually try-completion should obey the first, whereas
+ ;; test-completion should obey the second.d
+
+ ;; Fixup case of the field, if necessary.
+ (and (not (equal string compl))
+ ;; If it weren't for this piece of paranoia, I'd replace
+ ;; the whole thing with a call to do-completion.
+ ;; This is important, e.g. when the current minibuffer's
+ ;; content is a directory which only contains a single
+ ;; file, so `try-completion' actually completes to
+ ;; that file.
+ (= (length string) (length compl)))))
+ (completion--replace beg end compl)))
+ (funcall exit-function))
+
+ ((memq minibuffer-completion-confirm '(confirm confirm-after-completion))
+ ;; The user is permitted to exit with an input that's rejected
+ ;; by test-completion, after confirming her choice.
+ (if (or (eq last-command this-command)
+ ;; For `confirm-after-completion' we only ask for confirmation
+ ;; if trying to exit immediately after typing TAB (this
+ ;; catches most minibuffer typos).
+ (and (eq minibuffer-completion-confirm 'confirm-after-completion)
+ (not (memq last-command minibuffer-confirm-exit-commands))))
+ (funcall exit-function)
+ (minibuffer-message "Confirm")
+ nil))
+
+ (t
+ ;; Call do-completion, but ignore errors.
+ (funcall completion-function))))
(defun completion--try-word-completion (string table predicate point md)
(let ((comp (completion-try-completion string table predicate point md)))
--
2.6.1
next prev parent reply other threads:[~2015-10-08 10:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-07 22:55 bug#21644: 24.4; completing-read acts differently on functional collection Ryan C. Thompson
2015-10-08 10:13 ` Oleh Krehel [this message]
2015-10-13 1:23 ` Dmitry Gutov
2015-10-13 1:34 ` Ryan
2015-10-13 2:27 ` Dmitry Gutov
2015-10-13 18:59 ` Ryan C. Thompson
2015-10-15 5:12 ` Dmitry Gutov
2015-10-15 5:17 ` Ryan
2015-10-15 9:18 ` Dmitry Gutov
2015-10-15 15:01 ` Drew Adams
2015-10-15 15:24 ` Dmitry Gutov
2015-10-15 16:47 ` Drew Adams
2015-10-15 17:03 ` Dmitry Gutov
2015-10-15 20:28 ` Drew Adams
2015-10-15 21:07 ` Dmitry Gutov
2015-10-16 9:45 ` Eli Zaretskii
2015-10-16 10:24 ` Dmitry Gutov
2015-10-16 9:46 ` Eli Zaretskii
2015-10-16 9:54 ` Dmitry Gutov
2015-10-16 13:12 ` Stefan Monnier
2015-10-16 13:44 ` Eli Zaretskii
2015-10-16 14:03 ` Stefan Monnier
2015-10-16 13:12 ` Stefan Monnier
[not found] <<5615A2EA.4@thompsonclan.org>
[not found] ` <<87vbahmzwd.fsf@gmail.com>
[not found] ` <<561C5D0B.9070303@yandex.ru>
[not found] ` <<561C5FB0.6030105@thompsonclan.org>
[not found] ` <<561C6C12.20803@yandex.ru>
[not found] ` <<561D54AF.7090701@thompsonclan.org>
[not found] ` <<561F35AD.8000803@yandex.ru>
[not found] ` <<c92dc5c7-bf93-4040-9da1-96b1a57b560a@default>
[not found] ` <<561FC52F.1010606@yandex.ru>
[not found] ` <<4fe19dae-4269-401b-82bd-10f9d368a921@default>
[not found] ` <<561FDC63.6010609@yandex.ru>
[not found] ` <<917e38a9-d74b-4e41-bc7b-90aeee69584c@default>
[not found] ` <<5620159C.3060401@yandex.ru>
[not found] ` <<837fmn6tb3.fsf@gnu.org>
2015-10-16 15:53 ` Drew Adams
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=87vbahmzwd.fsf@gmail.com \
--to=ohwoeowho@gmail.com \
--cc=21644@debbugs.gnu.org \
--cc=rct@thompsonclan.org \
/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.