GNU bug report logs - #27397
[PATCH] New commands for bulk tracing of elisp functions

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Phil Sainty <psainty@HIDDEN>; Keywords: patch; merged with #1343, #6464; dated Fri, 16 Jun 2017 13:34:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 19 Jun 2017 11:27:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 19 07:27:53 2017
Received: from localhost ([127.0.0.1]:55673 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMuqX-0004DL-OG
	for submit <at> debbugs.gnu.org; Mon, 19 Jun 2017 07:27:53 -0400
Received: from mail-wm0-f41.google.com ([74.125.82.41]:38284)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1dMuqW-0004D9-76
 for 27397 <at> debbugs.gnu.org; Mon, 19 Jun 2017 07:27:52 -0400
Received: by mail-wm0-f41.google.com with SMTP id u195so58801502wmd.1
 for <27397 <at> debbugs.gnu.org>; Mon, 19 Jun 2017 04:27:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=eqWym4DfOy0bShrrWvZWlBXQ4thQi4vpcI+0sMIjmeI=;
 b=naS65J4ZelGogAdGPAMtsF5SugeG3eEui4t6eDoFEREgxsFkTwUU9wRbw+nTpreZ+j
 dPaXMnwX5YrJco+1/rX7UE6aiZ2vix6HlEuigA/+cONDRY7bJMOi/Yi/ZX4+F5hnbRR0
 v4rqNTjSY6vIjq+1FbEnd+n3csEWyEbhYD4obJu//Yu4GgqRjCDbLjG7XOvtbLX7Q2qD
 Ju0WFe/GZZL6682hOoLOpk/+UsBJMqSI6SMqna1m1Lpi8gsxOBFYQqhn4BzLIb0J3BZ0
 WmBUB+HDnyBGmXoGtqJTvYHcs92bCpctYrFz7Kn93Ea0MFLZIJy/Fka6RmOkCdUwKiFh
 lC2g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:cc:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=eqWym4DfOy0bShrrWvZWlBXQ4thQi4vpcI+0sMIjmeI=;
 b=FuQgxfVNKzCMjXKIc4JAzGLEJ0rRyFApz26tgtU9emQJ9JL0iDQg6I8qSGs+lDtghh
 hp/bgoMFaRQJz0CuS58dJ1/Gs1bkbPYrsVOMzW7rfBXpqTmoA0k4AvxQ1R6emnRLYDXn
 oAcr88JbROznb+eDUlMbK88e/VK3aYbV5OHlGPNwE6vW2PV3wdFGE3F1Z7i008fPgMY8
 ryoKIVcEAlWn1X2IQXOdtJ4scYTLTueksx+KQ4nMiVRCC3DTDKCW21aMqN5P/wLMQKRy
 w9+qwViw7o1tX0Ss7oJv67RC7BXHRwfzhmVjJDgHZFgr99bWhU48ApyopOQwoZBdSJCs
 +8Dw==
X-Gm-Message-State: AKS2vOze4OUKEx68VAMU2gt9v6GulAn/yfvMmRS0+hHwcbJECh3NX9SH
 ozL9IOnSX581dZvEGW8=
X-Received: by 10.80.165.243 with SMTP id b48mr16652290edc.84.1497871666123;
 Mon, 19 Jun 2017 04:27:46 -0700 (PDT)
Received: from [192.168.1.3] ([185.105.174.193])
 by smtp.googlemail.com with ESMTPSA id j2sm4291530edh.60.2017.06.19.04.27.44
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 19 Jun 2017 04:27:45 -0700 (PDT)
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Michael Albinus <michael.albinus@HIDDEN>,
 Phil Sainty <psainty@HIDDEN>
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
 <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN> <8760fs5sjw.fsf@detlef>
 <aa357d58-a309-d648-c3f0-47d8cd833581@HIDDEN> <871sqg5mig.fsf@detlef>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <25ce7f3c-6f70-82f1-b3fb-7dd7362bbdf2@HIDDEN>
Date: Mon, 19 Jun 2017 14:27:43 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101
 Thunderbird/54.0
MIME-Version: 1.0
In-Reply-To: <871sqg5mig.fsf@detlef>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
Cc: 27397 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

Hi Michael,

On 6/19/17 12:56 PM, Michael Albinus wrote:
> That's not what I want. Often, I hunt bugs related to the order of
> autoloaded functions, and this order shall be kept also when tracing.

Your case is surely valid, but sounds a bit niche to me. It shouldn't be 
too hard to evaluate this, though:

(with-eval-after-load 'tramp
   (trace-package "tramp-"))

And the current patch makes it easier.

>> Perhaps you're actually be suggesting some kind of `eval-after-load'
>> tracing behaviour, though?
> 
> Yes, that's the idea. If `trace-package' uses as argument a package name
> as proposed above, the instrumentation shall happen in an
> `eval-after-load' form for that package.

Considering elp-instrument-package does not do that, I think we should 
limit the scope of the currently discussed patch, and trace only already 
loaded functions.

If we do what you suggest, it should be a new discussion, and it should 
improve elp-instrument-package as well.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 19 Jun 2017 11:00:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 19 07:00:21 2017
Received: from localhost ([127.0.0.1]:55654 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMuPs-0003Z3-CD
	for submit <at> debbugs.gnu.org; Mon, 19 Jun 2017 07:00:21 -0400
Received: from smtp-1.orcon.net.nz ([60.234.4.34]:56309)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dMuPp-0003Yp-NL
 for 27397 <at> debbugs.gnu.org; Mon, 19 Jun 2017 07:00:19 -0400
Received: from [150.107.172.99] (port=65482 helo=[192.168.20.102])
 by smtp-1.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>)
 id 1dMuPf-000111-I1; Mon, 19 Jun 2017 23:00:07 +1200
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Michael Albinus <michael.albinus@HIDDEN>
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
 <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN> <8760fs5sjw.fsf@detlef>
 <aa357d58-a309-d648-c3f0-47d8cd833581@HIDDEN> <871sqg5mig.fsf@detlef>
From: Phil Sainty <psainty@HIDDEN>
Message-ID: <6282010c-b2ec-ebca-35b7-a382b30ea3f0@HIDDEN>
Date: Mon, 19 Jun 2017 23:00:07 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <871sqg5mig.fsf@detlef>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
Cc: 27397 <at> debbugs.gnu.org, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On 19/06/17 21:56, Michael Albinus wrote:
> Ahh, my error. I thought that `trace-package' takes a package name
> (or symbol), and traces only all functions which have been loaded by
> this package.

I concede that the name may cause some confusion, but I chose it
for consistency with `elp-instrument-package' which uses the same
function-name-prefix meaning, so the name makes sense from that
perspective. Obviously ELP pre-dates package.el. YMMV.

Maybe `elp-instrument-package' and `trace-package' should become
`elp-instrument-prefix' and `trace-prefix' ? (I'm not against that
idea.)


>> some kind of `eval-after-load' tracing behaviour
>
> Yes, that's the idea. If `trace-package' uses as argument a package
> name as proposed above, the instrumentation shall happen in an
> `eval-after-load' form for that package.

I think `trace-library' would be the appropriate name?

(If `trace-package' were about ELPA packages, then we have multi-file
packages to consider, which expands the scope further.)

Of course we can't guarantee that library foo.el adheres to a foo-*
naming scheme for all its functions (or that other libraries don't
define any foo-* functions). Would we just ignore this and trace
everything starting with foo- on the assumption that this is good
enough? Or would we parse the library in order to trace that library's
functions precisely?


> `trace-regexp', on the other hand, shall instrument the functions in
> a form added to `after-load-functions', additonally to the functions
> already loaded.

Which could also apply to (the current meaning of) `trace-package'.

I suppose this could potentially be an additional y-or-n-p prompt for
the extended interactive argument input (after BUFFER and CONTEXT)
when using a prefix arg.

I think that the equivalent `untrace-*' commands would need to remove
such `after-load-functions' entries by default, but perhaps a prefix
argument to those would allow users to choose.

I can see potential for users to end up with unwanted remnant entries
in after-load-functions (e.g. trace-regexp "A\\|B", then untrace-regexp
"A" and "B" separately), so I think there could be some fiddly aspects
to all of this; although one could argue that anyone using these
features in the first place is likely to know what they're doing, and
would be able to cope with such situations easily enough; especially
if `untrace-all' takes care of the after-load cases.


-Phil




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 19 Jun 2017 09:56:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 19 05:56:37 2017
Received: from localhost ([127.0.0.1]:55629 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMtQD-00023v-1v
	for submit <at> debbugs.gnu.org; Mon, 19 Jun 2017 05:56:37 -0400
Received: from mout.gmx.net ([212.227.15.15]:61301)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael.albinus@HIDDEN>) id 1dMtQB-00023h-VZ
 for 27397 <at> debbugs.gnu.org; Mon, 19 Jun 2017 05:56:36 -0400
Received: from detlef.gmx.de ([212.86.44.161]) by mail.gmx.com (mrgmx002
 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MS5Dm-1dFprf1xhS-00TFqP; Mon, 19
 Jun 2017 11:56:25 +0200
From: Michael Albinus <michael.albinus@HIDDEN>
To: Phil Sainty <psainty@HIDDEN>
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
 <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN>
 <8760fs5sjw.fsf@detlef>
 <aa357d58-a309-d648-c3f0-47d8cd833581@HIDDEN>
Date: Mon, 19 Jun 2017 11:56:23 +0200
In-Reply-To: <aa357d58-a309-d648-c3f0-47d8cd833581@HIDDEN> (Phil
 Sainty's message of "Mon, 19 Jun 2017 21:35:11 +1200")
Message-ID: <871sqg5mig.fsf@detlef>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K0:tsGD5pfluA1VyMIn4wrWJ3QyCSvek+bNqtO8aZtP0Tsvuj3NEH3
 S1xxZSqolyIsDWhGre+xhoW0yigvorInq1fRn/ddu4mT7isJkV/rYuznucFP3/BtUREiOE1
 MzCZ96Uq3t+f4cIhkDHM1OcztX8FTsGkm0SWbdjkooQfXHFwWc7ni3D72HVifGxkqY4iu29
 sHofER6w39nEHLCPlFy+w==
X-UI-Out-Filterresults: notjunk:1;V01:K0:lz44Xuta9vc=:OHTlQ1gZs4ah+9aNZDEuj8
 3/SOK5fO69tXI2PnH+ORcFlYMm9Zf4gneRkpbPQkur04+pDuSKjx8hMBtTQxgheTzWUgNM5mi
 qvpm+uXnDpvWHgYCfw5Oi3p5QAlJN7X41rcgNQPkpVdL0MYihJyBzJeaefli9XC9B6hZIOkbv
 QdWEr1xvfrK5+/IbzWHHNRTPWDEBGBoGAr6p6Wknctecj4JihAbYrqg3oHh6ukELQhqePyfpb
 YRhADSjnpeDBuzcOmYQtcN3VtUXCG4IZohbSUkKHfve2KhEcHm42OBK22pH85M5ieqNVZAmqk
 PkyBETVdM/ujTzeHJW6krlX2qm2Akrk1UKKm8z9CdB/uyfg2C1Jx5FWEL0NnD8lnnhhuwWbKr
 wMNwGHtSoTV0NmkKMP6AAKDVtFiLXQ/BWgX8Un+WOVVc+ecd94JSiw2U64++vwjDvYgXsMTky
 uj0M97xDmoqAdybfe9rst2NWpgHCwhVw1p+3E0lP6YL6jiQ9DaA+eMDVTUoPr/JyeqQU4QPWI
 Banl6q2RhGd+AI6d/zlWGqn+L4CHWX4m8IxR1P4TXKlg1yYAsnXNKgtqm8KXuaFmithgZZkOz
 ZV8hC3MBVD8sKq8gArZNpqIj0vODHpIm613BFwLoYeYF+LycGdOfL/G2NS+ctBsQaG21cq6Zb
 yh3XwWygvDEL3vFke/wCw55QMuyxMfHwcYBJPfuD+CgMFjEa73qd6Q778bDhDrX0XkfphvTJd
 Zy96/CSREuMqHnvMF8p+qLL3+ZscEtplJmMWwaVsoojxfjCMJ7R4q5Xq9M89sHCyHsRsp4JSI
 Li7MmSF
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 27397
Cc: 27397 <at> debbugs.gnu.org, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

Phil Sainty <psainty@HIDDEN> writes:

Hi Phil,

>> There's no package "tramp-". Better would be
>>
>>         (trace-regexp "^tramp-")
>
> To be clear, the two are functionally equivalent; but if you'd prefer
> it written that way then I'm happy to make that change.

Ahh, my error. I thought that `trace-package' takes a package name (or
symbol), and traces only all functions which have been loaded by this
package. (trace-package 'tramp) would then trace the function
`tramp-file-name-handler (defined in tramp.el) , but not the function
`tramp-sh-file-name-handler'. The latter one is defined in tramp-sh.el.

> With respect to the manual entry being discussed here, we could
> trivially show code to `require' all of the tramp-* libraries prior
> to calling trace-package or trace-regexp. e.g.:
>
> (mapc 'require '(tramp tramp-adb tramp-cache tramp-cmds
>                        tramp-compat tramp-ftp tramp-gvfs tramp-sh
>                        tramp-smb tramp-uu trampver))
>
> (or else something which automatically locates library names starting
> with "tramp-" and loads them all).

That's not what I want. Often, I hunt bugs related to the order of
autoloaded functions, and this order shall be kept also when tracing.

> Perhaps you're actually be suggesting some kind of `eval-after-load'
> tracing behaviour, though?

Yes, that's the idea. If `trace-package' uses as argument a package name
as proposed above, the instrumentation shall happen in an
`eval-after-load' form for that package.

`trace-regexp', on the other hand, shall instrument the functions in a
form added to `after-load-functions', additonally to the functions
already loaded.

> -Phil

Best regards, Michael.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 19 Jun 2017 09:35:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 19 05:35:22 2017
Received: from localhost ([127.0.0.1]:55622 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMt5e-0001Xo-7f
	for submit <at> debbugs.gnu.org; Mon, 19 Jun 2017 05:35:22 -0400
Received: from smtp-3.orcon.net.nz ([60.234.4.44]:42318)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dMt5c-0001Xa-5K
 for 27397 <at> debbugs.gnu.org; Mon, 19 Jun 2017 05:35:20 -0400
Received: from [150.107.172.99] (port=11950 helo=[192.168.20.102])
 by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>)
 id 1dMt5U-0005m6-BW; Mon, 19 Jun 2017 21:35:12 +1200
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Michael Albinus <michael.albinus@HIDDEN>
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
 <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN> <8760fs5sjw.fsf@detlef>
From: Phil Sainty <psainty@HIDDEN>
Message-ID: <aa357d58-a309-d648-c3f0-47d8cd833581@HIDDEN>
Date: Mon, 19 Jun 2017 21:35:11 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <8760fs5sjw.fsf@detlef>
Content-Type: text/plain; charset=utf-8
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
Cc: 27397 <at> debbugs.gnu.org, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On 19/06/17 19:45, Michael Albinus wrote:
>>      (trace-package "tramp-")
>
> There's no package "tramp-". Better would be
>
>         (trace-regexp "^tramp-")

To be clear, the two are functionally equivalent; but if you'd prefer
it written that way then I'm happy to make that change.


> One problem I'm always faced with Tramp are autoloaded functions.
> The code as given in the Tramp manual instruments only functions
> which are either already loaded, or which are marked as to be
> autoloaded. Functions from a Tramp package, which are loaded later
> on, are not handled.
>
> Could you add this functionality?

I'm not certain what you're asking here.

With respect to the manual entry being discussed here, we could
trivially show code to `require' all of the tramp-* libraries prior
to calling trace-package or trace-regexp. e.g.:

(mapc 'require '(tramp tramp-adb tramp-cache tramp-cmds
                       tramp-compat tramp-ftp tramp-gvfs tramp-sh
                       tramp-smb tramp-uu trampver))

(or else something which automatically locates library names starting
with "tramp-" and loads them all).

Perhaps you're actually be suggesting some kind of `eval-after-load'
tracing behaviour, though?


-Phil




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 19 Jun 2017 07:46:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 19 03:46:11 2017
Received: from localhost ([127.0.0.1]:55583 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMrNz-0007Nt-Fy
	for submit <at> debbugs.gnu.org; Mon, 19 Jun 2017 03:46:11 -0400
Received: from mout.gmx.net ([212.227.17.22]:60829)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael.albinus@HIDDEN>) id 1dMrNx-0007Nc-5s
 for 27397 <at> debbugs.gnu.org; Mon, 19 Jun 2017 03:46:09 -0400
Received: from detlef.gmx.de ([212.86.44.161]) by mail.gmx.com (mrgmx102
 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MUCTO-1dDcFr0oEs-00Qyi2; Mon, 19
 Jun 2017 09:45:57 +0200
From: Michael Albinus <michael.albinus@HIDDEN>
To: Phil Sainty <psainty@HIDDEN>
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
 <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN>
Date: Mon, 19 Jun 2017 09:45:55 +0200
In-Reply-To: <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN> (Phil
 Sainty's message of "Sat, 17 Jun 2017 20:43:00 +1200")
Message-ID: <8760fs5sjw.fsf@detlef>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K0:pDTPoZ47dPmkcwkDVhs68bNFamXTbfp3aVM4AtM+6mWQcafd/jh
 7mpsUer3ShYkNNnx51MQei0d85IhmTL4s5oCNbiZFlEjom7ltxbhQz/3wexwLJlO3MTngFH
 tCgZY/pwCsdkb6klYuB6ieSQhpiBVuaafbNJ9kUn45ECyEhFyuHRFWx58MdQzRZjrkS2GJx
 cz/1asMCTx9iOoQBm4wIA==
X-UI-Out-Filterresults: notjunk:1;V01:K0:mVCjV3rjcUY=:UAZh8JEsc+iEevgFAOin/d
 npx+xuvU1GxbDyQa2zVyN/CCVtuYiMiCbnxTYUjS2YcflBVyATNws3mURbDNZZjULNGst/1t9
 Rp4lcnq6uSPpA/B477aumGt4bzQvClCJG43RWhQsVYLXxitjSxqN+BP28sqn5fCXffAlDp79w
 jf5J+ZCpTIZFV1uONEy3lVcb73NwDhHM4N0ahnBK/oMdfZsZye2hqVlWj2HBEcrFxQ6reTcuu
 KUDlie4hKIzIOPpg9v+WV4UcqJsRI3a03SH1m7GlA65Jpw9rth5BLgWKZ0FdeUF7jEdTNFN3V
 mrN0Op6Lr/AJ7frJ5z6u35Vz3fSk0w0ckxcb3d+2fQahfuAc4Pq8Pu1Y7CASQ1aJ2KE2UGccA
 HNA/JyNhht2zj1ypAPN8/T184x/c3SQ/CkFAFX8EBupVFzBqHzGwZqPBYGYt02+hWcMS2rIbg
 48wbjlqYEy9YgrSJiZNP8TyNv1wazKGOmAAr9TD52+fFbdARR+9lb0efpvZIJcDzvJokkRigs
 lKDlthfu1Y8g1jd8mEjhWy7JqDdOK2kidO0eiL92zBwsD5enj0XCn7zRev5bcjnXMWSW3VedF
 /GByuXk54sPH0kS8sSQytQM5qDr2Q2qOH3D3IwMHDN2XH0nhYGFLwSS7PHRNtkk6Y26Dyi/O6
 gMRi+H4of4BATGHArdedD+ICMFKVVfrPO6ZIaAQB4njgVnFDg8+FcsZblrmOi6J/jTAwEkkFs
 J+dLmIUeCoS4qalQD5k3aZNc7eR6ewQxcGd7b7s6PlzMiSgrdBm5zgLiVvTmh45pXifuDd8Xt
 41SKC7H
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 27397
Cc: 27397 <at> debbugs.gnu.org, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.7 (/)

Phil Sainty <psainty@HIDDEN> writes:

Hi Phil,

> As there's no info node for trace.el, that could perhaps be a +++
> entry; although a grep shows me that "(tramp) Traces and Profiles"
> could be amended to change:
>
>      (require 'trace)
>      (dolist (elt (all-completions "tramp-" obarray 'functionp))
>        (trace-function-background (intern elt)))
>
> to:
>
>      (trace-package "tramp-")

There's no package "tramp-". Better would be

        (trace-regexp "^tramp-")

Could be changed in the Tramp manual (modulo backwards
compatibility). One problem I'm always faced with Tramp are autoloaded
functions. The code as given in the Tramp manual instruments only
functions, which are either already loaded, or which are marked as to be
autoloaded. Functions from a Tramp package, which are loaded later on,
are not handled.

Could you add this functionality?

> -Phil

Best regards, Michael.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 18 Jun 2017 11:23:10 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 18 07:23:10 2017
Received: from localhost ([127.0.0.1]:54031 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMYIQ-0005ad-4N
	for submit <at> debbugs.gnu.org; Sun, 18 Jun 2017 07:23:10 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45453)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dMYIO-0005aN-8L
 for submit <at> debbugs.gnu.org; Sun, 18 Jun 2017 07:23:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dMYIG-0005ka-S0
 for submit <at> debbugs.gnu.org; Sun, 18 Jun 2017 07:23:03 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:38817)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dMYIG-0005k5-NP
 for submit <at> debbugs.gnu.org; Sun, 18 Jun 2017 07:23:00 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36410)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dMYIE-0005qW-5h
 for bug-gnu-emacs@HIDDEN; Sun, 18 Jun 2017 07:23:00 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dMYI9-0005cp-6t
 for bug-gnu-emacs@HIDDEN; Sun, 18 Jun 2017 07:22:58 -0400
Received: from smtp-3.orcon.net.nz ([60.234.4.44]:46220)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dMYI8-0005a2-K1
 for bug-gnu-emacs@HIDDEN; Sun, 18 Jun 2017 07:22:53 -0400
Received: from [150.107.172.87] (port=24191 helo=[192.168.20.102])
 by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>) id 1dMYHo-0002fl-Br
 for bug-gnu-emacs@HIDDEN; Sun, 18 Jun 2017 23:22:42 +1200
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: bug-gnu-emacs@HIDDEN
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
 <70000e90-328c-c084-3e3c-bbde96b16110@HIDDEN>
 <adbc18a1-20ef-5261-6d8e-149b13d61674@HIDDEN>
 <6b195c26-066c-870f-3432-0b24c6f619ec@HIDDEN>
From: Phil Sainty <psainty@HIDDEN>
Message-ID: <d8ba5a45-ae3b-7f05-1749-ca5032d4bee9@HIDDEN>
Date: Sun, 18 Jun 2017 23:22:31 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <6b195c26-066c-870f-3432-0b24c6f619ec@HIDDEN>
Content-Type: multipart/mixed; boundary="------------5BDDD4D8641D5478F16D92E0"
Content-Language: en-US
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -2.7 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

This is a multi-part message in MIME format.
--------------5BDDD4D8641D5478F16D92E0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

Just attaching the current patch.  Thanks for the input Dmitry and
Kaushal.  I'll leave it a while to see whether anyone else wishes to
weigh in on the outstanding items:

* The inconsistent predicate naming of `trace-is-traced' vs
  `trace-is-traceable-p'.
  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27397#19

* Whether foreground-tracing variants of the new commands are wanted.
  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27397#25
  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27397#34

* Whether it's a good idea to display the trace buffer initially
  when one of the background tracing commands is invoked.


(I guess I'll follow up next weekend if no one has anything to add
in the interim.)


-Phil

--------------5BDDD4D8641D5478F16D92E0
Content-Type: text/x-patch;
 name="0001-New-commands-for-bulk-tracing-of-elisp-functions.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-New-commands-for-bulk-tracing-of-elisp-functions.patch"

From 5ca9108f585a06c2085ab180c390bf85d3657230 Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@HIDDEN>
Date: Sun, 11 Jun 2017 17:29:53 +1200
Subject: [PATCH] New commands for bulk tracing of elisp functions

* lisp/emacs-lisp/trace.el (trace-package, untrace-package)
(trace-regexp, untrace-regexp, trace-is-traceable-p): New functions.

(trace--read-function): New function, split from `trace--read-args'.
Changed to use the new `trace-is-traceable-p' predicate.

(trace--read-extra-args): New function, split from `trace--read-args'.
Changed to allow the user to enter an empty string at the context
expression prompt (previously an error; now treated as "nil"), and to
cause a "nil" context expression to produce no context output in the
trace buffer.

(trace--read-args): Removed function.  Replaced by the combination of
`trace--read-function' and `trace--read-extra-args'.

(trace-function-foreground, trace-function-background): Updated
interactive specs to use the new functions.

(trace-is-traced, untrace-function, untrace-all): Doc updates/fixes.

Commentary updated to cover the new commands.

Change log updated to cover the main changes since 1993.

* etc/NEWS: Mention the new trace commands.

* doc/misc/tramp.texi: Update "(tramp) Traces and Profiles" to use
`trace-package'.
---
 doc/misc/tramp.texi      |   4 +-
 etc/NEWS                 |   8 ++
 lisp/emacs-lisp/trace.el | 206 ++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 176 insertions(+), 42 deletions(-)

diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 4ca3932..54d5d00 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3672,9 +3672,7 @@ Traces and Profiles
 
 @lisp
 @group
-(require 'trace)
-(dolist (elt (all-completions "tramp-" obarray 'functionp))
-  (trace-function-background (intern elt)))
+(trace-package "tramp-")
 (untrace-function 'tramp-read-passwd)
 @end group
 @end lisp
diff --git a/etc/NEWS b/etc/NEWS
index 7972511..d3d73cc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -743,6 +743,14 @@ header's value.
 where the GnuPG home directory (used for signature verification) is
 located and whether GnuPG's option "--homedir" is used or not.
 
+** Trace
+
++++
+*** New commands 'trace-package' and 'trace-regexp' (and their
+counterparts 'untrace-package' and 'untrace-regexp') allow for the
+bulk tracing of calls to functions with names matching a specified
+prefix or regexp.
+
 ** Tramp
 
 +++
diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el
index 1c57d73..05ee780 100644
--- a/lisp/emacs-lisp/trace.el
+++ b/lisp/emacs-lisp/trace.el
@@ -52,14 +52,20 @@
 
 ;; Usage:
 ;; ======
-;; - To trace a function say `M-x trace-function', which will ask you for the
+;; - To trace a function use `M-x trace-function', which will ask you for the
 ;;   name of the function/subr/macro to trace.
 ;; - If you want to trace a function that switches buffers or does other
 ;;   display oriented stuff use `M-x trace-function-background', which will
 ;;   generate the trace output silently in the background without popping
 ;;   up windows and doing other irritating stuff.
-;; - To untrace a function say `M-x untrace-function'.
-;; - To untrace all currently traced functions say `M-x untrace-all'.
+;; - `M-x trace-package' will ask you for a function name prefix, and trace
+;;   (in the background) all matching functions.
+;; - `M-x trace-regexp' will ask you for a function name pattern (regexp),
+;;   and trace (in the background) all matching functions.
+;; - To untrace a function use `M-x untrace-function'.
+;; - To untrace multiple functions by prefix use `M-x untrace-package'.
+;; - To untrace multiple functions by regexp use `M-x untrace-regexp'.
+;; - To untrace all currently traced functions use `M-x untrace-all'.
 
 ;; Examples:
 ;; =========
@@ -120,6 +126,22 @@
 
 ;;; Change Log:
 
+;; 2017-06-17  Phil Sainty
+;;	* New commands `trace-package', `untrace-package', `trace-regexp',
+;;	  `untrace-regexp'
+;;
+;; 2012-2014  Stefan Monnier, Glenn Morris
+;;	* Adapted for nadvice.el
+;;	* New `context' argument and display in trace buffer
+;;	* `trace-function' renamed to (and now an alias of)
+;;	  `trace-function-foreground'
+;;
+;; 2005-02-27  Stefan Monnier
+;;	* New `inhibit-trace' variable
+;;
+;; 1998-04-05  Stephen Eglen
+;;	* New customize group `trace'
+;;
 ;; Revision 2.0 1993/05/18 00:41:16 hans
 ;;	* Adapted for advice.el 2.0; it now also works
 ;;	  for GNU Emacs-19 and Lemacs
@@ -257,42 +279,48 @@ trace-function-internal
                       (or context (lambda () "")))
    `((name . ,trace-advice-name) (depth . -100))))
 
+(defun trace-is-traceable-p (sym)
+  "Whether the given symbol is a traceable function."
+  (or (functionp sym) (macrop sym)))
+
 (defun trace-is-traced (function)
+  "Whether FUNCTION is currently traced."
   (advice-member-p trace-advice-name function))
 
-(defun trace--read-args (prompt)
-  "Read a function name, prompting with string PROMPT.
-If `current-prefix-arg' is non-nil, also read a buffer and a \"context\"
-\(Lisp expression).  Return (FUNCTION BUFFER FUNCTION-CONTEXT)."
-  (cons
-   (let ((default (function-called-at-point))
-         (beg (string-match ":[ \t]*\\'" prompt)))
-     (intern (completing-read (if default
-                                  (format
-                                   "%s (default %s)%s"
-                                   (substring prompt 0 beg)
-                                   default
-                                   (if beg (substring prompt beg) ": "))
-                                prompt)
-                              obarray 'fboundp t nil nil
-                              (if default (symbol-name default)))))
-   (when current-prefix-arg
-     (list
-      (read-buffer "Output to buffer: " trace-buffer)
-      (let ((exp
-             (let ((minibuffer-completing-symbol t))
-               (read-from-minibuffer "Context expression: "
-                                     nil read-expression-map t
-                                     'read-expression-history))))
-        (lambda ()
-          (let ((print-circle t))
-            (concat " [" (prin1-to-string (eval exp t)) "]"))))))))
+(defun trace--read-function (prompt)
+  "Read a function name, prompting with string PROMPT."
+  (let ((default (function-called-at-point))
+        (beg (string-match ":[ \t]*\\'" prompt)))
+    (intern (completing-read (if default
+                                 (format
+                                  "%s (default %s)%s"
+                                  (substring prompt 0 beg)
+                                  default
+                                  (if beg (substring prompt beg) ": "))
+                               prompt)
+                             obarray 'trace-is-traceable-p t nil nil
+                             (if default (symbol-name default))))))
+
+(defun trace--read-extra-args ()
+  "Read a buffer and a \"context\" (Lisp expression).
+Return (BUFFER CONTEXT)."
+  (list
+   (read-buffer "Output to buffer: " trace-buffer)
+   (let ((exp
+          (let ((minibuffer-completing-symbol t))
+            (read-from-minibuffer "Context expression: "
+                                  nil read-expression-map t
+                                  'read-expression-history "nil"))))
+     (and exp
+          (lambda ()
+            (let ((print-circle t))
+              (concat " [" (prin1-to-string (eval exp t)) "]")))))))
 
 ;;;###autoload
 (defun trace-function-foreground (function &optional buffer context)
   "Trace calls to function FUNCTION.
-With a prefix argument, also prompt for the trace buffer (default
-`trace-buffer'), and a Lisp expression CONTEXT.
+With a prefix argument, also prompt for the trace output BUFFER
+\(default `trace-buffer'), and a Lisp expression CONTEXT.
 
 Tracing a function causes every call to that function to insert
 into BUFFER Lisp-style trace messages that display the function's
@@ -306,7 +334,9 @@ trace-function-foreground
 stuff - use `trace-function-background' instead.
 
 To stop tracing a function, use `untrace-function' or `untrace-all'."
-  (interactive (trace--read-args "Trace function: "))
+  (interactive
+   (cons (trace--read-function "Trace function: ")
+         (and current-prefix-arg (trace--read-extra-args))))
   (trace-function-internal function buffer nil context))
 
 ;;;###autoload
@@ -314,24 +344,122 @@ trace-function-background
   "Trace calls to function FUNCTION, quietly.
 This is like `trace-function-foreground', but without popping up
 the output buffer or changing the window configuration."
-  (interactive (trace--read-args "Trace function in background: "))
+  (interactive
+   (cons (trace--read-function "Trace function in background: ")
+         (and current-prefix-arg (trace--read-extra-args))))
   (trace-function-internal function buffer t context))
 
 ;;;###autoload
 (defalias 'trace-function 'trace-function-foreground)
 
 (defun untrace-function (function)
-  "Untraces FUNCTION and possibly activates all remaining advice.
-Activation is performed with `ad-update', hence remaining advice will get
-activated only if the advice of FUNCTION is currently active.  If FUNCTION
-was not traced this is a noop."
+  "Remove trace from FUNCTION.  If FUNCTION was not traced this is a noop."
   (interactive
    (list (intern (completing-read "Untrace function: "
                                   obarray #'trace-is-traced t))))
   (advice-remove function trace-advice-name))
 
+;;;###autoload
+(defun trace-package (prefix &optional buffer context)
+  "Trace all functions with names starting with PREFIX.
+For example, to trace all diff functions, do the following:
+
+\\[trace-package] RET diff- RET
+
+With a prefix argument, also prompt for the trace output BUFFER
+\(default `trace-buffer'), and a Lisp expression CONTEXT.
+
+Background tracing is used.  Switch to the trace output buffer to view
+the results.
+
+See `trace-function-foreground' for details on the optional arguments
+and foreground vs background tracing.
+
+See also `untrace-package'."
+  ;; Derived in part from `elp-instrument-package'.
+  (interactive
+   (cons (completing-read "Prefix of package to trace: "
+                          obarray #'trace-is-traceable-p)
+         (and current-prefix-arg (trace--read-extra-args))))
+  (when (zerop (length prefix))
+    (error "Tracing all Emacs functions would render Emacs unusable"))
+  (mapc (lambda (name)
+          (trace-function-background (intern name) buffer context))
+        (all-completions prefix obarray #'trace-is-traceable-p))
+  (message
+   "Tracing to %s.  Use %s to untrace a package, or %s to remove all traces."
+   (or buffer trace-buffer)
+   (substitute-command-keys "\\[untrace-package]")
+   (substitute-command-keys "\\[untrace-all]")))
+
+(defun untrace-package (prefix)
+  "Remove all traces from functions with names starting with PREFIX.
+
+See also `trace-package'."
+  (interactive
+   (list (completing-read "Prefix of package to untrace: "
+                          obarray #'trace-is-traced)))
+  (if (and (zerop (length prefix))
+           (y-or-n-p "Remove all function traces?"))
+      (untrace-all)
+    (mapc (lambda (name)
+            (untrace-function (intern name)))
+          (all-completions prefix obarray #'trace-is-traceable-p))))
+
+;;;###autoload
+(defun trace-regexp (regexp &optional buffer context)
+  "Trace all functions with names matching REGEXP.
+For example, to trace indentation-related functions, you could try:
+
+\\[trace-regexp] RET indent\\|offset RET
+
+Warning: Do not attempt to trace all functions.  Tracing too many
+functions at one time will render Emacs unusable.
+
+With a prefix argument, also prompt for the trace output BUFFER
+\(default `trace-buffer'), and a Lisp expression CONTEXT.
+
+Background tracing is used.  Switch to the trace output buffer to view
+the results.
+
+See `trace-function-foreground' for details on the optional arguments
+and foreground vs background tracing.
+
+See also `untrace-regexp'."
+  (interactive
+   (cons (read-regexp "Regexp matching functions to trace: ")
+         (and current-prefix-arg (trace--read-extra-args))))
+  (when (member regexp '("" "." ".+" ".*"))
+    ;; Not comprehensive, but it catches the most likely attempts.
+    (error "Tracing all Emacs functions would render Emacs unusable"))
+  (mapatoms
+   (lambda (sym)
+     (and (trace-is-traceable-p sym)
+          (string-match-p regexp (symbol-name sym))
+          (trace-function-background sym buffer context))))
+  (message
+   "Tracing to %s.  Use %s to untrace by regexp, or %s to remove all traces."
+   (or buffer trace-buffer)
+   (substitute-command-keys "\\[untrace-regexp]")
+   (substitute-command-keys "\\[untrace-all]")))
+
+(defun untrace-regexp (regexp)
+  "Remove all traces from functions with names matching REGEXP.
+
+See also `trace-regexp'."
+  (interactive
+   (list (read-regexp "Regexp matching functions to untrace: ")))
+  (if (and (zerop (length regexp))
+           (y-or-n-p "Remove all function traces?"))
+      (untrace-all)
+    (mapatoms
+     (lambda (sym)
+       (and (trace-is-traceable-p sym)
+            (string-match-p regexp (symbol-name sym))
+            (untrace-function sym))))))
+
 (defun untrace-all ()
-  "Untraces all currently traced functions."
+  "Remove traces from all currently traced functions."
   (interactive)
   (mapatoms #'untrace-function))
 
-- 
2.8.3


--------------5BDDD4D8641D5478F16D92E0--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 18 Jun 2017 06:32:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 18 02:32:16 2017
Received: from localhost ([127.0.0.1]:53912 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMTkt-0004sk-TV
	for submit <at> debbugs.gnu.org; Sun, 18 Jun 2017 02:32:16 -0400
Received: from mail-wm0-f47.google.com ([74.125.82.47]:37440)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1dMTks-0004sU-C2
 for 27397 <at> debbugs.gnu.org; Sun, 18 Jun 2017 02:32:14 -0400
Received: by mail-wm0-f47.google.com with SMTP id d73so50459605wma.0
 for <27397 <at> debbugs.gnu.org>; Sat, 17 Jun 2017 23:32:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=fKb7LRoepipmSbbwqOLclnDY/RvqWAJlgm0gOr85kc0=;
 b=XFXk35AlXM1dMoj0EH6c1AEwlkmAbd6o7XkE2n03OtZSjerR+zE4/AM6qd3IAOjD3l
 kocG/A0BKEZnogr2XEkFOuiCGEEHKG3GKvDL1+X04pB484NeQftH0O+8rQb7PQ04ga0v
 WOS9wr5DixpLIn72ZQ8VmCDNhaNyvs1UMQFHb7ixoar5re+jLZFIEh/MPnL6xnOXPpJx
 T7BOwxs84IbMA5QNy9iF2zVE+BBOPHFW6pgAfwrPJcmCQdP/n2MbHoD6hdIvNfkFoQKv
 rzJmUwR8RgdLomwVsIa1tCbIfJ5qJss22vLXzls1ISOiJaofiCE9i80NtYcpOti4Sicz
 gwdw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=fKb7LRoepipmSbbwqOLclnDY/RvqWAJlgm0gOr85kc0=;
 b=gyW59v/QC2RE3Qpm6pc9+UXCmSOGXEMLC0V+0+tBdKEusgSnrYKJ4XkfYZV0WwxI6h
 RP1l2NVepiiGF/uklesUXWs1rW71ZBzsHkU9VN6IG67ncyPe9VZwCpI6Up3A5KXb3RWI
 05Y3CbabPlS3ONWFYqrK34QWFIJXJX8D1d6lqiSjf2UjfqSau+Y4yx8Cz4EI+/CRJCEM
 l4+9b8ANyrgPsrWWdRlsJBFcJlJ0atUhffFvZot/AKmjqgbmVxcvbvjYJ4JLX8JPx3Bd
 CgdKDWtEhY9pWbYSUA86EKv86SLMjgrRdK2Nk3DL0sj8Q3tP9c5jBdBMpXFxRlfaihZe
 XY/A==
X-Gm-Message-State: AKS2vOyBs4jyxg57CN0xiGoA3UbrxJf3fUJTB3U1e9KaNtdZVX+OkbJi
 chkuWddPBs19sN4B7H8=
X-Received: by 10.80.180.188 with SMTP id w57mr12877799edd.42.1497767528076;
 Sat, 17 Jun 2017 23:32:08 -0700 (PDT)
Received: from [192.168.1.3] ([185.105.174.193])
 by smtp.googlemail.com with ESMTPSA id d37sm3854733edb.54.2017.06.17.23.32.05
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 17 Jun 2017 23:32:07 -0700 (PDT)
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Phil Sainty <psainty@HIDDEN>, 27397 <at> debbugs.gnu.org
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
 <70000e90-328c-c084-3e3c-bbde96b16110@HIDDEN>
 <adbc18a1-20ef-5261-6d8e-149b13d61674@HIDDEN>
 <6b195c26-066c-870f-3432-0b24c6f619ec@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <132824c4-39b4-a46c-79e6-0d48d3d88c0e@HIDDEN>
Date: Sun, 18 Jun 2017 09:32:04 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101
 Thunderbird/54.0
MIME-Version: 1.0
In-Reply-To: <6b195c26-066c-870f-3432-0b24c6f619ec@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On 6/18/17 4:06 AM, Phil Sainty wrote:

> I've now refactored this like so:
> 
> * `trace--read-args' has been split into `trace--read-function` and
>    `trace--read-extra-args'.
> 
> * `trace--read-function` reads only a function.

That sounds better, thanks!




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 18 Jun 2017 01:06:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 21:06:25 2017
Received: from localhost ([127.0.0.1]:53857 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMOfZ-00054O-4w
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 21:06:25 -0400
Received: from smtp-3.orcon.net.nz ([60.234.4.44]:45801)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dMOfW-00054B-Ly
 for 27397 <at> debbugs.gnu.org; Sat, 17 Jun 2017 21:06:23 -0400
Received: from [150.107.172.87] (port=17473 helo=[192.168.20.102])
 by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>)
 id 1dMOfP-0001n2-8n; Sun, 18 Jun 2017 13:06:15 +1200
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Dmitry Gutov <dgutov@HIDDEN>, 27397 <at> debbugs.gnu.org
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
 <70000e90-328c-c084-3e3c-bbde96b16110@HIDDEN>
 <adbc18a1-20ef-5261-6d8e-149b13d61674@HIDDEN>
From: Phil Sainty <psainty@HIDDEN>
Message-ID: <6b195c26-066c-870f-3432-0b24c6f619ec@HIDDEN>
Date: Sun, 18 Jun 2017 13:06:14 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <adbc18a1-20ef-5261-6d8e-149b13d61674@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On 18/06/17 10:59, Dmitry Gutov wrote:
> Why the rename, though? Those are not arguments for the function we're
> going to trace. trace--read-args sounds as appropriate, if not more.

That was because the behaviour of `trace--read-args' had been quite
specific to the `trace-function*' commands -- its primary purpose was
to prompt for a single function -- and I thought the name should reflect
that.  I agree with you, though -- the new name wasn't ideal either.

I've now refactored this like so:

* `trace--read-args' has been split into `trace--read-function` and
  `trace--read-extra-args'.

* `trace--read-function` reads only a function.

* `The interactive specs for the trace-function*' commands are now
   similar to those of the new bulk trace commands, in explicitly
   calling `trace--read-extra-args':

  (interactive
   (cons (trace--read-function "Trace function: ")
         (and current-prefix-arg (trace--read-extra-args))))

I think this name change makes better sense, and the code is now more
consistent between commands.


-Phil




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 17 Jun 2017 23:04:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 19:04:03 2017
Received: from localhost ([127.0.0.1]:53803 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMMl9-0005FR-1t
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 19:04:03 -0400
Received: from mail-wr0-f171.google.com ([209.85.128.171]:33607)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1dMMl7-0005Ex-3P
 for 27397 <at> debbugs.gnu.org; Sat, 17 Jun 2017 19:04:01 -0400
Received: by mail-wr0-f171.google.com with SMTP id r103so54388807wrb.0
 for <27397 <at> debbugs.gnu.org>; Sat, 17 Jun 2017 16:04:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=1y9yJMFHzpG3xQ1LY5vHWNZm8kFPQSF0NyZzKolHDcU=;
 b=r4wIdQHZ/iPgNrszbM7snqz3pzzRgtjj4lmTtwRPYV6rXhR06N7zwBjFzkhjPXwYNN
 mQWQOrWuzADiiQ+qFcxBSzdRA+vSAcGJ13OoYKFtDGxNdWTB8y8wLWyDK422LsJcDGVy
 3XTDW35gZQkqEZpJ45itbkWOZTuwWFAS8+ps9y97Y7HlELRhTejuuCnfBa7OlhltlsAS
 aGrXgNybbf09mCHB0Jk0TiKbvMTnH7zMmY7ivbZg1e7iRF/vJAu7hwG1eET1KjonJkt9
 +X+SsMRtpNBRq2TooAcsq0Pflut737L95Z+hSC6FiJcKTu0M2Un0GQ1kiw71Jb+ZbQ2D
 7V3Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=1y9yJMFHzpG3xQ1LY5vHWNZm8kFPQSF0NyZzKolHDcU=;
 b=hvUxy0vxhnD+Z56EDyY6BPq0e+uiUiCr1AESL/Ac105kjKxYwGatyHdSt+90l9Ehft
 Ob2JMFWc0azSZuVBGooCjh2KRxod4oQ3b+woBdRUR2Mo8S5OZWKCoBrD9ml3KOEaBx3p
 Ft6Sh3He1m/XzwtAV+k2laVW+1bRKpwATaOgE56dN8KlItiDByWVecGO9R6bEG9XWSwJ
 vIGIGw+8NRn1YOmCM8kIxTGARZlCk2qPGi5T6aBNYWaRWRD5zZS3LS+YS9SZEijuQHmT
 Dk3GGAH0779ndt1Ynz7iRG0C6uef6C81kgy6LdEtnDL3FJBIA+KbvvXDguNA15mYrqMd
 5cEA==
X-Gm-Message-State: AKS2vOwRyt/8+nD1SsfxWO7m1BmIJUtMcey9lVaKO83nd/OlC31Gciax
 3sbafC+0tdO4QaluvEo=
X-Received: by 10.223.162.151 with SMTP id s23mr10725895wra.68.1497740635059; 
 Sat, 17 Jun 2017 16:03:55 -0700 (PDT)
Received: from [192.168.1.3] ([185.105.174.193])
 by smtp.googlemail.com with ESMTPSA id x71sm11797951wmd.32.2017.06.17.16.03.53
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 17 Jun 2017 16:03:54 -0700 (PDT)
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Phil Sainty <psainty@HIDDEN>, 27397 <at> debbugs.gnu.org
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <7aecfe49-89bd-f684-20e7-9d75572eb6a6@HIDDEN>
Date: Sun, 18 Jun 2017 02:03:52 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101
 Thunderbird/54.0
MIME-Version: 1.0
In-Reply-To: <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -1.0 (-)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 6/17/17 12:20 PM, Phil Sainty wrote:

> Actually popping up that buffer when
> the `trace-package' or `trace-regexp' command is used would be another
> (perhaps nicer) option?

Perhaps.

> Do others think that foreground versions of these commands would be
> a good idea?

I'm fine with having only the background versions, but others are 
welcome to weigh in.

> A prefix argument could mean "use foreground tracing"

Nah, if we do want foreground tracing, adding separate commands 
shouldn't be a problem.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 17 Jun 2017 23:00:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 19:00:08 2017
Received: from localhost ([127.0.0.1]:53799 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMMhM-0005A5-Bz
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 19:00:08 -0400
Received: from mail-wm0-f50.google.com ([74.125.82.50]:36773)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1dMMhK-00057t-R9
 for 27397 <at> debbugs.gnu.org; Sat, 17 Jun 2017 19:00:07 -0400
Received: by mail-wm0-f50.google.com with SMTP id m125so51621086wmm.1
 for <27397 <at> debbugs.gnu.org>; Sat, 17 Jun 2017 16:00:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=CL3YP4AiD2Q4CVF3b3CbmOOn7NkwMcGpqV2pT0yRspI=;
 b=OFL1XMug7DXEGoTyvDR3MOsKXYyBbjqJsTfwn6CgbvDiwTZQr0KtCvG/f7oNH7D4+m
 8aDcCcJJWS3V++SiXguq5d6K9Xf0A57XBSF4ctveIf8cxFuf1lNufZG/IJCc0mWw/gFN
 7JDV4bVpwkC0yEShQ9pkX9SXMUT4kl3+4T5JBlgqMNaYdKKwzRnUeSqqF+cpmVmWyPMn
 UJx8D8ayf2N3sEAcfjMcYTybTDFQvCCErYEe+KXz0QHvkp/Rv0izJWfGXSm50t6KGYkE
 A2J5tDYHv4oWDEMDuV0ZZhn0brKHdS+Aywz3Q9bxXdaMKYXOaAlPF6RUUxfCCzHIap3s
 iSCQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=CL3YP4AiD2Q4CVF3b3CbmOOn7NkwMcGpqV2pT0yRspI=;
 b=DScI5C0Kxk33DHRLUYaWKRLc7v/UCE0CPir0ktn4chiwHBbJR3wMSjXucz9vS96I37
 s4ERiIBqnHZJaoSJXeZb9zlEdC0NM4EoyLx4yt5eKeknsRm6V0+RGpBKT/ROxxJZvRls
 WZv8fcnR/519g5IJCZPA7NQNkoYqM2gwyIkfCKCqt9sD/ZijcRs6wnguvJfDkKwsds+v
 2eqEnFYN/2lku1qX0GI0Onq72ObX2IxrCLgtFEdAV9+baQxYKoO6hHIt4BpEPPPhgQA3
 Uxiy6CMBfgZ12geAsXHYxZTcF3SXZzuRC9WSoFpF1vH/HB0kz9Om6UXBkJU2DdJfCuoj
 yxhw==
X-Gm-Message-State: AKS2vOzd0pgDz2fijTuTxvGKpUSKtJx/8G4VopZ7YAhmjY1DgeSCkgwR
 h9u7lu3k0Pk08zI2Woo=
X-Received: by 10.28.145.12 with SMTP id t12mr2482306wmd.7.1497740400649;
 Sat, 17 Jun 2017 16:00:00 -0700 (PDT)
Received: from [192.168.1.3] ([185.105.174.193])
 by smtp.googlemail.com with ESMTPSA id j10sm4979295wre.67.2017.06.17.15.59.58
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 17 Jun 2017 15:59:59 -0700 (PDT)
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Phil Sainty <psainty@HIDDEN>, 27397 <at> debbugs.gnu.org
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
 <70000e90-328c-c084-3e3c-bbde96b16110@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <adbc18a1-20ef-5261-6d8e-149b13d61674@HIDDEN>
Date: Sun, 18 Jun 2017 01:59:57 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101
 Thunderbird/54.0
MIME-Version: 1.0
In-Reply-To: <70000e90-328c-c084-3e3c-bbde96b16110@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On 6/17/17 3:31 PM, Phil Sainty wrote:

> In the process I noticed that the existing behaviour of trace--read-args
> was quite unfriendly if you wanted to set a trace buffer but had no need
> of a context expression -- typing RET at the context expression prompt
> triggered an "End of file during parsing" error, as that input string
> is processed by `read-from-string'.
> 
> I've changed that code to treat an empty input as "nil" (which is read
> to `nil'), and to ignore `nil' context expressions entirely (as opposed
> to printing their evaluated value as "[nil]" in the trace buffer).

Sounds good.

Why the rename, though? Those are not arguments for the function we're 
going to trace. trace--read-args sounds as appropriate, if not more.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jun 2017 12:31:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 08:31:33 2017
Received: from localhost ([127.0.0.1]:52202 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dMCt3-0001Gx-94
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 08:31:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:48591)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dMCt1-0001Gi-Cj
 for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 08:31:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dMCsu-0007km-Ig
 for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 08:31:26 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:51882)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dMCsu-0007kg-E6
 for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 08:31:24 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39560)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dMCss-00042T-Dj
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 08:31:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dMCsp-0007kP-A0
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 08:31:22 -0400
Received: from smtp-1.orcon.net.nz ([60.234.4.34]:47346)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dMCso-0007kG-NS
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 08:31:19 -0400
Received: from [150.107.172.84] (port=6352 helo=[192.168.20.102])
 by smtp-1.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>) id 1dMCsh-0003YN-IG
 for bug-gnu-emacs@HIDDEN; Sun, 18 Jun 2017 00:31:15 +1200
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: bug-gnu-emacs@HIDDEN
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
From: Phil Sainty <psainty@HIDDEN>
Message-ID: <70000e90-328c-c084-3e3c-bbde96b16110@HIDDEN>
Date: Sun, 18 Jun 2017 00:31:10 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
Content-Type: multipart/mixed; boundary="------------E1EE229F6C2D01E03D4D939F"
Content-Language: en-GB
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -2.7 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

This is a multi-part message in MIME format.
--------------E1EE229F6C2D01E03D4D939F
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 17/06/17 21:20, Phil Sainty wrote:
> inconsistent with `trace--read-args' which uses a prefix arg to prompt
> the user for the trace buffer and a context expression -- which I now
> realise is behaviour that my commands should incorporate as well.

I've implemented this change, and attached the current WIP patch.

In the process I noticed that the existing behaviour of trace--read-args
was quite unfriendly if you wanted to set a trace buffer but had no need
of a context expression -- typing RET at the context expression prompt
triggered an "End of file during parsing" error, as that input string
is processed by `read-from-string'.

I've changed that code to treat an empty input as "nil" (which is read
to `nil'), and to ignore `nil' context expressions entirely (as opposed
to printing their evaluated value as "[nil]" in the trace buffer).


-Phil

--------------E1EE229F6C2D01E03D4D939F
Content-Type: text/x-patch;
 name="0001-New-commands-for-bulk-tracing-of-elisp-functions.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-New-commands-for-bulk-tracing-of-elisp-functions.patch"

From 4d9ea7ac95b070d55b8e1502c3091168891f433e Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@HIDDEN>
Date: Sun, 11 Jun 2017 17:29:53 +1200
Subject: [PATCH] New commands for bulk tracing of elisp functions

* lisp/emacs-lisp/trace.el (trace-package, untrace-package)
(trace-regexp, untrace-regexp, trace-is-traceable-p): New functions.

(trace--read-extra-args): New function, split from `trace--read-args'.
Changed to allow the user to enter an empty string at the context
expression prompt (previously an error; now treated as "nil"), and to
cause a "nil" context expression to produce no context output in the
trace buffer.

(trace--read-function-args): New name for `trace--read-args'.
Changed to use the new `trace-is-traceable-p' predicate.
(trace--read-args): Renamed to `trace--read-function-args'
(trace-function-foreground, trace-function-background): Call the
renamed `trace--read-function-args'.

(trace-is-traced, untrace-function, untrace-all): Doc updates/fixes.

* etc/NEWS: Mention the new trace commands.

* doc/misc/tramp.texi: Update "(tramp) Traces and Profiles" to use
`trace-package'.
---
 doc/misc/tramp.texi      |   4 +-
 etc/NEWS                 |   8 +++
 lisp/emacs-lisp/trace.el | 133 ++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 123 insertions(+), 22 deletions(-)

diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index 4ca3932..54d5d00 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -3672,9 +3672,7 @@ Traces and Profiles
 
 @lisp
 @group
-(require 'trace)
-(dolist (elt (all-completions "tramp-" obarray 'functionp))
-  (trace-function-background (intern elt)))
+(trace-package "tramp-")
 (untrace-function 'tramp-read-passwd)
 @end group
 @end lisp
diff --git a/etc/NEWS b/etc/NEWS
index 7972511..d3d73cc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -743,6 +743,14 @@ header's value.
 where the GnuPG home directory (used for signature verification) is
 located and whether GnuPG's option "--homedir" is used or not.
 
+** Trace
+
++++
+*** New commands 'trace-package' and 'trace-regexp' (and their
+counterparts 'untrace-package' and 'untrace-regexp') allow for the
+bulk tracing of calls to functions with names matching a specified
+prefix or regexp.
+
 ** Tramp
 
 +++
diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el
index 1c57d73..949bb54 100644
--- a/lisp/emacs-lisp/trace.el
+++ b/lisp/emacs-lisp/trace.el
@@ -257,10 +257,15 @@ trace-function-internal
                       (or context (lambda () "")))
    `((name . ,trace-advice-name) (depth . -100))))
 
+(defun trace-is-traceable-p (sym)
+  "Whether the given symbol is a traceable function."
+  (or (functionp sym) (macrop sym)))
+
 (defun trace-is-traced (function)
+  "Whether FUNCTION is currently traced."
   (advice-member-p trace-advice-name function))
 
-(defun trace--read-args (prompt)
+(defun trace--read-function-args (prompt)
   "Read a function name, prompting with string PROMPT.
 If `current-prefix-arg' is non-nil, also read a buffer and a \"context\"
 \(Lisp expression).  Return (FUNCTION BUFFER FUNCTION-CONTEXT)."
@@ -274,19 +279,25 @@ trace--read-args
                                    default
                                    (if beg (substring prompt beg) ": "))
                                 prompt)
-                              obarray 'fboundp t nil nil
+                              obarray 'trace-is-traceable-p t nil nil
                               (if default (symbol-name default)))))
    (when current-prefix-arg
-     (list
-      (read-buffer "Output to buffer: " trace-buffer)
-      (let ((exp
-             (let ((minibuffer-completing-symbol t))
-               (read-from-minibuffer "Context expression: "
-                                     nil read-expression-map t
-                                     'read-expression-history))))
-        (lambda ()
-          (let ((print-circle t))
-            (concat " [" (prin1-to-string (eval exp t)) "]"))))))))
+     (trace--read-extra-args))))
+
+(defun trace--read-extra-args ()
+  "Read a buffer and a \"context\" (Lisp expression).
+Return (BUFFER FUNCTION-CONTEXT)."
+  (list
+   (read-buffer "Output to buffer: " trace-buffer)
+   (let ((exp
+          (let ((minibuffer-completing-symbol t))
+            (read-from-minibuffer "Context expression: "
+                                  nil read-expression-map t
+                                  'read-expression-history "nil"))))
+     (and exp
+          (lambda ()
+            (let ((print-circle t))
+              (concat " [" (prin1-to-string (eval exp t)) "]")))))))
 
 ;;;###autoload
 (defun trace-function-foreground (function &optional buffer context)
@@ -306,7 +317,7 @@ trace-function-foreground
 stuff - use `trace-function-background' instead.
 
 To stop tracing a function, use `untrace-function' or `untrace-all'."
-  (interactive (trace--read-args "Trace function: "))
+  (interactive (trace--read-function-args "Trace function: "))
   (trace-function-internal function buffer nil context))
 
 ;;;###autoload
@@ -314,24 +325,108 @@ trace-function-background
   "Trace calls to function FUNCTION, quietly.
 This is like `trace-function-foreground', but without popping up
 the output buffer or changing the window configuration."
-  (interactive (trace--read-args "Trace function in background: "))
+  (interactive (trace--read-function-args "Trace function in background: "))
   (trace-function-internal function buffer t context))
 
 ;;;###autoload
 (defalias 'trace-function 'trace-function-foreground)
 
 (defun untrace-function (function)
-  "Untraces FUNCTION and possibly activates all remaining advice.
-Activation is performed with `ad-update', hence remaining advice will get
-activated only if the advice of FUNCTION is currently active.  If FUNCTION
-was not traced this is a noop."
+  "Remove trace from FUNCTION.  If FUNCTION was not traced this is a noop."
   (interactive
    (list (intern (completing-read "Untrace function: "
                                   obarray #'trace-is-traced t))))
   (advice-remove function trace-advice-name))
 
+;;;###autoload
+(defun trace-package (prefix &optional buffer context)
+  "Trace all functions with names starting with PREFIX.
+For example, to trace all diff functions, do the following:
+
+\\[trace-package] RET diff- RET
+
+Background tracing is used.  Switch to the trace output buffer to
+view the results.
+
+See also `untrace-package'."
+  ;; Derived in part from `elp-instrument-package'.
+  (interactive
+   (cons (completing-read "Prefix of package to trace: "
+                          obarray #'trace-is-traceable-p)
+         (and current-prefix-arg (trace--read-extra-args))))
+  (when (zerop (length prefix))
+    (error "Tracing all Emacs functions would render Emacs unusable"))
+  (mapc (lambda (name)
+          (trace-function-background (intern name) buffer context))
+        (all-completions prefix obarray #'trace-is-traceable-p))
+  (message
+   "Tracing to %s.  Use %s to untrace a package, or %s to remove all traces."
+   (or buffer trace-buffer)
+   (substitute-command-keys "\\[untrace-package]")
+   (substitute-command-keys "\\[untrace-all]")))
+
+(defun untrace-package (prefix)
+  "Remove traces from all functions with names starting with PREFIX.
+
+See also `trace-package'."
+  (interactive
+   (list (completing-read "Prefix of package to untrace: "
+                          obarray #'trace-is-traced)))
+  (if (and (zerop (length prefix))
+           (y-or-n-p "Remove all function traces?"))
+      (untrace-all)
+    (mapc (lambda (name)
+            (untrace-function (intern name)))
+          (all-completions prefix obarray #'trace-is-traceable-p))))
+
+;;;###autoload
+(defun trace-regexp (regexp &optional buffer context)
+  "Trace all functions with names matching REGEXP.
+For example, to trace indentation-related functions, you could try:
+
+\\[trace-regexp] RET indent\\|offset RET
+
+Warning: Do not attempt to trace all functions.  Tracing too many
+functions at one time will render Emacs unusable.
+
+Background tracing is used.  Switch to the trace output buffer to
+view the results.
+
+See also `untrace-regexp'."
+  (interactive
+   (cons (read-regexp "Regexp matching functions to trace: ")
+         (and current-prefix-arg (trace--read-extra-args))))
+  (when (member regexp '("" "." ".+" ".*"))
+    ;; Not comprehensive, but it catches the most likely attempts.
+    (error "Tracing all Emacs functions would render Emacs unusable"))
+  (mapatoms
+   (lambda (sym)
+     (and (trace-is-traceable-p sym)
+          (string-match-p regexp (symbol-name sym))
+          (trace-function-background sym buffer context))))
+  (message
+   "Tracing to %s.  Use %s to untrace by regexp, or %s to remove all traces."
+   (or buffer trace-buffer)
+   (substitute-command-keys "\\[untrace-regexp]")
+   (substitute-command-keys "\\[untrace-all]")))
+
+(defun untrace-regexp (regexp)
+  "Remove traces from all functions with names matching REGEXP.
+
+See also `trace-regexp'."
+  (interactive
+   (list (read-regexp "Regexp matching functions to untrace: ")))
+  (if (and (zerop (length regexp))
+           (y-or-n-p "Remove all function traces?"))
+      (untrace-all)
+    (mapatoms
+     (lambda (sym)
+       (and (trace-is-traceable-p sym)
+            (string-match-p regexp (symbol-name sym))
+            (untrace-function sym))))))
+
 (defun untrace-all ()
-  "Untraces all currently traced functions."
+  "Remove traces from all currently traced functions."
   (interactive)
   (mapatoms #'untrace-function))
 
-- 
2.8.3


--------------E1EE229F6C2D01E03D4D939F--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jun 2017 09:20:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 05:20:32 2017
Received: from localhost ([127.0.0.1]:52108 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dM9uC-0003TB-AD
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 05:20:32 -0400
Received: from eggs.gnu.org ([208.118.235.92]:49958)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dM9uA-0003Sw-Al
 for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 05:20:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dM9u4-0002gw-3K
 for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 05:20:25 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:53703)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dM9u4-0002gr-0E
 for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 05:20:24 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:40920)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dM9u2-0004Ta-Jo
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 05:20:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dM9tx-0002cs-Lb
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 05:20:22 -0400
Received: from smtp-3.orcon.net.nz ([60.234.4.44]:40173)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dM9tx-0002bq-B1
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 05:20:17 -0400
Received: from [150.107.172.84] (port=54249 helo=[192.168.20.102])
 by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>) id 1dM9tg-0005Tu-NR
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 21:20:12 +1200
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: bug-gnu-emacs@HIDDEN
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
From: Phil Sainty <psainty@HIDDEN>
Message-ID: <94d27dbb-46d3-1d6f-4849-251a0929d413@HIDDEN>
Date: Sat, 17 Jun 2017 21:20:00 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-GB
Content-Transfer-Encoding: 8bit
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -2.7 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

Thanks to the merge with
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=1343 and
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6464 I see that there
was a previous submission of a `trace-package' command which (a) used
foreground tracing, and (b) provided `trace-package-background' as a
separate command.

I should note that I elected not to support foreground tracing for
my proposed commands, simply because it seemed to me that foreground
tracing could be problematic in too many cases, when the traces are
being applied en masse on the basis of function name pattern matching.

The current `trace-function-foreground' docstring says:

> This function creates BUFFER if it does not exist.  This buffer will
> popup whenever FUNCTION is called.  Do not use this function to trace
> functions that switch buffers, or do any other display-oriented
> stuff - use ‘trace-function-background’ instead.

My compromise was to indicate the `trace-buffer' value in the echo
area when the commands are invoked, so that the user would know where
the trace output was happening.  Actually popping up that buffer when
the `trace-package' or `trace-regexp' command is used would be another
(perhaps nicer) option?

I'm open to recommendations for the most useful approach.

Do others think that foreground versions of these commands would be
a good idea?

A prefix argument could mean "use foreground tracing", but that's
inconsistent with `trace--read-args' which uses a prefix arg to prompt
the user for the trace buffer and a context expression -- which I now
realise is behaviour that my commands should incorporate as well.


-Phil




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 17 Jun 2017 09:13:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 05:13:16 2017
Received: from localhost ([127.0.0.1]:52099 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dM9nA-0003Hy-2C
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 05:13:16 -0400
Received: from mail-wr0-f179.google.com ([209.85.128.179]:33213)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1dM9n8-0003Hm-Ok
 for 27397 <at> debbugs.gnu.org; Sat, 17 Jun 2017 05:13:15 -0400
Received: by mail-wr0-f179.google.com with SMTP id r103so48968353wrb.0
 for <27397 <at> debbugs.gnu.org>; Sat, 17 Jun 2017 02:13:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=GULtWU2/tGwhCejdCH1ibo18V+yOFZ1gZ6XJ40oGxB8=;
 b=PJKdDCZHyNDl1Q694QDrWM5IDc0ZYBdQgrZ3k3oNqMNgKXGmcG0nXl1ltBD0ZHEKRM
 uUllQak90t2UAGoGrnnQk2qzc0Rt2DLj9SCZ9YZaJ0bLv7LagPAyDdhqvn/XBXs9j1MP
 ZSdKtPPRubTPy4x++dfNaJZFoQSD/nmHnF+fne9PJ2fOkB8ysDZHkTmANuD0C8ZnbhzH
 fxYJq2nGjNC12mmPi/XlujOyNtiCdt4yUvQHD8XmknEFB736W1yweoztWxWKxpNSpJkI
 tI7IcFvA+kL0SPoWhcjqJ7VkPKlTR4s+OmZAKcsBCOuglx01edlOBjiC19AMZcZCyPGV
 BVgw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=GULtWU2/tGwhCejdCH1ibo18V+yOFZ1gZ6XJ40oGxB8=;
 b=sHvmnsbSqLGK587zgyO6QJ8H8kLEtwAegECqFBLWSQZS2zXOVs043UqfD2100q3v0i
 rNVuUNYQ/djltt5ePlSDpOvPMdYFkZE/cAGAAHGe1ErEa9W9LaTKjY/St8pO6DeiTfLu
 CYkabztGn5k29aitnkAU7/rgn0ZBTiPBI+Wk0jPxLj5XFEvjzuGn1inqeS8nnTwqs6JJ
 pP7/4O1JJ+7Q/LMJKOebljfdPfo5VoWfpSsrO5LL6NBul+Y8iGanRuyGmeNMX3yVlOOL
 9lp+fAOOfQL3wJ9gkRtaIGBmpHHTBDNSt0RahYoyzUuIBSzJ/uUD9l2NhGuRnQ+vUwFc
 aagA==
X-Gm-Message-State: AKS2vOzy/pySho22VFhDjP0CgJOqSWQlIsRe9VvpO1WVFyzkJzthmvvQ
 HNT1/i3/5Cis4b2JFVw=
X-Received: by 10.223.160.1 with SMTP id k1mr11063372wrk.102.1497690788797;
 Sat, 17 Jun 2017 02:13:08 -0700 (PDT)
Received: from [192.168.1.3] ([185.105.174.193])
 by smtp.googlemail.com with ESMTPSA id a28sm6622606wra.17.2017.06.17.02.13.07
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Sat, 17 Jun 2017 02:13:07 -0700 (PDT)
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Phil Sainty <psainty@HIDDEN>, 27397 <at> debbugs.gnu.org
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
 <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <5c1f6ddd-9589-6726-0536-730e20dbe249@HIDDEN>
Date: Sat, 17 Jun 2017 12:13:06 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101
 Thunderbird/54.0
MIME-Version: 1.0
In-Reply-To: <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

On 6/17/17 11:43 AM, Phil Sainty wrote:
> On 17/06/17 02:58, Dmitry Gutov wrote:
>> This patch could probably use a NEWS entry, though.
> 
> Yes, that's a good point. I'll add one to the next revision.
> Something like this?

Looks good to me, both proposed changes.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 17 Jun 2017 08:49:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 04:49:08 2017
Received: from localhost ([127.0.0.1]:52079 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dM9Po-0002k5-GX
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 04:49:08 -0400
Received: from smtp-3.orcon.net.nz ([60.234.4.44]:48518)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dM9Pm-0002jY-Hd
 for 27397 <at> debbugs.gnu.org; Sat, 17 Jun 2017 04:49:07 -0400
Received: from [150.107.172.84] (port=44275 helo=[192.168.20.102])
 by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>)
 id 1dM9PT-00026X-CN; Sat, 17 Jun 2017 20:48:57 +1200
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Kaushal Modi <kaushal.modi@HIDDEN>, 27397 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov@HIDDEN>
References: <CAFyQvY00pMR6u_7NA00GUuUe90eX0_OXxP5vPjZAzAEfrdGCCQ@HIDDEN>
From: Phil Sainty <psainty@HIDDEN>
Message-ID: <ecdd1135-93fe-f6b8-77c0-99c94bc7eb08@HIDDEN>
Date: Sat, 17 Jun 2017 20:48:46 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <CAFyQvY00pMR6u_7NA00GUuUe90eX0_OXxP5vPjZAzAEfrdGCCQ@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

> On 6/16/17 4:32 PM, Phil Sainty wrote:
>> (I note that the `trace-is-traced' function does not follow the usual
>> naming convention for predicates.  Should this be renamed to
>> `trace-is-traced-p' ?)


On 17/06/17 02:58, Dmitry Gutov wrote:
> I'm not 100% sure about the protocol here, but including both "-is-"
> and "-p" in a function name seems too much.
>
> So maybe you should do the opposite and rename trace-is-traceable-p to
> trace-is-traceable.


On 17/06/17 03:43, Kaushal Modi wrote:
> Based on current examples[1], it is more common to see predicate
> *functions* end in "-p". So the "-is-" portion is maybe redundant.
>
> My suggestion would be something like "trace-traced-p" or
> "trace-fn-traced-p".
>
> [1]: https://debbugs.gnu.org/cgi/bugreport.cgi?att=0;bug=26564;msg=5


FWIW, after loading more or less all the lisp in trunk, apropos tells me:

2381 matches for ".*-p$"
126 matches for "-is-"
28 matches for "-is-.*-p$"


The -p suffix is certainly what I'm used to seeing, but -is- is entirely
readable to my mind, so I'm happy either way.  Consistency is good, so
some kind of change seemed sensible to me, but I don't especially mind
one way or the other.

If one of the maintainers wants to make a recommendation, I'll update
the code (or leave it as-is) accordingly.


-Phil





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 17 Jun 2017 08:43:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 04:43:14 2017
Received: from localhost ([127.0.0.1]:52073 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dM9K5-0002bg-Rt
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2017 04:43:13 -0400
Received: from smtp-3.orcon.net.nz ([60.234.4.44]:44695)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dM9K4-0002bT-4A
 for 27397 <at> debbugs.gnu.org; Sat, 17 Jun 2017 04:43:12 -0400
Received: from [150.107.172.84] (port=26965 helo=[192.168.20.102])
 by smtp-3.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>)
 id 1dM9Js-0001bT-TX; Sat, 17 Jun 2017 20:43:02 +1200
From: Phil Sainty <psainty@HIDDEN>
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Dmitry Gutov <dgutov@HIDDEN>, 27397 <at> debbugs.gnu.org
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
 <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
Message-ID: <aeea08bc-f2e1-f6de-e3c0-a2389643eb81@HIDDEN>
Date: Sat, 17 Jun 2017 20:43:00 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

On 17/06/17 02:58, Dmitry Gutov wrote:
> This patch could probably use a NEWS entry, though.

Yes, that's a good point. I'll add one to the next revision.
Something like this?


** Trace

*** New commands 'trace-package' and 'trace-regexp' (and their
counterparts 'untrace-package' and 'untrace-regexp') allow for the
bulk tracing of calls to functions with names matching a specified
prefix or regexp.


As there's no info node for trace.el, that could perhaps be a +++
entry; although a grep shows me that "(tramp) Traces and Profiles"
could be amended to change:

     (require 'trace)
     (dolist (elt (all-completions "tramp-" obarray 'functionp))
       (trace-function-background (intern elt)))

to:

     (trace-package "tramp-")


It would be good to add a node to the elisp manual covering trace.el,
but that's not strictly part of this patch.


-Phil




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 16 Jun 2017 15:43:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 16 11:43:52 2017
Received: from localhost ([127.0.0.1]:51544 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dLtPc-0004MJ-7c
	for submit <at> debbugs.gnu.org; Fri, 16 Jun 2017 11:43:52 -0400
Received: from mail-lf0-f44.google.com ([209.85.215.44]:34138)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <kaushal.modi@HIDDEN>) id 1dLtPa-0004M4-4o
 for 27397 <at> debbugs.gnu.org; Fri, 16 Jun 2017 11:43:50 -0400
Received: by mail-lf0-f44.google.com with SMTP id v20so27475897lfa.1
 for <27397 <at> debbugs.gnu.org>; Fri, 16 Jun 2017 08:43:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=XuQg6Eh+hM85UybIt5FY26EZWaYiHOzKOFTcBsutJ1c=;
 b=Wzqtqo25dG7Ab+wS9BBMuH2OEI8HZXq3+suPlQ3hstRZQJubzbxmNQ4YYAh5gZpIH0
 TkmS1MfiwzLUcplLyinJLKEnU16jgGBW4SLYx31allVWCfeKtwcLOvamFI0DL1JiCxCI
 7IDnHm8zgqHx2J8IvxatQRkOvubluxZWs3PdEFtOvYmeblobr2DsBo/k4rXZVu6z/b0z
 A+TPbD32JrF09C6QIjujs8QEtHfbeP+j6RWWJKJ56ubR72dFb0Pjp3yEXpVvuRo7+Cxr
 w9aK9tBA3KMTtaHYifMsY4rBb7lXb43WViPrde9Y57rfDUubidfRiDWquTd3DZvM4GvM
 JGlA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=XuQg6Eh+hM85UybIt5FY26EZWaYiHOzKOFTcBsutJ1c=;
 b=qrTjtGO1hs4K5+croiblNwed+TX3wYzumC+RZSWYSs7TcRxjuR9GhfMlma8xFUEPw4
 CTDHRG2ABQS1CPGWP5gHswVNk/VJsQERtITokQSzyX7vNoaLhA4zkHeszYgBqEItHusJ
 HxAqx5LwIg1OIXiiJZoGnvkFJSxZYAfTGikiDy1QsoN3LB3Ow9rcwlRiQXBprQ32INUA
 A47IyPF4cB0bVbM0+xJ5VLaxQkGSVvbA5dm/9xcP+0vOZ9hwscaIIZe6PUrLtBic80BQ
 E8FNBXmAe8zBMVmo/i4zmxrSjEDjH8QB01NmZLPeccOYctc9JFnwaemjlk2gp/jTCnog
 K7rg==
X-Gm-Message-State: AKS2vOy5CiIfh0+U0Rihyj7KT4hTncINbAXF8eEFqs3VKcgjDH4dm/W0
 oTZ/mCaDzLQcu90y+KJVBx+z6ituTA==
X-Received: by 10.46.81.26 with SMTP id f26mr880079ljb.33.1497627823791; Fri,
 16 Jun 2017 08:43:43 -0700 (PDT)
MIME-Version: 1.0
From: Kaushal Modi <kaushal.modi@HIDDEN>
Date: Fri, 16 Jun 2017 15:43:32 +0000
Message-ID: <CAFyQvY00pMR6u_7NA00GUuUe90eX0_OXxP5vPjZAzAEfrdGCCQ@HIDDEN>
Subject: [PATCH] New commands for bulk tracing of elisp functions
To: 27397 <at> debbugs.gnu.org, psainty@HIDDEN, 
 Dmitry Gutov <dgutov@HIDDEN>
Content-Type: multipart/alternative; boundary="f403045fff247167d4055215a62b"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--f403045fff247167d4055215a62b
Content-Type: text/plain; charset="UTF-8"

> I note that the `trace-is-traced' function does not follow the usual
> naming convention for predicates.  Should this be renamed to
> `trace-is-traced-p'

Based on current examples[1], it is more common to see predicate
*functions* end in "-p". So the "-is-" portion is maybe redundant.

My suggestion would be something like "trace-traced-p" or
"trace-fn-traced-p".

[1]: https://debbugs.gnu.org/cgi/bugreport.cgi?att=0;bug=26564;msg=5

-- 

Kaushal Modi

--f403045fff247167d4055215a62b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>&gt; I note that the `trace-is-traced&#39; function d=
oes not follow the usual</div><div>&gt; naming convention for predicates.=
=C2=A0 Should this be renamed to</div><div>&gt; `trace-is-traced-p&#39;</di=
v><div><br></div>Based on current examples[1], it is more common to see pre=
dicate *functions* end in &quot;-p&quot;. So the &quot;-is-&quot; portion i=
s maybe redundant.<div><br></div><div>My suggestion would be something like=
 &quot;trace-traced-p&quot; or &quot;trace-fn-traced-p&quot;.</div><div><br=
></div><div>[1]:=C2=A0<a href=3D"https://debbugs.gnu.org/cgi/bugreport.cgi?=
att=3D0;bug=3D26564;msg=3D5">https://debbugs.gnu.org/cgi/bugreport.cgi?att=
=3D0;bug=3D26564;msg=3D5</a></div><div><br></div></div><div dir=3D"ltr">-- =
<br></div><div data-smartmail=3D"gmail_signature"><p dir=3D"ltr">Kaushal Mo=
di</p>
</div>

--f403045fff247167d4055215a62b--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.
Forcibly Merged 1343 6464 27397. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 27397 <at> debbugs.gnu.org:


Received: (at 27397) by debbugs.gnu.org; 16 Jun 2017 14:58:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 16 10:58:11 2017
Received: from localhost ([127.0.0.1]:51493 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dLshP-0001Ks-Kb
	for submit <at> debbugs.gnu.org; Fri, 16 Jun 2017 10:58:11 -0400
Received: from mail-wr0-f179.google.com ([209.85.128.179]:34486)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1dLshO-0001Ke-Ch
 for 27397 <at> debbugs.gnu.org; Fri, 16 Jun 2017 10:58:10 -0400
Received: by mail-wr0-f179.google.com with SMTP id 77so39915872wrb.1
 for <27397 <at> debbugs.gnu.org>; Fri, 16 Jun 2017 07:58:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=sender:subject:to:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=REpf8yDhxRou52eIcUVKn60gxBQQTpRGbMx8ts8/7vc=;
 b=Wadkt7HazS7ZA3MuBpV5PrO7lB+MfNIcrN/rkvIZboDjOWFMvGKB9DoYqEWRaIGnnS
 wC6YZMqyqeGy2S+pZRcgy3lhYi7ClcYPx/o+9/7ReaAnUAsgzCmk4P7x1wy4fgBdVbh/
 KX/0Pc7ChF9Ef7p10evUXVY7s+Q9ftLGAJ3T4KsJ+clH5mAhGJRUSw0JoxCwEi+Z1ioH
 HHcpETxLr4hrmrbYOGoWLcvrM4Awy2dXYhNXrc0PPxG66TARFuJAhHVc5ulAv/erUTGA
 MdiItGDjcpkAN7yIbRjT6r+lnc/5t53m1udnPMDSLtFJOqkJbQ3cbJEUjon4Oc3w4ZCR
 CCMw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:sender:subject:to:references:from:message-id
 :date:user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=REpf8yDhxRou52eIcUVKn60gxBQQTpRGbMx8ts8/7vc=;
 b=EvoCKCnJ7stN4i8RI1EvJs0qXgH2zJ21zgGL28gmXUe9QrY3xhg3mDkr2SofENlcoX
 JtN9KtuGJs5mnw3TXFsb9qm82qbquDTpsyW9hz5pDzij0GMvVwxlFdBwLs0EWXvQC0xe
 thN2PNNwBZXrUfh5VngeIWrnqFSX7eZnWMHMTOWXeiLdD81tE+kpCqCOp6VUGQLJ6aKH
 vnVabg7DFrzyIZa+qkZAy0EnRJES3/kVmEZvY8e66tNn5lANkYxkX+CxrjcVkuJ0Agdd
 m6UeZIb9NabUxX4z3rBjFgNedX8clL41T2BIJECSrF/F+Mr1//8HY1/O1AZWlzxY9F3X
 ogeQ==
X-Gm-Message-State: AKS2vOx9/G5vj735h8GpDbsICv7bMG+V0NE4Vc3itERK+PGjqiDlFMy7
 eNqVBdaXYrrFP6VC3II=
X-Received: by 10.223.145.78 with SMTP id j72mr7419309wrj.7.1497625084006;
 Fri, 16 Jun 2017 07:58:04 -0700 (PDT)
Received: from [192.168.1.3] ([185.105.174.193])
 by smtp.googlemail.com with ESMTPSA id 29sm3692637wrv.23.2017.06.16.07.58.02
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Fri, 16 Jun 2017 07:58:03 -0700 (PDT)
Subject: Re: bug#27397: [PATCH] New commands for bulk tracing of elisp
 functions
To: Phil Sainty <psainty@HIDDEN>, 27397 <at> debbugs.gnu.org
References: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
Message-ID: <34fcc090-6a8b-42de-b6c8-df182f8de938@HIDDEN>
Date: Fri, 16 Jun 2017 17:58:01 +0300
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101
 Thunderbird/54.0
MIME-Version: 1.0
In-Reply-To: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: 27397
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.0 (+)

On 6/16/17 4:32 PM, Phil Sainty wrote:

> This patch adds commands for tracing and untracing functions in bulk,
> either by function name prefix (`trace-package' and `untrace-package')
> or by regexp (`trace-regexp' and `untrace-regexp').

Looking good. And I've wanted these commands both times I've had a need 
to use trace.el.

This patch could probably use a NEWS entry, though.

> (I note that the `trace-is-traced' function does not follow the usual
> naming convention for predicates.  Should this be renamed to
> `trace-is-traced-p' ?)

I'm not 100% sure about the protocol here, but including both "-is-" and 
"-p" in a function name seems too much.

So maybe you should do the opposite and rename trace-is-traceable-p to 
trace-is-traceable.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Jun 2017 13:33:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 16 09:33:20 2017
Received: from localhost ([127.0.0.1]:50487 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1dLrNH-0007Vo-OE
	for submit <at> debbugs.gnu.org; Fri, 16 Jun 2017 09:33:20 -0400
Received: from eggs.gnu.org ([208.118.235.92]:32915)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <psainty@HIDDEN>) id 1dLrNG-0007VZ-30
 for submit <at> debbugs.gnu.org; Fri, 16 Jun 2017 09:33:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dLrN8-0005Ez-RR
 for submit <at> debbugs.gnu.org; Fri, 16 Jun 2017 09:33:12 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:37893)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dLrN8-0005Ev-Nh
 for submit <at> debbugs.gnu.org; Fri, 16 Jun 2017 09:33:10 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52109)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dLrN6-0003QN-Tc
 for bug-gnu-emacs@HIDDEN; Fri, 16 Jun 2017 09:33:10 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <psainty@HIDDEN>) id 1dLrN1-00059g-Re
 for bug-gnu-emacs@HIDDEN; Fri, 16 Jun 2017 09:33:08 -0400
Received: from smtp-1.orcon.net.nz ([60.234.4.34]:37750)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <psainty@HIDDEN>)
 id 1dLrN1-00057D-AQ
 for bug-gnu-emacs@HIDDEN; Fri, 16 Jun 2017 09:33:03 -0400
Received: from [150.107.172.84] (port=41275 helo=[192.168.20.102])
 by smtp-1.orcon.net.nz with esmtpa (Exim 4.86_2)
 (envelope-from <psainty@HIDDEN>) id 1dLrMm-0001x5-6z
 for bug-gnu-emacs@HIDDEN; Sat, 17 Jun 2017 01:32:58 +1200
To: bug-gnu-emacs@HIDDEN
From: Phil Sainty <psainty@HIDDEN>
Subject: [PATCH] New commands for bulk tracing of elisp functions
Message-ID: <1348823a-7623-8146-8cc0-8c0eff13e458@HIDDEN>
Date: Sat, 17 Jun 2017 01:32:47 +1200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.1.1
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------5E3E67DFA1FB0FE1DB2D8CCE"
Content-Language: en-US
X-GeoIP: NZ
X-Spam_score: -1.0
X-Spam_score_int: -9
X-Spam_bar: -
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -2.7 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.7 (--)

This is a multi-part message in MIME format.
--------------5E3E67DFA1FB0FE1DB2D8CCE
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

trace.el currently only has commands for adding a trace to a single
function, and for untracing either a single function or ALL traced
functions.

This patch adds commands for tracing and untracing functions in bulk,
either by function name prefix (`trace-package' and `untrace-package')
or by regexp (`trace-regexp' and `untrace-regexp').

The use of the term "package" for the prefix-based commands was chosen
for consistency with `elp-instrument-package', from which this code is
partly derived, and from which I have also maintained a warning and
basic protection against attempts to trace too many functions at once
(which can indeed render Emacs unusable).  It it still possible to do
this, but I feel the checks which are currently in place are probably
sufficient to protect against accidents.

`trace-is-traceable-p' is using Stefan's suggestion in his comment on
my initial implementation at https://stackoverflow.com/a/44241058 and
I have changed the completing-read filter predicate in
`trace--read-args' to also use this (instead of `fboundp'), on the
assumption that this makes more sense.

(I note that the `trace-is-traced' function does not follow the usual
naming convention for predicates.  Should this be renamed to
`trace-is-traced-p' ?)

This patch also removes some outdated docstring comments for
`untrace-function' which were clearly remnants of the earlier
implementation using advice.el (whereas the current library is based
on nadvice.el).


-Phil

--------------5E3E67DFA1FB0FE1DB2D8CCE
Content-Type: text/x-patch;
 name="0001-New-commands-for-bulk-tracing-of-elisp-functions.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename*0="0001-New-commands-for-bulk-tracing-of-elisp-functions.patch"

From c7262056db33722bc84dd94fbadaa71ed8fbf5fc Mon Sep 17 00:00:00 2001
From: Phil Sainty <psainty@HIDDEN>
Date: Sun, 11 Jun 2017 17:29:53 +1200
Subject: [PATCH] New commands for bulk tracing of elisp functions

* lisp/emacs-lisp/trace.el (trace-package, untrace-package)
(trace-regexp, untrace-regexp, trace-is-traceable-p): New functions.
(trace--read-args): Use new trace-is-traceable-p predicate.
(trace-is-traced, untrace-function, untrace-all): Doc updates/fixes.
---
 lisp/emacs-lisp/trace.el | 98 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 92 insertions(+), 6 deletions(-)

diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el
index 1c57d73..5dba151 100644
--- a/lisp/emacs-lisp/trace.el
+++ b/lisp/emacs-lisp/trace.el
@@ -257,7 +257,12 @@ trace-function-internal
                       (or context (lambda () "")))
    `((name . ,trace-advice-name) (depth . -100))))
 
+(defun trace-is-traceable-p (sym)
+  "Whether the given symbol is a traceable function."
+  (or (functionp sym) (macrop sym)))
+
 (defun trace-is-traced (function)
+  "Whether FUNCTION is currently traced."
   (advice-member-p trace-advice-name function))
 
 (defun trace--read-args (prompt)
@@ -274,7 +279,7 @@ trace--read-args
                                    default
                                    (if beg (substring prompt beg) ": "))
                                 prompt)
-                              obarray 'fboundp t nil nil
+                              obarray 'trace-is-traceable-p t nil nil
                               (if default (symbol-name default)))))
    (when current-prefix-arg
      (list
@@ -321,17 +326,98 @@ trace-function-background
 (defalias 'trace-function 'trace-function-foreground)
 
 (defun untrace-function (function)
-  "Untraces FUNCTION and possibly activates all remaining advice.
-Activation is performed with `ad-update', hence remaining advice will get
-activated only if the advice of FUNCTION is currently active.  If FUNCTION
-was not traced this is a noop."
+  "Remove trace from FUNCTION.  If FUNCTION was not traced this is a noop."
   (interactive
    (list (intern (completing-read "Untrace function: "
                                   obarray #'trace-is-traced t))))
   (advice-remove function trace-advice-name))
 
+;;;###autoload
+(defun trace-package (prefix)
+  "Trace all functions with names starting with PREFIX.
+For example, to trace all diff functions, do the following:
+
+\\[trace-package] RET diff- RET
+
+Background tracing is used.  Switch to the trace output buffer to
+view the results.
+
+See also `untrace-package'."
+  (interactive ;; derived from `elp-instrument-package'.
+   (list (completing-read "Prefix of package to trace: "
+                          obarray #'trace-is-traceable-p)))
+  (when (zerop (length prefix))
+    (error "Tracing all Emacs functions would render Emacs unusable"))
+  (mapc (lambda (name)
+          (trace-function-background (intern name)))
+        (all-completions prefix obarray #'trace-is-traceable-p))
+  (message
+   "Tracing to %s.  Use %s to untrace a package, or %s to remove all traces."
+   trace-buffer
+   (substitute-command-keys "\\[untrace-package]")
+   (substitute-command-keys "\\[untrace-all]")))
+
+(defun untrace-package (prefix)
+  "Remove traces from all functions with names starting with PREFIX.
+
+See also `trace-package'."
+  (interactive
+   (list (completing-read "Prefix of package to untrace: "
+                          obarray #'trace-is-traced)))
+  (if (and (zerop (length prefix))
+           (y-or-n-p "Remove all function traces?"))
+      (untrace-all)
+    (mapc (lambda (name)
+            (untrace-function (intern name)))
+          (all-completions prefix obarray #'trace-is-traceable-p))))
+
+;;;###autoload
+(defun trace-regexp (regexp)
+  "Trace all functions with names matching REGEXP.
+For example, to trace indentation-related functions, you could try:
+
+\\[trace-regexp] RET indent\\|offset RET
+
+Warning: Do not attempt to trace all functions.  Tracing too many
+functions at one time will render Emacs unusable.
+
+Background tracing is used.  Switch to the trace output buffer to
+view the results.
+
+See also `untrace-regexp'."
+  (interactive
+   (list (read-regexp "Regexp matching functions to trace: ")))
+  (when (member regexp '("" "." ".+" ".*"))
+    ;; Not comprehensive, but it catches the most likely attempts.
+    (error "Tracing all Emacs functions would render Emacs unusable"))
+  (mapatoms
+   (lambda (sym)
+     (and (trace-is-traceable-p sym)
+          (string-match-p regexp (symbol-name sym))
+          (trace-function-background sym))))
+  (message
+   "Tracing to %s.  Use %s to untrace by regexp, or %s to remove all traces."
+   trace-buffer
+   (substitute-command-keys "\\[untrace-regexp]")
+   (substitute-command-keys "\\[untrace-all]")))
+
+(defun untrace-regexp (regexp)
+  "Remove traces from all functions with names matching REGEXP.
+
+See also `trace-regexp'."
+  (interactive
+   (list (read-regexp "Regexp matching functions to untrace: ")))
+  (if (and (zerop (length regexp))
+           (y-or-n-p "Remove all function traces?"))
+      (untrace-all)
+    (mapatoms
+     (lambda (sym)
+       (and (trace-is-traceable-p sym)
+            (string-match-p regexp (symbol-name sym))
+            (untrace-function sym))))))
+
 (defun untrace-all ()
-  "Untraces all currently traced functions."
+  "Remove traces from all currently traced functions."
   (interactive)
   (mapatoms #'untrace-function))
 
-- 
2.8.3


--------------5E3E67DFA1FB0FE1DB2D8CCE--




Acknowledgement sent to Phil Sainty <psainty@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#27397; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 19 Jun 2017 11:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.