Last active
June 23, 2025 12:21
-
-
Save dotemacs/30cecbddcd8ee3dd5447d37e4286b9cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
;; inspiration taken from Marcin Borkowski's tweet, that makes non | |
;; interactive functions, interactive: | |
;; https://x.com/marcin_mbork/status/1937033217389076789 | |
(defun my/make-function-interactive (function-name) | |
"Make a non-interactive function interactive by adding advice. | |
Prompts for FUNCTION-NAME and adds :before advice with an interactive declaration." | |
(interactive "aFunction to make interactive: ") | |
(let ((func-symbol (if (stringp function-name) | |
(intern function-name) | |
function-name))) | |
(if (fboundp func-symbol) | |
(progn | |
(advice-add func-symbol | |
:before | |
(lambda () (interactive) nil)) | |
(message "Made %s interactive" func-symbol)) | |
(error "Function %s is not defined" func-symbol)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment