forked from colonelpanic/dotfiles
[Emacs] Add with-advice macro
This commit is contained in:
parent
3f4513132f
commit
500af20185
@ -548,6 +548,20 @@ new macro name and the -fn suffix.
|
|||||||
'arg
|
'arg
|
||||||
`(funcall ,(car funcs) (imalison:compose-helper-unary ,(cdr funcs)))))
|
`(funcall ,(car funcs) (imalison:compose-helper-unary ,(cdr funcs)))))
|
||||||
#+END_SRC
|
#+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
|
** Make Interactive
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defmacro imalison:make-interactive-fn (function)
|
(defmacro imalison:make-interactive-fn (function)
|
||||||
|
Loading…
Reference in New Issue
Block a user