Function: ad-read-advised-function

ad-read-advised-function is a byte-compiled function defined in advice.el.gz.

Signature

(ad-read-advised-function &optional PROMPT PREDICATE DEFAULT)

Documentation

Read name of advised function with completion from the minibuffer.

An optional PROMPT will be used to prompt for the function. PREDICATE plays the same role as for try-completion (which see). DEFAULT will be returned on empty input (defaults to the first advised function or function at point for which PREDICATE returns non-nil).

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/advice.el.gz
(defun ad-read-advised-function (&optional prompt predicate default)
  "Read name of advised function with completion from the minibuffer.
An optional PROMPT will be used to prompt for the function.  PREDICATE
plays the same role as for `try-completion' (which see).  DEFAULT will
be returned on empty input (defaults to the first advised function or
function at point for which PREDICATE returns non-nil)."
  (if (null ad-advised-functions)
      (error "ad-read-advised-function: There are no advised functions"))
  (setq default
	(or default
	    ;; Prefer func name at point, if it's an advised function etc.
	    (let ((function (progn
                              (function-called-at-point))))
	      (and function
		   (member (symbol-name function) ad-advised-functions)
		   (or (null predicate)
		       (funcall predicate function))
		   function))
            (cl-block nil
              (ad-do-advised-functions (function)
                (if (or (null predicate)
                        (funcall predicate function))
                    (cl-return function))))
	    (error "ad-read-advised-function: %s"
		   "There are no qualifying advised functions")))
  (let* ((function
	  (completing-read
	   (format-prompt (or prompt "Function") default)
	   ad-advised-functions
	   (if predicate
               (lambda (function)
                 (funcall predicate (intern function))))
	   t)))
    (if (equal function "")
	(if (ad-is-advised default)
	    default
	  (error "ad-read-advised-function: `%s' is not advised" default))
      (intern function))))