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: Sun, 24 Mar 2024 11:04:07 +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="25680"; 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 Sun Mar 24 12:04:50 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 1roLek-0006P4-2s for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Mar 2024 12:04:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1roLeJ-0007xB-AP; Sun, 24 Mar 2024 07:04:23 -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 1roLeH-0007wy-EC for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 07:04:21 -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 1roLeH-0007gs-66 for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 07:04:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1roLew-0001Pe-H3 for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 07:05: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: Sun, 24 Mar 2024 11:05: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.17112782995415 (code B ref 67455); Sun, 24 Mar 2024 11:05:02 +0000 Original-Received: (at 67455) by debbugs.gnu.org; 24 Mar 2024 11:04:59 +0000 Original-Received: from localhost ([127.0.0.1]:49224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1roLes-0001PH-JL for submit@debbugs.gnu.org; Sun, 24 Mar 2024 07:04:58 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:49039) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1roLeq-0001Oq-2J for 67455@debbugs.gnu.org; Sun, 24 Mar 2024 07:04:56 -0400 Original-Received: (qmail 7042 invoked by uid 3782); 24 Mar 2024 12:04:08 +0100 Original-Received: from acm.muc.de (p4fe15d23.dip0.t-ipconnect.de [79.225.93.35]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 24 Mar 2024 12:04:08 +0100 Original-Received: (qmail 11567 invoked by uid 1000); 24 Mar 2024 11:04:07 -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:282020 Archived-At: Hello, Stefan. On Sun, Mar 10, 2024 at 17:03:28 -0400, Stefan Monnier wrote: > >> >> - Testing `byte-compile-in-progress` can't be right. Do you to test > >> >> whether the result of this backquote will be byte-compiled or do you > >> >> really mean to test whether this backquote happens to be executed > >> >> during compilation (which could be because the compiler ends up > >> >> loading code while executing `eval-when-compile` or `require`)? > >> > Quite simply, during compilation, all symbols (except nil) get read with > >> > position, so to strip their positions here would be wrong. > >> This isn't quite right: during compilation, some code is read with > >> positions (the code that we will compile), but some code is read in the > >> normal way (the code we load for the purpose of running). > >> The distinction is important. > > OK, I wasn't really counting code that we load as "during compilation", > > but I take the point. > The point is that `byte-compile-in-progress` will be non-nil during > those loads, so you can't use this variable to get the information you need. Yes. How about binding it to nil around `load' and recursive edits, and possibly one or two other things? > >> More generally: what goes wrong in the above example if you just treat > >> that as a list of symbol (stripping them all of their position info). > >> AFAICT when *that* macro is expanded (i.e. ME2) you'll presumably get > >> code like > >> (mapatoms #'(lambda (FOO/p) (DO/p SOME/p (THING/p)))) > >> right? [ where "/p" means that the symbol has a sympos. ] > >> Isn't that sufficient info to add a docstring with position? > > It's the lambda which has a position rather than the expanded bits from > > ME2. > Hmm... then I misunderstand something. How can the `lambda` have > a position if you don't include any special treatment of backquote? In read-positioning-defined-symbols, lambdas get positioned, along with symbols being defined by defun, defmacro, cl-defmethod, .... This is not to do with backquote handling. > AFAICT the `lambda` in the result of ME1 should not include position > information because at that time we don't know that it will be used to > build code rather than be some element of a normal list. read-positioning-defined-symbols cannot know how (lambda ...) is going to be used. It is up to other code (here, macroexp--expand-all) to strip the position from the lambda when it would be obtrusive. > And how come the rest doesn't have position information? read-positioning-defined-symbols is specifically coded (with a state machine) to position only the lambdas and the defined symbols. > Stefan -- Alan Mackenzie (Nuremberg, Germany).