Last active
April 6, 2021 07:20
-
-
Save dgutov/5042865 to your computer and use it in GitHub Desktop.
Find unused definitions in Emacs Lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun check-next-def () | |
(push-mark nil t) | |
(when (re-search-forward | |
(concat "(def\\(?:un\\|macro\\|subst\\|var\\|const\\) " | |
"\\(\\(?:\\sw\\|\\s_\\)+\\)") | |
nil 'move) | |
(save-excursion | |
(let ((name (match-string 1))) | |
(goto-char (point-min)) | |
(unless (re-search-forward (concat "\\_<" name "\\_>") nil t 2) | |
name))))) | |
(defun find-unused-def () | |
(interactive) | |
(let (name) | |
(while (and (not (eobp)) | |
(not (setq name (check-next-def))))) | |
(message "Found! %s" name))) | |
(global-set-key [f7] 'find-unused-def) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment