From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Gemini Lasswell Newsgroups: gmane.emacs.bugs Subject: bug#24773: 26.0.50; Error when using Edebug on a function that uses :documentation Date: Fri, 29 Sep 2017 16:12:18 -0700 Message-ID: <87tvzlje0d.fsf@runbox.com> References: <87insjrnkz.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1506726802 24152 195.159.176.226 (29 Sep 2017 23:13:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 29 Sep 2017 23:13:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) Cc: 24773@debbugs.gnu.org To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Sep 30 01:13:13 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dy4T2-0005XL-ED for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Sep 2017 01:13:12 +0200 Original-Received: from localhost ([::1]:37362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dy4T9-0003Kr-JM for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Sep 2017 19:13:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dy4Sw-0003I9-I8 for bug-gnu-emacs@gnu.org; Fri, 29 Sep 2017 19:13:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dy4Ss-000137-HU for bug-gnu-emacs@gnu.org; Fri, 29 Sep 2017 19:13:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:59324) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dy4Ss-00012c-3Z for bug-gnu-emacs@gnu.org; Fri, 29 Sep 2017 19:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dy4Sr-00085x-Nk for bug-gnu-emacs@gnu.org; Fri, 29 Sep 2017 19:13:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gemini Lasswell Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Sep 2017 23:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24773 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 24773-submit@debbugs.gnu.org id=B24773.150672676231092 (code B ref 24773); Fri, 29 Sep 2017 23:13:01 +0000 Original-Received: (at 24773) by debbugs.gnu.org; 29 Sep 2017 23:12:42 +0000 Original-Received: from localhost ([127.0.0.1]:39772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dy4SY-00085L-AX for submit@debbugs.gnu.org; Fri, 29 Sep 2017 19:12:42 -0400 Original-Received: from aibo.runbox.com ([91.220.196.211]:47870) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dy4SV-000856-DB; Fri, 29 Sep 2017 19:12:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=rbselector1; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From; bh=n59Uj9yWXF2tM0x98Prmuw+u3oKo3x3ij+eHR7Rubm8=; b=ljfq4iqjmUTduAwMdXbgTHuKXy /jeyw0YxpZC8WVkldBSphXLkTFpPa7CImrWc8OqBQWncueWopRqwy8jS1mS33tSfX7a2VhvnaRQ3e wOx0v97uYy9v5/3tOtUO25FsZTUg5xMKh9uP8TSxv4DltCxmrVrHxCDvpKm1JqE8CJYx+uHJ0PNVR GIHKtvdVpAJsjI7/gUIWUaq5TAqZtIqiarx1gMYQD5p8yD5kxxxmA4mU/JCLWQVTcAaVFb2kaYnGQ InkKph3Hez2t6/MoSNrqOku6LyhCqW0G8RhPW6ix8nk0fVxntKbj7JgOjx8VAv9eQrFCwdmmy2+aR hESv8BkA==; Original-Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1dy4ST-0000Vm-Oi; Sat, 30 Sep 2017 01:12:37 +0200 Original-Received: from c-24-22-244-161.hsd1.wa.comcast.net ([24.22.244.161] helo=chinook) by mailfront12.runbox.com with esmtpsa (uid:179284 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1dy4SD-00037F-Jr; Sat, 30 Sep 2017 01:12:22 +0200 In-Reply-To: <87insjrnkz.fsf@users.sourceforge.net> (npostavs's message of "Sun, 23 Oct 2016 13:18:20 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:137656 Archived-At: --=-=-= Content-Type: text/plain tags 24773 patch quit Here is a patch to add support for :documentation to the Edebug specs of the macros where it can be used (see bug#28557 for a list of those, and some related bugs). cl-defgeneric was missing an Edebug spec and I reported that as bug#27747. Since it uses :documentation, I wrote one for it and included it here, so that bug will also be fixed by this patch. Before this patch there weren't any Edebug specs in lisp/emacs-lisp/generator.el, and lots of macros. Consequently, while iterators can be instrumented, they don't work under Edebug. I'll report that as a separate bug. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=0001-Create-new-Edebug-spec-for-docstrings-and-use-it-in-.patch >From d048fe3f0372011f4aef5cae0a89ccdbe3d59bf8 Mon Sep 17 00:00:00 2001 From: Gemini Lasswell Date: Fri, 29 Sep 2017 14:58:20 -0700 Subject: [PATCH] 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/cl-generic.el | 13 +++++++++++-- lisp/emacs-lisp/cl-macs.el | 6 +++--- lisp/emacs-lisp/edebug.el | 27 +++++++++++++++------------ lisp/emacs-lisp/generator.el | 6 ++++-- lisp/emacs-lisp/pcase.el | 2 +- lisp/subr.el | 3 +-- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index b2f76abd88..62befd4742 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el @@ -204,7 +204,16 @@ cl-defgeneric DEFAULT-BODY, if present, is used as the body of a default method. \(fn NAME ARGS [DOC-STRING] [OPTIONS-AND-METHODS...] &rest DEFAULT-BODY)" - (declare (indent 2) (doc-string 3)) + (declare (indent 2) (doc-string 3) + (debug + (&define name cl-lambda-list lambda-doc + [&rest [&or + ("declare" &rest sexp) + (":argument-precedence-order" &rest sexp) + (&define ":method" [&rest atom] + cl-generic-method-args lambda-doc + def-body)]] + def-body))) (let* ((doc (if (stringp (car-safe options-and-methods)) (pop options-and-methods))) (declarations nil) @@ -422,7 +431,7 @@ cl-defmethod ; Like in CLOS spec, we support ; any non-list values. cl-generic-method-args ; arguments - [ &optional stringp ] ; documentation string + lambda-doc ; documentation string def-body))) ; part to be debugged (let ((qualifiers nil)) (while (not (listp args)) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 32ba0ac309..40eda1e0d6 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -190,7 +190,7 @@ cl-declarations (&rest ("cl-declare" &rest sexp))) (def-edebug-spec cl-declarations-or-string - (&or stringp cl-declarations)) + (&or lambda-doc cl-declarations)) (def-edebug-spec cl-lambda-list (([&rest arg] @@ -447,8 +447,8 @@ cl-defmacro (def-edebug-spec cl-lambda-expr (&define ("lambda" cl-lambda-list - ;;cl-declarations-or-string - ;;[&optional ("interactive" interactive)] + cl-declarations-or-string + [&optional ("interactive" interactive)] def-body))) ;; Redefine function-form to also match cl-function diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index dbc56e272f..d00b14e803 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -1986,15 +1986,14 @@ defconst (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 @@ lambda-list &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 @@ edebug-instrument-function 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 @@ edebug-instrument-function (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) diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el index f3597cc387..23af6143a7 100644 --- a/lisp/emacs-lisp/generator.el +++ b/lisp/emacs-lisp/generator.el @@ -681,7 +681,8 @@ iter-defun When called as a function, NAME returns an iterator value that encapsulates the state of a computation that produces a sequence of values. Callers can retrieve each value using `iter-next'." - (declare (indent defun)) + (declare (indent defun) + (debug (&define name lambda-list lambda-doc def-body))) (cl-assert lexical-binding) (let* ((parsed-body (macroexp-parse-body body)) (declarations (car parsed-body)) @@ -693,7 +694,8 @@ iter-defun (defmacro iter-lambda (arglist &rest body) "Return a lambda generator. `iter-lambda' is to `iter-defun' as `lambda' is to `defun'." - (declare (indent defun)) + (declare (indent defun) + (debug (&define lambda-list lambda-doc def-body))) (cl-assert lexical-binding) `(lambda ,arglist ,(cps-generate-evaluator body))) diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el index c703cae445..36af88423c 100644 --- a/lisp/emacs-lisp/pcase.el +++ b/lisp/emacs-lisp/pcase.el @@ -226,7 +226,7 @@ pcase-lambda formal argument can be any pattern accepted by `pcase' (a mere variable name being but a special case of it)." (declare (doc-string 2) (indent defun) - (debug ((&rest pcase-PAT) body))) + (debug (&define (&rest pcase-PAT) lambda-doc def-body))) (let* ((bindings ()) (parsed-body (macroexp-parse-body body)) (args (mapcar (lambda (pat) diff --git a/lisp/subr.el b/lisp/subr.el index cf15ec287f..e0ef3e5885 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -110,8 +110,7 @@ lambda \(fn ARGS [DOCSTRING] [INTERACTIVE] BODY)" (declare (doc-string 2) (indent defun) - (debug (&define lambda-list - [&optional stringp] + (debug (&define lambda-list lambda-doc [&optional ("interactive" interactive)] def-body))) ;; Note that this definition should not use backquotes; subr.el should not -- 2.14.1 --=-=-=--