GNU bug report logs - #72915
Docstrings of add-hook and remove-hook improvement?

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Tomas Nordin <tomasn@HIDDEN>; dated Sat, 31 Aug 2024 12:38:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 15 Sep 2024 13:49:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 15 09:49:40 2024
Received: from localhost ([127.0.0.1]:48705 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sppdD-0005gB-Pp
	for submit <at> debbugs.gnu.org; Sun, 15 Sep 2024 09:49:40 -0400
Received: from mout01.posteo.de ([185.67.36.65]:58805)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tomasn@HIDDEN>) id 1sppdA-0005fw-8d
 for 72915 <at> debbugs.gnu.org; Sun, 15 Sep 2024 09:49:37 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 76366240027
 for <72915 <at> debbugs.gnu.org>; Sun, 15 Sep 2024 15:49:18 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1726408158; bh=UXZZR71nnMSwl7vGlbwbFtcvVunTtNDntvivFw/1Tv0=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type:
 From;
 b=UGGNzWLDMPvzUCoEV1S8lTecAP3JaRkxXP/EcRAUjFgGdZ4P+K/10vQYCXT+9BjWL
 TkhaGpC/h+nKfwSwXhXU3WRgKbXV6fQb3Ixm/q34JrEKXzgVzWxofLM/WI6rtBTnLi
 xh6UxTst/krqFplUrDiMHWVSaS4zDPM3JUZuQYPnkRj+CHJNyRG5Fp6cbMKlxsvGam
 IYYm1i6dvg7jyHT9SlbKBQuJerTxUZMYWkah0cB5XWCUCgIdpDm0nY23fuKzMZVIGK
 EQJFoa8E5RSj3+OsjQ7qQUUu1AxQxWI9DbOOYTbpKUwCoqZcCPdVcz+2I3vcdgVZIU
 emzpaqWN4iyeQ==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4X68Xr3wzhz6txy;
 Sun, 15 Sep 2024 15:49:16 +0200 (CEST)
From: Tomas Nordin <tomasn@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
In-Reply-To: <jwvr09ldpuo.fsf-monnier+emacs@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <jwvzforo3tv.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=y0cUe0JBEFEygzZQJPHbyjNA4jceXU-HjGw64_oO3Sg@HIDDEN>
 <87ldztmaho.fsf@HIDDEN> <jwvr09ldpuo.fsf-monnier+emacs@HIDDEN>
Date: Sun, 15 Sep 2024 13:49:15 +0000
Message-ID: <87frq1m3hg.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 72915
Cc: Eli Zaretskii <eliz@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>,
 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Stefan Monnier <monnier@HIDDEN> writes:

> The `add-hook` part was OK for me, indeed.
>
> [ I'm no great fan of that paragraph (neither the original nor the one
>   you replace it with), tho, because it's a bit "too detailed" for my
>   taste.  E.g. the value *always* ends up being a list of functions, and
>   the parenthesis states something which sounds to me like it should be
>   inferrable from the rest of the docstring.  ]

I think I agree, the parenthesized part could be discarded, shortening
the paragraph to

"HOOK should be a symbol.  If HOOK is void, or if HOOK's value is a
single function, it is changed to a list of functions."




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 15 Sep 2024 13:20:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 15 09:20:06 2024
Received: from localhost ([127.0.0.1]:48643 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sppAc-0003va-0Q
	for submit <at> debbugs.gnu.org; Sun, 15 Sep 2024 09:20:06 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:46210)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1sppAa-0003ue-L3
 for 72915 <at> debbugs.gnu.org; Sun, 15 Sep 2024 09:20:05 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id F21D0801BA;
 Sun, 15 Sep 2024 09:19:46 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1726406385;
 bh=9If+zivbYeV7m7lo2Scljp4f22mq/4P7s7hFQyU/NXg=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=JsgIYMl/vrEVXGkjqhYL7S2M/+4bpW1JboT5upXLqCRpmfpt0RqTd25P/nGab6lNa
 5gbmXJricIvDx31aZj366HXci6R0QzeBMi5IHXQutTp8jVF1APr8OEM7qi84g/BYMq
 YyKiQrRQ7B6nDrM2248tSDacw/ihwguVGNTOhBcGpyHT/iUIyx+QFod3lErh21oeer
 kbWexIrIVPcf1GbmKOmFL4di/z0QhZTcwnmjq157Ln9MF0q2h6QbMpSb2NhHsF4fEN
 yw1ONHVyOgoX8BnmYsDfHnDGT7n7Tvmmze/5vWPJGzglXlL/ygpwqjIQIPHNxj7RPI
 QSTySRLU0hSxg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 8653D80357;
 Sun, 15 Sep 2024 09:19:45 -0400 (EDT)
Received: from pastel (104-195-209-174.cpe.teksavvy.com [104.195.209.174])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4FD4812068E;
 Sun, 15 Sep 2024 09:19:45 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Tomas Nordin <tomasn@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
In-Reply-To: <87ldztmaho.fsf@HIDDEN> (Tomas Nordin's message of "Sun, 15
 Sep 2024 11:17:55 +0000")
Message-ID: <jwvr09ldpuo.fsf-monnier+emacs@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <jwvzforo3tv.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=y0cUe0JBEFEygzZQJPHbyjNA4jceXU-HjGw64_oO3Sg@HIDDEN>
 <87ldztmaho.fsf@HIDDEN>
Date: Sun, 15 Sep 2024 09:19:43 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.002 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 72915
Cc: Eli Zaretskii <eliz@HIDDEN>, Stefan Kangas <stefankangas@HIDDEN>,
 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Tomas Nordin [2024-09-15 11:17:55] wrote:

> Stefan Kangas <stefankangas@HIDDEN> writes:
>
>> Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
>> text editors" <bug-gnu-emacs@HIDDEN> writes:
>>
>>> Something like:
>>>
>>>       "Remove FUNCTION from HOOK's functions.
>>>     HOOK should be a symbol, and FUNCTION may be any valid function.
>>>     Does nothing if HOOK does not currently contain FUNCTION.
>>>     Compares functions with `equal`, which means that it can be
>>>     slow if FUNCTION is not a symbol.  See `add-hook'.
>>
>> Ah, now I see that you posted this proposal.  This is a better start
>> than what I had.
>>
>> Should we install it?
>
> This is about the doc of remove-hook. What about the edits in the
> add-hook docstring, was that OK? There was a question on the bit about
> setting the HOOK to nil, but I think that was sorted out.

The `add-hook` part was OK for me, indeed.

[ I'm no great fan of that paragraph (neither the original nor the one
  you replace it with), tho, because it's a bit "too detailed" for my
  taste.  E.g. the value *always* ends up being a list of functions, and
  the parenthesis states something which sounds to me like it should be
  inferrable from the rest of the docstring.  ]


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 15 Sep 2024 11:18:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 15 07:18:18 2024
Received: from localhost ([127.0.0.1]:48517 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1spnGk-0005pH-A4
	for submit <at> debbugs.gnu.org; Sun, 15 Sep 2024 07:18:18 -0400
Received: from mout01.posteo.de ([185.67.36.65]:32933)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tomasn@HIDDEN>) id 1spnGi-0005p2-0X
 for 72915 <at> debbugs.gnu.org; Sun, 15 Sep 2024 07:18:17 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 3FF4B240028
 for <72915 <at> debbugs.gnu.org>; Sun, 15 Sep 2024 13:17:58 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1726399078; bh=2xo/VPnlwNig0+6RP58QwgFjwgW033X0XKzolHJPFhk=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type:
 From;
 b=sIZ9QnjFoEFxbjN/3iAR3pXKorZfUfcAreuKh5AZIDP70Et264aUoj924j49kt5bS
 Yz7RXZzEI1gQVBYoYqgalTPi1kZ2J2V87V9/jkSDySLi8je1oH2KjjkMjkKN2wSN5f
 Zpz5CFaKx4aPdwmmS5u5+wO2Y5fmVkXJRb0LBmrheJypPF4iLURyZAQpa4Q13w3sHi
 Kdan/qJ7RarJ7JSNoanjmvOQYgjLx+ELyJHhOn9NaypqrMcYcvSO0lXRCqBBJNdYy4
 RrYROiYmFIJGvFysb5Fcdot2FOBGPRs2L1eB0GVmFMs5DVyVEHxirXR1/g7yXLrq2x
 ubhCSDqUxVP4w==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4X65BD3tyKz9rxD;
 Sun, 15 Sep 2024 13:17:56 +0200 (CEST)
From: Tomas Nordin <tomasn@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>, Stefan Monnier
 <monnier@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
In-Reply-To: <CADwFkm=y0cUe0JBEFEygzZQJPHbyjNA4jceXU-HjGw64_oO3Sg@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <jwvzforo3tv.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=y0cUe0JBEFEygzZQJPHbyjNA4jceXU-HjGw64_oO3Sg@HIDDEN>
Date: Sun, 15 Sep 2024 11:17:55 +0000
Message-ID: <87ldztmaho.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 72915
Cc: 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Stefan Kangas <stefankangas@HIDDEN> writes:

> Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs@HIDDEN> writes:
>
>> Something like:
>>
>>       "Remove FUNCTION from HOOK's functions.
>>     HOOK should be a symbol, and FUNCTION may be any valid function.
>>     Does nothing if HOOK does not currently contain FUNCTION.
>>     Compares functions with `equal`, which means that it can be
>>     slow if FUNCTION is not a symbol.  See `add-hook'.
>
> Ah, now I see that you posted this proposal.  This is a better start
> than what I had.
>
> Should we install it?

This is about the doc of remove-hook. What about the edits in the
add-hook docstring, was that OK? There was a question on the bit about
setting the HOOK to nil, but I think that was sorted out.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 14 Sep 2024 23:25:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 14 19:25:32 2024
Received: from localhost ([127.0.0.1]:47952 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1spc8y-0007Q7-03
	for submit <at> debbugs.gnu.org; Sat, 14 Sep 2024 19:25:32 -0400
Received: from mail-ej1-f53.google.com ([209.85.218.53]:61507)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1spc8v-0007Po-5u
 for 72915 <at> debbugs.gnu.org; Sat, 14 Sep 2024 19:25:30 -0400
Received: by mail-ej1-f53.google.com with SMTP id
 a640c23a62f3a-a8d100e9ce0so391397766b.2
 for <72915 <at> debbugs.gnu.org>; Sat, 14 Sep 2024 16:25:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1726356252; x=1726961052; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=xAo0C63zfyW6VOWUd3f5nat1pqHpnFkpuWl5UxqdHAQ=;
 b=ZXzJdbV3xR64q8Fa7O6zQsZKtK1VOIHg2cUcGdYo1zDejTYYmx3onoEeRB9Tq8vSPe
 JoEK0V80JVR0SnWyn12lSlZAZ1FTUPfiW+30NOv7iRxAZjWahSpKMeWn+m2Nl9h+54Ce
 9IlxGMgPa/Wh3r1LgLWe55HvWwJsGpJApvCjK0eZTeStkbrboBnqeXJtrK243kqMbGc5
 t714n1kerlkyxetGy57OIOCKoEGhtV6TxzG+rMZc4rSjYZ6h03QKwE0S/SUUNRSOpulJ
 HhdSjLDWFte32XIRTjHHbWSEAdcrVCKVhElAW2OYyX/ivyqVh1WUxv0o5WCWAHhdNX8J
 KlkQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1726356252; x=1726961052;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=xAo0C63zfyW6VOWUd3f5nat1pqHpnFkpuWl5UxqdHAQ=;
 b=F+4J2AIJpgijnPTyhFQz5nb5EQJFcO2dqF58hS2d72b0H4DaVAtw4bhz9DxqUIWtt9
 84MEm8gdjKwmoYQosHpNiMc8IKs0J52PJ+ZGj/pMPEpL2wwEtK9ch/bwe+ECGdtNdpGx
 SXIie1bEYOeJcHbjKT0oPT1FALLD9qx6j7c3o945BknU5u3+a3TtGYaVDrl+oq7AB+2u
 233V6xVw1lgQTeYb4Uyqx6xgCyYhmm5HfH7hk5onmkVHgLcr3edEYa69Hj6jwh+T6UGa
 f0Xn22guP1cpEAoEcVDL248PpwT+w45BIE95UHjb9cWyuWvttm33jSw7G5GF/rWznxbK
 E+Dw==
X-Forwarded-Encrypted: i=1;
 AJvYcCWST/la6zOfT9VrN3A2geVQC2q+PnaVWWh0DtmWxA7a+Z6U9on9DQXDmawz5ZHAHvC/yBVbpA==@debbugs.gnu.org
X-Gm-Message-State: AOJu0YyAltLaWx6JhHKuFVa71m+JAUulCwgp9NmODYWL7vavOeHTzvrE
 gh5A2A1+qLWHXqdehpq+sWnD8HqPLXbdYmAU5BJ7Men6hMOrjn6MvfcLg/XQYgw2yFMwa9Xzm1P
 1ekyhSRuSxiTJM8ny81stNumXvwE=
X-Google-Smtp-Source: AGHT+IGtDyulvUhqq9umKvvNQvnJQe/di76LEDCfjW6EzLxdH5oLg7ajPWBHWQ9DZg9QY/qLpTAxPxRokvpAHuyksM0=
X-Received: by 2002:a17:907:c88f:b0:a86:8e3d:86e2 with SMTP id
 a640c23a62f3a-a902941dc57mr1025688366b.11.1726356251732; Sat, 14 Sep 2024
 16:24:11 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sat, 14 Sep 2024 19:24:11 -0400
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <jwvzforo3tv.fsf-monnier+emacs@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <jwvzforo3tv.fsf-monnier+emacs@HIDDEN>
MIME-Version: 1.0
Date: Sat, 14 Sep 2024 19:24:11 -0400
Message-ID: <CADwFkm=y0cUe0JBEFEygzZQJPHbyjNA4jceXU-HjGw64_oO3Sg@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
To: Stefan Monnier <monnier@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 72915
Cc: Tomas Nordin <tomasn@HIDDEN>, 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@HIDDEN> writes:

> Something like:
>
>       "Remove FUNCTION from HOOK's functions.
>     HOOK should be a symbol, and FUNCTION may be any valid function.
>     Does nothing if HOOK does not currently contain FUNCTION.
>     Compares functions with `equal`, which means that it can be
>     slow if FUNCTION is not a symbol.  See `add-hook'.

Ah, now I see that you posted this proposal.  This is a better start
than what I had.

Should we install it?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 14 Sep 2024 13:33:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Sep 14 09:33:00 2024
Received: from localhost ([127.0.0.1]:45126 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1spStY-0006Pz-Iy
	for submit <at> debbugs.gnu.org; Sat, 14 Sep 2024 09:33:00 -0400
Received: from mail-ed1-f43.google.com ([209.85.208.43]:47244)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1spStW-0006Pa-GG
 for 72915 <at> debbugs.gnu.org; Sat, 14 Sep 2024 09:32:59 -0400
Received: by mail-ed1-f43.google.com with SMTP id
 4fb4d7f45d1cf-5c4226a56a8so1658812a12.2
 for <72915 <at> debbugs.gnu.org>; Sat, 14 Sep 2024 06:32:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1726320702; x=1726925502; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=XLPkc+5V0cNRqQy1o2dUc9g1uNorBNLVgtL+yrZOcRU=;
 b=m95SedJzF7u08uPcO9ZvuwKZOIlTkzAk8JNkkUVOXD5USaImWorBakaIvOHG59YcEG
 rGunOJv51nrmNpFaHfP4ngNiHaSqGFZ4PS4Vmg3akvG7nyNSNYwy2ZRPqqNwfmcn1QF8
 wiWJxG6Fc2PF2pAPvsuAxQUyLwCF6kMpm5X2TNMpvtognZr0/VenEjOdfDot+uajoIgM
 h2fRyyJekSmkuYsd50ewfWr4bWH4tRtROgSmaXQw56pGEGh2zooa2eC/MQxJNDth7Q/a
 bg0/qdquBNOgjB2WcMvi1zha2Ogh50PwEowIaZRBxheDoi16TSsFf0WUYPs9ZVQW84V5
 iqgg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1726320702; x=1726925502;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=XLPkc+5V0cNRqQy1o2dUc9g1uNorBNLVgtL+yrZOcRU=;
 b=EXeBNOI36f/QBCweSrmWQkEQhk0NxK50ktuIH02Owpf6VIPAG42pLGm0ehCISy89T6
 7jkqmqP/XATmNI5xWz1ZBFisuwM/ZK+cPhwUDnnCvXIdCiiyDXDDHmXKBfQ4EdzMFXUU
 aLls+/bYdYX6JaUQLHl4Vc5xi2XzGYaCTwfY7TgJtoDQfK32q2NL6aVPfWs+oKKYB/A9
 WSBa/m09ACyTNoZT5jGJZdLvWdHqSpG/dOjctZWUR2Ne1Q1bE32HI/NXHtpZ88Xqz53G
 r7mnW9zE1NmVTwHPib3ACWtLy56luVcwFZecgO6U7aryV/JWcL07VQZCNIbQOI7zVMUR
 hKOA==
X-Gm-Message-State: AOJu0Yx0Anin+KPrdTp/+B64ZxujXvVNZX0Xed3bBHMUZf/AzFblD9n3
 q0uVR637rsbxhYTa4Dru8LSMxisMdixEgtr+RSRqAFYTQVGh/Iu7rMQPchbhyJrRwH8KgbH+0zL
 G6MQ/geJU4HPHeg8f7FoRIw94Hqw=
X-Google-Smtp-Source: AGHT+IFDAtGAE2SVIIPCvxONGCT1pZQs+9XVa6+nkWuF9yN0eSlgllPP7mW8FHZh3FmgL7PaK9VWE5sIw7XTi3IRovs=
X-Received: by 2002:a05:6402:295:b0:5c2:7727:6109 with SMTP id
 4fb4d7f45d1cf-5c413e53f72mr6180428a12.30.1726320701608; Sat, 14 Sep 2024
 06:31:41 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sat, 14 Sep 2024 09:31:41 -0400
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <87plpnqstj.fsf@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <CADwFkmkLcKOAE3snjkgzS_yQNcq-LOrBcdRrD3pLPe7HzJRmAg@HIDDEN>
 <CADwFkmnbTbJKkg=w+xWqHTUJ7gNYK8wKN4TM5GtGDknndgiRNQ@HIDDEN>
 <87plpnqstj.fsf@HIDDEN>
MIME-Version: 1.0
Date: Sat, 14 Sep 2024 09:31:41 -0400
Message-ID: <CADwFkmmc=fOzP+9wEA+NpPVS=gTX7yGsw7nJQMZZgM7GQ7Rdmg@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
To: Tomas Nordin <tomasn@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, 
 Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 72915
Cc: 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Tomas Nordin <tomasn@HIDDEN> writes:

> Stefan Kangas <stefankangas@HIDDEN> writes:
>
>> Stefan Kangas <stefankangas@HIDDEN> writes:
>>
>>> The wording in the manual is probably all that is needed here:
>>>
>>>     This function removes FUNCTION from the hook variable HOOK.
>>
>> BTW.  Here's another idea:
>>
>>     If HOOK is a list of functions, remove FUNCTION from that list.
>>
>>     If HOOK is equal to FUNCTION, set HOOK to nil.
>>
>>     Otherwise do nothing.
>
> I like that, adjusted maybe to respect Stefan M's nitpick:
>
> If HOOK's value is a list of functions, remove FUNCTION from that list.
> If HOOK's value is FUNCTION, set HOOK to nil.
> Otherwise do nothing.

Stefan M, does Tomas' edited version look okay to you?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 1 Sep 2024 15:48:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 01 11:48:48 2024
Received: from localhost ([127.0.0.1]:37203 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1skmoq-0004JF-80
	for submit <at> debbugs.gnu.org; Sun, 01 Sep 2024 11:48:48 -0400
Received: from mout01.posteo.de ([185.67.36.65]:53311)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tomasn@HIDDEN>) id 1skmom-0004Ix-TI
 for 72915 <at> debbugs.gnu.org; Sun, 01 Sep 2024 11:48:46 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 2196124002B
 for <72915 <at> debbugs.gnu.org>; Sun,  1 Sep 2024 17:47:38 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1725205658; bh=w4tDUeQWAsHuUpIHhwQEsCbqObpMrscRLd3Gx9+tz+Y=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type:
 From;
 b=M1w+idBnEqXJRgX3L9rMyg9Se93BDAzopbzS2J2D2R5gfpfs9EKQg4Zvn9xLqXEd4
 htOXNXNUmE/GvPArNE5BK/1OQ9FV4aVMRAnYGEU3AC/lV7J4MP4lFe6vqPD+N1W/9G
 OJpNJmyZPGTCNYHa09bvbxXei8gy29bAtvVatzTmVSA/IDYn9YIU/UlFWWBa1uMFtH
 7m+FFTgrr8s9nFbfJfIpEap0R0aY+xXRrGKR4jvMv/2mnsiY1xBIaornErgjimU/wE
 xP12rcLMbH2JxUP6Uyd8PTPZg3INeqYeRsCLu8kqoi/sLM+Mtd6IIuCi0RQlqpMOYB
 MjMO4CoYxJGfA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4Wxbqs0k6zz6tsb;
 Sun,  1 Sep 2024 17:47:37 +0200 (CEST)
From: Tomas Nordin <tomasn@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
In-Reply-To: <CADwFkmnbTbJKkg=w+xWqHTUJ7gNYK8wKN4TM5GtGDknndgiRNQ@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <CADwFkmkLcKOAE3snjkgzS_yQNcq-LOrBcdRrD3pLPe7HzJRmAg@HIDDEN>
 <CADwFkmnbTbJKkg=w+xWqHTUJ7gNYK8wKN4TM5GtGDknndgiRNQ@HIDDEN>
Date: Sun, 01 Sep 2024 15:47:36 +0000
Message-ID: <87plpnqstj.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 72915
Cc: 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Stefan Kangas <stefankangas@HIDDEN> writes:

> Stefan Kangas <stefankangas@HIDDEN> writes:
>
>> The wording in the manual is probably all that is needed here:
>>
>>     This function removes FUNCTION from the hook variable HOOK.
>
> BTW.  Here's another idea:
>
>     If HOOK is a list of functions, remove FUNCTION from that list.
>
>     If HOOK is equal to FUNCTION, set HOOK to nil.
>
>     Otherwise do nothing.

I like that, adjusted maybe to respect Stefan M's nitpick:

If HOOK's value is a list of functions, remove FUNCTION from that list.
If HOOK's value is FUNCTION, set HOOK to nil.
Otherwise do nothing.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 1 Sep 2024 14:35:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 01 10:35:28 2024
Received: from localhost ([127.0.0.1]:35943 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sklfs-0001jg-7y
	for submit <at> debbugs.gnu.org; Sun, 01 Sep 2024 10:35:28 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:9059)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1sklfq-0001jU-Dv
 for 72915 <at> debbugs.gnu.org; Sun, 01 Sep 2024 10:35:26 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 7BF1A80A1B;
 Sun,  1 Sep 2024 10:34:21 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1725201259;
 bh=USITyD8jfwe8TixjhAlCOpuni1gKTzBYUfTxxqQsWKI=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=jy8Rpq9sYrnDD2X3TJqRShvZlvDofTYkt3r7ZsGzKKCj7b9WBkdMun7m1FXIqeW9G
 wFh65VIe7OjTwVbajgeXNPXEwlMJ4WU1MwTkt1LoccafYMNeqMpuMhe6wqwFkMgicE
 s2+fRBU8TIuGohSOjR6rM2dLd/dB39aERfQX9VqrG5duEOIzGNS3t9s/jgsKqlAjkP
 O2/QqGUaUP2hfWAT/lnjlIWou/NQSC8vNDaQnu4vxXfG1didiCmqFpEg70CQ523r0g
 G1twCLMf6wdqnMjfztNsHa4Q/NgtKexPB30Fld4PxqpCy9oEiPZO3rLjVTb9F5uGeM
 RockB/GTA6elw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id E8C8A80348;
 Sun,  1 Sep 2024 10:34:19 -0400 (EDT)
Received: from pastel (104-195-234-246.cpe.teksavvy.com [104.195.234.246])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BC15112016C;
 Sun,  1 Sep 2024 10:34:19 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
In-Reply-To: <86y14c9dk3.fsf@HIDDEN> (Eli Zaretskii's message of "Sun, 01 Sep
 2024 07:57:00 +0300")
Message-ID: <jwvzforo3tv.fsf-monnier+emacs@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
Date: Sun, 01 Sep 2024 10:34:19 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 72915
Cc: Tomas Nordin <tomasn@HIDDEN>, 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> -HOOK should be a symbol.  If HOOK is void, it is first set to
>> -nil.  If HOOK's value is a single function, it is changed to a
>> -list of functions.
> Is the bit about setting HOOK to nil incorrect?  Because the new text
> drops that part.

That's an internal detail that's not observable to the caller anyway.

>>    "Remove from the value of HOOK the function FUNCTION.
>>  HOOK should be a symbol, and FUNCTION may be any valid function.  If
>>  FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
>> -list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
>> +list of functions to run in HOOK, then nothing is done.  See `add-hook'.
>
> "list of functions to run in HOOK" is ambiguous wrt what "in HOOK"
> refers to.  I would rephrase:
>
>   If FUNCTION is not the value of HOOK and is not a member of the list
>   that is the value of HOOK, do nothing.

Maybe we can simplify the wording a bit by focusing less about whether
the hook's value is a function or a list of functions, and talking about
the "sequence" or "set" of functions (which can be represented by
a list of functions or a function)?

Something like:

      "Remove FUNCTION from HOOK's functions.
    HOOK should be a symbol, and FUNCTION may be any valid function.
    Does nothing if HOOK does not currently contain FUNCTION.
    Compares functions with `equal`, which means that it can be
    slow if FUNCTION is not a symbol.  See `add-hook'.



- Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 1 Sep 2024 14:18:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 01 10:18:53 2024
Received: from localhost ([127.0.0.1]:35819 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sklPp-0001Cz-88
	for submit <at> debbugs.gnu.org; Sun, 01 Sep 2024 10:18:53 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:15787)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1sklPn-0001Ck-VV
 for 72915 <at> debbugs.gnu.org; Sun, 01 Sep 2024 10:18:52 -0400
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 8CBF7441BB6;
 Sun,  1 Sep 2024 10:17:46 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1725200265;
 bh=QDNHp7Y1IBfrGmu0IMYdjp6kDlvb1WVnzSESCbzNOBE=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=Hjuj14cNfzpFCdlEUFW47+tzL7nUDG79ScZwsfSQWZCV+0KQkvX3uOpZ1awlwEFam
 6g8OW/rlp6qb9cw/Lyb0qn0KQ8II2ogQSaqONHAAOrCumdWW3rxSyJ0Fy4kV0r/e95
 6jQWZ+3YaV9Pe5bFAk4wAnKttrjnP+ONS1pXS0ibh1heJdfSj7W6JD+sdOgW/RamKv
 s8uMiLGvE82naDt8sw1b7R8mg2bIrynLIy4j7BCmG0Ge0dLeQhkY1bU4R8Uf5Yr7vH
 ZD83ITdZL/MC/hBnZ+664So1uVtPWQkqq1p+FDs8aco9xBlrF/Ia2rCJADfYleKWvU
 i/83FbaNbi6kA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 1F241440511;
 Sun,  1 Sep 2024 10:17:45 -0400 (EDT)
Received: from pastel (104-195-234-246.cpe.teksavvy.com [104.195.234.246])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E04411202C5;
 Sun,  1 Sep 2024 10:17:44 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
In-Reply-To: <CADwFkmnbTbJKkg=w+xWqHTUJ7gNYK8wKN4TM5GtGDknndgiRNQ@HIDDEN>
 (Stefan Kangas's message of "Sun, 1 Sep 2024 00:18:38 -0700")
Message-ID: <jwv5xrfpig9.fsf-monnier+emacs@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <CADwFkmkLcKOAE3snjkgzS_yQNcq-LOrBcdRrD3pLPe7HzJRmAg@HIDDEN>
 <CADwFkmnbTbJKkg=w+xWqHTUJ7gNYK8wKN4TM5GtGDknndgiRNQ@HIDDEN>
Date: Sun, 01 Sep 2024 10:17:43 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain T_SCC_BODY_TEXT_LINE    -0.01 -
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 72915
Cc: Eli Zaretskii <eliz@HIDDEN>, Tomas Nordin <tomasn@HIDDEN>,
 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> The wording in the manual is probably all that is needed here:
>>
>>     This function removes FUNCTION from the hook variable HOOK.
>
> BTW.  Here's another idea:
>
>     If HOOK is a list of functions, remove FUNCTION from that list.
>
>     If HOOK is equal to FUNCTION, set HOOK to nil.
>
>     Otherwise do nothing.

Nit pick: a hook *is* not a function or a list of functions.
It only *holds* such things.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 1 Sep 2024 07:20:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 01 03:20:46 2024
Received: from localhost ([127.0.0.1]:32990 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sketC-0005Zq-0f
	for submit <at> debbugs.gnu.org; Sun, 01 Sep 2024 03:20:46 -0400
Received: from mail-ed1-f53.google.com ([209.85.208.53]:60517)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1sket9-0005Za-Eq
 for 72915 <at> debbugs.gnu.org; Sun, 01 Sep 2024 03:20:44 -0400
Received: by mail-ed1-f53.google.com with SMTP id
 4fb4d7f45d1cf-5c245c62362so813105a12.0
 for <72915 <at> debbugs.gnu.org>; Sun, 01 Sep 2024 00:19:44 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1725175118; x=1725779918; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=Wzw8Wk2Indpks14Bq4Vfo4R+Zv+tPPM0QrCDVMZT614=;
 b=D4KF47A6rNfqpw0c1YodYC4BxBhpG6yeGa+qSyfsBygqTTRGKYm0omAydA5XGLBoHm
 CF7osppTyQwkai5EP8u3a0AlrDLIMsJsUJQZ0HtAYARaY5cEu2ztDM4o2Qir11x+PMip
 vILJKk3NwW08v3EnLp6h6omcTj/wH68gLtTbdmWlxtVm5mm7BXVFKqUilcDI81NZtz2V
 /eVIYcVtg8cwxsfi970KandB9o363q+UWcUgrGkpdPF90cWPpkYrHDnMVP1eMhgbgBfA
 lAFBVd7aRLyqjnGVYKOswWm8IxkxdIWPrUjVMqGXGLNRMqr0/mUFTXdjwbAUgJrnBJ3X
 Sp2g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1725175118; x=1725779918;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=Wzw8Wk2Indpks14Bq4Vfo4R+Zv+tPPM0QrCDVMZT614=;
 b=etuz5uzZH0KqklQuijcgzefF17YCP4cD0/a6f1Vb91W9G3zI4Lg72FKGT72wfKPh3V
 U2OCTLCo+npTv0kJUrGsiVAV2+zQ6k64gAJII8G5BeJh2JSkUVvR3O/YL60hJ6xnv3cy
 Da0yvUKVYidzkm6n9kqEzAd7WJv7B/g67Qfw7bdQ/1E0zbMEqnNsw/jkiawD9iJk6McD
 h2ojE5BFzbLVNLtkb23QEwZzBc1CtSZpFmUYQGU0s25tzkr9zHfha/umzVQzSo13uEkw
 9b9VN2FkgsNPXQwPje8YNmOdQF6fpuYmhsVzOO2OwBV27MvORBwI7epTYoLylffyULAT
 Bawg==
X-Gm-Message-State: AOJu0YzQgpJXyJKHzkyHSeTBJMHcWCwc6Rzj2VkHfXufxDkK4zzMCEic
 BlxCNbDlV/wPXaJu5UK4sDswkKkepF6iFc5/iSGuwry0ltHV2MN+Yy4b9LaTFa8uK0M3A8gcGTT
 ta9hpHw++R1j6IA4e7S6ftOECPrzwSo+i
X-Google-Smtp-Source: AGHT+IGg9pN/ZBWp4S/1vuFQqI8ZgsKQPKdlEXU9z2JK+hdkPBjo1PBXpyv5Y4VEmHmZCF4UbBw7P1pB+Uiq5+KjDpc=
X-Received: by 2002:a05:6402:2690:b0:5bf:1301:84cd with SMTP id
 4fb4d7f45d1cf-5c21ed41db7mr8777280a12.12.1725175118363; Sun, 01 Sep 2024
 00:18:38 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sun, 1 Sep 2024 00:18:38 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <CADwFkmkLcKOAE3snjkgzS_yQNcq-LOrBcdRrD3pLPe7HzJRmAg@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
 <CADwFkmkLcKOAE3snjkgzS_yQNcq-LOrBcdRrD3pLPe7HzJRmAg@HIDDEN>
MIME-Version: 1.0
Date: Sun, 1 Sep 2024 00:18:38 -0700
Message-ID: <CADwFkmnbTbJKkg=w+xWqHTUJ7gNYK8wKN4TM5GtGDknndgiRNQ@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
To: Eli Zaretskii <eliz@HIDDEN>, Tomas Nordin <tomasn@HIDDEN>, 
 Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 72915
Cc: 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Kangas <stefankangas@HIDDEN> writes:

> The wording in the manual is probably all that is needed here:
>
>     This function removes FUNCTION from the hook variable HOOK.

BTW.  Here's another idea:

    If HOOK is a list of functions, remove FUNCTION from that list.

    If HOOK is equal to FUNCTION, set HOOK to nil.

    Otherwise do nothing.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 1 Sep 2024 07:17:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 01 03:17:26 2024
Received: from localhost ([127.0.0.1]:32982 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1skepy-0005UE-AE
	for submit <at> debbugs.gnu.org; Sun, 01 Sep 2024 03:17:26 -0400
Received: from mail-ed1-f41.google.com ([209.85.208.41]:55704)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1skepv-0005Ty-Oz
 for 72915 <at> debbugs.gnu.org; Sun, 01 Sep 2024 03:17:25 -0400
Received: by mail-ed1-f41.google.com with SMTP id
 4fb4d7f45d1cf-5bf01bdaff0so3064669a12.3
 for <72915 <at> debbugs.gnu.org>; Sun, 01 Sep 2024 00:16:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1725174919; x=1725779719; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=SxbkjHTXpt5rJZmd9pyHGLKM+gDx05MpQjUDW9jp5F0=;
 b=W0UCDDA0tAuabSxQZYrUnClBjmqxDuy8LhyJR/GMv+OpOqRI5y169Ye1WqgQ6sXKoU
 3XDjwwaIv0uY102zLlCOO4Oxa6UQIv11i0X5+6NcWVhJ/CVQ9cBTcjPBzZHbjesPXldy
 q0Ap217EBjpAp8t4wyScBRfSge5poxdAclnCmBZC3v0Ja/rUq9dKuy0pwbER+tXwpJEU
 d1ta/EK/oCgMhAu+uO8ARN7zEV4DI/vJRhPGj1G+W4geJnLTft5u8pbFUUFfnIVVHIbD
 8KjRuk2SzWr+aGZizFDHwjG7bvwb726KX4dyNxZxV0PPgGDTcriucZU/sk28g+5BWuW8
 8ung==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1725174919; x=1725779719;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=SxbkjHTXpt5rJZmd9pyHGLKM+gDx05MpQjUDW9jp5F0=;
 b=sXS6SUy8gtyj4XsdIfi6zgNuQz9LR5OO9Eijx1uLyxj4KUqWcEvYcPZl0NfjwlIhIw
 gMB+ZSuF0fcWoHQcnLJvOlgYDaGlmODUCqKUiGOfSXCp8zHL2+k+agGm8Cc1BD8HBeBf
 nOEm7+cZKdVWu/PyYA7qxgo52EcE347rcAXr+UFcv9k13yZevSqkFuKPol8+0y8ggMBq
 CTXnTFFZFgPpcbS77FtN7YIz1NXmGBlmll1IgtnZrc41swksuQNJdD6iaezWgzaA9mC8
 bBPr9DP1W69L7/9Iw607LMDA4EWSG5p4z74ol6zqZsBLcMzD00+XZvpQp1HW00qMx4mL
 NA/g==
X-Gm-Message-State: AOJu0YyF1krSg9rIoaMp+oko5eqnc3AwHXSsF2ElSMj75vgVefOxo8Ff
 HXrbt6S6uIQ5SnBh63zqDWnLSTD3gTQA1C8s+2nnhQRBTLRpw57EW1oJe7HARTLJHQVDSlQRs6b
 jah1crNOlHpYi1aJ8Zhm8HcdjCPA=
X-Google-Smtp-Source: AGHT+IE7BMyH69Ud5fqFtZ+5JsuyKGKTLtzWIFmWnTbV1CpwfC2aUjowZJALY5NIr3XDX0Uj2d+eBXwEK/GhlLddLt0=
X-Received: by 2002:a05:6402:2685:b0:5c2:54a3:6b3e with SMTP id
 4fb4d7f45d1cf-5c254a36d72mr664271a12.16.1725174918378; Sun, 01 Sep 2024
 00:15:18 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sun, 1 Sep 2024 00:15:17 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <86y14c9dk3.fsf@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN> <86y14c9dk3.fsf@HIDDEN>
MIME-Version: 1.0
Date: Sun, 1 Sep 2024 00:15:17 -0700
Message-ID: <CADwFkmkLcKOAE3snjkgzS_yQNcq-LOrBcdRrD3pLPe7HzJRmAg@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
To: Eli Zaretskii <eliz@HIDDEN>, Tomas Nordin <tomasn@HIDDEN>, 
 Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 72915
Cc: 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Tomas Nordin <tomasn@HIDDEN>
>> Date: Sat, 31 Aug 2024 12:36:22 +0000
>>
>> The following on top of emacs-30.
>>
>> diff --git a/lisp/subr.el b/lisp/subr.el
>> index 28ba30f584e..e60c4119c60 100644
>> --- a/lisp/subr.el
>> +++ b/lisp/subr.el
>> @@ -2090,6 +2090,10 @@ add-hook
>>    "Add to the value of HOOK the function FUNCTION.
>>  FUNCTION is not added if already present.
>>
>> +HOOK should be a symbol.  If HOOK is void, or if HOOK's value is a
>> +single function, it is changed to a list of functions (containing only
>> +FUNCTION in the void case).
>> +
>>  The place where the function is added depends on the DEPTH
>>  parameter.  DEPTH defaults to 0.  By convention, it should be
>>  a number between -100 and 100 where 100 means that the function
>> @@ -2108,10 +2112,6 @@ add-hook
>>  buffer-local value.  That acts as a flag to run the hook
>>  functions of the global value as well as in the local value.
>>
>> -HOOK should be a symbol.  If HOOK is void, it is first set to
>> -nil.  If HOOK's value is a single function, it is changed to a
>> -list of functions.
>> -
>
> Is the bit about setting HOOK to nil incorrect?  Because the new text
> drops that part.

It makes no difference if HOOK is "first" set to nil from the POV of the
end user, I think.  The end result is that HOOK will be a list of
functions.

IOW, the point here is that `add-hook` will work even if HOOK is void,
and that aspect is preserved in the above change.

>
>>    "Remove from the value of HOOK the function FUNCTION.
>>  HOOK should be a symbol, and FUNCTION may be any valid function.  If
>>  FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
>> -list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
>> +list of functions to run in HOOK, then nothing is done.  See `add-hook'.
>
> "list of functions to run in HOOK" is ambiguous wrt what "in HOOK"
> refers to.  I would rephrase:
>
>   If FUNCTION is not the value of HOOK and is not a member of the list
>   that is the value of HOOK, do nothing.

While the original is not ideal, I don't find this to be an improvement.
Sorry.  I'd suggest trying to reformulate it again, to make it more
direct and avoid repeating the phrase "the value of".

The wording in the manual is probably all that is needed here:

    This function removes FUNCTION from the hook variable HOOK.

In other words, we either get to assume that the user knows what a hook
is, or we can point the user to the relevant manual section to read
about it.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 1 Sep 2024 04:58:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 01 00:58:08 2024
Received: from localhost ([127.0.0.1]:60830 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1skcfA-000173-32
	for submit <at> debbugs.gnu.org; Sun, 01 Sep 2024 00:58:08 -0400
Received: from eggs.gnu.org ([209.51.188.92]:35030)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1skcf8-00016V-C5
 for 72915 <at> debbugs.gnu.org; Sun, 01 Sep 2024 00:58:06 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1skce5-0000yV-Le; Sun, 01 Sep 2024 00:57:01 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=owZT5uacMnWUCBAPecg/GT0XQkvApG/4VaGdFYlsZUo=; b=T9MXdt9+fH54
 VRFkDjID6bDuo+knSBwBeg0PssNi5bPbZp/2KjkiWv2S6UlFyr4fGR418e4oQYhMKvsEBgmUiQ0BU
 XZWWPBF+cWmq/wuUgav+NvxiADKWMheChEvs68kv/IWJ6SvsroPkSzOor8aeGvvbUcmOi8RByHW5i
 kOZbJv3bNjWiVxhPr/5ca9idEFNvofS6iYHBLwHo7HiqlwlqweUJVuOvTA/aYO+exccC3VB3vCsyi
 clUMOrwUjqdEoHIkOQuHQdsLEhpn5KAdNmYAGoXd304iAfHF4dsEQYlGirzAXI2NdA9gvmlL/q+FQ
 LVEhnLxDYNawWqIw087ziA==;
Date: Sun, 01 Sep 2024 07:57:00 +0300
Message-Id: <86y14c9dk3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Tomas Nordin <tomasn@HIDDEN>, Stefan Monnier <monnier@HIDDEN>
In-Reply-To: <87v7zgrhrt.fsf@HIDDEN> (message from Tomas Nordin on Sat, 31
 Aug 2024 12:36:22 +0000)
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
References: <87v7zgrhrt.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 72915
Cc: 72915 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Tomas Nordin <tomasn@HIDDEN>
> Date: Sat, 31 Aug 2024 12:36:22 +0000
> 
> The following on top of emacs-30.
> 
> diff --git a/lisp/subr.el b/lisp/subr.el
> index 28ba30f584e..e60c4119c60 100644
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -2090,6 +2090,10 @@ add-hook
>    "Add to the value of HOOK the function FUNCTION.
>  FUNCTION is not added if already present.
>  
> +HOOK should be a symbol.  If HOOK is void, or if HOOK's value is a
> +single function, it is changed to a list of functions (containing only
> +FUNCTION in the void case).
> +
>  The place where the function is added depends on the DEPTH
>  parameter.  DEPTH defaults to 0.  By convention, it should be
>  a number between -100 and 100 where 100 means that the function
> @@ -2108,10 +2112,6 @@ add-hook
>  buffer-local value.  That acts as a flag to run the hook
>  functions of the global value as well as in the local value.
>  
> -HOOK should be a symbol.  If HOOK is void, it is first set to
> -nil.  If HOOK's value is a single function, it is changed to a
> -list of functions.
> -

Is the bit about setting HOOK to nil incorrect?  Because the new text
drops that part.

>    "Remove from the value of HOOK the function FUNCTION.
>  HOOK should be a symbol, and FUNCTION may be any valid function.  If
>  FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
> -list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
> +list of functions to run in HOOK, then nothing is done.  See `add-hook'.

"list of functions to run in HOOK" is ambiguous wrt what "in HOOK"
refers to.  I would rephrase:

  If FUNCTION is not the value of HOOK and is not a member of the list
  that is the value of HOOK, do nothing.

(This also avoids passive tense and clarifies the wording in other
aspects.)




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at 72915 <at> debbugs.gnu.org:


Received: (at 72915) by debbugs.gnu.org; 31 Aug 2024 22:37:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 31 18:37:53 2024
Received: from localhost ([127.0.0.1]:58398 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1skWjA-0007NR-RP
	for submit <at> debbugs.gnu.org; Sat, 31 Aug 2024 18:37:53 -0400
Received: from mail-lj1-f176.google.com ([209.85.208.176]:59752)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1skWj8-0007NE-GI
 for 72915 <at> debbugs.gnu.org; Sat, 31 Aug 2024 18:37:51 -0400
Received: by mail-lj1-f176.google.com with SMTP id
 38308e7fff4ca-2f5064816edso33236121fa.3
 for <72915 <at> debbugs.gnu.org>; Sat, 31 Aug 2024 15:36:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1725143746; x=1725748546; darn=debbugs.gnu.org;
 h=to:subject:message-id:date:mime-version:references:in-reply-to:from
 :from:to:cc:subject:date:message-id:reply-to;
 bh=4iLTYUvBv8BzUH+EdxpzfRurhFGiloM11klNX0lv8Ds=;
 b=fpCehJlTgnairtuCtgy82xw5Q7mEckPqrW+oxDoO4T6rBQVTWay2EQfREKyErY9quu
 B5fiolguPlwC1aZMI7A5uv09kbO1/7/9VY9CMNvmX5/l39EcqwWE27THtNmDk0mmOTsF
 hc5xrUxIqFhCYJP0SwxBMql3qsMikTzUbbU5e8eCp43oQ44za1BVhoogWBiDBdKvbGYP
 1zhXRdRO68rqzrwzonS60Imh3OKLXdvkUBMJWjfddHN6qrTMApf3VKBAVmyZVsWr0N/X
 RbITH6mbU6Ekwom5bwVXLDT7ARMLjDv5gYsKOhgFSInXqRycvJdVFZbR5H14I5V42hvR
 v+bA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1725143746; x=1725748546;
 h=to:subject:message-id:date:mime-version:references:in-reply-to:from
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=4iLTYUvBv8BzUH+EdxpzfRurhFGiloM11klNX0lv8Ds=;
 b=dRUtDfBUSKb3sERzf9fgcbyDKd39mnbvkAVy3T1y5dBsJopE0Fv719ReeQ5wbsxS9Y
 ZmOYXv46RGMsclm44h6xonJKSb0yhM+ml1MJ/42KS+JgqVPFxksxIwQP7XC7tL3gv255
 CjdbZLJDUYSNWIOEpgx0eOM3ogGqha1XhWn//nsSNsUaz3wy7AsANpzDI6hxBk7e9Ilc
 LXiW5Cx3HKyT742cgdiR1du8Jxe95RFavt9PrZjfnnI57o3tcH2826Tr1Vc3AcXweUWJ
 ryx8sD3bQuQNnArx8sDP4rSZHoExD5H2eTNu3ukibJHxZ2/KLsbGmFVErJi/dQbvDsat
 +FcQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCV4jpVH75+pGrTVNnja14mlyyAAyr4+cFM9klg3Hw03mwu4iuIqI+BhGf9y86vNgMiiWkFLKQ==@debbugs.gnu.org
X-Gm-Message-State: AOJu0Yxpk9SbuE/9nQIdUrH7eYpLJCkjP1cod/m8xdjnJ1jk2/D4JOjQ
 9HugWvaPTxht6Iad0qYRP+U589m7B4q5752cSYOj0/nMc2ZU418Xn9PoW0AL/hDKFnYT8Czj4uL
 rQ6/NsQ9nkAvJgVXyyNjX9pNs34A=
X-Google-Smtp-Source: AGHT+IFUSM2eSAlkOYE74Pf7a6m5m8cdcdd+iRDHWk819kMkXXw4dIu1ZD1y6YKJ3L3PXZs1DWBp+IHiwJ8buaMByqQ=
X-Received: by 2002:a2e:5152:0:b0:2ef:2e1c:79ae with SMTP id
 38308e7fff4ca-2f6103a76c6mr52291731fa.19.1725143745541; Sat, 31 Aug 2024
 15:35:45 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Sat, 31 Aug 2024 15:35:44 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <87v7zgrhrt.fsf@HIDDEN>
References: <87v7zgrhrt.fsf@HIDDEN>
MIME-Version: 1.0
Date: Sat, 31 Aug 2024 15:35:44 -0700
Message-ID: <CADwFkm=5A0rCU5kCS4Ro_Le91GwAjL6+8A3EBHvBr-sC1u3POA@HIDDEN>
Subject: Re: bug#72915: Docstrings of add-hook and remove-hook improvement?
To: Tomas Nordin <tomasn@HIDDEN>, 72915 <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 72915
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Tomas Nordin <tomasn@HIDDEN> writes:

> diff --git a/lisp/subr.el b/lisp/subr.el
> index 28ba30f584e..e60c4119c60 100644
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -2090,6 +2090,10 @@ add-hook
>    "Add to the value of HOOK the function FUNCTION.
>  FUNCTION is not added if already present.
>
> +HOOK should be a symbol.  If HOOK is void, or if HOOK's value is a
> +single function, it is changed to a list of functions (containing only
> +FUNCTION in the void case).
> +
>  The place where the function is added depends on the DEPTH
>  parameter.  DEPTH defaults to 0.  By convention, it should be
>  a number between -100 and 100 where 100 means that the function
> @@ -2108,10 +2112,6 @@ add-hook
>  buffer-local value.  That acts as a flag to run the hook
>  functions of the global value as well as in the local value.
>
> -HOOK should be a symbol.  If HOOK is void, it is first set to
> -nil.  If HOOK's value is a single function, it is changed to a
> -list of functions.
> -
>  FUNCTION may be any valid function, but it's recommended to use a
>  function symbol and not a lambda form.  Using a symbol will
>  ensure that the function is not re-added if the function is
> @@ -2179,7 +2179,7 @@ remove-hook
>    "Remove from the value of HOOK the function FUNCTION.
>  HOOK should be a symbol, and FUNCTION may be any valid function.  If
>  FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
> -list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
> +list of functions to run in HOOK, then nothing is done.  See `add-hook'.
>
>  The optional third argument, LOCAL, if non-nil, says to modify
>  the hook's buffer-local value rather than its default value.

LGTM.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 31 Aug 2024 12:37:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 31 08:37:30 2024
Received: from localhost ([127.0.0.1]:54233 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1skNM9-0005pj-R2
	for submit <at> debbugs.gnu.org; Sat, 31 Aug 2024 08:37:30 -0400
Received: from lists.gnu.org ([209.51.188.17]:45596)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <tomasn@HIDDEN>) id 1skNM7-0005pb-KT
 for submit <at> debbugs.gnu.org; Sat, 31 Aug 2024 08:37:28 -0400
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 <tomasn@HIDDEN>) id 1skNLB-0000MK-3h
 for bug-gnu-emacs@HIDDEN; Sat, 31 Aug 2024 08:36:29 -0400
Received: from mout01.posteo.de ([185.67.36.65])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <tomasn@HIDDEN>) id 1skNL8-0007p5-WC
 for bug-gnu-emacs@HIDDEN; Sat, 31 Aug 2024 08:36:28 -0400
Received: from submission (posteo.de [185.67.36.169]) 
 by mout01.posteo.de (Postfix) with ESMTPS id 70D5E240027
 for <bug-gnu-emacs@HIDDEN>; Sat, 31 Aug 2024 14:36:23 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1725107783; bh=MAw1T9lsuc2m3zR4Jw3CNgEnlFKW5Ow+VtP/O2a8coA=;
 h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From;
 b=AMT+nK7wCPk6b7xAzrvcM3USi6nefONtkEdWgl1Lzw7AZmq0Vx0yZst/dt/IBEQiD
 ZBWLQ6KWgzlfW4SuFyjjsRWhWhlpeHfQlFvheZJDxxtWqOwo2EekKmmdSNJhn0fjxj
 WVw3VVsGfvTEAEOZXiJ+HickxOPldtrM/uJZOWY45ozUG5wLD7gQJ6+IrwBNwdugow
 EHj/bBdhvzLnsqdMCk0UyAlbNtOww7ZMaTRbFOGWX88TahtxE2V2fchAgmSbqXkOBL
 QF08wpkjNoeqqS4snjh2dnY8hSBDP4vnMDIjMUMbHkemlV1ayGYtOXicNBCK0KOQ5U
 v976jIi2iRY1w==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4Wwvdg0gLfz9rxF
 for <bug-gnu-emacs@HIDDEN>; Sat, 31 Aug 2024 14:36:22 +0200 (CEST)
From: Tomas Nordin <tomasn@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Docstrings of add-hook and remove-hook improvement?
Date: Sat, 31 Aug 2024 12:36:22 +0000
Message-ID: <87v7zgrhrt.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=185.67.36.65; envelope-from=tomasn@HIDDEN;
 helo=mout01.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Hello List

In bug#70820 August 14, Stefan mentions that it is a common confusion to
think of the functions in a hook as hooks. It got my attention because I
belong to the confused ones every second year or so adding or removing
functions from a hook.

I suggest the provided patch as a small improvement of the function
documentation of add-hook and remove-hook. Maybe it doesn't mitigate the
confusion mentioned that much, but it seem to align better with the
manual as I read it.

What do you think?

In add-hook doc, lift up the paragraph about HOOK and FUNCTION and
remove the mention about first setting the HOOK to nil. I think that is
something internal to the add-hook function and not relevant to the
programmer calling the add-hook function? And then say that the
resulting hook will be a list both when the HOOK symbol is void or a
single function.

In remove-hook, stick to the notion that a hook contain functions to
run, not hooks.

This notion though is a bit confusing in relation to the names of those
functions, but that's another story I guess.

The following on top of emacs-30.

diff --git a/lisp/subr.el b/lisp/subr.el
index 28ba30f584e..e60c4119c60 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2090,6 +2090,10 @@ add-hook
   "Add to the value of HOOK the function FUNCTION.
 FUNCTION is not added if already present.
 
+HOOK should be a symbol.  If HOOK is void, or if HOOK's value is a
+single function, it is changed to a list of functions (containing only
+FUNCTION in the void case).
+
 The place where the function is added depends on the DEPTH
 parameter.  DEPTH defaults to 0.  By convention, it should be
 a number between -100 and 100 where 100 means that the function
@@ -2108,10 +2112,6 @@ add-hook
 buffer-local value.  That acts as a flag to run the hook
 functions of the global value as well as in the local value.
 
-HOOK should be a symbol.  If HOOK is void, it is first set to
-nil.  If HOOK's value is a single function, it is changed to a
-list of functions.
-
 FUNCTION may be any valid function, but it's recommended to use a
 function symbol and not a lambda form.  Using a symbol will
 ensure that the function is not re-added if the function is
@@ -2179,7 +2179,7 @@ remove-hook
   "Remove from the value of HOOK the function FUNCTION.
 HOOK should be a symbol, and FUNCTION may be any valid function.  If
 FUNCTION isn't the value of HOOK, or, if FUNCTION doesn't appear in the
-list of hooks to run in HOOK, then nothing is done.  See `add-hook'.
+list of functions to run in HOOK, then nothing is done.  See `add-hook'.
 
 The optional third argument, LOCAL, if non-nil, says to modify
 the hook's buffer-local value rather than its default value.




Acknowledgement sent to Tomas Nordin <tomasn@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#72915; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 12 Jan 2025 05:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.