emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#17545: closed (24.4.50; icomplete conflicts with m


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#17545: closed (24.4.50; icomplete conflicts with minibuffer default)
Date: Sun, 01 Jun 2014 02:26:02 +0000

Your message dated Sat, 31 May 2014 22:25:26 -0400
with message-id <address@hidden>
and subject line Re: bug#17545: 24.4.50; icomplete conflicts with minibuffer 
default
has caused the debbugs.gnu.org bug report #17545,
regarding 24.4.50; icomplete conflicts with minibuffer default
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
17545: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17545
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 24.4.50; icomplete conflicts with minibuffer default Date: Wed, 21 May 2014 08:40:03 -0700
When completing in the minibuffer using icomplete-mode, an invisible
completion can circumvent the minibuffer's default selection.

For example, say you have icomplete enabled, and you try to kill the
current buffer. The minibuffer will show a confirmation message like,
"Kill buffer (default: foo)". If you type C-j to trigger icomplete
without having actually typed any characters, icomplete will terminate
an unrelated buffer and won't even tell you which it was. It will
terminate whatever buffer it decides is the completion of nothing at
that time.

This is confusing because the minibuffer prompt suggests a completely
different default. Here's a function that fixes the behavior:

(defun icomplete-complete-or-default ()
  (interactive)
  (let* ((start (minibuffer-prompt-end))
         (end (point-max))
         (phrase (buffer-substring start end)))
         
    (if (zerop (length phrase))
        ; Select the minibuffer's default if there's no text after
        ; the prompt.
        (minibuffer-complete-and-exit)
        
      ; Select icomplete's default completion if the user has typed
      ; something.
      (minibuffer-force-complete-and-exit))
  ))

Then remapping C-j to call that in the icomplete keymap fixes the bug:

 (defvar icomplete-minibuffer-map
   (let ((map (make-sparse-keymap)))
     (define-key map [?\M-\t] 'minibuffer-force-complete)
-    (define-key map [?\C-j]  'minibuffer-force-complete-and-exit)
+    (define-key map [?\C-j]  'icomplete-complete-or-default)
     (define-key map [?\C-.]  'icomplete-forward-completions)
     (define-key map [?\C-,]  'icomplete-backward-completions)
     map)
   "Keymap used by `icomplete-mode' in the minibuffer.")

I came across this trying to remap icomplete to <return> instead of C-j
so that the keys are more like the (apparently dead) iswitchb. That
doesn't seem like an unreasonable thing to do, although I don't know how
many people used iswitchb.


--- End Message ---
--- Begin Message --- Subject: Re: bug#17545: 24.4.50; icomplete conflicts with minibuffer default Date: Sat, 31 May 2014 22:25:26 -0400 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)
>> This is confusing because the minibuffer prompt suggests a completely
>> different default. Here's a function that fixes the behavior:
> I think a better fix is to change icomplete such that if the default is
> among the possible completions, then it appears first.

In the end I installed patch following the same idea as yours (but
folded into minibuffer-force-complete-and-exit).  Thank you.


        Stefan


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]