mirror of
https://github.com/protesilaos/dotfiles.git
synced 2026-09-10 07:16:20 -04:00
emacs: add some comments about corfu and completion-preview-mode
This commit is contained in:
parent
108a81175a
commit
f6a423159f
|
|
@ -411,6 +411,26 @@ Development continues on GitHub with GitLab as a mirror."))
|
|||
(corfu-history-mode 1)
|
||||
(add-to-list 'savehist-additional-variables 'corfu-history))))
|
||||
|
||||
(prot-emacs-comment
|
||||
(prot-emacs-configure
|
||||
(setq completion-preview-exact-match-only nil)
|
||||
(setq completion-preview-commands '(self-insert-command
|
||||
insert-char
|
||||
analyze-text-conversion
|
||||
completion-preview-insert-word))
|
||||
(setq completion-preview-minimum-symbol-length 4)
|
||||
(setq completion-preview-idle-delay 0.3)
|
||||
(setq completion-preview-ignore-case t)
|
||||
(setq completion-preview-sort-function #'identity)
|
||||
|
||||
(add-hook 'prog-mode-hook #'completion-preview-mode)
|
||||
|
||||
(with-eval-after-load 'completion-preview
|
||||
(prot-emacs-keybind completion-preview-active-mode-map
|
||||
"M-n" #'completion-preview-next-candidate
|
||||
"M-p" #'completion-preview-prev-candidate
|
||||
"<tab>" #'completion-preview-complete))))
|
||||
|
||||
;;; Enhanced minibuffer commands (consult.el)
|
||||
(when prot-emacs-completion-extras
|
||||
(prot-emacs-configure
|
||||
|
|
|
|||
|
|
@ -4810,21 +4810,24 @@ Development continues on GitHub with GitLab as a mirror."))
|
|||
(remove-hook 'save-some-buffers-functions #'abbrev--possibly-save))
|
||||
#+end_src
|
||||
|
||||
*** The =prot-emacs-completion.el= for in-buffer completion popup (~corfu~)
|
||||
*** The =prot-emacs-completion.el= settings for in-buffer completion popup (~corfu~)
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: h:804b858f-7913-47ef-aaf4-8eef5b59ecb4
|
||||
:END:
|
||||
|
||||
I generally do not rely on in-buffer text completion. I feel it slows
|
||||
me down and distracts me. When I do, however, need to rely on it, I
|
||||
have the ~corfu~ package by Daniel Mendler: it handles the task
|
||||
splendidly as it works with Emacs' underlying infrastructure for
|
||||
~completion-at-point-functions~.
|
||||
I generally do not rely on in-buffer text completion, no matter how
|
||||
minimalist it is ([[#h:bb7959b3-d8e6-4163-8e32-bec2b96b7dde][The =prot-emacs-completion.el= for in-buffer completion hints (~completion-preview-mode~)]]).
|
||||
I feel it slows me down and distracts me. When I do, however, need to
|
||||
rely on it, I appreciate the ~corfu~ package by Daniel Mendler: it handles
|
||||
the task splendidly and works with Emacs' underlying infrastructure
|
||||
for ~completion-at-point-functions~.
|
||||
|
||||
Completion is triggered with the =TAB= key, which produces a popup
|
||||
where the cursor is. The companion ~corfu-popupinfo-mode~ will show a
|
||||
secondary documentation popup if we move over a candidate but do not
|
||||
do anything with it.
|
||||
where the cursor is, if re-indentation cannot be performed there ([[#h:559713c8-0e1e-44aa-bca8-0caae01cc8bb][The =prot-emacs-langs.el= settings for TAB]]).
|
||||
The companion ~corfu-popupinfo-mode~ will show a secondary
|
||||
documentation popup if we move over a candidate but do not do anything
|
||||
with it for the first number in ~corfu-popupinfo-delay~ and then
|
||||
subsequent popups are subject to the second number of that same variable.
|
||||
|
||||
Also see [[#h:567bb00f-1d82-4746-93e5-e0f60721728a][the =prot-emacs-completion.el= settings for dynamic text expansion (~dabbrev~)]].
|
||||
|
||||
|
|
@ -4854,12 +4857,19 @@ Also see [[#h:567bb00f-1d82-4746-93e5-e0f60721728a][the =prot-emacs-completion.e
|
|||
(add-to-list 'savehist-additional-variables 'corfu-history))))
|
||||
#+end_src
|
||||
|
||||
*** COMMENT The =prot-emacs-completion.el= for in-buffer completion hints (~completion-preview-mode~)
|
||||
*** The =prot-emacs-completion.el= for in-buffer completion hints (~completion-preview-mode~)
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: h:bb7959b3-d8e6-4163-8e32-bec2b96b7dde
|
||||
:END:
|
||||
|
||||
[ NOTE 2025-12-10: I stopped using this because I find it distracting. ]
|
||||
[ NOTE 2025-12-10: I stopped using this because I find it distracting.
|
||||
Same with ~corfu~, by the way ([[#h:804b858f-7913-47ef-aaf4-8eef5b59ecb4][The =prot-emacs-completion.el= settings for in-buffer completion popup (~corfu~)]]):
|
||||
I ultimately prefer to type than to have things come in and out of
|
||||
focus all the time. Though the ~completion-preview-mode~ is extra
|
||||
difficult for me because it usually gives me a false positive,
|
||||
meaning that I get distracted about something I do not need to know,
|
||||
anyway. I keep this configuration here in case anybody wants to
|
||||
learn from it. ]
|
||||
|
||||
The built-in ~completion-preview~ by Eshel Yaron provides a minimalist
|
||||
interface for in-buffer completion. Instead of popping up a list with
|
||||
|
|
@ -4889,24 +4899,25 @@ overarching theme of my choices is to reduce noise. More specifically:
|
|||
need a hint for longer words/symbols.
|
||||
|
||||
#+begin_src emacs-lisp :tangle "prot-emacs-modules/prot-emacs-completion.el"
|
||||
(prot-emacs-configure
|
||||
(setq completion-preview-exact-match-only nil)
|
||||
(setq completion-preview-commands '(self-insert-command
|
||||
insert-char
|
||||
analyze-text-conversion
|
||||
completion-preview-insert-word))
|
||||
(setq completion-preview-minimum-symbol-length 4)
|
||||
(setq completion-preview-idle-delay 0.3)
|
||||
(setq completion-preview-ignore-case t)
|
||||
(setq completion-preview-sort-function #'identity)
|
||||
(prot-emacs-comment
|
||||
(prot-emacs-configure
|
||||
(setq completion-preview-exact-match-only nil)
|
||||
(setq completion-preview-commands '(self-insert-command
|
||||
insert-char
|
||||
analyze-text-conversion
|
||||
completion-preview-insert-word))
|
||||
(setq completion-preview-minimum-symbol-length 4)
|
||||
(setq completion-preview-idle-delay 0.3)
|
||||
(setq completion-preview-ignore-case t)
|
||||
(setq completion-preview-sort-function #'identity)
|
||||
|
||||
(add-hook 'prog-mode-hook #'completion-preview-mode)
|
||||
(add-hook 'prog-mode-hook #'completion-preview-mode)
|
||||
|
||||
(with-eval-after-load 'completion-preview
|
||||
(prot-emacs-keybind completion-preview-active-mode-map
|
||||
"M-n" #'completion-preview-next-candidate
|
||||
"M-p" #'completion-preview-prev-candidate
|
||||
"<tab>" #'completion-preview-complete)))
|
||||
(with-eval-after-load 'completion-preview
|
||||
(prot-emacs-keybind completion-preview-active-mode-map
|
||||
"M-n" #'completion-preview-next-candidate
|
||||
"M-p" #'completion-preview-prev-candidate
|
||||
"<tab>" #'completion-preview-complete))))
|
||||
#+end_src
|
||||
|
||||
*** The =prot-emacs-completion.el= settings for ~consult~
|
||||
|
|
@ -15416,6 +15427,37 @@ Also see `prot-register-use-dwim'."
|
|||
(t
|
||||
(error "The register is unknown: %S" contents)))))
|
||||
|
||||
(defcustom prot-register-save-file (locate-user-emacs-file "prot-register.eld")
|
||||
"File to store registers to and retrieve from."
|
||||
:type 'file)
|
||||
|
||||
(defun prot-register-store ()
|
||||
"Write `register-alist' to `prot-register-save-file'."
|
||||
(with-temp-file prot-register-save-file
|
||||
(insert ";; Auto-generated file: DO NOT EDIT -*- mode: emacs-lisp -*-\n")
|
||||
(pp register-alist (current-buffer))))
|
||||
|
||||
(defun prot-register-load ()
|
||||
"Read `prot-register-save-file' and return its contents."
|
||||
(with-temp-buffer
|
||||
(insert-file-contents prot-register-save-file)
|
||||
(read (buffer-string))))
|
||||
|
||||
(defun prot-register-watcher (symbol newval operation where)
|
||||
(when (and (eq operation 'set) (null where) newval)
|
||||
(prot-register-store)))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode prot-register-persist-mode
|
||||
"When enabled save `register-alist' to `prot-register-save-file' when a change occurs."
|
||||
:globat t
|
||||
(if prot-register-persist-mode
|
||||
(progn
|
||||
(add-variable-watcher 'register-alist #'prot-register-watcher)
|
||||
(add-hook 'kill-emacs-hook #'prot-register-store))
|
||||
(remove-variable-watcher 'register-alist #'prot-register-watcher)
|
||||
(remove-hook 'kill-emacs-hook #'prot-register-store)))
|
||||
|
||||
(provide 'prot-register)
|
||||
;;; prot-register.el ends here
|
||||
#+end_src
|
||||
|
|
|
|||
Loading…
Reference in a new issue