aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/emacs-lisp/nadvice.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/nadvice.el')
-rw-r--r--lisp/emacs-lisp/nadvice.el24
1 files changed, 12 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index 2d5a1b5e77b..a9a20ab5abf 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -167,31 +167,31 @@ DOC is a string where \"FUNCTION\" and \"OLDFUN\" are expected.")
167 167
168(defun advice--interactive-form (function) 168(defun advice--interactive-form (function)
169 "Like `interactive-form' but tries to avoid autoloading functions." 169 "Like `interactive-form' but tries to avoid autoloading functions."
170 (when (commandp function) 170 (if (not (and (symbolp function) (autoloadp (indirect-function function))))
171 (if (not (and (symbolp function) (autoloadp (indirect-function function)))) 171 (interactive-form function)
172 (interactive-form function) 172 (when (commandp function)
173 `(interactive (advice-eval-interactive-spec 173 `(interactive (advice-eval-interactive-spec
174 (cadr (interactive-form ',function))))))) 174 (cadr (interactive-form ',function)))))))
175 175
176(defun advice--make-interactive-form (function main) 176(defun advice--make-interactive-form (iff ifm)
177 ;; TODO: make it so that interactive spec can be a constant which 177 ;; TODO: make it so that interactive spec can be a constant which
178 ;; dynamically checks the advice--car/cdr to do its job. 178 ;; dynamically checks the advice--car/cdr to do its job.
179 ;; For that, advice-eval-interactive-spec needs to be more faithful. 179 ;; For that, advice-eval-interactive-spec needs to be more faithful.
180 (let* ((iff (advice--interactive-form function)) 180 (let* ((fspec (cadr iff)))
181 (ifm (advice--interactive-form main))
182 (fspec (cadr iff)))
183 (when (eq 'function (car-safe fspec)) ;; Macroexpanded lambda? 181 (when (eq 'function (car-safe fspec)) ;; Macroexpanded lambda?
184 (setq fspec (nth 1 fspec))) 182 (setq fspec (eval fspec t)))
185 (if (functionp fspec) 183 (if (functionp fspec)
186 `(funcall ',fspec ',(cadr ifm)) 184 `(funcall ',fspec ',(cadr ifm))
187 (cadr (or iff ifm))))) 185 (cadr (or iff ifm)))))
188 186
189 187
190(cl-defmethod oclosure-interactive-form ((ad advice) &optional _) 188(cl-defmethod oclosure-interactive-form ((ad advice) &optional _)
191 (let ((car (advice--car ad)) 189 (let* ((car (advice--car ad))
192 (cdr (advice--cdr ad))) 190 (cdr (advice--cdr ad))
193 (when (or (commandp car) (commandp cdr)) 191 (ifa (advice--interactive-form car))
194 `(interactive ,(advice--make-interactive-form car cdr))))) 192 (ifd (advice--interactive-form cdr)))
193 (when (or ifa ifd)
194 `(interactive ,(advice--make-interactive-form ifa ifd)))))
195 195
196(cl-defmethod cl-print-object ((object advice) stream) 196(cl-defmethod cl-print-object ((object advice) stream)
197 (cl-assert (advice--p object)) 197 (cl-assert (advice--p object))