Function: ad-enable-advice-internal

ad-enable-advice-internal is a byte-compiled function defined in advice.el.gz.

Signature

(ad-enable-advice-internal FUNCTION CLASS NAME FLAG)

Documentation

Set enable FLAG of FUNCTION's advices in CLASS matching NAME.

If NAME is a string rather than a symbol then it's interpreted as a regular expression and all advices whose name contain a match for it will be affected. If CLASS is any advices in all valid advice classes will be considered. The number of changed advices will be returned (or nil if FUNCTION was not advised).

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/advice.el.gz
(defun ad-enable-advice-internal (function class name flag)
  "Set enable FLAG of FUNCTION's advices in CLASS matching NAME.
If NAME is a string rather than a symbol then it's interpreted as a regular
expression and all advices whose name contain a match for it will be
affected.  If CLASS is `any' advices in all valid advice classes will be
considered.  The number of changed advices will be returned (or nil if
FUNCTION was not advised)."
  (if (ad-is-advised function)
      (let ((matched-advices 0))
	(dolist (advice-class ad-advice-classes)
	  (if (or (eq class 'any) (eq advice-class class))
	      (dolist (advice (ad-get-advice-info-field
                               function advice-class))
		(cond ((or (and (stringp name)
				(string-match
				 name (symbol-name (ad-advice-name advice))))
			   (eq name (ad-advice-name advice)))
		       (setq matched-advices (1+ matched-advices))
		       (ad-advice-set-enabled advice flag))))))
	matched-advices)))