Last active
August 29, 2015 13:56
-
-
Save ShingoFukuyama/8875572 to your computer and use it in GitHub Desktop.
This file contains 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
(defun baz1 (arg) | |
arg) | |
(defsubst baz2 (arg) | |
arg) | |
;; ---------------------------------------------------------------------- | |
(defsubst foo1 (aaa) | |
(baz1 aaa) | |
(baz2 aaa)) | |
(foo1 "fff") ; => "fff" | |
;; baz2 isn't found in byte-compiled foo1 | |
(byte-compile 'foo1) | |
;; => #[(aaa) | |
;; "\301!\210\207" | |
;; [aaa baz1] | |
;; 3] | |
(foo1 "fff") ; => "fff" | |
(defadvice foo1 (around bar1 activate) | |
(setq ad-return-value (concat (ad-get-arg 0) (ad-get-arg 0)))) | |
(byte-compile 'foo1) | |
;; => #[(aaa) | |
;; "\302 \211P\211)\207" | |
;; [ad-return-value aaa nil] | |
;; 3 | |
;; #("Advice doc string" 0 17 | |
;; (ad-advice-info foo1))] | |
(foo1 "fff") ; => "ffffff" | |
(defun foo2 (arg) | |
(foo1 arg)) | |
(foo1 "fff") ; => "ffffff" | |
(foo2 "fff") ; => "ffffff" | |
(byte-compile 'foo2) | |
;; => #[(arg) | |
;; "\303 \211P\211*\207" | |
;; [arg aaa ad-return-value nil] | |
;; 2] | |
(defadvice foo1 (around bar2 activate) | |
(setq ad-return-value (concat (ad-get-arg 0) "zzz"))) | |
;;; foo2 doesn't return "fffzzz" because foo1 is adviced after foo2 bytecompiled | |
(foo1 "fff") ; => "fffzzz" | |
(foo2 "fff") ; => "ffffff" | |
(byte-compile 'foo2) | |
;; => #[(arg) | |
;; "\303 \211P\211*\207" | |
;; [arg aaa ad-return-value nil] | |
;; 2] | |
;; Deactivate | |
(progn | |
(ad-disable-advice 'foo1 'around 'bar1) | |
(ad-disable-advice 'foo1 'around 'bar2) | |
(ad-activate 'foo1)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment