From unknown Mon Aug 18 09:04:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook Resent-From: Aleksandar Dimitrov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Mar 2023 13:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 62204@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16788858427957 (code B ref -1); Wed, 15 Mar 2023 13:11:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 Mar 2023 13:10:42 +0000 Received: from localhost ([127.0.0.1]:39384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcQtt-00024H-EK for submit@debbugs.gnu.org; Wed, 15 Mar 2023 09:10:41 -0400 Received: from lists.gnu.org ([209.51.188.17]:44176) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcPeY-0008FA-Ij for submit@debbugs.gnu.org; Wed, 15 Mar 2023 07:50:47 -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 ) id 1pcPeY-00029b-Bv for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 07:50:46 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcPeW-0004s0-2m for bug-gnu-emacs@gnu.org; Wed, 15 Mar 2023 07:50:46 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 27A695C0846 for ; Wed, 15 Mar 2023 07:50:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 15 Mar 2023 07:50:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aleks.bg; h=cc :content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t=1678881041; x=1678967441; bh=Hs6af7AXixDJ3j+Mo5546XuTG I4ENEGL5qSOvBDeOH0=; b=vPWtjLFM/fq6r+Lkbx77PMi6ZxDq5q8vrY8ojGrY8 tt2OJmDN7RqNTHWH1GMkqE3Q8QC+oO1XNv2hIkpKt5njQZY3yasKSfMQB8B0umLx kA1QYT33itBlWYD2VclxUWuSuww4toHq48+rYzDaw0oqtdmLO6psfJl9t7OF8ciW yyJ0WJnpKHpLMXMz9vWvWhUcLTmv4QQonvHCFCmBsuZwcuo+sDIQQaNOAfDy9xkQ 9cFOrPNtzJ0qdxzJRp1gcmqMd6yYxuK46Bz96ibkm5tZE64T9fqTTtnFRW7cDXeo sPbPvV1JjJOn+1YmvYVBOPWA5mdhXdGRhpOZslCp4BCYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1678881041; x=1678967441; bh=Hs6af7AXixDJ3j+Mo5546XuTGI4ENEGL5qS OvBDeOH0=; b=hRCywCHhdSaPzeC0X0QjV7jG6w6JTEea72eqdEy0uHLRislsDue LCW2OrcVCxm31CcE2IeyX9c8J1uLP5Rh2kaYxpDs4XSVb16/OFv6kzyo4zMvau0W C/UGaq/+PpB7ukWyUXrRZqwqB0SJvkT2XZXNuSMSOgiQ2GzsFYT6bmwv2y0leprZ fhzEPetDzYl25ZXnG5auFs9jzIlzuepSTI3PqWqy+4OIWPZIgFg/8tVRJj6Rtdmo 7MODfQ+bOt+xzlIr41Z51J9ByDLPRSr3YCrahoNFPfc/AGrHwDvzj2up+pE4YQbz tcs9JY4WkJvmIpXj0upqWZsrKZzHk0weJ/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvddvkedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpegfhffvufffkfggtgesthdtredttd ertdenucfhrhhomheptehlvghkshgrnhgurghrucffihhmihhtrhhovhcuoegtohguvges rghlvghkshdrsghgqeenucggtffrrghtthgvrhhnpeegfeehgfejhfetteehffelvedvge ejhffgtddvveeugeeivdduteetveffhfdugeenucffohhmrghinhepghhithhhuhgsrdgt ohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheptg houggvsegrlhgvkhhsrdgsgh X-ME-Proxy: Feedback-ID: i015146a0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 15 Mar 2023 07:50:40 -0400 (EDT) User-agent: mu4e 1.8.14; emacs 30.0.50 From: Aleksandar Dimitrov Date: Wed, 15 Mar 2023 12:50:38 +0100 Message-ID: <86cz5adyi9.fsf@aleks.bg> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=66.111.4.29; envelope-from=code@aleks.bg; helo=out5-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-Mailman-Approved-At: Wed, 15 Mar 2023 09:10:40 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) I'd like to propose a major mode hook that is called every time any treesit-based major mode is enabled. My use case is this: I'd like to extend the expand-region.el package so that it can make use of treesit to set the region to any treesit node. This should work in all treesit-based major modes. Currently, I've found two ways to accomplish loading my functionality for all ts-modes: - enumerate them all and use their respective hooks - advise something like `treesit-major-mode-setup` to execute my code The first idea might miss a mode if Emacs decides to add one down the line, or if the user defines her own ts-mode. The second idea does not feel idiomatic, as this sort of functionality is usually covered by hooks. I'd imagine there are other use cases for minor modes and other functionality that we'd like to provide to any ts-based mode, not just particular ones. The concrete use-case is exemplified here: https://github.com/magnars/expand-region.el/pull/279/ From unknown Mon Aug 18 09:04:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Mar 2023 14:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Aleksandar Dimitrov Cc: 62204@debbugs.gnu.org Received: via spool by 62204-submit@debbugs.gnu.org id=B62204.167889029616375 (code B ref 62204); Wed, 15 Mar 2023 14:25:02 +0000 Received: (at 62204) by debbugs.gnu.org; 15 Mar 2023 14:24:56 +0000 Received: from localhost ([127.0.0.1]:40302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcS3k-0004G3-0e for submit@debbugs.gnu.org; Wed, 15 Mar 2023 10:24:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcS3j-0004Fq-7f for 62204@debbugs.gnu.org; Wed, 15 Mar 2023 10:24:55 -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 ) id 1pcS3d-0005AC-8m; Wed, 15 Mar 2023 10:24:49 -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=eo+P6KkdmMkUB5VegzBEGYUD3byw5Q4/Aw6RZxUeX5c=; b=d32QstVfuMtP sO20KbxvjXWBIhAZR2CnnRV51atB9mNF10414RTqHIEEfRQD4ZMfT9BEDIr9ogAeEktuW0N3tMWX+ NMBo1VsO9Xd+8hBKD3lRDhAKEncMSs0OEbxN1ZektafCgvH2ALUBtrG3d8UEHLrSqejK4AfG9JjC/ DtUuBGgNiACih7dZGhlJ/YEz5QOEliqNh8L6T/ocwrVt+r/k4vOarBQ3FqcMSglElwKFP3ZNZO73S bLhv12t8S9ltT1f1Utm45JV8amFYXPMQG6dMvQBygAn8+gaKVHHpeGW3AsRl+MpQFjDRJuGofIIog 29uMr6vw6CfiAA66G+Rt+w==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcS3c-0000wN-PV; Wed, 15 Mar 2023 10:24:49 -0400 Date: Wed, 15 Mar 2023 16:24:45 +0200 Message-Id: <83wn3iqehe.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <86cz5adyi9.fsf@aleks.bg> (message from Aleksandar Dimitrov on Wed, 15 Mar 2023 12:50:38 +0100) References: <86cz5adyi9.fsf@aleks.bg> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Aleksandar Dimitrov > Date: Wed, 15 Mar 2023 12:50:38 +0100 > > > I'd like to propose a major mode hook that is called every time any treesit-based major mode is enabled. > > My use case is this: I'd like to extend the expand-region.el package so that it can make use of treesit to set the region to any treesit node. This should work in all treesit-based major modes. > > Currently, I've found two ways to accomplish loading my functionality for all ts-modes: > > - enumerate them all and use their respective hooks > - advise something like `treesit-major-mode-setup` to execute my code Isn't it enough to check that the buffer has a treesit parser? A hooks sounds too blunt and ad-hoc for your purposes, AFAIU. From unknown Mon Aug 18 09:04:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook Resent-From: Aleksandar Dimitrov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Mar 2023 04:27:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 62204@debbugs.gnu.org Received: via spool by 62204-submit@debbugs.gnu.org id=B62204.167894078220605 (code B ref 62204); Thu, 16 Mar 2023 04:27:03 +0000 Received: (at 62204) by debbugs.gnu.org; 16 Mar 2023 04:26:22 +0000 Received: from localhost ([127.0.0.1]:40925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcfC1-0005MC-Qx for submit@debbugs.gnu.org; Thu, 16 Mar 2023 00:26:22 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:39411) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pcbhJ-0007l8-B4 for 62204@debbugs.gnu.org; Wed, 15 Mar 2023 20:42:25 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 438D45C00A7; Wed, 15 Mar 2023 20:42:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 15 Mar 2023 20:42:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aleks.bg; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1678927340; x=1679013740; bh=fC /UQOgjbfr/nnSmtqmD1n19DX3JJ0T4St7Db4qFTrk=; b=XwIC/Akmf4PbmdxYVq 9mzzFdUOJIN7OVl/XdVO90mj7SZ8Er02lgTph334wO1UBQRwyEO1N2XT6/q7Abmt WUeoX31wqgxb+E128BbJXxsmlIIeyEg4ZYq2GLv+hsZJInFgoNrFW4ivgf35PEl/ bacud08fuXCzTcBgvPWs9HHHJbXMjOZnmDm83v8mUQYUs1Z0OxyDTtqtQPzYohFk xbMs5M4qWfOWUb2gOk0gvnswYZoSMyae++Bt1RZenWap0eLOY7ogrBHbyAClwh+U Lu5OFW7KjNHaXemSocfja4UEbfZKdj97wA32WCRG0NAztpic0UAgo3J/U0retbMF 4xkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1678927340; x=1679013740; bh=fC/UQOgjbfr/n nSmtqmD1n19DX3JJ0T4St7Db4qFTrk=; b=HxU+7YEhrawx2u8NzS2t6gXqKHJhZ yhQ06e/SlIYOXBP9JETzBCRw0GySBE5cFx1Tsd61fI8wy6n61XXjeBpDMPutKi+K oYhQuhfpNiuMgcZS1i0AiZxtDVUApiW/qkj18iv9ZHSno5B2MGxfogxjzm+rIs1o EBITUWVCzRtr3NWfjQ49OIrsM/kScQe+Sk7bOMJkk6BgrF6dix49J4zeBTBsi6Zq o1McMB44JWY4YBq/N+YA4Ruci3Qp18PtZ8CtCSs91TBhxHT+pUImqLkWvCrTULtm mVaG1ZPOgyruYPQpzM0U3IKrKrPrHUAl29hysMwBktyDS6PGaGCJDavxA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvddvledgvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvvefuffgjkfggtgesthdtredttdertdenucfhrhhomheptehlvghk shgrnhgurghrucffihhmihhtrhhovhcuoegtohguvgesrghlvghkshdrsghgqeenucggtf frrghtthgvrhhnpeejtedtgffhudefleefieeuieffvefhjefhvdetjeelkeehieejheeu hfetleegkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegtohguvgesrghlvghkshdrsghg X-ME-Proxy: Feedback-ID: i015146a0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Mar 2023 20:42:19 -0400 (EDT) References: <86cz5adyi9.fsf@aleks.bg> <83wn3iqehe.fsf@gnu.org> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Aleksandar Dimitrov Date: Thu, 16 Mar 2023 01:35:17 +0100 In-reply-to: <83wn3iqehe.fsf@gnu.org> Message-ID: <86pm99y1av.fsf@aleks.bg> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Mailman-Approved-At: Thu, 16 Mar 2023 00:26:15 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) >> Currently, I've found two ways to accomplish loading my functionality for all ts-modes: >> >> - enumerate them all and use their respective hooks >> - advise something like `treesit-major-mode-setup` to execute my code > > Isn't it enough to check that the buffer has a treesit parser? I'm not sure I understand you, so I'll try to provide some code. I'd like to be able to do something like this: (defun my-setup () "Code that depends on the presence of TS") (add-hook 'treesit-major-mode-hook 'my-setup) If I understand you correctly, I could probably do something like this: (defmacro add-ts-mode-hook (f) "Add mode hook that only executes in ts modes" `(add-hook 'prog-mode-hook (lambda () (when (treesit-language-at (point)) (,f))))) I'd say there's bound to be more people who would like to configure a certain behaviour whenever treesit is available, regardless of major mode. A macro like the above could be a possible solution, but it doesn't feel terribly ergonomic. > A hooks sounds too blunt and ad-hoc for your purposes, AFAIU. The reason I want to execute my function in a hook is that it sets buffer local variables, and configures buffer-local behaviour, perhaps even keybindings. I was under the impression that hooks are the correct place to do this. From unknown Mon Aug 18 09:04:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Mar 2023 06:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Aleksandar Dimitrov Cc: 62204@debbugs.gnu.org Received: via spool by 62204-submit@debbugs.gnu.org id=B62204.16789487282719 (code B ref 62204); Thu, 16 Mar 2023 06:39:01 +0000 Received: (at 62204) by debbugs.gnu.org; 16 Mar 2023 06:38:48 +0000 Received: from localhost ([127.0.0.1]:41064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pchGB-0000hn-SL for submit@debbugs.gnu.org; Thu, 16 Mar 2023 02:38:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pchGA-0000hZ-UW for 62204@debbugs.gnu.org; Thu, 16 Mar 2023 02:38:47 -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 ) id 1pchG4-00089q-Vk; Thu, 16 Mar 2023 02:38:40 -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=RjSNMtthEHiopC8f19h0/3jl0EBU3SUjJnPG8e4DW/k=; b=kw42SogjkDAD KvYMvIZJSPu4B/5brANdX9B4knYeykN2/H9FE8bXHGQTiLe5YtB0yzQccww1/6u/fj9pBLgGwTsX5 Hf4d0V7pTrGii0chNfstgWPEF6/SDekWGV6jXfOaQH2jx77WCA/kCT+Lx5jDHC/lCwT1qTkAx5OJT qvccWI0BfXySgJ5qpoVZ/Rmw8ZAcBvXnuWjwoEvS6qGu4DMBzr6d/cElmf1QIjUymVcv5lXbrniOL ZtRfpKatFOTDjU/QbJVk9+nkuNWmVFa9JjTfCp2DiAgW1XFK24dm6BwagZ6v1pfllTn4qySQqtNoN mXF4u40aiKBTtU8UjxegJw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pchG1-0001Dz-39; Thu, 16 Mar 2023 02:38:38 -0400 Date: Thu, 16 Mar 2023 08:38:34 +0200 Message-Id: <83fsa5qjyt.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: <86pm99y1av.fsf@aleks.bg> (message from Aleksandar Dimitrov on Thu, 16 Mar 2023 01:35:17 +0100) References: <86cz5adyi9.fsf@aleks.bg> <83wn3iqehe.fsf@gnu.org> <86pm99y1av.fsf@aleks.bg> X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Aleksandar Dimitrov > Cc: 62204@debbugs.gnu.org > Date: Thu, 16 Mar 2023 01:35:17 +0100 > > I'd like to be able to do something like this: > > (defun my-setup () > "Code that depends on the presence of TS") > (add-hook 'treesit-major-mode-hook 'my-setup) > > If I understand you correctly, I could probably do something like this: > > (defmacro add-ts-mode-hook (f) > "Add mode hook that only executes in ts modes" > `(add-hook 'prog-mode-hook > (lambda () > (when (treesit-language-at (point)) > (,f))))) Something like that. Basically, any function that wants to do something that depends on tree-sitter being available for the major mode should make such a test to determine whether tree-sitter support is available. > I'd say there's bound to be more people who would like to configure a > certain behaviour whenever treesit is available, regardless of major > mode. A macro like the above could be a possible solution, but it > doesn't feel terribly ergonomic. The above code doesn't have to run from a mode hook, it could be done directly where the "certain behavior" is implemented, as the condition for invoking that certain behavior. And if running the test each time is too expensive for some reason, the test could be optimized by performing it just once for each buffer where it runs, and saving the result in some buffer-local variable. If the above is for some reason unworkable or otherwise problematic, please tell why. > > A hooks sounds too blunt and ad-hoc for your purposes, AFAIU. > > The reason I want to execute my function in a hook is that it sets > buffer local variables, and configures buffer-local behaviour, perhaps > even keybindings. I was under the impression that hooks are the correct > place to do this. They are, but they are not the only such place. Many features in Emacs use buffer-local variables and keybindings without a special hook. Please also keep in mind that proliferation of general-purpose hooks is not without disadvantages. For starters, a hook disconnects the cause from the effect, and makes it harder to track the control flow and thus harder to understand how a given Lisp program works. From unknown Mon Aug 18 09:04:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook References: <86cz5adyi9.fsf@aleks.bg> In-Reply-To: <86cz5adyi9.fsf@aleks.bg> Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Mar 2023 07:50:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: code@aleks.bg Cc: 62204@debbugs.gnu.org, Eli Zaretskii Received: via spool by 62204-submit@debbugs.gnu.org id=B62204.167912576214772 (code B ref 62204); Sat, 18 Mar 2023 07:50:01 +0000 Received: (at 62204) by debbugs.gnu.org; 18 Mar 2023 07:49:22 +0000 Received: from localhost ([127.0.0.1]:46111 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdRJa-0003qC-Bt for submit@debbugs.gnu.org; Sat, 18 Mar 2023 03:49:22 -0400 Received: from mail-pf1-f175.google.com ([209.85.210.175]:37410) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pdRJY-0003pu-HS for 62204@debbugs.gnu.org; Sat, 18 Mar 2023 03:49:21 -0400 Received: by mail-pf1-f175.google.com with SMTP id z11so4334297pfh.4 for <62204@debbugs.gnu.org>; Sat, 18 Mar 2023 00:49:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679125754; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=iJxInpkBTWRifh65p/VcXSLv1Nj/mhjQImEcSndzWH4=; b=cAj9FDT+Il17XJYSUjsE2nDFs9glbs1XlxSbL97iNeh0U+y9MtazT0OpLeV5G9W8vf b2oPLjer0wqE2REmjE3bqP97/NzaB60jevK7lQvm2mp6v7ov5tc5Z7obvMsoHWB2Jg0R xUnPfl0Ww5bGdko5XlFmuebZuVzc4IkSprST98ptSghMDfGrfD5tce7ymxS18vvEv3e/ RnGpDuqMGjOCNEeTzA15XC6tL2IXkzaL62A5ia+c5sjoEJVkjvMYOFdaOzSYCWVCfNuR GLzS9sEuAEQU14DRwQNmYSuFT5RgVbfo4N4az6/B9Zmpty2THBYuOvL1jTYjAcyiLCd1 dOeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679125754; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iJxInpkBTWRifh65p/VcXSLv1Nj/mhjQImEcSndzWH4=; b=BZzYBNl4E35ZlwspS+chlvZQyCXhUOLT0FeS+HVgpoU7P6jWbMSQxLt6YqSul7mOqa oG/KsRfJQafsp2g3qNTQMxgkDWUye1Fr05SItSDkzJq0Mh9rU89j7IAsh+9dXeeulpP2 JgXiyxwd0B7Tv5Lv2ysxPMVGjXCEjvVZgJaWBhM8VPgDeuOimZIDwudhA3dsPsOXik6Y cqy5FoIdm2r04bO4BKTb24cg7NGC1Vy8NK6VY9qGwQMAoj4S15pFtO2RLNBnFCr1Ovf0 jLWnPVca00CQRMWFuo/1iRY+py9puSybETJRykBdgphPtWzRl8ceJqM49s3XxU/gHMcB SHYg== X-Gm-Message-State: AO0yUKUYLRrGSe6n7JNJUkA/5w+vwp+WUCOgzrZh6TEBDOoIWv6/hyfK 8UMm95QvZOerJ9z64EFhZoyU2h25M+ZjVw== X-Google-Smtp-Source: AK7set8gsxF8IZMxbaSJxmJ3fBE3ZQis6LXyxZGJ4uwmY1cWjUKrNK1A71DvGBjxDhTHAs09zUIZhQ== X-Received: by 2002:a62:4e03:0:b0:5a8:aca5:817d with SMTP id c3-20020a624e03000000b005a8aca5817dmr8689908pfb.5.1679125754572; Sat, 18 Mar 2023 00:49:14 -0700 (PDT) Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id j6-20020a62e906000000b00625e885a6ffsm2757135pfh.18.2023.03.18.00.49.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Mar 2023 00:49:14 -0700 (PDT) From: Yuan Fu Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.400.51.1.1\)) Message-Id: Date: Sat, 18 Mar 2023 00:49:02 -0700 X-Mailer: Apple Mail (2.3731.400.51.1.1) X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Aleksandar Dimitrov writes: >>> Currently, I've found two ways to accomplish loading my = functionality for all ts-modes: >>>=20 >>> - enumerate them all and use their respective hooks >>> - advise something like `treesit-major-mode-setup` to execute my = code >> >> Isn't it enough to check that the buffer has a treesit parser? > > I'm not sure I understand you, so I'll try to provide some code. > > I'd like to be able to do something like this: > > (defun my-setup () > "Code that depends on the presence of TS") > (add-hook 'treesit-major-mode-hook 'my-setup) > > If I understand you correctly, I could probably do something like = this: > > (defmacro add-ts-mode-hook (f) > "Add mode hook that only executes in ts modes" > `(add-hook 'prog-mode-hook > (lambda () > (when (treesit-language-at (point)) > (,f))))) > > I'd say there's bound to be more people who would like to configure a > certain behaviour whenever treesit is available, regardless of major > mode. A macro like the above could be a possible solution, but it > doesn't feel terribly ergonomic. > >> A hooks sounds too blunt and ad-hoc for your purposes, AFAIU. > > The reason I want to execute my function in a hook is that it sets > buffer local variables, and configures buffer-local behaviour, perhaps > even keybindings. I was under the impression that hooks are the = correct > place to do this. IIUC, you are trying to do something like (er/enable-mode-expansions 'clojure-mode = 'er/add-clojure-mode-expansions) right? But a tree-sitter-based expander doesn=E2=80=99t really depend on any = particular major mode. In essence, they depend on the existence of a tree-sitter parser in the current buffer. So I suggest that you define a universal expander (similar to er/expand-word, etc) that checks the existence of a tree-sitter parser and uses the parser to expand the region, and simply do nothing if there isn=E2=80=99t a parser. But to work with tree-sitter, expand-region might need to disable some of its expanders when a tree-sitter parser is available, in case = there=E2=80=99s some conflict between the existing language-specific expander and the tree-sitter expander. Yuan From unknown Mon Aug 18 09:04:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook Resent-From: Aleksandar Dimitrov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Mar 2023 22:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Yuan Fu Cc: 62204@debbugs.gnu.org, Eli Zaretskii , code@aleks.bg Received: via spool by 62204-submit@debbugs.gnu.org id=B62204.167926530516150 (code B ref 62204); Sun, 19 Mar 2023 22:36:02 +0000 Received: (at 62204) by debbugs.gnu.org; 19 Mar 2023 22:35:05 +0000 Received: from localhost ([127.0.0.1]:52937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pe1cG-0004CQ-LK for submit@debbugs.gnu.org; Sun, 19 Mar 2023 18:35:04 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:59693) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pe1cE-0004Br-Gx for 62204@debbugs.gnu.org; Sun, 19 Mar 2023 18:35:03 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 708083200923; Sun, 19 Mar 2023 18:34:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 19 Mar 2023 18:34:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aleks.bg; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1679265296; x=1679351696; bh=ti+BrGcx/WHr4MDrEbWD5zAAcYzxnXwOEhG AoYa/kRM=; b=Fg+RPmNTuXHwikFlZ07dX2NLiqGCZQ4kCS7M3KVuk5ljOoS1Uc0 M9ujIhW7EmrQe5xnEsZRm6vaLnWWBJPycmcE7/hviGTYEaT4Ud/bnX2Tet38J4Dl CPS5Mdhee8VjSp/ltk0Jk3SrdJXo+h6+HyiFf+U6kur/STg9YlTulThnTUiWwhw3 nJllgQcsCuGpcJ1sHJQsKx5FFxrMdrK8dVn7bpgxnxUuQBtBIl4NhvF3D7U8rC7r Rms6R6Ifw8SCfUV2goppOaY3JPsrgZ5n9vtNqnxJRq0XIeCGAoBtuz1QPuoXXdev 79hl4xZhrkG8dFbxKCg33pdEGuRuJbAzlXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1679265296; x=1679351696; bh=ti+BrGcx/WHr4MDrEbWD5zAAcYzxnXwOEhG AoYa/kRM=; b=h8aaO2N+iJuPzqidED94ret6ZL09Z5VtIFMkY3ahGZbLp0td2s7 +wcLZq0F9De2q/iow+6gzRv4yHLgixwmSV0w71dB6sbqthmdlQN2opFk5caGO7lI 6m5n3WxRz0vgBhulcrp/PmrppsJ7WROvW6DUXqtP7eyaCIS45owjEf7OygLgIr1W uaDn2HsVy2jGDzDxq5XfkcksChmXm3Lfc93utbXsLY5V0aA7yQHb2SFr51ropjUX YpT4VS1PQ6dRelXK8WPGz/XxO5luvPVeZsoxuUnvleASdqZ4ggJHYb3iO9djDKRM CJgFWfAUllVm/oYoApyCUMieRklDyqoaS6A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefjedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvvefuffgjkfggtgfgsehtqhertddtreejnecuhfhrohhmpeetlhgv khhsrghnuggrrhcuffhimhhithhrohhvuceotghouggvsegrlhgvkhhsrdgsgheqnecugg ftrfgrthhtvghrnhepgedvvdekveehueevieevgeejfeetveeghfehhfelheejteehheev tdejheegvedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheptghouggvsegrlhgvkhhsrdgsgh X-ME-Proxy: Feedback-ID: i015146a0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 19 Mar 2023 18:34:53 -0400 (EDT) References: User-agent: mu4e 1.8.14; emacs 30.0.50 From: Aleksandar Dimitrov Date: Sun, 19 Mar 2023 23:26:03 +0100 In-reply-to: Message-ID: <86o7ool69h.fsf@aleks.bg> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Yuan Fu writes: > IIUC, you are trying to do something like > > (er/enable-mode-expansions 'clojure-mode 'er/add-clojure-mode-expansions) > > right? Yes! > But a tree-sitter-based expander doesn=E2=80=99t really depend on any par= ticular > major mode. In essence, they depend on the existence of a tree-sitter > parser in the current buffer. So I suggest that you define a universal > expander (similar to er/expand-word, etc) that checks the existence of a > tree-sitter parser and uses the parser to expand the region, and simply > do nothing if there isn=E2=80=99t a parser. That's exactly what I did. However, instead of having an expander check every time whether there's a tree-sitter parser, a check that's redundant past the first one, I wanted to only load that expander whenever it makes sense and not even call it otherwise. I feel that makes the code easier to follow, and it makes more sense for the domain. > But to work with tree-sitter, expand-region might need to disable some > of its expanders when a tree-sitter parser is available, in case there=E2= =80=99s > some conflict between the existing language-specific expander and the > tree-sitter expander. Yes, it's not quite straight-forward, but that's a discussion for the PR I opened against expand-region. Thanks for your insight! Aleks From unknown Mon Aug 18 09:04:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#62204: 30.0.50; Feature Request: treesit-major-mode-hook Resent-From: Aleksandar Dimitrov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 19 Mar 2023 22:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62204 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 62204@debbugs.gnu.org, Aleksandar Dimitrov Received: via spool by 62204-submit@debbugs.gnu.org id=B62204.167926574816825 (code B ref 62204); Sun, 19 Mar 2023 22:43:02 +0000 Received: (at 62204) by debbugs.gnu.org; 19 Mar 2023 22:42:28 +0000 Received: from localhost ([127.0.0.1]:52943 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pe1jP-0004NJ-Jy for submit@debbugs.gnu.org; Sun, 19 Mar 2023 18:42:27 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:52455) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pe1jO-0004N7-7w for 62204@debbugs.gnu.org; Sun, 19 Mar 2023 18:42:26 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 4C2D0320070D; Sun, 19 Mar 2023 18:42:20 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 19 Mar 2023 18:42:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aleks.bg; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1679265739; x=1679352139; bh=PL XkkLuq4qqOJ8QQL6tRhz0L1bCEf2l49zIJtgnuCyo=; b=TJuUU/Qfgf6655c25a LTfYGVNyZUMR2HYIHSifbFNwVp9I/kgNCRh62ps/iqDJ0VSORm1qgBDhBaAKjw2m 0O8EphCOvsnUikV9w5smpw8wHy1NHKKUDiQiPJBD1D/ehjCTg4Oxxdj7DB69KQg5 R7TdIcBzXBIPrLBD6JkXqtho2YHF9udslhPQxZzvUcUHaPiaY62F5jXuXrmtLOtk 6eFGWL26FHSRryTVm78VksfWdgqRN1T7jwMgrN3xfRkDC59g2fABrzClTFMJxF96 puiA3Qp3ysDaCAjiogpIsb3kvmehkmScWe8AgPAblLHsK/RJ/81GEygxhkNbclNT 5lOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1679265739; x=1679352139; bh=PLXkkLuq4qqOJ 8QQL6tRhz0L1bCEf2l49zIJtgnuCyo=; b=PR24bsWcuu8N1R5JyC2p9DkIn83GE r9jjFzWQgNYM+QlPDHDHq+9k882JFB1fK/DvSg9o9ViQ35Wr4NMYEI359MHYdp6N LRPAMYWeaQ9t214ew1sRGA9IfDiRI2Ccrp+G1HfufhyDQpHTn0JEddWtlDvGBPUs Wff03YJw9yz3CKSx/lsq0koMoeotLM/K/wCUvfs56iZVbgcW9/gOf+OnJDgAffgF O8eYvliDOUCNliVPpXl2vK4jgHs9z20rUUmjWmRH6ZtbDRgQopJkmn+LTO0hcE2n bCu3pmmfZVTHpq+k4QgwtmtfWf7uSY0E+OKpUmi9MqltbrTPz8MeNViwQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefjedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvvefuffgjkfggtgesthdtredttdertdenucfhrhhomheptehlvghk shgrnhgurghrucffihhmihhtrhhovhcuoegtohguvgesrghlvghkshdrsghgqeenucggtf frrghtthgvrhhnpeejtedtgffhudefleefieeuieffvefhjefhvdetjeelkeehieejheeu hfetleegkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegtohguvgesrghlvghkshdrsghg X-ME-Proxy: Feedback-ID: i015146a0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 19 Mar 2023 18:42:19 -0400 (EDT) References: <86cz5adyi9.fsf@aleks.bg> <83wn3iqehe.fsf@gnu.org> <86pm99y1av.fsf@aleks.bg> <83fsa5qjyt.fsf@gnu.org> User-agent: mu4e 1.8.14; emacs 30.0.50 From: Aleksandar Dimitrov Date: Sun, 19 Mar 2023 23:35:25 +0100 In-reply-to: <83fsa5qjyt.fsf@gnu.org> Message-ID: <86ttygjrcm.fsf@aleks.bg> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Hi Eli, Eli Zaretskii writes: > Something like that. Basically, any function that wants to do > something that depends on tree-sitter being available for the major > mode should make such a test to determine whether tree-sitter support > is available. As mentioned in the other email to Yuan Fu, my goal was to avoid such a check, and only install those functions that depend on treesitter when treesitter was available. The reason is less performance-driven and more about my subjective goal to avoid cluttering functions with conditionals whenever possible. > They are, but they are not the only such place. Many features in > Emacs use buffer-local variables and keybindings without a special > hook. > > Please also keep in mind that proliferation of general-purpose hooks > is not without disadvantages. For starters, a hook disconnects the > cause from the effect, and makes it harder to track the control flow > and thus harder to understand how a given Lisp program works. I agree that hooks add indirection. They were the first tool I pulled out of my (very limited) Emacs toolbox, because I'm very used to working with them. But if such a hook isn't desirable in the grand scheme of things, that's OK! There are certainly viable alternatives. Thanks for taking your time to explain this. Aleks