From 238fbcb20e9281fc44f4029f52cf31e0dc5b6281 Mon Sep 17 00:00:00 2001 From: Gemini Lasswell Date: Fri, 6 Oct 2017 11:30:22 -0700 Subject: Create new Edebug spec for docstrings and use it in closures Since (:documentation FORM) can be used to create a docstring when lexical-binding is on, allow for that possibility in Edebug specs (bug#24773). * lisp/emacs-lisp/edebug.el: Define an Edebug spec for docstrings called lambda-doc and modify the Edebug specs for defun and defmacro to use it. (edebug-instrument-function): Check for generic functions first, to fix bug where edebug-step-in didn't work on methods now that cl-defgeneric has an Edebug spec. * lisp/subr.el (lambda): Modify Edebug spec to use lambda-doc. * lisp/emacs-lisp/cl-generic.el (cl-defgeneric): Add Edebug spec (bug#27747). (cl-defmethod): Use lambda-doc in Edebug spec. * lisp/emacs-lisp/cl-macs.el: Modify Edebug spec for cl-declarations-or-string to use lambda-doc, and modify Edebug spec for cl-lambda-expr to use cl-declarations-or-string. * lisp/emacs-lisp/pcase.el (pcase-lambda): Modify Edebug spec to use lambda-doc, as well as &define and def-body which are necessary for using Edebug on code wrapped by lambda. * lisp/emacs-lisp/generator.el (iter-defun, iter-lambda): Add Edebug specs. --- lisp/emacs-lisp/edebug.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'lisp/emacs-lisp/edebug.el') diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index dbc56e272fd..d00b14e803e 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -1986,15 +1986,14 @@ expressions; a `progn' form will be returned enclosing these forms." (def-edebug-spec defvar (symbolp &optional form stringp)) (def-edebug-spec defun - (&define name lambda-list - [&optional stringp] + (&define name lambda-list lambda-doc [&optional ("declare" &rest sexp)] [&optional ("interactive" interactive)] def-body)) (def-edebug-spec defmacro ;; FIXME: Improve `declare' so we can Edebug gv-expander and ;; gv-setter declarations. - (&define name lambda-list [&optional stringp] + (&define name lambda-list lambda-doc [&optional ("declare" &rest sexp)] def-body)) (def-edebug-spec arglist lambda-list) ;; deprecated - use lambda-list. @@ -2005,6 +2004,10 @@ expressions; a `progn' form will be returned enclosing these forms." &optional ["&rest" arg] ))) +(def-edebug-spec lambda-doc + (&optional [&or stringp + (&define ":documentation" def-form)])) + (def-edebug-spec interactive (&optional &or stringp def-form)) @@ -3204,15 +3207,6 @@ generated symbols for methods. If a function or method to instrument cannot be found, signal an error." (let ((func-marker (get func 'edebug))) (cond - ((and (markerp func-marker) (marker-buffer func-marker)) - ;; It is uninstrumented, so instrument it. - (with-current-buffer (marker-buffer func-marker) - (goto-char func-marker) - (edebug-eval-top-level-form) - (list func))) - ((consp func-marker) - (message "%s is already instrumented." func) - (list func)) ((cl-generic-p func) (let ((method-defs (cl--generic-method-files func)) symbols) @@ -3227,6 +3221,15 @@ instrument cannot be found, signal an error." (edebug-eval-top-level-form) (push (edebug-form-data-symbol) symbols)))) symbols)) + ((and (markerp func-marker) (marker-buffer func-marker)) + ;; It is uninstrumented, so instrument it. + (with-current-buffer (marker-buffer func-marker) + (goto-char func-marker) + (edebug-eval-top-level-form) + (list func))) + ((consp func-marker) + (message "%s is already instrumented." func) + (list func)) (t (let ((loc (find-function-noselect func t))) (unless (cdr loc) -- cgit v1.2.3