unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
@ 2019-02-20  3:55 Michael Heerdegen
  2019-02-20 17:13 ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2019-02-20  3:55 UTC (permalink / raw)
  To: 34588


Hello,

I'm not sure why "write-contents-functions" isn't named "...-hook".
Anyway, since its named -functions, shouldn't we say what arguments the
members should accept? (AFAIK the answer is: functions are called with
no arguments).

You might argue that the thing is also called a "hook" in the docstring,
but it also seems to call the members of the variable "hooks" later in
the doc, as far as I understand it.  So for me it's all a bit unclear
and confusing.


Thanks,

Michael.







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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-20  3:55 bug#34588: 27.0.50; Doc of write-contents-functions: arguments? Michael Heerdegen
@ 2019-02-20 17:13 ` Eli Zaretskii
  2019-02-21  2:59   ` Michael Heerdegen
  2019-02-21  3:32   ` Richard Stallman
  0 siblings, 2 replies; 10+ messages in thread
From: Eli Zaretskii @ 2019-02-20 17:13 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 34588

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Date: Wed, 20 Feb 2019 04:55:49 +0100
> 
> I'm not sure why "write-contents-functions" isn't named "...-hook".

Because we need to call those functions with
run-hook-with-args-until-success, I guess.

> Anyway, since its named -functions, shouldn't we say what arguments the
> members should accept? (AFAIK the answer is: functions are called with
> no arguments).

I agree it would be good to say that in the doc string (yes, no
arguments is the right answer).

> You might argue that the thing is also called a "hook" in the docstring,
> but it also seems to call the members of the variable "hooks" later in
> the doc, as far as I understand it.  So for me it's all a bit unclear
> and confusing.

Is it less confusing now?





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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-20 17:13 ` Eli Zaretskii
@ 2019-02-21  2:59   ` Michael Heerdegen
  2019-02-21  3:32   ` Richard Stallman
  1 sibling, 0 replies; 10+ messages in thread
From: Michael Heerdegen @ 2019-02-21  2:59 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 34588

Eli Zaretskii <eliz@gnu.org> writes:

> I agree it would be good to say that in the doc string (yes, no
> arguments is the right answer).

Ok, good.

> Is it less confusing now?

Yes, I'm fine with doing that to fix this.


Thanks,

Michael.





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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-20 17:13 ` Eli Zaretskii
  2019-02-21  2:59   ` Michael Heerdegen
@ 2019-02-21  3:32   ` Richard Stallman
  2019-02-21  3:47     ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Richard Stallman @ 2019-02-21  3:32 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: michael_heerdegen, 34588

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > I'm not sure why "write-contents-functions" isn't named "...-hook".

  > Because we need to call those functions with
  > run-hook-with-args-until-success, I guess.

This naming convention should be documented in the Emacs Lisp
Reference Manual.

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-21  3:32   ` Richard Stallman
@ 2019-02-21  3:47     ` Eli Zaretskii
  2019-02-21  4:24       ` Michael Heerdegen
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2019-02-21  3:47 UTC (permalink / raw)
  To: rms; +Cc: michael_heerdegen, 34588

> From: Richard Stallman <rms@gnu.org>
> Cc: michael_heerdegen@web.de, 34588@debbugs.gnu.org
> Date: Wed, 20 Feb 2019 22:32:08 -0500
> 
>   > Because we need to call those functions with
>   > run-hook-with-args-until-success, I guess.
> 
> This naming convention should be documented in the Emacs Lisp
> Reference Manual.

It is, but this case goes against the convention, thus Michael's
question.





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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-21  3:47     ` Eli Zaretskii
@ 2019-02-21  4:24       ` Michael Heerdegen
  2019-02-21  9:17         ` martin rudalics
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2019-02-21  4:24 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rms, 34588

Eli Zaretskii <eliz@gnu.org> writes:

> > From: Richard Stallman <rms@gnu.org>
> > Cc: michael_heerdegen@web.de, 34588@debbugs.gnu.org
> > Date: Wed, 20 Feb 2019 22:32:08 -0500
> >
> >   > Because we need to call those functions with
> >   > run-hook-with-args-until-success, I guess.
> >
> > This naming convention should be documented in the Emacs Lisp
> > Reference Manual.
>
> It is, but this case goes against the convention, thus Michael's
> question.

Maybe Richard meant we should document that something should _not_ be
called "-hook" when it is called with
`run-hook-with-args-until-success'?  That _would_ have answered my
question, and stating that as a convention would make sense to me.

Michael.





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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-21  4:24       ` Michael Heerdegen
@ 2019-02-21  9:17         ` martin rudalics
  2019-02-21  9:29           ` Michael Heerdegen
  0 siblings, 1 reply; 10+ messages in thread
From: martin rudalics @ 2019-02-21  9:17 UTC (permalink / raw)
  To: Michael Heerdegen, Eli Zaretskii; +Cc: rms, 34588

 > Maybe Richard meant we should document that something should _not_ be
 > called "-hook" when it is called with
 > `run-hook-with-args-until-success'?  That _would_ have answered my
 > question, and stating that as a convention would make sense to me.

The Elisp manual already says that as

      If the hook variable's name does not end with `-hook', that
   indicates it is probably an "abnormal hook".  That means the hook
   functions are called with arguments, or their return values are used in
   some way.  The hook's documentation says how the functions are called.
   You can use `add-hook' to add a function to an abnormal hook, but you
   must write the function to follow the hook's calling convention.  By
   convention, abnormal hook names end in `-functions'.

and

      The variables whose names end in `-functions' are usually "abnormal
   hooks" (some old code may also use the deprecated `-hooks' suffix);
   their values are lists of functions, but these functions are called in
   a special way (they are passed arguments, or their return values are
   used).  The variables whose names end in `-function' have single
   functions as their values.

and for 'write-contents-functions' it says that

      If any of the functions in this hook returns non-`nil', the file
      is considered already written and the rest are not called and
      neither are the functions in `write-file-functions'.

so the naming convention is preserved and everything should have been
clear.  I believe that due to how the documentation is written,
readers intuitively pay less attention to the "or their return values
are used in some way" and "or their return values are used" phrases.

martin





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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-21  9:17         ` martin rudalics
@ 2019-02-21  9:29           ` Michael Heerdegen
  2019-02-22  2:06             ` Richard Stallman
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Heerdegen @ 2019-02-21  9:29 UTC (permalink / raw)
  To: martin rudalics; +Cc: rms, 34588

martin rudalics <rudalics@gmx.at> writes:

> so the naming convention is preserved and everything should have been
> clear.  I believe that due to how the documentation is written,
> readers intuitively pay less attention to the "or their return values
> are used in some way" and "or their return values are used" phrases.

Hmm, you're right, the explanation clearly tells it.  Dunno how to
improve it to let people pay more attention - more jokes maybe?

Michael.





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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-21  9:29           ` Michael Heerdegen
@ 2019-02-22  2:06             ` Richard Stallman
  2021-10-23 18:11               ` Stefan Kangas
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Stallman @ 2019-02-22  2:06 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 34588

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > so the naming convention is preserved and everything should have been
  > > clear.  I believe that due to how the documentation is written,
  > > readers intuitively pay less attention to the "or their return values
  > > are used in some way" and "or their return values are used" phrases.

  > Hmm, you're right, the explanation clearly tells it.  Dunno how to
  > improve it to let people pay more attention - more jokes maybe?

If people work on this, I think they will find a way.

-- 
Dr Richard Stallman
President, Free Software Foundation (https://gnu.org, https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







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

* bug#34588: 27.0.50; Doc of write-contents-functions: arguments?
  2019-02-22  2:06             ` Richard Stallman
@ 2021-10-23 18:11               ` Stefan Kangas
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Kangas @ 2021-10-23 18:11 UTC (permalink / raw)
  To: Richard Stallman; +Cc: Michael Heerdegen, 34588

close 34588 28.1
thanks

martin rudalics <rudalics@gmx.at> writes:

>> Maybe Richard meant we should document that something should _not_ be
>> called "-hook" when it is called with
>> `run-hook-with-args-until-success'?  That _would_ have answered my
>> question, and stating that as a convention would make sense to me.
>
> The Elisp manual already says that as
>
>      If the hook variable's name does not end with `-hook', that
>   indicates it is probably an "abnormal hook".  That means the hook
>   functions are called with arguments, or their return values are used in
>   some way.  The hook's documentation says how the functions are called.
>   You can use `add-hook' to add a function to an abnormal hook, but you
>   must write the function to follow the hook's calling convention.  By
>   convention, abnormal hook names end in `-functions'.
>
> and
>
>      The variables whose names end in `-functions' are usually "abnormal
>   hooks" (some old code may also use the deprecated `-hooks' suffix);
>   their values are lists of functions, but these functions are called in
>   a special way (they are passed arguments, or their return values are
>   used).  The variables whose names end in `-function' have single
>   functions as their values.
>
> and for 'write-contents-functions' it says that
>
>      If any of the functions in this hook returns non-`nil', the file
>      is considered already written and the rest are not called and
>      neither are the functions in `write-file-functions'.
>
> so the naming convention is preserved and everything should have been
> clear.  I believe that due to how the documentation is written,
> readers intuitively pay less attention to the "or their return values
> are used in some way" and "or their return values are used" phrases.

I clarified this to:

    "That means one of two things: either that the hook functions are
    called with arguments, or that their their return values are used in
    some way."

And:

    "Their values are lists of functions, but these functions are called
    in a special way: they are either passed arguments, or their return
    values are used in some way."

This change has been pushed to emacs-28 (commit 4fd5c8df67).

I believe this is sufficiently clear, so I'm closing this bug report.
Feel free to install any further tweaks.  Thanks.





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

end of thread, other threads:[~2021-10-23 18:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20  3:55 bug#34588: 27.0.50; Doc of write-contents-functions: arguments? Michael Heerdegen
2019-02-20 17:13 ` Eli Zaretskii
2019-02-21  2:59   ` Michael Heerdegen
2019-02-21  3:32   ` Richard Stallman
2019-02-21  3:47     ` Eli Zaretskii
2019-02-21  4:24       ` Michael Heerdegen
2019-02-21  9:17         ` martin rudalics
2019-02-21  9:29           ` Michael Heerdegen
2019-02-22  2:06             ` Richard Stallman
2021-10-23 18:11               ` Stefan Kangas

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).