XahTV 2021-04-18 Emacs Lisp. Fuzzy Matching. Explore Ido and Helm Source Code, Part 1
- highlight https://youtu.be/FC5qzH0yxyk?t=4461 exceptions in programing languages, not what you think it is
- Write a command that let user select from predefined list of choices. Using ido mode's fuzzy matching.
- Explain what the type of fuzzy matching ido is using.
- Explain that we want a word based fuzzy matching, and order does not matter.
- Explore helm M-x to see how it works.
- Optional: see how ido implements fuzzy matching.
- Why I Hate Exceptions
(defun select-choices () "Select from a list of predefine choices, then insert them into buffer. version 2021-04-18 " (interactive) (let ( (phrases '( "This heart follows the brain of __" "This field closely follows the paradigm of __" "Widely considered to be a good way to __" "This has been widely adopted in the field of __" "This is more widely used at the time of __" "This phenomenon has been widely observed" "A common technique is to __" "This is a technique common in __" "There are several common kinds of __" )) userChoice ) ;; (message "%s" (car phrases)) (setq userChoice (ido-completing-read "Make a choice:" phrases )) (insert userChoice) ;; )) ;; ido fuzzy matching is a character based fuzzy matching, and order matters ;; now let's explor other tyes of fuzzy matching. In particular, let's look at helm's M-x. i know it does fuzzy matching, but word based, and order does not matter. ;; now, let's look at helm's implementation of M-x: helm-M-x ;; the call stack ;; helm-M-x ;; helm ;; helm-internal ;; helm-read-from-minibuffer