unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions
@ 2009-09-21 14:20 ` Bruno Barbier
  2009-09-24  2:39   ` Stefan Monnier
  2009-09-24 15:15   ` bug#4504: marked as done (23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions) Emacs bug Tracking System
  0 siblings, 2 replies; 4+ messages in thread
From: Bruno Barbier @ 2009-09-21 14:20 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]


* 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-<tab>\" )                      \
                               #'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-<tab>


* Result

   M-<tab> offers only "set-visited-file-name" as the sole completion.


* Expected result

   M-<tab> 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    <bruno.barbier.cs@orange.fr> 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).


[-- Attachment #2: minibuffer.el.patch --]
[-- Type: text/plain, Size: 3141 bytes --]

*** 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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions
  2009-09-21 14:20 ` bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions Bruno Barbier
@ 2009-09-24  2:39   ` Stefan Monnier
  2009-09-24  7:51     ` Bruno Barbier
  2009-09-24 15:15   ` bug#4504: marked as done (23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions) Emacs bug Tracking System
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2009-09-24  2:39 UTC (permalink / raw)
  To: Bruno Barbier; +Cc: bug-gnu-emacs, 4504

> The function `minibuffer-force-complete' does not cycle
> through completions; it just steps through the completion list once.

Indeed.

> See attached patch against today CVS version ([2009-09-21 Mon]).

Thank you.  I've installed a simpler patch (see below) that makes use of
the `last' function.

> 2009-09-21    <bruno.barbier.cs@orange.fr> or whoever commits it

Actually, this part of the changelog should list the author of the
patch, not the person who committed it.


        Stefan


Index: lisp/minibuffer.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/minibuffer.el,v
retrieving revision 1.83
diff -u -r1.83 minibuffer.el
--- lisp/minibuffer.el	2 Sep 2009 03:09:19 -0000	1.83
+++ lisp/minibuffer.el	24 Sep 2009 02:37:30 -0000
@@ -546,7 +546,9 @@
       ;; 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)))))
+      (let ((last (last all)))
+        (setcdr last (cons (car all) (cdr last)))
+        (setq completion-all-sorted-completions (cdr all))))))
 
 (defvar minibuffer-confirm-exit-commands
   '(minibuffer-complete minibuffer-complete-word PC-complete PC-complete-word)





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions
  2009-09-24  2:39   ` Stefan Monnier
@ 2009-09-24  7:51     ` Bruno Barbier
  0 siblings, 0 replies; 4+ messages in thread
From: Bruno Barbier @ 2009-09-24  7:51 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: bug-gnu-emacs, 4504

On Wed, Sep 23, 2009 at 10:39:06PM -0400, Stefan Monnier wrote:
> 
> Thank you.  I've installed a simpler patch (see below) that makes use of
> the `last' function.
> 

Great. It's simpler and it works.

Thank you.

Bruno








^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#4504: marked as done (23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions)
  2009-09-21 14:20 ` bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions Bruno Barbier
  2009-09-24  2:39   ` Stefan Monnier
@ 2009-09-24 15:15   ` Emacs bug Tracking System
  1 sibling, 0 replies; 4+ messages in thread
From: Emacs bug Tracking System @ 2009-09-24 15:15 UTC (permalink / raw)
  To: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 991 bytes --]

Your message dated Thu, 24 Sep 2009 11:07:24 -0400
with message-id <jwvocp0crg7.fsf-monnier+emacsbugreports@gnu.org>
and subject line Re: bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions
has caused the Emacs bug report #4504,
regarding 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com
immediately.)


-- 
4504: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=4504
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 7785 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 1418 bytes --]


* 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-<tab>\" )                      \
                               #'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-<tab>


* Result

   M-<tab> offers only "set-visited-file-name" as the sole completion.


* Expected result

   M-<tab> 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    <bruno.barbier.cs@orange.fr> 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).


[-- Attachment #2.1.2: minibuffer.el.patch --]
[-- Type: text/plain, Size: 3141 bytes --]

*** 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)

[-- Attachment #3: Type: message/rfc822, Size: 1997 bytes --]

From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Bruno Barbier <bruno.barbier.cs@orange.fr>
Subject: Re: bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions
Date: Thu, 24 Sep 2009 11:07:24 -0400
Message-ID: <jwvocp0crg7.fsf-monnier+emacsbugreports@gnu.org>

>> Thank you.  I've installed a simpler patch (see below) that makes use of
>> the `last' function.
> Great. It's simpler and it works.
> Thank you.

Thanks for confirming,


        Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-09-24 15:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <jwvocp0crg7.fsf-monnier+emacsbugreports@gnu.org>
2009-09-21 14:20 ` bug#4504: 23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions Bruno Barbier
2009-09-24  2:39   ` Stefan Monnier
2009-09-24  7:51     ` Bruno Barbier
2009-09-24 15:15   ` bug#4504: marked as done (23.1; [missing feature] `minibuffer-force-completion' does not cycle through completions) Emacs bug Tracking System

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).