From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bruno Barbier Newsgroups: gmane.emacs.bugs Subject: bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions Date: Mon, 21 Sep 2009 16:20:16 +0200 Message-ID: <20090921142016.GA4717@mycomputer> Reply-To: Bruno Barbier , 4504@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="M9NhX3UHpAaciwkO" X-Trace: ger.gmane.org 1253570047 16092 80.91.229.12 (21 Sep 2009 21:54:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Sep 2009 21:54:07 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Sep 21 23:54:00 2009 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.50) id 1Mpqpb-0002sg-W7 for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Sep 2009 23:54:00 +0200 Original-Received: from localhost ([127.0.0.1]:47961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mpqpb-0001u8-4P for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Sep 2009 17:53:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MpkTu-0005A9-Kj for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 11:07:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MpkTp-00059W-RF for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 11:07:10 -0400 Original-Received: from [199.232.76.173] (port=34497 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MpkTp-00059T-Or for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 11:07:05 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:57450) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MpkTp-00047P-33 for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 11:07:05 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n8LF73Nx024193; Mon, 21 Sep 2009 08:07:03 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n8LEo4ge020745; Mon, 21 Sep 2009 07:50:04 -0700 Resent-Date: Mon, 21 Sep 2009 07:50:04 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Bruno Barbier Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Mon, 21 Sep 2009 14:50:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 4504 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.125354417419754 (code B ref -1); Mon, 21 Sep 2009 14:50:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 21 Sep 2009 14:42:54 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n8LEgqes019751 for ; Mon, 21 Sep 2009 07:42:53 -0700 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mpk6O-0003tb-0M for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 10:42:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mpk6I-0003tB-JH for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 10:42:50 -0400 Original-Received: from [199.232.76.173] (port=60777 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mpk6I-0003t8-Ck for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 10:42:46 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]:63401) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mpk6H-0006UZ-Tu for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 10:42:46 -0400 Original-Received: from smtp2f.orange.fr ([80.12.242.152]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mpk6G-0001bt-4l for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2009 10:42:44 -0400 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2f21.orange.fr (SMTP Server) with ESMTP id 34E598000041 for ; Mon, 21 Sep 2009 16:42:37 +0200 (CEST) Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2f21.orange.fr (SMTP Server) with ESMTP id 28FDA80000A6 for ; Mon, 21 Sep 2009 16:42:37 +0200 (CEST) Original-Received: from orange.fr (ADijon-258-1-78-183.w90-13.abo.wanadoo.fr [90.13.61.183]) by mwinf2f21.orange.fr (SMTP Server) with SMTP id AA23A800004A for ; Mon, 21 Sep 2009 16:42:36 +0200 (CEST) X-ME-UUID: 20090921144236696.AA23A800004A@mwinf2f21.orange.fr Original-Received: by orange.fr (nbSMTP-1.00) for uid 1000 bruno.barbier.cs@orange.fr; Mon, 21 Sep 2009 16:20:16 +0200 (CEST) Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Mon, 21 Sep 2009 11:07:10 -0400 X-Mailman-Approved-At: Mon, 21 Sep 2009 17:49:10 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list 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:31328 Archived-At: --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * Problem The function `minibuffer-force-complete' does not cycle through completions; it just steps through the completion list once. * Step to reproduce: 1. In a shell emacs -Q --eval "(progn \ (define-key minibuffer-local-completion-map \ (kbd \"M-\" ) \ #'minibuffer-force-complete) \ (setq unread-command-events \ (append '(?\M-x ?s ?e ?t ?- ?v) \ '(tab M-tab M-tab) \ unread-command-events )) \ ) \ " 2. Hit M- * Result M- offers only "set-visited-file-name" as the sole completion. * Expected result M- should allow cycling through the choices: set-variable set-visited-file-name * Proposed solution See attached patch against today CVS version ([2009-09-21 Mon]). * Proposed ChangeLog item if needed. 2009-09-21 or whoever commits it * minibuffer.el: The function `minibuffer-force-complete' now cycles through the completion choices (it was just stepping through the completion list once). --M9NhX3UHpAaciwkO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="minibuffer.el.patch" *** emacs/lisp/minibuffer.el Wed Sep 2 05:09:19 2009 --- patched-emacs/lisp/minibuffer.el Mon Sep 21 15:40:24 2009 *************** *** 528,536 **** (setq completion-all-sorted-completions (nconc all base-size)))))) (defun minibuffer-force-complete () "Complete the minibuffer to an exact match. ! Repeated uses step through the possible completions." (interactive) ;; FIXME: Need to deal with the extra-size issue here as well. (let* ((start (field-beginning)) --- 528,576 ---- (setq completion-all-sorted-completions (nconc all base-size)))))) + (defun minibuffer--rotate-completions (l) + "Rotate the list of completions L. + + The first element becomes the last one. More precisely: + (minibuffer--rotate-completions '(c1 c2 .. c_{n-1} cn . basesize)) + ==> + (cn c1 c2 .. c_{n-1} . basesize)" + (if (not l) l + (let* ( ;; The first pair of the final result. We will set its elements + ;; when we meet them. + (result (cons nil nil)) + ;; The current pair we are building. + (now result) + ;; The tail of the completions we want to rotate. + (tail (cdr l)) + ) + ;; We copy until the last pair. + (while (consp tail) + (let ((next (cons (car l) nil)) + ) + ;; make `now' points to next and shift to next. + (setcdr now next) + (setq now next) + ;; update what we want to rotate on. + (setq l tail) + (setq tail (cdr l)) + )) + ;; Tail is the final element: it is basesize or nil, + ;; l is the last pair and its car is the last completion item. + (setcar result (car l)) + (setcdr now (cdr l)) + result) + )) + ;; @TEST with basesize: (minibuffer--rotate-completions '(1 2 3 . 4)) + ;; ==> (3 1 2 . 4) + ;; @TEST no basesize: (minibuffer--rotate-completions '(1 2 3 4)) + ;; ==> (4 1 2 3) + ;; @TEST limit case: (minibuffer--rotate-completions '()) + ;; ==> nil + (defun minibuffer-force-complete () "Complete the minibuffer to an exact match. ! Repeated uses cycle through the possible completions." (interactive) ;; FIXME: Need to deal with the extra-size issue here as well. (let* ((start (field-beginning)) *************** *** 546,552 **** ;; completion-all-sorted-completions to nil, but we prefer not to, ;; so that repeated calls minibuffer-force-complete still cycle ;; through the previous possible completions. ! (setq completion-all-sorted-completions (cdr all))))) (defvar minibuffer-confirm-exit-commands '(minibuffer-complete minibuffer-complete-word PC-complete PC-complete-word) --- 586,594 ---- ;; completion-all-sorted-completions to nil, but we prefer not to, ;; so that repeated calls minibuffer-force-complete still cycle ;; through the previous possible completions. ! (setq completion-all-sorted-completions ! (minibuffer--rotate-completions all)) ! ))) (defvar minibuffer-confirm-exit-commands '(minibuffer-complete minibuffer-complete-word PC-complete PC-complete-word) --M9NhX3UHpAaciwkO--