Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Last active June 23, 2025 12:21
Show Gist options
  • Save dotemacs/30cecbddcd8ee3dd5447d37e4286b9cd to your computer and use it in GitHub Desktop.
Save dotemacs/30cecbddcd8ee3dd5447d37e4286b9cd to your computer and use it in GitHub Desktop.
;; 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