From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#67455: (Record source position, etc., in doc strings, and use this in *Help* and backtraces.) Date: Tue, 26 Mar 2024 16:55:16 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3631"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, Eli Zaretskii , 67455@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Mar 26 17:56:41 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rpA6K-0000nb-Vr for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Mar 2024 17:56:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpA5m-0001px-H1; Tue, 26 Mar 2024 12:56:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rpA5k-0001nv-Dd for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2024 12:56:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rpA5i-0002SJ-JT for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2024 12:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rpA5i-0005nD-5j for bug-gnu-emacs@gnu.org; Tue, 26 Mar 2024 12:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 Mar 2024 16:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67455 X-GNU-PR-Package: emacs Original-Received: via spool by 67455-submit@debbugs.gnu.org id=B67455.171147212822213 (code B ref 67455); Tue, 26 Mar 2024 16:56:02 +0000 Original-Received: (at 67455) by debbugs.gnu.org; 26 Mar 2024 16:55:28 +0000 Original-Received: from localhost ([127.0.0.1]:34811 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rpA59-0005mB-Oc for submit@debbugs.gnu.org; Tue, 26 Mar 2024 12:55:28 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:22272) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rpA56-0005lM-6y for 67455@debbugs.gnu.org; Tue, 26 Mar 2024 12:55:25 -0400 Original-Received: (qmail 80073 invoked by uid 3782); 26 Mar 2024 17:55:18 +0100 Original-Received: from acm.muc.de (p4fe15213.dip0.t-ipconnect.de [79.225.82.19]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 26 Mar 2024 17:55:17 +0100 Original-Received: (qmail 14083 invoked by uid 1000); 26 Mar 2024 16:55:16 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282100 Archived-At: Hello, Stefan. On Tue, Mar 26, 2024 at 09:40:19 -0400, Stefan Monnier wrote: > >> > Sorry about that. A quick summary: defined symbols (and lambda) get > >> > positioned by the new reader function read-positioning-defined symbols. > >> > The new declare clause defining-symbol marks a macro such as defun or > >> > cl-defgeneric as a macro which defines such symbols. > Since I still don't understand the general picture, let me tell you how > I would plan to do it, so you can tell me where it matches your > approach and where it doesn't: > - Change `load-source-file-function` so it uses > `read-positioning-symbols` instead of plain `read`. > [ This means that macro-expansion will now almost always have sympos, > rather than only during compilation, ] load-source-file-function is set to read-positioning-defined-symbols. (In a change to be committed, it gets bound to this function in Fload). In reading (defun foo () "foo doc" (lambda (bar) "lambda doc" (car bar))) , foo gets positioned (because it follows defun), and so does lambda (because it is a lambda following "("). > - This in turn requires a strip-sympos pass after the > eager-macroexpansion phase of `load-source-file-function`. No such pass is needed, due to the state machine in read-positioning-defined-symbols. > - Change macros like `lambda` so as to use the extract position info > from themselves/theirargs/thecontext (when available, since there will > still be corner cases where it's not available, such as during > non-eager macro expansion) .... The macro lambda has become obsolete; it had no access to the SWP lambda for which it was invoked. It has been replaced by code in macroexpand-1 and Fmacroexpand which wraps the lambda form in (function ....) and preserves the SWP lambda. I'm not entirely sure, but I think in non-eager macro expansion the position information in SWPs is typically available. > .... and stash it in their docstring. > This might be as simple as adding a line > (setq docstring (add-pos-to-docstring docstring ARG)). This posification is done (mainly) in a call to byte-run-posify-lambda-form from the (function (lambda ...)) pcase arm in macroexp--expand-all. > - Stefan -- Alan Mackenzie (Nuremberg, Germany).