oantolin / orderless

Emacs completion style that matches multiple regexps in any order
GNU General Public License v3.0
745 stars 27 forks source link

Keybinding to switch between smart and strict case #154

Closed dwrz closed 5 months ago

dwrz commented 9 months ago

Do you have any suggestions on being able to switch between smart and strict while in the middle of a search?

I'm currently manually setting orderless-smart-case when I need strict search.

minad commented 5 months ago

You can write a toggle command and bind it to a key. It may be necessary to tell the completion UI to refresh (to clear the completion candidate cache, since the input did not change), for example in Vertico:

(defun +orderless-toggle-smart-case ()
  (interactive)
  (message
   "Smart case: %s"
   (setq-local orderless-smart-case (not orderless-smart-case)))
  (setq-local vertico--input t)) ;; Enforce Vertico refresh

(keymap-set vertico-map "M-$" #'+orderless-toggle-smart-case)