[Emacs] Add with-advice macro

This commit is contained in:
Ivan Malison 2016-11-02 18:12:58 -07:00
parent 3f4513132f
commit 500af20185
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -548,6 +548,20 @@ new macro name and the -fn suffix.
'arg
`(funcall ,(car funcs) (imalison:compose-helper-unary ,(cdr funcs)))))
#+END_SRC
** With Advice
Taken from [[http://emacs.stackexchange.com/questions/16490/emacs-let-bound-advice][here]].
#+BEGIN_SRC emacs-lisp
(defmacro imalison:with-advice (args &rest body)
(declare (indent 1))
(let ((fun-name (car args))
(advice (cadr args))
(orig-sym (make-symbol "orig")))
`(cl-letf* ((,orig-sym (symbol-function ',fun-name))
((symbol-function ',fun-name)
(lambda (&rest args)
(apply ,advice ,orig-sym args))))
,@body)))
#+END_SRC
** Make Interactive
#+BEGIN_SRC emacs-lisp
(defmacro imalison:make-interactive-fn (function)