Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
;; Matching words containing all given letters in any order
(defun my/match-word ()
"Matches words containing all chars d, l, s in any order: dollars solid
Match will fail if a word is missing any of those characters. e.g. dollar"
(let ((this-word (thing-at-point 'word)) ; get the word at point
(insert this-word)
(sort-regexp-fields nil "\\w" "\\&" (point-min) (point-max)) ; sort chars in word
;; Now that the chars are sorted alphabetically, you can search for
;; the letters in alphabetical order: d, l, s
(if (looking-at "\\w*[d]+\\w*[l]+\\w*[s]+\\w*")
(setq match t)
(setq match nil)))
(when match
(defun my/match-word-whole-buffer ()
(while (not (eobp))
(when (string-match "\\w\\{3,\\}" (thing-at-point 'word))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.