From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Newsgroups: gmane.emacs.bugs Subject: bug#48584: 28.0.50; Incorrect hook ordering between local and global hooks with depth Date: Mon, 5 Jul 2021 20:37:16 +0200 Message-ID: <06A4701F-78A8-4904-AD18-ECBE4617ECDC@gmail.com> References: <871r9uefvy.fsf@gnus.org> <87bl8xb1vg.fsf@gnus.org> <87o8cjuzk7.fsf@gnus.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20155"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48584@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 05 20:38:10 2021 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 1m0TTu-00051Q-OF for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 20:38:10 +0200 Original-Received: from localhost ([::1]:41584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0TTt-0006Pc-Nq for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Jul 2021 14:38:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0TTm-0006PU-CU for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 14:38:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0TTm-0002ki-3H for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 14:38:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0TTl-0002wX-TL for bug-gnu-emacs@gnu.org; Mon, 05 Jul 2021 14:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Jul 2021 18:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48584 X-GNU-PR-Package: emacs Original-Received: via spool by 48584-submit@debbugs.gnu.org id=B48584.162551024511266 (code B ref 48584); Mon, 05 Jul 2021 18:38:01 +0000 Original-Received: (at 48584) by debbugs.gnu.org; 5 Jul 2021 18:37:25 +0000 Original-Received: from localhost ([127.0.0.1]:46654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0TTB-0002ve-2i for submit@debbugs.gnu.org; Mon, 05 Jul 2021 14:37:25 -0400 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:51106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0TT9-0002vR-OH for 48584@debbugs.gnu.org; Mon, 05 Jul 2021 14:37:24 -0400 Original-Received: by mail-wm1-f50.google.com with SMTP id o22so12001150wms.0 for <48584@debbugs.gnu.org>; Mon, 05 Jul 2021 11:37:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=og9+5sdwq7ocDmTbUyT8UJR/NolSjLJ7FHwGz3UunPc=; b=udE/lFWItVNEVhQZtlczgCNkWFQGn8kuYCSTrfA7eEy10BLp5ktzx0ioruTBGeTGKn UP65gXbLjNFPYMNvOphgAkoJPAbBJJHH3zLbMU430oZziiqmJbR3ciRYK35KBTTUUj1C 1Tkbt/nBK9Qnglt4qG5K10L+ZPpZF+NwFuccOe8rMtuSK+9kLNxbzRSl0qHwiYt3uasN nbHQa3hxws53Liem2h6HYhhTd00863RIz9lNU+7d1Sas2wnc5geeFAOWrKaiVjKXaqlB Ax/eeYfWk79UmwKqHVFq1eZPpIPuVuVeN2b+ymwdMulmHxW5ad8gDBLQbiXd/1zH9uUI 1H4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=og9+5sdwq7ocDmTbUyT8UJR/NolSjLJ7FHwGz3UunPc=; b=lWeaWfco1b1v9qTYnRTaiHNVcg8c6QQFx/2R3FKYDj4i9LUcMPhlbrN2nS2KsHr5// toPlrMfKQAbiWUXfWZO8qEKZkhhv0+y1NAfJoU3YOxc63e0LLVwguC4is4gjre26ksFW wuiIaDR2hv5W4qdjl+rhr1coiA//1Zb9KMKihF7FhQEogiLZUqfvwCQABTWTL2ra0bCM 143tzKsIGOdrI8haAO1WpA/pGskNPGmSnDSbl2mHTIESL4R0h4KECccnIuzDN8gETsCI ht+m+ScJIuwN+iBty8bUddD6AgCmuTyUMW63tCVK2GZ4zWzZvbqJZHH0N6Q8C+GRjXjh Xefg== X-Gm-Message-State: AOAM532Vfyijh+7lX8qelS05GI2RH6Zk3CD438tgPU/TNvJfO74nx3m4 MWwSCRcRJKMotUPqwLfBlOP9A0e+LNUY0Q== X-Google-Smtp-Source: ABdhPJwdnTHOR9d1l4oFXe5kGdlgodU7AwChjBuzC0rzmOMAuhrAUV2iPJvEguMkDNmNaUCjeWlAiA== X-Received: by 2002:a7b:c449:: with SMTP id l9mr466186wmi.98.1625510237651; Mon, 05 Jul 2021 11:37:17 -0700 (PDT) Original-Received: from smtpclient.apple ([46.128.198.100]) by smtp.gmail.com with ESMTPSA id l17sm261855wmq.3.2021.07.05.11.37.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jul 2021 11:37:17 -0700 (PDT) In-Reply-To: <87o8cjuzk7.fsf@gnus.org> X-Mailer: Apple Mail (2.3654.100.0.2.22) 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:209483 Archived-At: > Am 06.06.2021 um 11:12 schrieb Lars Ingebrigtsen : >=20 > Philipp writes: >=20 >>> If I'm reading run_hook_with_args correctly, it'll loop over the = local >>> hook first (in order), and when it happens upon a t in that value, = it'll >>> then loop over the global value (in order), and then finish up the = rest >>> of the local ones. >>=20 >> Yes - and that's a reasonable behavior to expect, and we should = document it. >=20 > I think it's an implementation detail that users should not depend on. > Where that `t' ends up being depends on many subtle things like the > order of your add-hook/remove-hook calls in your .emacs file. What we think about this doesn't matter much. As I explained, people = depend on observable/observed behavior. Besides, hook ordering for abnormal hooks is crucial, so we can't just = say "don't depend on it." >=20 >> Correct hook ordering is crucial for abnormal hooks. We already rely >> on the very specific ordering behavior several times in the Emacs >> codebase alone. I've searched a bit through the Emacs codebase, and >> found the following places where Emacs runs an abnormal hook with >> `run-hook-with-args-until-success/failure' that also gains a local >> part somewhere the codebase: >=20 > [...] >=20 >> That is, we rely on this "undefined" behavior already in very basic >> operations such as saving buffers to file. In Eldoc, we even >> explicitly tell users to add functions to the local part of this >> abnormal hook (eldoc-documentation-functions), thereby telling them = to >> rely on "undefined" behavior! This hopefully shows that the behavior >> is far from being undefined. >=20 > I don't think it shows any such thing. Why not? Clearly there are hooks that are both abnormal and = partially-local in the Emacs codebase, and for those hooks this issue = arises. >=20 > I think it'd be a good idea to implement (and document) something in > this area that actually allows users to control the hook running order > properly, which currently just isn't possible. >=20 Yes, and arguably the current implementation with the "shadow" ordering = stored in a private symbol property is already kind of a hack. However, = the second-best option is still to document the current behavior. As = I've tried to explain, just stating "it's undefined" won't fly.