all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* History completion
@ 2021-12-08 18:54 Juri Linkov
  2021-12-08 20:02 ` André A. Gomes
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Juri Linkov @ 2021-12-08 18:54 UTC (permalink / raw)
  To: emacs-devel

Wouldn't it be nice to allow completion on previous input
in the minibuffer.

There are two unbound commands ‘previous-complete-history-element’ and
‘next-complete-history-element’ but their completion is limited
only to the beginnings of history items.

So tried to set the minibuffer completion table to the history list:

#+begin_src emacs-lisp
(defun minibuffer-setup-history-completions ()
  (unless (or minibuffer-completion-table minibuffer-completion-predicate)
    (setq-local minibuffer-completion-table (symbol-value minibuffer-history-variable))))
(add-hook 'minibuffer-setup-hook 'minibuffer-setup-history-completions)
#+end_src

It works nicely with ‘icomplete-mode’ and ‘fido-vertical-mode’
by automatically displaying completions from the history
depending on input in the minibuffer.  But this also has drawbacks:
while typing a completely new command that doesn't exist in the history,
it permanently says at the end of the minibuffer: [No matches]

So instead of this, tried to show history completions only after
typing a special key.  TAB can't be reused because in some minibuffers
such as ‘M-!’ (shell-command), TAB completes the command/file names.

There is ‘C-tab’ bound to file-cache-minibuffer-complete.
When file-cache is not used, then ‘C-tab’ could be rebound
to a command that completes on the minibuffer history:

#+begin_src emacs-lisp
;; Adapted from ‘minibuffer-complete’:
(defun minibuffer-complete-history ()
  (interactive)
  (completion-in-region (minibuffer--completion-prompt-end) (point-max)
                        (symbol-value minibuffer-history-variable)
                        nil))
(define-key minibuffer-local-map [C-tab] 'minibuffer-complete-history)
#+end_src



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

end of thread, other threads:[~2022-06-09  7:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-08 18:54 History completion Juri Linkov
2021-12-08 20:02 ` André A. Gomes
2021-12-09  6:05   ` Manuel Uberti
2021-12-09 17:12   ` Juri Linkov
2021-12-09 22:52     ` André A. Gomes
2021-12-08 20:52 ` [External] : " Drew Adams
2021-12-09  8:30   ` Daniel Fleischer
2021-12-09 17:16   ` Juri Linkov
2021-12-09 18:13     ` [External] : " Drew Adams
2021-12-09  7:51 ` Manuel Uberti
2021-12-09 17:18   ` Juri Linkov
2021-12-09 17:40     ` Manuel Uberti
2022-06-09  7:01 ` Juri Linkov

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.