[Top][All Lists]

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

Re: Emacs completion matches selection UI

From: Stefan Monnier
Subject: Re: Emacs completion matches selection UI
Date: Tue, 19 Nov 2013 09:00:40 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> In modern UIs, auto-completion works such a way that after you type text
>> it pops up a drop-down menu with a list of candidates where you can
>> select one by using <down> and <up> arrow keys.
> Helm works like this. You type and the candidates appear automatically.

For the "appear" part you could start with the trivial minor-mode below.
But I think what Ted is after is the other part: down/up/...

While there is a risk of conflict in key-bindings, I do think it should
be possible to "keep the best of both worlds" such that it could be
enabled by default.

E.g.: keep the same behavior by default as we have now, except that we
add a new `select-completion-mode'.  In this new mode, cursor keys move
between elements of the completions list, RET selects the completion
element from there, and most other keys just exit the mode.

The main issue is then to figure out how/when to switch to this
new mode.  E.g. when the user hits `up' right after the *Completions*
buffer got displayed/updated?

> It could also be considered as a possible alternative completion UI.

Part of Helm is an alternative completion UI, indeed.  Another part is
a much fancier completion-list-mode.  And then yet another part relies
on this much fancier completion-list-mode to change the argument order
around, so that instead of first specifying the command and then the
object on which to apply it, you first specify the object and then
the command.


(defun verbose--icomplete-do ()
  (let ((beg (minibuffer-prompt-end))
        (end (point-max))
        (non-essential t))
    (when (and (not (eq beg end)) buffer-undo-list)
        (minibuffer-completion-help beg end)))))

(defun verbose--icomplete-setup ()
  (when minibuffer-completion-table
    (add-hook 'post-command-hook #'verbose--icomplete-do nil 'local)))

(define-minor-mode verbose-icomplete-mode
  :global t
  (if verbose-icomplete-mode
      (add-hook 'minibuffer-setup-hook 'verbose--icomplete-setup)
    (remove-hook 'minibuffer-setup-hook 'verbose--icomplete-setup)))

reply via email to

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