u/the_cecep

New Prot video: Write with input method (e.g. French) and Jinx for spelling
▲ 55 r/emacs

New Prot video: Write with input method (e.g. French) and Jinx for spelling

Another great video by him. I didn't know about input methods, especially the postfix variants Prot is showing here are very useful to me.

youtu.be
u/the_cecep — 3 days ago
▲ 69 r/emacs

Underappreciated Emacs built-ins: completion-preview-mode

As a small contribution to this month's Emacs Carnival, I want to highlight completion-preview-mode. Whether it's really "underappreciated" is debatable, the feature did receive some attention when it was introduced in Emacs 30, but I didn't see it mentioned often here and it is getting better with the upcoming update to Emacs 31.

If you never heard about completion-preview-mode: It's a minor mode that shows completions as you type as an in-line preview right after point. Pressing Tab while the preview is visible inserts it. The mode was developed by Eshel Yaron and I recommend reading his article to learn more (and see screenshots). As he put it, completion-preview-mode is meant to be "maximally helpful while remaining minimally intrusive." And at least for me, it manages to strike this balance nicely.

Emacs 31 added two new options: completion-preview-sort-function and completion-preview-inhibit-functions. The latter fixes the main issue I had with completion preview: Org tables. When the preview is shown, its keybindings overwrite Org's, so pressing Tab inserts the completion rather than moving to the next cell. Now it's easy to disable completion previews inside Org tables to avoid that.

Here is my config, including the new completion-preview-inhibit-functions option:

(use-package completion-preview
  :ensure nil
  :hook (after-init . global-completion-preview-mode)
  :bind
  ( :map completion-preview-active-mode-map
    ("M-n" . completion-preview-next-candidate)
    ("M-p" . completion-preview-prev-candidate))
  :custom
  (completion-preview-minimum-symbol-length 2) ; Show the preview already after two symbol characters
  (completion-preview-exact-match-only nil) ; If t, only show suggestion if there is only one candidate
  (completion-preview-idle-delay 0.3) ; If non-nil, wait this many idle seconds before displaying preview
  :config
  (with-eval-after-load 'org
    ;; Add Org mode's custom 'self-insert-command' to completion-previews
    (push 'org-self-insert-command completion-preview-commands)
    )
  ;; Disable completion preview in Org tables (Emacs 31+)
  (defun my/detect-org-table ()
    "Return true if point in Org table."
    (and (derived-mode-p 'org-mode) (org-at-table-p)))
  (add-hook 'completion-preview-inhibit-functions
            #'my/detect-org-table))
reddit.com
u/the_cecep — 15 days ago