Subject: Re: bug#67455: (Record source position, etc., in doc strings, and use this in *Help* and backtraces.)

From: Stefan Monnier <[email-masked]>
Date: Tue, 26 Mar 2024 09:40:19 -0400

>> > 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,  ]
- This in turn requires a strip-sympos pass after the
  eager-macroexpansion phase of `load-source-file-function`.
- 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) and stash it in their docstring.
  This might be as simple as adding a line
  (setq docstring (add-pos-to-docstring docstring ARG)).

- Stefan