From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.bugs Subject: bug#21644: 24.4; completing-read acts differently on functional collection Date: Thu, 08 Oct 2015 12:13:22 +0200 Message-ID: <87vbahmzwd.fsf@gmail.com> References: <5615A2EA.4@thompsonclan.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1444299340 27878 80.91.229.3 (8 Oct 2015 10:15:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Oct 2015 10:15:40 +0000 (UTC) Cc: 21644@debbugs.gnu.org To: "Ryan C. Thompson" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 08 12:15:23 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from eggs.gnu.org ([208.118.235.92]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zk8EM-0003RL-Go for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 12:15:22 +0200 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zk8DH-00005N-Jd for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 06:15:21 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:49143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk8DH-0008VO-8T for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 06:14:15 -0400 Original-Received: from localhost ([::1]:33319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk8DH-0004wL-3Z for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Oct 2015 06:14:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk8D8-0004rM-O5 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 06:14:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zk8D4-0007rp-IG for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 06:14:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42576) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zk8D4-0007rk-FS for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 06:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Zk8D4-0008Of-14 for bug-gnu-emacs@gnu.org; Thu, 08 Oct 2015 06:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Oleh Krehel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Oct 2015 10:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21644 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21644-submit@debbugs.gnu.org id=B21644.144429918332184 (code B ref 21644); Thu, 08 Oct 2015 10:14:01 +0000 Original-Received: (at 21644) by debbugs.gnu.org; 8 Oct 2015 10:13:03 +0000 Original-Received: from localhost ([127.0.0.1]:59780 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zk8C6-0008N2-DC for submit@debbugs.gnu.org; Thu, 08 Oct 2015 06:13:03 -0400 Original-Received: from mail-wi0-f169.google.com ([209.85.212.169]:37092) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zk8C3-0008Mc-Co for 21644@debbugs.gnu.org; Thu, 08 Oct 2015 06:13:00 -0400 Original-Received: by wicfx3 with SMTP id fx3so17874317wic.0 for <21644@debbugs.gnu.org>; Thu, 08 Oct 2015 03:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=P3G24U6XeZkf39glGJCy0FmzH9BBSv1x8TIBx6nOZ9Q=; b=BX1SFqnassziCEZz/GViym9fY+IQDybNwI2CM9bD6555zjGOpomKFcaslAbnFT1IBb +p9IHgKMmOZ8GjxrJjnfewZNeHzBj2N6sUvGmBNM256YtHzfnUtiteM5RQ/fRH7hS8Ks 6UzG0hEI+aBGnC0AW+WfynIyyrXZS3bz7Ztv3WLrkQN/cSm1MlEGAA5s5NWv+jC3la2i baJO+6XHbeRO2ULjhcRPkfk0eSqfXB3r1oBjGzAFfoUpgJX5596OW0UZ89MdDiiDSEHI i3gkMS+azEBQAAwjnGJml0EwWgDTw4Rw0SKlIZns6NglEMdzRp+SKTggv0cz4U5Hx6mA 2spA== X-Received: by 10.194.134.197 with SMTP id pm5mr6825803wjb.118.1444299178581; Thu, 08 Oct 2015 03:12:58 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by smtp.gmail.com with ESMTPSA id cc8sm31748681wjc.46.2015.10.08.03.12.57 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 08 Oct 2015 03:12:57 -0700 (PDT) In-Reply-To: <5615A2EA.4@thompsonclan.org> (Ryan C. Thompson's message of "Wed, 7 Oct 2015 15:55:38 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 Xref: news.gmane.org gmane.emacs.bugs:107435 Archived-At: --=-=-= Content-Type: text/plain > 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-minibuffer.el-completion-complete-and-exit-Fix-.patch >From 6eca5cbbe328bc035fff41d33b47f03ac5b6ca81 Mon Sep 17 00:00:00 2001 From: Oleh Krehel 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 --=-=-=--