Skip to content

Instantly share code, notes, and snippets.

@djuber
Created May 26, 2021 21:12
Show Gist options
  • Save djuber/a3071cd7ed5f0ad322e079358f5904aa to your computer and use it in GitHub Desktop.
Save djuber/a3071cd7ed5f0ad322e079358f5904aa to your computer and use it in GitHub Desktop.
make ivy (counsel-M-x) expansion respect ido style dashed abbreviations
;; Thanks @bschmeck
(defun shmk/ivy--regex-dashes (str)
"Build a regex sequence from STR.
Insert .* before each -."
(let ((subs (split-string str "-")))
(if (= (length subs) 1)
(ivy--regex str)
(ivy--regex (concat "^" (string-join subs "[[:alnum:]]*-"))))))
(setq ivy-re-builders-alist
'((execute-extended-command . shmk/ivy--regex-dashes)
(t . ivy--regex-plus)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment