From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 06e452a 1/3: Allow Edebug's instrumentation to be used for other purposes Date: Mon, 09 Oct 2017 00:13:24 -0400 Message-ID: References: <20171008231448.29638.520@vcs0.savannah.gnu.org> <20171008231451.3FBBC20326@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1507522417 10532 195.159.176.226 (9 Oct 2017 04:13:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 9 Oct 2017 04:13:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Gemini Lasswell To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 09 06:13:30 2017 Return-path: Envelope-to: ged-emacs-devel@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 1e1PRX-0001gy-QN for ged-emacs-devel@m.gmane.org; Mon, 09 Oct 2017 06:13:27 +0200 Original-Received: from localhost ([::1]:55987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1PRe-00030S-SB for ged-emacs-devel@m.gmane.org; Mon, 09 Oct 2017 00:13:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1PRY-00030B-CZ for emacs-devel@gnu.org; Mon, 09 Oct 2017 00:13:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1PRV-0005hu-6j for emacs-devel@gnu.org; Mon, 09 Oct 2017 00:13:28 -0400 Original-Received: from pmta31.teksavvy.com ([76.10.157.38]:9028) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1PRV-0005hk-0Z for emacs-devel@gnu.org; Mon, 09 Oct 2017 00:13:25 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2GkFgBb9tpZ/5+ESC1cHAEBBAEBCgEBg?= =?us-ascii?q?12BUo4nkAOCb5dIHYUoAoQhQxQBAgEBAQEBAQEDaCiFGQZ5EAsNJxIUGIp0qXs?= =?us-ascii?q?iAosBAQEBAQEFAQEBASSDLYICgzuCdDWKeAWRQIcYiF2gMyiHF5cTNiKBDjIhC?= =?us-ascii?q?DJJhU+BaiSKIAEBAQ?= X-IPAS-Result: =?us-ascii?q?A2GkFgBb9tpZ/5+ESC1cHAEBBAEBCgEBg12BUo4nkAOCb5d?= =?us-ascii?q?IHYUoAoQhQxQBAgEBAQEBAQEDaCiFGQZ5EAsNJxIUGIp0qXsiAosBAQEBAQEFA?= =?us-ascii?q?QEBASSDLYICgzuCdDWKeAWRQIcYiF2gMyiHF5cTNiKBDjIhCDJJhU+BaiSKIAE?= =?us-ascii?q?BAQ?= X-IronPort-AV: E=Sophos;i="5.42,498,1500955200"; d="scan'208";a="5768678" Original-Received: from unknown (HELO pastel.home) ([45.72.132.159]) by smtp.teksavvy.com with ESMTP; 09 Oct 2017 00:13:24 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 0FB80605CC; Mon, 9 Oct 2017 00:13:24 -0400 (EDT) In-Reply-To: <20171008231451.3FBBC20326@vcs0.savannah.gnu.org> (Gemini Lasswell's message of "Sun, 8 Oct 2017 19:14:51 -0400 (EDT)") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.10.157.38 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:219284 Archived-At: > +@defopt edebug-after-instrumentation-functions > +An abnormal hook run by Edebug after it instruments a form. > +Each function is called with one argument, a form which has > +just been instrumented by Edebug. This seems a bit awkward. How 'bout something like the 100% untested patch below? Stefan diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index a070ff25d1..cfdd699bd9 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -1072,9 +1072,9 @@ edebug-after-instrumentation-functions Each function is called with one argument, a form which has just been instrumented for Edebugging.") -(defvar edebug-new-definition-functions '(edebug-announce-definition) - "Abnormal hook run after Edebug wraps a new definition. -After Edebug has initialized its own data, each hook function is +(defvar edebug-new-definition-function #'edebug-announce-definition + "Function to call after Edebug wraps a new definition. +After Edebug has initialized its own data, this function is called with one argument, the symbol associated with the definition, which may be the actual symbol defined or one generated by Edebug.") @@ -1383,13 +1383,13 @@ edebug-make-form-wrapper edebug-offset-list edebug-top-window-data )) - (put edebug-def-name 'edebug-behavior 'edebug) - (run-hook-with-args 'edebug-new-definition-functions edebug-def-name) + (funcall edebug-new-definition-function edebug-def-name) result ))) (defun edebug-announce-definition (def-name) "Announce Edebug's processing of DEF-NAME." + (put def-name 'edebug-behavior 'edebug) (message "Edebug: %s" def-name)) diff --git a/lisp/emacs-lisp/testcover.el b/lisp/emacs-lisp/testcover.el index 3628968974..be07bc82cb 100644 --- a/lisp/emacs-lisp/testcover.el +++ b/lisp/emacs-lisp/testcover.el @@ -195,10 +195,10 @@ testcover-start testcover-module-potentially-1value-functions nil) (cl-letf ((edebug-all-defs t) (edebug-after-instrumentation-functions) - (edebug-new-definition-functions)) + (edebug-new-definition-function)) (add-hook 'edebug-after-instrumentation-functions 'testcover-after-instrumentation) - (add-hook 'edebug-new-definition-functions 'testcover-init-definition) - (remove-hook 'edebug-new-definition-functions 'edebug-announce-definition) + (add-function :override edebug-new-definition-function + #'testcover-init-definition) (eval-buffer buf))) (when byte-compile (dolist (x (reverse edebug-form-data)) @@ -212,10 +212,10 @@ testcover-this-defun (interactive) (cl-letf ((edebug-all-defs t) (edebug-after-instrumentation-functions) - (edebug-new-definition-functions)) + (edebug-new-definition-function)) (add-hook 'edebug-after-instrumentation-functions 'testcover-after-instrumentation) - (add-hook 'edebug-new-definition-functions 'testcover-init-definition) - (remove-hook 'edebug-new-definition-functions 'edebug-announce-definition) + (add-function :override edebug-new-definition-function + #'testcover-init-definition) (eval-defun nil))) (defun testcover-end (filename)