From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#7266: Patch to fix minibuffer-complete when icomplete-mode is on and completion-cycle-threshold is nil Date: Wed, 27 Oct 2010 22:23:15 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1288233816 3690 80.91.229.12 (28 Oct 2010 02:43:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 28 Oct 2010 02:43:36 +0000 (UTC) Cc: 7266@debbugs.gnu.org To: Fran Litterio Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 28 04:43:34 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PBISk-0004oo-9O for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Oct 2010 04:43:34 +0200 Original-Received: from localhost ([127.0.0.1]:49187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBISj-0007GR-Nd for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Oct 2010 22:43:33 -0400 Original-Received: from [140.186.70.92] (port=54409 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PBISM-000725-CT for bug-gnu-emacs@gnu.org; Wed, 27 Oct 2010 22:43:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PBISK-0001Nr-UN for bug-gnu-emacs@gnu.org; Wed, 27 Oct 2010 22:43:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48184) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PBISK-0001Nn-SP for bug-gnu-emacs@gnu.org; Wed, 27 Oct 2010 22:43:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PBI5y-0002EQ-Qt; Wed, 27 Oct 2010 22:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Oct 2010 02:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7266 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 7266-submit@debbugs.gnu.org id=B7266.12882323518565 (code B ref 7266); Thu, 28 Oct 2010 02:20:02 +0000 Original-Received: (at 7266) by debbugs.gnu.org; 28 Oct 2010 02:19:11 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PBI58-0002E6-7R for submit@debbugs.gnu.org; Wed, 27 Oct 2010 22:19:10 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PBI56-0002E1-Rc for 7266@debbugs.gnu.org; Wed, 27 Oct 2010 22:19:09 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgQJAGR7yExFxL/T/2dsb2JhbACgSHxywD6FSASSKg X-IronPort-AV: E=Sophos;i="4.58,248,1286164800"; d="scan'208";a="80872790" Original-Received: from 69-196-191-211.dsl.teksavvy.com (HELO pastel.home) ([69.196.191.211]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 27 Oct 2010 22:23:15 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 59C49A8558; Wed, 27 Oct 2010 22:23:15 -0400 (EDT) In-Reply-To: (Fran Litterio's message of "Fri, 22 Oct 2010 11:03:44 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 27 Oct 2010 22:20:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:41180 Archived-At: > 2. Type: ESC ESC : (icomplete-mode 1) RET C-h v mini TAB TAB > Notice that minibuffer-complete (which is bound to TAB at this point) > is cycling through the completion choices instead of popping up a > window to display the completion choices. This bug is caused code in > lisp/minibuffer.el that does not check that the value of > completion-cycle-threshold is not nil before deciding to cycle > completions. This patch (to the Bazaar sources) fixes the bug: Thanks very much. Indeed, there's a problem here, but... > @@ -607,7 +607,8 @@ > (completion-all-sorted-completions)))) > (setq completion-all-sorted-completions nil) > (cond > - ((and (not (ignore-errors > + ((and completion-cycle-threshold ;; Never cycle if > completion-cycle-threshold is nil. > + (not (ignore-errors > ;; This signal an (intended) error if comps is too > ;; short or if completion-cycle-threshold is t. > (consp (nthcdr completion-cycle-threshold comps)))) Hmm... AFAICT if completion-cycle-threshold is nil, then comps will also be nil, so this change should not make any difference. > @@ -664,7 +665,8 @@ > (scroll-other-window)) > nil))) > ;; If we're cycling, keep on cycling. > - (completion-all-sorted-completions > + ((and completion-cycle-threshold ;; Never cycle if > completion-cycle-threshold is nil. > + completion-all-sorted-completions) > (minibuffer-force-complete) > t) > (t (case (completion--do-completion) It goes a bit further than that: even if completion-cycle-threshold is non-nil and completion-all-sorted-completions is set, it may still be wrong to call minibuffer-force-complete since completion-all-sorted-completions may only be set because of icomplete rather than because we're cycling (e.g. the completion list may be larger than the threshold). So I've installed the patch below instead. Please confirm that it fixes the problem. Stefan === modified file 'lisp/minibuffer.el' --- lisp/minibuffer.el 2010-10-19 11:44:07 +0000 +++ lisp/minibuffer.el 2010-10-28 02:16:06 +0000 @@ -526,6 +526,10 @@ (const :tag "Always cycle" t) (integer :tag "Threshold"))) +(defvar completion-all-sorted-completions nil) +(make-variable-buffer-local 'completion-all-sorted-completions) +(defvar completion-cycling nil) + (defun completion--do-completion (&optional try-completion-function) "Do the completion and return a summary of what happened. M = completion was performed, the text was Modified. @@ -605,14 +609,13 @@ "")) comp-pos))) (completion-all-sorted-completions)))) - (setq completion-all-sorted-completions nil) + (completion--flush-all-sorted-completions) (cond - ((and (not (ignore-errors + ((and (consp (cdr comps)) ;; There's something to cycle. + (not (ignore-errors ;; This signal an (intended) error if comps is too ;; short or if completion-cycle-threshold is t. - (consp (nthcdr completion-cycle-threshold comps)))) - ;; More than 1, so there's something to cycle. - (consp (cdr comps))) + (consp (nthcdr completion-cycle-threshold comps))))) ;; Fewer than completion-cycle-threshold remaining ;; completions: let's cycle. (setq completed t exact t) @@ -648,7 +651,7 @@ ;; If the previous command was not this, ;; mark the completion buffer obsolete. (unless (eq this-command last-command) - (setq completion-all-sorted-completions nil) + (completion--flush-all-sorted-completions) (setq minibuffer-scroll-window nil)) (cond @@ -664,7 +667,7 @@ (scroll-other-window)) nil))) ;; If we're cycling, keep on cycling. - (completion-all-sorted-completions + ((and completion-cycling completion-all-sorted-completions) (minibuffer-force-complete) t) (t (case (completion--do-completion) @@ -675,10 +678,8 @@ t) (t t))))) -(defvar completion-all-sorted-completions nil) -(make-variable-buffer-local 'completion-all-sorted-completions) - (defun completion--flush-all-sorted-completions (&rest ignore) + (setq completion-cycling nil) (setq completion-all-sorted-completions nil)) (defun completion-all-sorted-completions () @@ -720,6 +721,7 @@ (all (completion-all-sorted-completions))) (if (not (consp all)) (minibuffer-message (if all "No more completions" "No completions")) + (setq completion-cycling t) (goto-char end) (insert (car all)) (delete-region (+ start (cdr (last all))) end)