I'm not sure I am using ad-get-args and ad-get-arg right.
For example, the following code doesn't work.
(defun my-add (a b)
(+ a b))
(defadvice my-add (after my-log-on activate)
(message "my-add: %s" (ad-get-args)))
(my-add 1 2)
The last expression causes an error:
Debugger entered--Lisp error: (void-function ad-get-args).
The following doesn't work either.
(defun my-substract (a b)
(- a b))
(defadvice my-substract (around my-log-on activate)
(message "my-substract: %s" (ad-get-arg 0))
(ad-do-it))
(my-substract 10 1)
The defadvice gives a warning:
Warning: `(setq ad-return-value (ad-Orig-my-substract a b))' is a malformed
function
And the last expression gives an error:
Debugger entered--Lisp error: (invalid-function (setq ad-return-value (ad-Orig-my-substract a b)))
(setq ad-return-value (ad-Orig-my-substract a b))()
I was trying to use defadvice to watch start-process arguments for debugging purposes and I found my way of using ad-get-arg didn't work.
Update: Answer,
From the answers it turns out that I should have used (ad-get-args 0)
instead of (ad-get-args)
in (defadvice my-add ..)
, and I should have used ad-do-it
instead of (ad-do-it)
in in (defadvice my-substract ..)
.
And it's better to use trace-function
.