From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#25581: 25.1; Incorrect statement in (elisp) `Hooks' Date: Mon, 24 Aug 2020 09:01:59 -0700 (PDT) Message-ID: <36b5b868-29b0-4592-92aa-83f19fbff1c3@default> References: <8e81acfe-ecaa-4fac-9484-24541b232ba1@default> <87k0xo83ww.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2161"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 25581@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 24 18:03:53 2020 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 1kAEwr-0000Tl-JV for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Aug 2020 18:03:53 +0200 Original-Received: from localhost ([::1]:45902 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kAEwq-00078S-LW for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 24 Aug 2020 12:03:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kAEw3-0006Dv-99 for bug-gnu-emacs@gnu.org; Mon, 24 Aug 2020 12:03:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47457) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kAEw3-0001UH-0K for bug-gnu-emacs@gnu.org; Mon, 24 Aug 2020 12:03:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kAEw2-0002HY-6H for bug-gnu-emacs@gnu.org; Mon, 24 Aug 2020 12:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Aug 2020 16:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25581 X-GNU-PR-Package: emacs Original-Received: via spool by 25581-submit@debbugs.gnu.org id=B25581.15982849438687 (code B ref 25581); Mon, 24 Aug 2020 16:03:02 +0000 Original-Received: (at 25581) by debbugs.gnu.org; 24 Aug 2020 16:02:23 +0000 Original-Received: from localhost ([127.0.0.1]:58993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAEvD-0002Fj-GT for submit@debbugs.gnu.org; Mon, 24 Aug 2020 12:02:23 -0400 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:52030) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kAEvA-0002FK-JQ for 25581@debbugs.gnu.org; Mon, 24 Aug 2020 12:02:10 -0400 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07OG017W084660; Mon, 24 Aug 2020 16:02:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=WkzWNldQ4FuVpm/BRj/rG7wbYsWHKddGvPMZp0solIM=; b=y5NI4Wtj0r95EpEHEsaU62guoitKgeUket+OrOr5oRqsOyATJjrstWqNwMBGVqrhMUmW ZEOLgq0C0cXPH6NStnncV6n+az+N9egylfs+DbfXeHzU1wUo4wJ5A4VNfJGIjnPSjEU6 M9JtC1phFD79yK5YMglcrfu7FiIFYyeyu78YabBnfCpF052jeUnd70mfuBQ3JlYH0z/L d6Jq4jzu0BkkStnaiLs07Mx6zHIBJDFF8GMycZbalIosouKq2OdnmB9ItQLfgA01unTQ RzHIASrVmlf6MkeXzrL/esEiYxFiF5TVICPbCZgB8tFR6jDNwi4xGkrWx1hCbABXCyEJ qw== Original-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 333dbrnegh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 24 Aug 2020 16:02:02 +0000 Original-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 07OFtE83192537; Mon, 24 Aug 2020 16:02:01 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 333r9herru-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Aug 2020 16:02:01 +0000 Original-Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 07OG200n026288; Mon, 24 Aug 2020 16:02:00 GMT In-Reply-To: <87k0xo83ww.fsf@gnus.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.5044.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9722 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008240128 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9723 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1011 priorityscore=1501 impostorscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2008240128 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" Xref: news.gmane.io gmane.emacs.bugs:186179 Archived-At: > > The second sentence here is incorrect: > > > > If the variable=E2=80=99s name ends in =E2=80=98-function=E2=80=99, th= en its value is just a > > single function, not a list of functions. =E2=80=98add-hook=E2=80=99 = cannot be used to > > modify such a _single function hook_, and you have to use =E2=80=98add= -function=E2=80=99 > > instead (*note Advising Functions::). > > > > You CAN use `add-hook' to modify such a single-function hook. > > Nothing prevents you from doing so. And nothing even suggests > > that you should not. And you have always been able to do so. >=20 > Well, the name -function suggests that you shouldn't. No, I don't think so. Nothing suggests you shouldn't. Because it's not true that you shouldn't. It all depends on whether the variable is a hook. If it is, then it's fine to use `add-hook' on it - in fact, it's advisable. > I think the confusing thing here is that foo-function isn't a hook at > all -- variables ending with -function are normally not executed with > run-hooks at all, so using add-hook on such a variable will normally > break. This isn't true. `add-hook' works fine with a variable named `*-function'. What it does is treat the variable as a hook (since you called `add-hook' on it). It turns the value into a singleton list with the given function as element. `add-hook' does what it's supposed to with any variable. What's wrong is to use `add-hook' on a variable (whatever the name) that's not intended to be used as a hook. Using `add-hook' on a variable treats it like a hook: it adds the argument function as an element in the variable's list value. If you use `add-hook' on a var that's NOT intended as a hook, in particular, a variable whose value should NOT be a list of functions, then that's on you. Some variables named `*-function' are not intended as hooks. For those, it makes no sense to use `add-hook' (and `run-hooks'). Others _are_ intended as hooks. The latter case is legacy, AFAIK. Such vars would be better named `*-hook' or `*-functions', depending on whether they are normal or abnormal hooks.=20 > So I'm not sure what that section is doing in the Hooks node at all. It > origin starts here, where unfortunately vc-region-history gives up. I don't understand that last sentence, and I'm not sure what you mean by "that section". The text of node `Hooks' is longstanding, and though not perfect, it is generally accurate. The problem is the change that someone made by adding this paragraph, fairly recently (presumably when `add-function' came into being): "=E2=80=98add-hook=E2=80=99 cannot be used to modify such a single function hook, and you have to use =E2=80=98add-function=E2=80=99 instead (*note Advising Functions::)." That's what this bug is about - that text. > My preference here would be just to remove the paragraph, > which is pretty confusing. If you mean the paragraph I mentioned just above then yes, that was the suggestion. There's a lot of careful consideration in this thread, and there's a lot of info in node `Hooks'. Let's not throw out the baby with the bathwater. A variable named `*-function' can be a hook, but it need not be. Such a name doesn't tell us whether the variable is a hook, unfortunately. Yes, that's a point of confusion. The right change, if one is needed in this regard, is to rename any such hooks. Note that Emacs has, in some cases, tried to make clear when a `*-function' variable is not a hook. For example, `C-h v auto-fill-function' says, among other things: NOTE: This variable is not a hook; its value may not be a list of functions. That makes the purpose and allowable value of that variable pretty clear. More recently, there's been addition of more non-hook variables with names `*-function', and _without_ such caveats in their doc strings. It's maybe time to rename the hook variables with names `*-function'. But as long as such exist the doc should cover them.