Emacs Lisp: How to use ad-get-arg and ad-get-args?

Posted by RamyenHead on Stack Overflow See other posts from Stack Overflow or by RamyenHead
Published on 2010-04-12T13:23:57Z Indexed on 2010/04/12 14:23 UTC
Read the original article Hit count: 338

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about emacs

Related posts about emacs-lisp