Frage

How do you prevent the advised function from running when the advice returns nil?

(defadvice beginning-of-line (before test activate)
 nil)

-> Not running beginning-of-line at all.

EDIT: Just to take away your worries, I do not intend to use it on beginning-of-line.

War es hilfreich?

Lösung

You can use an around advice, as is:

(defadvice foo (around test activate)
  (if my-test
      ad-do-it))

The construct ad-do-it corresponds to running the original function.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top