unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#33164: 26.1; Compiled function information in *Help*
@ 2018-10-26 15:05 Drew Adams
  2018-10-28 13:27 ` Noam Postavsky
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2018-10-26 15:05 UTC (permalink / raw)
  To: 33164

emacs -Q

C-h v region-extract-function tells me:

region-extract-function is a variable defined in 'simple.el'.
Its value is #f(compiled-function (method) #<bytecode 0x1001ae2e9>)
...

There is a link to `simple.el'.  And the #<bytecode...> is also a link,
to the disassembled byte-code.

This is a bit more helpful than what we had in Emacs 24 (which was the
byte-code, printed).

But it is less helpful than what we had back in Emacs 23, which printed
the name or the lambda expression of the function that is the value of
the variable.  Examples:

 comment-line-break-function is a variable defined in `simple.el'.
 Its value is comment-indent-new-line


 completion-annotate-function is a variable defined in `minibuffer.el'.
 Its value is (lambda (var)
                (and (custom-variable-p (intern-soft var))
                "  (option)"))

Such description provided lots of helpful information, and we've lost
that now.

I guess this comes from eager macroexpansion (?).  But is there no way
for our help system to know what the function name or original lambda
expression is, and print that?

Yes, it would be helpful for it to _also_ provide the info that the
value is actually the byte-compilation of that function, when that is
the case, and to provide a link to the disassembly of that byte-code.

But just showing the byte code, even disassembled, is not so helpful.
What if a user wants to go to the function definition, to use it as a
model for defining a new value for the variable or just to study it?

Our help system should not become _less_ helpful just because we find
ways to optimize Emacs or make other improvements.  From a help
perspective, this is a step backward for users.

But maybe I'm missing something?  Is there currently some way to get to
the source code defining the function that is the variable value?


In GNU Emacs 26.1 (build 1, x86_64-w64-mingw32)
 of 2018-05-30 built on CIRROCUMULUS
Repository revision: 07f8f9bc5a51f5aa94eb099f3e15fbe0c20ea1ea
Windowing system distributor 'Microsoft Corp.', version 10.0.16299





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#33164: 26.1; Compiled function information in *Help*
  2018-10-26 15:05 bug#33164: 26.1; Compiled function information in *Help* Drew Adams
@ 2018-10-28 13:27 ` Noam Postavsky
  2018-10-28 14:17   ` Drew Adams
  2021-06-23 14:05   ` bug#33164: Compiled function value " Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Noam Postavsky @ 2018-10-28 13:27 UTC (permalink / raw)
  To: Drew Adams; +Cc: 33164

retitle 33164 Compiled function value information in *Help*
quit

Drew Adams <drew.adams@oracle.com> writes:

> C-h v region-extract-function tells me:
>
> region-extract-function is a variable defined in 'simple.el'.
> Its value is #f(compiled-function (method) #<bytecode 0x1001ae2e9>)
> ...
>
> There is a link to `simple.el'.  And the #<bytecode...> is also a link,
> to the disassembled byte-code.

> But it is less helpful than what we had back in Emacs 23, which printed
> the name or the lambda expression of the function that is the value of
> the variable.  Examples:
>
>  comment-line-break-function is a variable defined in `simple.el'.
>  Its value is comment-indent-new-line

This one is still the same in newer Emacs versions.

> But just showing the byte code, even disassembled, is not so helpful.
> What if a user wants to go to the function definition, to use it as a
> model for defining a new value for the variable or just to study it?

Similarly, C-h v float-pi tells me

    float-pi is a variable defined in ‘float-sup.el’.
    Its value is 3.141592653589793

It doesn't show me (* 4 (atan 1)) for study.

> But maybe I'm missing something?  Is there currently some way to get to
> the source code defining the function that is the variable value?

In this case, the link to `simple.el' takes you there because it's the
default value.  But in general, no, that information is not saved
anywhere.

The easiest fix is to say we should never assign anonymous functions to
variables (there have already been a couple of cases where some
anonymous function values were given names), so then they would all show
a symbol like comment-line-break-function.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#33164: 26.1; Compiled function information in *Help*
  2018-10-28 13:27 ` Noam Postavsky
@ 2018-10-28 14:17   ` Drew Adams
  2021-06-23 14:05   ` bug#33164: Compiled function value " Lars Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Drew Adams @ 2018-10-28 14:17 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33164

> In this case, the link to `simple.el' takes you there because it's the
> default value.  But in general, no, that information is not saved
> anywhere.

Yes, what you say makes sense.  I guess I am wondering whether
the byte-compiler might (be made to) record the source in the
byte-compiled function definition.  A byte-compiled file
records the absolute name of the source file, as well as the
Emacs release/build and the time of the compilation (creation
of the .elc).

Perhaps some "source" location information could be recorded
in the byte-code, and be retrievable by a help function?
In the case of a source definition in a file, the info could
be similar to what we record in a .elc.  But perhaps even if
the source code were in a buffer, or even via `M-:', perhaps
some textual indication/description of that source could be
recorded, along with the date & time.

Just a thought.  Yes, that would increase byte-code size,
and it should anyway be optional I guess.  But it might
allow for a little more introspection than what we can get
now (disassembled code).

If you want to recast this bug report as an enhancement
request along those lines, perhaps (again) retitling, please
do so.

> The easiest fix is to say we should never assign anonymous functions to
> variables (there have already been a couple of cases where some
> anonymous function values were given names), so then they would all show
> a symbol like comment-line-break-function.

That would not be something I'd ask for or appreciate.
I want to be able to get more info about existing function
values, not reduce the types of function values we can
assign to variables.

It can be helpful for help functions if someone uses a
symbol (providing a name and perhaps a source location),
but users need to be able to define and assign code as
values on the fly.  The idea of this report is to ask
for possible improvement in the introspection of byte-code
values - specifically time and location of definition.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#33164: Compiled function value information in *Help*
  2018-10-28 13:27 ` Noam Postavsky
  2018-10-28 14:17   ` Drew Adams
@ 2021-06-23 14:05   ` Lars Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-06-23 14:05 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 33164

Noam Postavsky <npostavs@gmail.com> writes:

>> But it is less helpful than what we had back in Emacs 23, which printed
>> the name or the lambda expression of the function that is the value of
>> the variable.  Examples:
>>
>>  comment-line-break-function is a variable defined in `simple.el'.
>>  Its value is comment-indent-new-line
>
> This one is still the same in newer Emacs versions.
>
>> But just showing the byte code, even disassembled, is not so helpful.
>> What if a user wants to go to the function definition, to use it as a
>> model for defining a new value for the variable or just to study it?
>
> Similarly, C-h v float-pi tells me
>
>     float-pi is a variable defined in ‘float-sup.el’.
>     Its value is 3.141592653589793
>
> It doesn't show me (* 4 (atan 1)) for study.

The help buffer shows the actual value of the variable, which may be
set somewhere else than it has been defined.  It's not feasible for the
Emacs help system to take you to all locations a variable has been
changed, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-06-23 14:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-26 15:05 bug#33164: 26.1; Compiled function information in *Help* Drew Adams
2018-10-28 13:27 ` Noam Postavsky
2018-10-28 14:17   ` Drew Adams
2021-06-23 14:05   ` bug#33164: Compiled function value " Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).