Emacs Part 44
■ このスレッドは過去ログ倉庫に格納されています
0259名無しさん@お腹いっぱい。
2014/01/15(水) 01:17:18.21こういうことか? マクロ書き慣れてないから eval 沢山あってキモい
(defmacro keu:with-advice (on-or-off func class advice &rest body)
"[internal] Evaluate BODY with ADVICE enabled/disabled.
Note that there is a bug that it cannot restore the state of ADVICE.
Any ideas?"
(let ((adviced (caddr (assq (eval advice)
(assq (eval class)
(ad-get-advice-info (eval func)))))))
(if (or (and (eq (eval on-or-off) 'on) adviced)
(and (eq (eval on-or-off) 'off) (not adviced)))
`(progn
,@body)
`(progn
,(pcase on-or-off
(`'on `(ad-enable-advice ,func ,class ,advice))
(`'off `(ad-disable-advice ,func ,class ,advice))
(_ (error "the first argument must be the symol 'on or 'off")))
(ad-activate ,func)
(let ((keu:with-advice:return-value ,@body))
,(pcase on-or-off
(`'on `(ad-disable-advice ,func ,class ,advice))
(`'off `(ad-enable-advice ,func ,class ,advice))
(_ (error "the first argument must be the symol 'on or 'off")))
(ad-activate ,func)
keu:with-advice:return-value)))))
■ このスレッドは過去ログ倉庫に格納されています