From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Nov 2023 04:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 67034@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.169958876031902 (code B ref -1); Fri, 10 Nov 2023 04:00:02 +0000 Received: (at submit) by debbugs.gnu.org; 10 Nov 2023 03:59:20 +0000 Received: from localhost ([127.0.0.1]:49278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1Ifv-0008IT-Ps for submit@debbugs.gnu.org; Thu, 09 Nov 2023 22:59:20 -0500 Received: from lists.gnu.org ([2001:470:142::17]:40034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1Ifs-0008ID-Ra for submit@debbugs.gnu.org; Thu, 09 Nov 2023 22:59:19 -0500 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 1r1IfA-0001La-1l for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 22:58:32 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r1If8-0000BY-87 for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 22:58:31 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CCD711000AD for ; Thu, 9 Nov 2023 22:58:27 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1699588707; bh=sHckZheSuMiGB0ASZmYzivqvRZaTaDs2IEku+qrSigs=; h=From:To:Subject:Date:From; b=mJm0y2mMGMp66w1Ov/iWpMfIx1dN5Hcd6fQ+oT7QYohnbNNA2YZk5pWb5BNXU20qt TzA1YTqKQOcZAonhCBZ6uCoY9ThnVBpqgWdZhuR6qVVpi7aIHDcsb8Z3B1kU7tDtqi ODjKQliCxsrnyYE+hCHRzYoCAQEsA2+q4WKgKPuBxOXOFzhndmQy9tMv5B4iqXUb8U 8LMuQgXKvYzv7M8C78GxWFlk/6jCnpjzIjp7EJDyXgvRaRNH6rBwQLW2WV3dbk7Ok1 oNZ8lZY5ECxtNUCy8hQKvNOxmEIhYyuZAVxppcGtTB5HA+iGa2S7uENVRX3S6xT2ZA vipNYb/P5uKLw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 14579100061 for ; Thu, 9 Nov 2023 22:58:27 -0500 (EST) Received: from pastel (unknown [45.72.227.120]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id ED7D91203DD for ; Thu, 9 Nov 2023 22:58:26 -0500 (EST) From: Stefan Monnier Date: Thu, 09 Nov 2023 22:58:26 -0500 Message-ID: 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.135 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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: 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 (-) Package: Emacs Version: 30.0.50 Looking at uses of `derived-mode-p`, I can't find a single use case where it wouldn't be preferable for it to take a single argument instead of `&rest`: all the calls are either passing a single argument anyway, or passing a fixed list of modes. So making `derived-mode-p` take a single arg (which we'd allow to be either a mode or a list of modes) would not make any real difference to the callers (it would even be more convenient since it could often avoid the use of `apply`), and in return we'd save allocating the `&rest` list. Same for `provided-mode-derived-p`. And yes, I plead guilty for the `&rest` of `derived-mode-p`. Seemed like a good idea at the time :-( Draft patch below. Stefan diff --git a/lisp/subr.el b/lisp/subr.el index d4173b4daba..cd6407ef4b2 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2678,11 +2678,17 @@ while-let ;; PUBLIC: find if the current mode derives from another. -(defun provided-mode-derived-p (mode &rest modes) +(defun provided-mode-derived-p (mode &optional parent &rest modes) "Non-nil if MODE is derived from one of MODES. Uses the `derived-mode-parent' property of the symbol to trace backwards. If you just want to check `major-mode', use `derived-mode-p'." - (declare (side-effect-free t)) + (declare (side-effect-free t) + (advertised-calling-convention (mode parent) "30.1")) + (setq modes (if (not (listp parent)) + (cons parent modes) + ;; New calling convention can't use MODES at the same time. + (cl-assert (null modes)) + parent)) (while (and (not (memq mode modes)) @@ -2693,11 +2699,19 @@ provided-mode-derived-p (and (symbolp alias) alias))))))) mode) -(defun derived-mode-p (&rest modes) - "Non-nil if the current major mode is derived from one of MODES. -Uses the `derived-mode-parent' property of the symbol to trace backwards." - (declare (side-effect-free t)) - (apply #'provided-mode-derived-p major-mode modes)) +(defun derived-mode-p (&optional mode &rest modes) + "Non-nil if the current major mode is derived from MODE. +MODE can also be a list of modes, in which case we check if major mode +is derived from one of them. +It also supports an obsolete `&rest MODES' calling convention." + (declare (side-effect-free t) + (advertised-calling-convention (mode) "30.1")) + (provided-mode-derived-p major-mode + (if (not (listp mode)) (cons mode modes) + ;; New calling convention can't use MODES + ;; at the same time. + (cl-assert (null modes)) + mode))) (defvar-local major-mode--suspended nil) (put 'major-mode--suspended 'permanent-local t) From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg References: In-Reply-To: Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Nov 2023 12:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 67034@debbugs.gnu.org Received: via spool by 67034-submit@debbugs.gnu.org id=B67034.169961876530094 (code B ref 67034); Fri, 10 Nov 2023 12:20:02 +0000 Received: (at 67034) by debbugs.gnu.org; 10 Nov 2023 12:19:25 +0000 Received: from localhost ([127.0.0.1]:49660 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1QTs-0007pK-OC for submit@debbugs.gnu.org; Fri, 10 Nov 2023 07:19:25 -0500 Received: from server.qxqx.de ([2a01:4f8:121:346::180]:44033 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1QTn-0007p1-E0 for 67034@debbugs.gnu.org; Fri, 10 Nov 2023 07:19:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:Subject:From:To: MIME-Version:Date:Message-ID:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZUWJxixitztV1J6XYMZopn8mGrcGrggOvBnuuWHeikY=; b=Tv5lQg5FojG3KPqCfQnJkHGTjB RH9iCbeJrpPnZLHvEJe7+AgYPrZSpPpjxCKbIuwtJU8GUweE+Unt43+cz6Hs/vpOYZ7gpJymJbs2B e+TsmJmiwGOeE/QhvGVq1P7KP5q1F+W4D0UpX5eCXPvbGsKGfuY0sAmYVIQR1rjFRW5s=; Message-ID: <96367d39-4861-41e6-9383-a9a18efa0678@daniel-mendler.de> Date: Fri, 10 Nov 2023 13:18:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Daniel Mendler Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 (---) This change would affect many packages. I grepped through my elpa directory and found multiple uses of derived-mode-p and provided-mode-derived-p with multiple arguments as shortcuts: (derived-mode-p 'mode1 'mode2) instead of (or (derived-mode-p 'mode1) (derived-mode-p 'mode2) There are also multiple call sites with apply, but these would be arguably nicer if derived-mode-p takes a list argument as proposed. Still, do the benefits of this change outweigh the required changes? From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Nov 2023 00:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Daniel Mendler , 67034@debbugs.gnu.org Received: via spool by 67034-submit@debbugs.gnu.org id=B67034.169966111816361 (code B ref 67034); Sat, 11 Nov 2023 00:06:01 +0000 Received: (at 67034) by debbugs.gnu.org; 11 Nov 2023 00:05:18 +0000 Received: from localhost ([127.0.0.1]:51053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1bV0-0004Fo-9c for submit@debbugs.gnu.org; Fri, 10 Nov 2023 19:05:18 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:36881) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1bUy-0004Fa-PH for 67034@debbugs.gnu.org; Fri, 10 Nov 2023 19:05:17 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 99B825C0218; Fri, 10 Nov 2023 19:04:31 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 10 Nov 2023 19:04:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=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=fm2; t= 1699661071; x=1699747471; bh=YQ1oKE6xVLJ3SZiua+KSMvjqEcBYK/Mvoe3 aj5mXTv8=; b=H7YqLWiSaOIHSY8q5VTfJDdRGxZI2wvcIvknjy+olgqMV3nlABi xfn/VfpzcbXxMMS4Hrs+XLtoVkhjgGDdVuQr2oHdp7AHV1CmNJCDYCQsUwU0qlui bdYAPkQ6HWEX6ttXAeAz8ROTX3D0Nq+J6qs8Yuh4fGdGu6DnliCZsVNx9C6IgsAw chvAK27u6bAJTgD4KTT+4KmiLdAlkDpXD8Eez96Zkq/4IJPIaeLQ/9yXGhTxhFya kI0UCVMB6vqypdT5bP14N1lVcHF/CwZ51+Gj8DAAk+XMH+5zh2acc6ahObpgpbsq sVLXj9nAr2FHDNomrHDjhwJL3PVR0doyVdA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm3; t=1699661071; x= 1699747471; bh=YQ1oKE6xVLJ3SZiua+KSMvjqEcBYK/Mvoe3aj5mXTv8=; b=H ufGdRniQrmhK5ukZCrIJw1McZFAiAHOg5VvDJ9WaF4NLpk6DFJd+Olr1kTgeMm4l DgSXvQBmvIWZ1i+h3n46Gl3P8LQzdxRUGf7zidhijhm0ar0L7KQjp3Tqevkjab1l 6C9sBtTn4s6rHXMTq2ileW9XLRL3YSMpiIEP1dR7u8w4lTP1AliIrKO5xHg/Duva MTY6RuemQVFAdGP3dw6IrWuPWaW+Guj4dVBId9LOXo4lf4ebhnh5NzNXNDwSbYVU +2PvjP6LF/F3hOx9tSCduEVbJp2JdnIIFWYjOdbuUaI8oJbQ4CkKCQEZzMh1Bj91 DbdsJaFcl9zsamvXJNeAg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedruddvgedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtje ertddtfeejnecuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhu thhovhdruggvvheqnecuggftrfgrthhtvghrnhepgeehtdehudejieetuedttdejkeehje etueekheffuddtjeeuvdefveeuveeiuddunecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 10 Nov 2023 19:04:30 -0500 (EST) Message-ID: <6ded2256-4537-3a51-8ecd-ab3bd5a862d1@gutov.dev> Date: Sat, 11 Nov 2023 02:04:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US References: <96367d39-4861-41e6-9383-a9a18efa0678@daniel-mendler.de> From: Dmitry Gutov In-Reply-To: <96367d39-4861-41e6-9383-a9a18efa0678@daniel-mendler.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.2 (--) 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.2 (---) On 10/11/2023 14:18, Daniel Mendler wrote: > There are also multiple call sites with apply, but these would be > arguably nicer if derived-mode-p takes a list argument as proposed. > Still, do the benefits of this change outweigh the required changes? I've also found some call sites with multiple arguments (one of them being sml-mode 6.12) and also uses with (apply #'derived-mode-p some-user-option-list-of-modes). But those are indeed in the minority. I wonder if this extra allocation of &rest makes any difference in any benchmark, though. From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg Resent-From: Daniel Mendler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Nov 2023 09:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov , 67034@debbugs.gnu.org Received: via spool by 67034-submit@debbugs.gnu.org id=B67034.16996937718312 (code B ref 67034); Sat, 11 Nov 2023 09:10:01 +0000 Received: (at 67034) by debbugs.gnu.org; 11 Nov 2023 09:09:31 +0000 Received: from localhost ([127.0.0.1]:51849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1jzf-00029z-1F for submit@debbugs.gnu.org; Sat, 11 Nov 2023 04:09:31 -0500 Received: from server.qxqx.de ([2a01:4f8:121:346::180]:48761 helo=mail.qxqx.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1jzc-00029X-Fr for 67034@debbugs.gnu.org; Sat, 11 Nov 2023 04:09:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=qxqx.de; s=mail1392553390; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=R6xDRYW3OCjwepFFm8XEqNjCcjRN9wD0p/SbfYQe5RY=; b=Q6Bdg35b6fjGLcVKD/9zNumtF+ 18Ct3Lg447Z49iBKbg5C4HA+a4iljDrpNSuXprbkKnzXYCpOCL19pawjy9aaMt1EL08xh5aCsQocA Rwp3/yadZlNCaA1J5mlmhfonVJTaD+5y2THdKi0ztYn329HnhQOALx7xMIRdRXICw4ng=; Message-ID: Date: Sat, 11 Nov 2023 10:08:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird References: <96367d39-4861-41e6-9383-a9a18efa0678@daniel-mendler.de> <6ded2256-4537-3a51-8ecd-ab3bd5a862d1@gutov.dev> Content-Language: en-US From: Daniel Mendler In-Reply-To: <6ded2256-4537-3a51-8ecd-ab3bd5a862d1@gutov.dev> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 (---) On 11/11/23 01:04, Dmitry Gutov wrote: > I wonder if this extra allocation of &rest makes any difference in any > benchmark, though. derived-mode-p is usually not called in some kind of hot loop, but rather during initialization/setup. So it shouldn't matter? I am generally a bit wary of backward incompatible calling convention changes. From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Nov 2023 22:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 67034@debbugs.gnu.org Received: via spool by 67034-submit@debbugs.gnu.org id=B67034.17001737192029 (code B ref 67034); Thu, 16 Nov 2023 22:29:01 +0000 Received: (at 67034) by debbugs.gnu.org; 16 Nov 2023 22:28:39 +0000 Received: from localhost ([127.0.0.1]:44787 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3kqk-0000Wc-3z for submit@debbugs.gnu.org; Thu, 16 Nov 2023 17:28:39 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:25799) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3kqh-0000WI-PW for 67034@debbugs.gnu.org; Thu, 16 Nov 2023 17:28:37 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6E452442792; Thu, 16 Nov 2023 17:28:29 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1700173705; bh=hU8OJCK80VcSOawpPpQjTvl40gMsTJ4HTqshTuhpgYg=; h=From:To:Subject:In-Reply-To:References:Date:From; b=gKUzlUidc0FCMm7yIYC4qddXaicpmtNMT2JRVUm+nECN85dnyik3XfXMWK+7Dzgre Eh0KX24v5tW0o90ux45QTCao8DG4GAonhxeVJFCYj+FWTec9uIaOpwX1WIZlsE+ZwX YMLcx5k8phxtXJBGKmw1nVEwfxCOAgAx+FNWaC6Hq2GzzxDjIlFO7aGR/i7Uogl3/B iKRroVCHjNvN45oekV62wqHfbndnmwpXJ9tbxwJi+/wuJruXZx8NO/JbN7kqsdv0CU pnMYBMW0zhWaUetHQHev8lr1U3AfAXjj714SSN3WZWiEMGHhtxFo8QV46otnXwfk8l iTTcV7UgqJT9A== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A33A244278B; Thu, 16 Nov 2023 17:28:25 -0500 (EST) Received: from pastel (unknown [45.72.227.120]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 80C051201B4; Thu, 16 Nov 2023 17:28:25 -0500 (EST) From: Stefan Monnier In-Reply-To: (Stefan Monnier's message of "Thu, 09 Nov 2023 22:58:26 -0500") Message-ID: References: Date: Thu, 16 Nov 2023 17:28:24 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.027 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: 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 (---) --=-=-= Content-Type: text/plain > Draft patch below. More realistic patches below. Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-derived-mode-p-Take-MODES-as-a-single-argument.patch >From 6ccf21f1e3137012d0335fac05dfc476cc9ebec2 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 16 Nov 2023 17:21:18 -0500 Subject: [PATCH 1/2] (derived-mode-p): Take MODES as a single argument Looking at uses of `derived-mode-p` and `provide-mode-derived-p`, I can't find a single use case where it wouldn't be preferable for it to take a single argument instead of `&rest`: all the calls are either passing a single argument anyway, or passing a fixed list of modes. The use of `&rest` just makes the code less efficient and sometimes more clunky (because of the need for `apply`). So let's change that (while preserving backward compatibility, of course). * doc/lispref/modes.texi (Derived Modes): Adjust accordingly. * lisp/subr.el (provided-mode-derived-p, derived-mode-p): Take the `modes` as a single argument. --- doc/lispref/modes.texi | 6 +++++- lisp/subr.el | 26 +++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 130bc10cd59..1d60c3a01e0 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -932,9 +932,13 @@ Derived Modes @code{define-derived-mode} does that automatically. @end defmac -@defun derived-mode-p &rest modes +@defun derived-mode-p modes This function returns non-@code{nil} if the current major mode is derived from any of the major modes given by the symbols @var{modes}. +Instead of a list, @var{modes} can also be a single symbol. + +Furthermore, we still support a deprecated calling convention where the +@var{modes} were passed as separate arguments. @end defun The graph of major modes is accessed with the following lower-level diff --git a/lisp/subr.el b/lisp/subr.el index dcf49509177..dd01d79b1d0 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2782,19 +2782,31 @@ derived-mode-all-parents (cons mode (remq mode all-parents)) (put mode 'derived-mode--all-parents (cons mode all-parents)))))))) -(defun provided-mode-derived-p (mode &rest modes) +(defun provided-mode-derived-p (mode &optional modes &rest old-modes) "Non-nil if MODE is derived from one of MODES. -If you just want to check `major-mode', use `derived-mode-p'." - (declare (side-effect-free t)) +MODES can also be a single mode instead of a list. +If you just want to check `major-mode', use `derived-mode-p'. +We also still support the deprecated calling convention: +\(provided-mode-derived-p MODE &rest MODES)." + (declare (side-effect-free t) + (advertised-calling-convention (mode modes) "30.1")) + (cond + (old-modes (setq modes (cons modes old-modes))) + ((not (listp modes)) (setq modes (list modes)))) (let ((ps (derived-mode-all-parents mode))) (while (and modes (not (memq (car modes) ps))) (setq modes (cdr modes))) (car modes))) -(defun derived-mode-p (&rest modes) - "Non-nil if the current major mode is derived from one of MODES." - (declare (side-effect-free t)) - (apply #'provided-mode-derived-p major-mode modes)) +(defun derived-mode-p (&optional modes &rest old-modes) + "Non-nil if the current major mode is derived from one of MODES. +MODES can also be a single mode instead of a list. +We also still support the deprecated calling convention: +\(derived-mode-p &rest MODES)." + (declare (side-effect-free t) + (advertised-calling-convention (modes) "30.1")) + (provided-mode-derived-p major-mode (if old-modes (cons modes old-modes) + modes))) (defun derived-mode-set-parent (mode parent) "Declare PARENT to be the parent of MODE." -- 2.42.0 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-Adjust-affected-callers-of-derived-mode-p-to-use-the.patch >From 705f1c15469985cb6387663c85c4d29fc66729b9 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 13 Nov 2023 19:09:17 -0500 Subject: [PATCH 2/2] Adjust affected callers of derived-mode-p` to use the new convention * lisp/align.el (align-rules-list): Prefer `derived-mode-p` over `provided-mode-derived-p`. (align--rule-should-run): * lisp/window.el (display-buffer-reuse-mode-window): * lisp/whitespace.el (whitespace-enable-predicate): * lisp/transient.el (transient--do-suffix-p): * lisp/so-long.el (so-long--set-auto-mode): * lisp/simple.el (command-completion-with-modes-p): * lisp/progmodes/tcl.el (tcl-current-word): * lisp/progmodes/idlwave.el (idlwave-fix-keywords): * lisp/progmodes/gdb-mi.el (gdb, gdb-locals-mode-map) (gdb-registers-mode-map, gdb-function-buffer-p): * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-style-setter) (c-ts-mode-set-style): * lisp/progmodes/bug-reference.el (bug-reference--try-setup-gnus-article): * lisp/help-fns.el (help-fns--list-local-commands): * lisp/emulation/viper.el (viper-mode) (viper-this-major-mode-requires-vi-state): * lisp/emacs-lisp/easy-mmode.el (easy-mmode--globalized-predicate-p): * lisp/dired.el (dired-hide-details-mode, dired-click-to-select-mode): * lisp/calendar/todo-mode.el (todo-reset-nondiary-marker) (todo-reset-done-string, todo-reset-comment-string): * lisp/vc/vc.el (vc-deduce-backend): Use new calling convention for `derived-mode-p` and `provided-mode-derived-p`. --- lisp/align.el | 5 ++--- lisp/calendar/todo-mode.el | 6 +++--- lisp/dired.el | 4 ++-- lisp/emacs-lisp/easy-mmode.el | 2 +- lisp/emulation/viper.el | 10 +++++----- lisp/help-fns.el | 2 +- lisp/progmodes/bug-reference.el | 8 ++++---- lisp/progmodes/c-ts-mode.el | 4 ++-- lisp/progmodes/gdb-mi.el | 15 +++++++++------ lisp/progmodes/idlwave.el | 4 ++-- lisp/progmodes/tcl.el | 4 ++-- lisp/simple.el | 4 +--- lisp/so-long.el | 2 +- lisp/transient.el | 5 +++-- lisp/vc/vc.el | 2 +- lisp/whitespace.el | 4 ++-- lisp/window.el | 6 ++---- 17 files changed, 43 insertions(+), 44 deletions(-) diff --git a/lisp/align.el b/lisp/align.el index 9fa78525ecb..4daa20ddd2a 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -555,8 +555,7 @@ align-rules-list (repeat . t) (run-if . ,(lambda () (and (not (eq '- current-prefix-arg)) - (not (apply #'provided-mode-derived-p - major-mode align-tex-modes)))))) + (not (derived-mode-p align-tex-modes)))))) ;; With a negative prefix argument, lists of dollar figures will ;; be aligned. @@ -1286,7 +1285,7 @@ align--rule-should-run This is decided by the `modes' and `run-if' keys in the alist RULE. Their meaning is documented in `align-rules-list' (which see)." (let-alist rule - (not (or (and .modes (not (apply #'derived-mode-p (eval .modes)))) + (not (or (and .modes (not (derived-mode-p (eval .modes)))) (and .run-if (not (funcall .run-if))))))) (defun align-region (beg end separate rules exclude-rules diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 4f6a964eb4d..ab9d629d9fc 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -6350,7 +6350,7 @@ todo-reset-nondiary-marker (replace-match (nth 1 value) t t nil 2)) (forward-line))) (if buf - (when (derived-mode-p 'todo-mode 'todo-archive-mode) + (when (derived-mode-p '(todo-mode todo-archive-mode)) (todo-category-select)) (save-buffer) (kill-buffer))))))))) @@ -6394,7 +6394,7 @@ todo-reset-done-string (replace-match value t t nil 1) (forward-line))) (if buf - (when (derived-mode-p 'todo-mode 'todo-archive-mode) + (when (derived-mode-p '(todo-mode todo-archive-mode)) (todo-category-select)) (save-buffer) (kill-buffer))))))))) @@ -6420,7 +6420,7 @@ todo-reset-comment-string (replace-match value t t nil 1) (forward-line))) (if buf - (when (derived-mode-p 'todo-mode 'todo-archive-mode) + (when (derived-mode-p '(todo-mode todo-archive-mode)) (todo-category-select)) (save-buffer) (kill-buffer))))))))) diff --git a/lisp/dired.el b/lisp/dired.el index 8919d2c223f..3f488afaa3c 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3074,7 +3074,7 @@ dired-hide-details-mode See options: `dired-hide-details-hide-symlink-targets' and `dired-hide-details-hide-information-lines'." :group 'dired - (unless (derived-mode-p 'dired-mode 'wdired-mode) + (unless (derived-mode-p '(dired-mode wdired-mode)) (error "Not a Dired buffer")) (dired-hide-details-update-invisibility-spec) (if dired-hide-details-mode @@ -5096,7 +5096,7 @@ dired-click-to-select-mode completes." :group 'dired :lighter " Click-To-Select" - (unless (derived-mode-p 'dired-mode 'wdired-mode) + (unless (derived-mode-p '(dired-mode wdired-mode)) (error "Not a Dired buffer")) (if dired-click-to-select-mode (setq-local tool-bar-map diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 529f6e90e88..c9e7b3a4dfe 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -661,7 +661,7 @@ easy-mmode--globalized-predicate-p (throw 'found nil)) ((and (consp elem) (eq (car elem) 'not)) - (when (apply #'derived-mode-p (cdr elem)) + (when (derived-mode-p (cdr elem)) (throw 'found nil))) ((symbolp elem) (when (derived-mode-p elem) diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 96da914275b..767ad57c471 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -593,8 +593,8 @@ viper-mode )) (viper-set-expert-level 'dont-change-unless))) - (or (apply #'derived-mode-p viper-emacs-state-mode-list) ; don't switch to Vi - (apply #'derived-mode-p viper-insert-state-mode-list) ; don't switch + (or (derived-mode-p viper-emacs-state-mode-list) ; don't switch to Vi + (derived-mode-p viper-insert-state-mode-list) ; don't switch (viper-change-state-to-vi)) )) @@ -607,9 +607,9 @@ viper-mode ;; that are not listed in viper-vi-state-mode-list (defun viper-this-major-mode-requires-vi-state (mode) (let ((major-mode mode)) - (cond ((apply #'derived-mode-p viper-vi-state-mode-list) t) - ((apply #'derived-mode-p viper-emacs-state-mode-list) nil) - ((apply #'derived-mode-p viper-insert-state-mode-list) nil) + (cond ((derived-mode-p viper-vi-state-mode-list) t) + ((derived-mode-p viper-emacs-state-mode-list) nil) + ((derived-mode-p viper-insert-state-mode-list) nil) (t (and (eq (key-binding "a") 'self-insert-command) (eq (key-binding " ") 'self-insert-command)))))) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index e723d97cfc2..a8c60946121 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -2240,7 +2240,7 @@ help-fns--list-local-commands (not (get sym 'byte-obsolete-info)) ;; Ignore everything bound. (not (where-is-internal sym nil t)) - (apply #'derived-mode-p (command-modes sym))) + (derived-mode-p (command-modes sym))) (push sym functions)))) (with-temp-buffer (when functions diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 3f6e1e68e5b..0afed5276f5 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -467,10 +467,10 @@ bug-reference-mode (defun bug-reference--try-setup-gnus-article () (when (and bug-reference-mode ;; Only if enabled in article buffers. (derived-mode-p - 'gnus-article-mode - ;; Apparently, gnus-article-prepare-hook is run in the - ;; summary buffer... - 'gnus-summary-mode) + '(gnus-article-mode + ;; Apparently, `gnus-article-prepare-hook' is run in the + ;; summary buffer... + gnus-summary-mode)) gnus-article-buffer gnus-original-article-buffer (buffer-live-p (get-buffer gnus-article-buffer)) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 70717a90caa..a56ce26fc79 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -135,7 +135,7 @@ c-ts-mode--indent-style-setter res) (let ((buffer (car buffers))) (with-current-buffer buffer - (if (derived-mode-p 'c-ts-mode 'c++-ts-mode) + (if (derived-mode-p '(c-ts-mode c++-ts-mode)) (loop (append res (list buffer)) (cdr buffers)) (loop res (cdr buffers)))))))) @@ -193,7 +193,7 @@ c-ts-mode-set-style To set the default indent style globally, use `c-ts-mode-set-global-style'." (interactive (list (c-ts-mode--prompt-for-style))) - (if (not (derived-mode-p 'c-ts-mode 'c++-ts-mode)) + (if (not (derived-mode-p '(c-ts-mode c++-ts-mode))) (user-error "The current buffer is not in `c-ts-mode' nor `c++-ts-mode'") (setq-local c-ts-mode-indent-style style) (setq treesit-simple-indent-rules diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 3afdc59a67e..7ae4bcea1e1 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1006,9 +1006,10 @@ gdb (gud-def gud-pp (gud-call (concat - "pp " (if (eq (buffer-local-value - 'major-mode (window-buffer)) 'speedbar-mode) - (gdb-find-watch-expression) "%e")) arg) + "pp " (if (eq (buffer-local-value 'major-mode (window-buffer)) + 'speedbar-mode) + (gdb-find-watch-expression) "%e")) + arg) nil "Print the Emacs s-expression.") (define-key gud-minor-mode-map [left-margin mouse-1] @@ -4586,7 +4587,8 @@ gdb-locals-mode-map (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-registers-buffer - gdb-thread-number) t))) + gdb-thread-number) + t))) map)) (define-derived-mode gdb-locals-mode gdb-parent-mode "Locals" @@ -4706,7 +4708,8 @@ gdb-registers-mode-map (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-locals-buffer - gdb-thread-number) t))) + gdb-thread-number) + t))) (define-key map "f" #'gdb-registers-toggle-filter) map)) @@ -5106,7 +5109,7 @@ gdb-function-buffer-p not including main command buffer (the one where you type GDB commands) or source buffers (that display program source code)." (with-current-buffer buffer - (derived-mode-p 'gdb-parent-mode 'gdb-inferior-io-mode))) + (derived-mode-p '(gdb-parent-mode gdb-inferior-io-mode)))) (defun gdb--buffer-type (buffer) "Return the type of BUFFER if it is a function buffer. diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index d9eccacc48b..f60cc9372eb 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el @@ -6892,7 +6892,7 @@ idlwave-one-key-select ;; Display prompt and wait for quick reply (message "%s[%s]" prompt (mapconcat (lambda(x) (char-to-string (car x))) - keys-alist "")) + keys-alist)) (if (sit-for delay) ;; No quick reply: Show help (save-window-excursion @@ -7958,7 +7958,7 @@ idlwave-fix-keywords ;; If this is the OBJ_NEW function, try to figure out the class and use ;; the keywords from the corresponding INIT method. (if (and (equal (upcase name) "OBJ_NEW") - (derived-mode-p 'idlwave-mode 'idlwave-shell-mode)) + (derived-mode-p '(idlwave-mode idlwave-shell-mode))) (let* ((bos (save-excursion (idlwave-beginning-of-statement) (point))) (string (buffer-substring bos (point))) (case-fold-search t) diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el index ba0cbc8b066..b983c671cd9 100644 --- a/lisp/progmodes/tcl.el +++ b/lisp/progmodes/tcl.el @@ -1340,7 +1340,7 @@ tcl-current-word If FLAG is nil, just uses `current-word'. Otherwise scans backward for most likely Tcl command word." (if (and flag - (derived-mode-p 'tcl-mode 'inferior-tcl-mode)) + (derived-mode-p '(tcl-mode inferior-tcl-mode))) (condition-case nil (save-excursion ;; Look backward for first word actually in alist. @@ -1575,7 +1575,7 @@ tcl-quote (if (memq char '(?\[ ?\] ?{ ?} ?\\ ?\" ?$ ?\s ?\;)) (concat "\\" (char-to-string char)) (char-to-string char))) - string "")) + string)) diff --git a/lisp/simple.el b/lisp/simple.el index de6eed3fe8f..2e2d73e9bf4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2427,9 +2427,7 @@ command-completion-with-modes-p "Say whether MODES are in action in BUFFER. This is the case if either the major mode is derived from one of MODES, or (if one of MODES is a minor mode), if it is switched on in BUFFER." - (or (apply #'provided-mode-derived-p - (buffer-local-value 'major-mode buffer) - modes) + (or (provided-mode-derived-p (buffer-local-value 'major-mode buffer) modes) ;; It's a minor mode. (seq-intersection modes (buffer-local-value 'local-minor-modes buffer) diff --git a/lisp/so-long.el b/lisp/so-long.el index e5f7b81e717..d91002e873a 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el @@ -1716,7 +1716,7 @@ so-long--set-auto-mode (not so-long--inhibited) (not so-long--calling) (or (eq so-long-target-modes t) - (apply #'derived-mode-p so-long-target-modes)) + (derived-mode-p so-long-target-modes)) (setq so-long-detected-p (funcall so-long-predicate)) ;; `so-long' should be called; but only if and when the buffer is ;; displayed in a window. Long lines in invisible buffers are generally diff --git a/lisp/transient.el b/lisp/transient.el index 52c21871548..dd2b4e0db0b 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1959,10 +1959,11 @@ transient--do-suffix-p (if-not-mode (not (if (atom if-not-mode) (eq major-mode if-not-mode) (memq major-mode if-not-mode)))) - (if-derived (if (atom if-derived) + (if-derived (if (or (atom if-derived) (>= emacs-major-version 30)) (derived-mode-p if-derived) (apply #'derived-mode-p if-derived))) - (if-not-derived (not (if (atom if-not-derived) + (if-not-derived (not (if (or (atom if-not-derived) + (>= emacs-major-version 30)) (derived-mode-p if-not-derived) (apply #'derived-mode-p if-not-derived)))) (t default))) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index d768af678c3..1bd9ecb2193 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1084,7 +1084,7 @@ vc-deduce-backend ((derived-mode-p 'log-edit-mode) log-edit-vc-backend) ((derived-mode-p 'diff-mode) diff-vc-backend) ((or (null vc-deduce-backend-nonvc-modes) - (apply #'derived-mode-p vc-deduce-backend-nonvc-modes)) + (derived-mode-p vc-deduce-backend-nonvc-modes)) (ignore-errors (vc-responsible-backend default-directory))) (vc-mode (vc-backend buffer-file-name)))) diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 86fc179396e..f4095c99089 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -1026,8 +1026,8 @@ whitespace-enable-predicate ((eq whitespace-global-modes t)) ((listp whitespace-global-modes) (if (eq (car-safe whitespace-global-modes) 'not) - (not (apply #'derived-mode-p (cdr whitespace-global-modes))) - (apply #'derived-mode-p whitespace-global-modes))) + (not (derived-mode-p (cdr whitespace-global-modes))) + (derived-mode-p whitespace-global-modes))) (t nil)) ;; ...we have a display (not running a batch job) (not noninteractive) diff --git a/lisp/window.el b/lisp/window.el index 06d5cfc0077..0c5ccf167dc 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8054,10 +8054,8 @@ display-buffer-reuse-mode-window (dolist (window windows) (let ((mode? (with-current-buffer (window-buffer window) - (cond ((memq major-mode allowed-modes) - 'same) - ((apply #'derived-mode-p allowed-modes) - 'derived))))) + (cond ((memq major-mode allowed-modes) 'same) + ((derived-mode-p allowed-modes) 'derived))))) (when (and mode? (not (and inhibit-same-window-p (eq window curwin)))) -- 2.42.0 --=-=-=-- From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Nov 2023 22:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Daniel Mendler Cc: 67034@debbugs.gnu.org Received: via spool by 67034-submit@debbugs.gnu.org id=B67034.170017429112945 (code B ref 67034); Thu, 16 Nov 2023 22:39:02 +0000 Received: (at 67034) by debbugs.gnu.org; 16 Nov 2023 22:38:11 +0000 Received: from localhost ([127.0.0.1]:44800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3kzy-0003Mh-SF for submit@debbugs.gnu.org; Thu, 16 Nov 2023 17:38:11 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11584) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3kzw-0003MU-P8 for 67034@debbugs.gnu.org; Thu, 16 Nov 2023 17:38:09 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A770380595; Thu, 16 Nov 2023 17:38:02 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1700174281; bh=VSBLW7ykDi6JeEDRGtf0dFpVY72fQ2cjGeO3vourRUA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=UGbubxzMRVyrvASDEaROEI/LFTh0SNSixW6Nw+QtLN6QrYiczLJwXIuIogOitYZId SM1R0MUkDPNvrfJZhnCsIc72vvBeqg2mAgAjj7dxFrCxkLrMETizdnwXHTC4c3++9u XA+9+nuL15xdbMP/Nz+ksQw3RbcAKBi8ipLQDmD4E71v/6dwpzxm92mzc2i9fh8Uqv OSZ7MuF3v5gwVoDRO7QKAk83S5jOwN0gYACsUjwnR2ugO8ZyVxfmVk79wBrxKcXPda 2gqMliRaVwPa+rTVCLePG5/odLbkyWR0Ame9gzKAjKaqKq0WNhEQK1AxjvCcotRlF6 DvMJ4kyS6u2/A== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 859F98076B; Thu, 16 Nov 2023 17:38:01 -0500 (EST) Received: from pastel (unknown [45.72.227.120]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 5F4A11203EF; Thu, 16 Nov 2023 17:38:01 -0500 (EST) From: Stefan Monnier In-Reply-To: <96367d39-4861-41e6-9383-a9a18efa0678@daniel-mendler.de> (Daniel Mendler's message of "Fri, 10 Nov 2023 13:18:32 +0100") Message-ID: References: <96367d39-4861-41e6-9383-a9a18efa0678@daniel-mendler.de> Date: Thu, 16 Nov 2023 17:38:00 -0500 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.021 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: 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 (---) > This change would affect many packages. I grepped through my elpa > directory and found multiple uses of derived-mode-p and > provided-mode-derived-p with multiple arguments as shortcuts: > > (derived-mode-p 'mode1 'mode2) instead of (or (derived-mode-p 'mode1) > (derived-mode-p 'mode2) With the new convention the code would be (derived-mode-p '(mode1 mode2)) which seems just as good. > There are also multiple call sites with apply, but these would be > arguably nicer if derived-mode-p takes a list argument as proposed. Exactly. > Still, do the benefits of this change outweigh the required changes? I think they do, especially since we preserve backward compatibility, so the change can be done progressively. > I wonder if this extra allocation of &rest makes any difference in any > benchmark, though. I hope not, tho I've seen several situations where the cost of apply+&rest dominates execution time (mostly because of the time spent in the GC collecting the allocated cons cells), so it's within the realm of possible. Note that the recent introduction of `derived-mode-all-parents` should already have made `derived-mode-p` faster (tho it wasn't the purpose). Stefan From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Nov 2023 08:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Stefan Monnier Cc: 67034@debbugs.gnu.org Received: via spool by 67034-submit@debbugs.gnu.org id=B67034.170020949114350 (code B ref 67034); Fri, 17 Nov 2023 08:25:01 +0000 Received: (at 67034) by debbugs.gnu.org; 17 Nov 2023 08:24:51 +0000 Received: from localhost ([127.0.0.1]:45075 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3u9i-0003jO-Jh for submit@debbugs.gnu.org; Fri, 17 Nov 2023 03:24:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3u9c-0003j6-Vd for 67034@debbugs.gnu.org; Fri, 17 Nov 2023 03:24:48 -0500 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 1r3u9V-00017H-SA; Fri, 17 Nov 2023 03:24:38 -0500 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=TbWVwWPzeQV05osOvsuc5QjVriouPLKpbrYUXKVxsdA=; b=m+5+rHrTK+Dj N5tTzNVbq/P6YV16gVnrFE+S1Sn5achavFT8RZhmdt9kr2ukvFvGYNEBrmJyEi+Lj09saZrNTjgx7 +9zoj+Xy+VLZAS2Es+6fQ/WbSNqKtNmodJARvgRZofIH0KM9VoHz3431U2gO/ryeqKrGBHvamatsq yWFuRXXa4PY5O5N4x5621QJrRfOIR7SdTv9w2n/lPbooqh44jEUvrw4xDum5wf8afmzGyh6j77svm 6+zyquKOqMSWdDkRilct43rbsEwSWUWb2tVEtdWvcA9UG8zuSRizOW48V+8dXZ3y0Nlnp6LCeEFm3 1VpDtp1jXZ0QEWPIDwyAjw==; Date: Fri, 17 Nov 2023 10:24:32 +0200 Message-Id: <83y1ewokhr.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (bug-gnu-emacs@gnu.org) References: 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 (---) > Date: Thu, 16 Nov 2023 17:28:24 -0500 > From: Stefan Monnier via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > -@defun derived-mode-p &rest modes > +@defun derived-mode-p modes > This function returns non-@code{nil} if the current major mode is > derived from any of the major modes given by the symbols @var{modes}. > +Instead of a list, @var{modes} can also be a single symbol. If MODES is supposed to be a list, then why does the first sentence say "given by the symbols MODES"? It should probably say "given by the list of symbols in MODES" instead, right? And the last sentence would be a tad less confusing if it said Instead of a list, @var{modes} can also be a single mode symbol. > -(defun provided-mode-derived-p (mode &rest modes) > +(defun provided-mode-derived-p (mode &optional modes &rest old-modes) > "Non-nil if MODE is derived from one of MODES. This should IMO say Non-nil if MODE is derived from a mode that is a member of the list MODES. > +(defun derived-mode-p (&optional modes &rest old-modes) > + "Non-nil if the current major mode is derived from one of MODES. Likewise here. Thanks. From unknown Sun Jun 22 07:49:27 2025 X-Loop: help-debbugs@gnu.org Subject: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Nov 2023 21:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67034 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 67034@debbugs.gnu.org Received: via spool by 67034-submit@debbugs.gnu.org id=B67034.170025594020938 (code B ref 67034); Fri, 17 Nov 2023 21:19:01 +0000 Received: (at 67034) by debbugs.gnu.org; 17 Nov 2023 21:19:00 +0000 Received: from localhost ([127.0.0.1]:47237 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r46Et-0005Rd-Co for submit@debbugs.gnu.org; Fri, 17 Nov 2023 16:19:00 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:22800) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r46Eo-0005RN-Ud for 67034@debbugs.gnu.org; Fri, 17 Nov 2023 16:18:58 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C925A444314; Fri, 17 Nov 2023 16:18:48 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1700255920; bh=yKznJ0WDumUGWEVvB2O1Ua7o+cTWt74/eIje1Vb818s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=C7WbT7oZVcKWTNlx2FiIfA9mJAywu3UZhn/JVd8mkQuogA56gQE8pWQxOhiw7WZf2 Ce1AUsojxmYG7GWrJ0YC94A43UAH+UXbS71KNRiy2NLbyyr6RS6c8IDMI3EFIr8Ob9 20EX4sE0Wy1QKyEkJqKzQxbg0flU/11D66YT0nCsEBSK3VmdwdEnH+LHHNE3hjRSwA sXjirKO3BCKMiairFWSZm2l6Jvuef/ikH1nRaKHl/zA/5V9lzGOtm2rjqIWrOvpm3L W9qrkvsSGbGYU5m5WFmn8TWbzsPW9dh0i8hhJG0bockEOuAbxUjQr46/pr1p/A06MP bhlmqSuKqluqg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 20AC9444322; Fri, 17 Nov 2023 16:18:40 -0500 (EST) Received: from pastel (unknown [45.72.227.120]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EC9DC12017B; Fri, 17 Nov 2023 16:18:39 -0500 (EST) From: Stefan Monnier In-Reply-To: <83y1ewokhr.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 17 Nov 2023 10:24:32 +0200") Message-ID: References: <83y1ewokhr.fsf@gnu.org> Date: Fri, 17 Nov 2023 16:18:39 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.027 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: 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 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> -@defun derived-mode-p &rest modes >> +@defun derived-mode-p modes >> This function returns non-@code{nil} if the current major mode is >> derived from any of the major modes given by the symbols @var{modes}. >> +Instead of a list, @var{modes} can also be a single symbol. > > If MODES is supposed to be a list, then why does the first sentence > say "given by the symbols MODES"? Oh, right, in the current text, the `&rest modes` makes it clear that `modes` is a list, whereas with my change we need to spell it out more clearly. > And the last sentence would be a tad less confusing if it said > > Instead of a list, @var{modes} can also be a single mode symbol. Done. >> -(defun provided-mode-derived-p (mode &rest modes) >> +(defun provided-mode-derived-p (mode &optional modes &rest old-modes) >> "Non-nil if MODE is derived from one of MODES. > > This should IMO say > > Non-nil if MODE is derived from a mode that is a member of the list MOD= ES. Changed (tho it now goes over the 72 columns =F0=9F=99=81). >> +(defun derived-mode-p (&optional modes &rest old-modes) >> + "Non-nil if the current major mode is derived from one of MODES. > Likewise here. I'm having trouble making this change fit into the 80 columns limit, so I left this first line unchanged and reworked the second line to clarify that MODES should be a list of symbols. Stefan --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-derived-mode-p-Take-MODES-as-a-single-argument.patch >From f51c65125176a271c9b1f57d67456bede1bc8e80 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Thu, 16 Nov 2023 17:21:18 -0500 Subject: [PATCH 1/2] (derived-mode-p): Take MODES as a single argument Looking at uses of `derived-mode-p` and `provide-mode-derived-p`, I can't find a single use case where it wouldn't be preferable for it to take a single argument instead of `&rest`: all the calls are either passing a single argument anyway, or passing a fixed list of modes. The use of `&rest` just makes the code less efficient and sometimes more clunky (because of the need for `apply`). So let's change that (while preserving backward compatibility, of course). * doc/lispref/modes.texi (Derived Modes): Adjust accordingly. * lisp/subr.el (provided-mode-derived-p, derived-mode-p): Take the `modes` as a single argument. --- doc/lispref/modes.texi | 9 +++++++-- lisp/subr.el | 28 ++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 130bc10cd59..a0fc3463a06 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -932,9 +932,14 @@ Derived Modes @code{define-derived-mode} does that automatically. @end defmac -@defun derived-mode-p &rest modes +@defun derived-mode-p modes This function returns non-@code{nil} if the current major mode is -derived from any of the major modes given by the symbols @var{modes}. +derived from any of the major modes given by the list of symbols +in @var{modes}. +Instead of a list, @var{modes} can also be a single mode symbol. + +Furthermore, we still support a deprecated calling convention where the +@var{modes} were passed as separate arguments. @end defun The graph of major modes is accessed with the following lower-level diff --git a/lisp/subr.el b/lisp/subr.el index dcf49509177..304b71e6168 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2782,19 +2782,31 @@ derived-mode-all-parents (cons mode (remq mode all-parents)) (put mode 'derived-mode--all-parents (cons mode all-parents)))))))) -(defun provided-mode-derived-p (mode &rest modes) - "Non-nil if MODE is derived from one of MODES. -If you just want to check `major-mode', use `derived-mode-p'." - (declare (side-effect-free t)) +(defun provided-mode-derived-p (mode &optional modes &rest old-modes) + "Non-nil if MODE is derived from a mode that is a member of the list MODES. +MODES can also be a single mode instead of a list. +If you just want to check `major-mode', use `derived-mode-p'. +We also still support the deprecated calling convention: +\(provided-mode-derived-p MODE &rest MODES)." + (declare (side-effect-free t) + (advertised-calling-convention (mode modes) "30.1")) + (cond + (old-modes (setq modes (cons modes old-modes))) + ((not (listp modes)) (setq modes (list modes)))) (let ((ps (derived-mode-all-parents mode))) (while (and modes (not (memq (car modes) ps))) (setq modes (cdr modes))) (car modes))) -(defun derived-mode-p (&rest modes) - "Non-nil if the current major mode is derived from one of MODES." - (declare (side-effect-free t)) - (apply #'provided-mode-derived-p major-mode modes)) +(defun derived-mode-p (&optional modes &rest old-modes) + "Non-nil if the current major mode is derived from one of MODES. +MODES should be a list of symbols or a single mode symbol instead of a list. +We also still support the deprecated calling convention: +\(derived-mode-p &rest MODES)." + (declare (side-effect-free t) + (advertised-calling-convention (modes) "30.1")) + (provided-mode-derived-p major-mode (if old-modes (cons modes old-modes) + modes))) (defun derived-mode-set-parent (mode parent) "Declare PARENT to be the parent of MODE." -- 2.42.0 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-Adjust-affected-callers-of-derived-mode-p-to-use-the.patch >From 1cb5471be64cea47738a4cbe30eda8d32f6bd3b6 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 13 Nov 2023 19:09:17 -0500 Subject: [PATCH 2/2] Adjust affected callers of derived-mode-p` to use the new convention * lisp/align.el (align-rules-list): Prefer `derived-mode-p` over `provided-mode-derived-p`. (align--rule-should-run): * lisp/window.el (display-buffer-reuse-mode-window): * lisp/whitespace.el (whitespace-enable-predicate): * lisp/transient.el (transient--do-suffix-p): * lisp/so-long.el (so-long--set-auto-mode): * lisp/simple.el (command-completion-with-modes-p): * lisp/progmodes/tcl.el (tcl-current-word): * lisp/progmodes/idlwave.el (idlwave-fix-keywords): * lisp/progmodes/gdb-mi.el (gdb, gdb-locals-mode-map) (gdb-registers-mode-map, gdb-function-buffer-p): * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-style-setter) (c-ts-mode-set-style): * lisp/progmodes/bug-reference.el (bug-reference--try-setup-gnus-article): * lisp/help-fns.el (help-fns--list-local-commands): * lisp/emulation/viper.el (viper-mode) (viper-this-major-mode-requires-vi-state): * lisp/emacs-lisp/easy-mmode.el (easy-mmode--globalized-predicate-p): * lisp/dired.el (dired-hide-details-mode, dired-click-to-select-mode): * lisp/calendar/todo-mode.el (todo-reset-nondiary-marker) (todo-reset-done-string, todo-reset-comment-string): * lisp/vc/vc.el (vc-deduce-backend): Use new calling convention for `derived-mode-p` and `provided-mode-derived-p`. --- lisp/align.el | 5 ++--- lisp/calendar/todo-mode.el | 6 +++--- lisp/dired.el | 4 ++-- lisp/emacs-lisp/easy-mmode.el | 2 +- lisp/emulation/viper.el | 10 +++++----- lisp/help-fns.el | 2 +- lisp/progmodes/bug-reference.el | 8 ++++---- lisp/progmodes/c-ts-mode.el | 4 ++-- lisp/progmodes/gdb-mi.el | 15 +++++++++------ lisp/progmodes/idlwave.el | 4 ++-- lisp/progmodes/tcl.el | 4 ++-- lisp/simple.el | 4 +--- lisp/so-long.el | 2 +- lisp/transient.el | 5 +++-- lisp/vc/vc.el | 2 +- lisp/whitespace.el | 4 ++-- lisp/window.el | 6 ++---- 17 files changed, 43 insertions(+), 44 deletions(-) diff --git a/lisp/align.el b/lisp/align.el index 9fa78525ecb..4daa20ddd2a 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -555,8 +555,7 @@ align-rules-list (repeat . t) (run-if . ,(lambda () (and (not (eq '- current-prefix-arg)) - (not (apply #'provided-mode-derived-p - major-mode align-tex-modes)))))) + (not (derived-mode-p align-tex-modes)))))) ;; With a negative prefix argument, lists of dollar figures will ;; be aligned. @@ -1286,7 +1285,7 @@ align--rule-should-run This is decided by the `modes' and `run-if' keys in the alist RULE. Their meaning is documented in `align-rules-list' (which see)." (let-alist rule - (not (or (and .modes (not (apply #'derived-mode-p (eval .modes)))) + (not (or (and .modes (not (derived-mode-p (eval .modes)))) (and .run-if (not (funcall .run-if))))))) (defun align-region (beg end separate rules exclude-rules diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el index 4f6a964eb4d..ab9d629d9fc 100644 --- a/lisp/calendar/todo-mode.el +++ b/lisp/calendar/todo-mode.el @@ -6350,7 +6350,7 @@ todo-reset-nondiary-marker (replace-match (nth 1 value) t t nil 2)) (forward-line))) (if buf - (when (derived-mode-p 'todo-mode 'todo-archive-mode) + (when (derived-mode-p '(todo-mode todo-archive-mode)) (todo-category-select)) (save-buffer) (kill-buffer))))))))) @@ -6394,7 +6394,7 @@ todo-reset-done-string (replace-match value t t nil 1) (forward-line))) (if buf - (when (derived-mode-p 'todo-mode 'todo-archive-mode) + (when (derived-mode-p '(todo-mode todo-archive-mode)) (todo-category-select)) (save-buffer) (kill-buffer))))))))) @@ -6420,7 +6420,7 @@ todo-reset-comment-string (replace-match value t t nil 1) (forward-line))) (if buf - (when (derived-mode-p 'todo-mode 'todo-archive-mode) + (when (derived-mode-p '(todo-mode todo-archive-mode)) (todo-category-select)) (save-buffer) (kill-buffer))))))))) diff --git a/lisp/dired.el b/lisp/dired.el index 8919d2c223f..3f488afaa3c 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -3074,7 +3074,7 @@ dired-hide-details-mode See options: `dired-hide-details-hide-symlink-targets' and `dired-hide-details-hide-information-lines'." :group 'dired - (unless (derived-mode-p 'dired-mode 'wdired-mode) + (unless (derived-mode-p '(dired-mode wdired-mode)) (error "Not a Dired buffer")) (dired-hide-details-update-invisibility-spec) (if dired-hide-details-mode @@ -5096,7 +5096,7 @@ dired-click-to-select-mode completes." :group 'dired :lighter " Click-To-Select" - (unless (derived-mode-p 'dired-mode 'wdired-mode) + (unless (derived-mode-p '(dired-mode wdired-mode)) (error "Not a Dired buffer")) (if dired-click-to-select-mode (setq-local tool-bar-map diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 529f6e90e88..c9e7b3a4dfe 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -661,7 +661,7 @@ easy-mmode--globalized-predicate-p (throw 'found nil)) ((and (consp elem) (eq (car elem) 'not)) - (when (apply #'derived-mode-p (cdr elem)) + (when (derived-mode-p (cdr elem)) (throw 'found nil))) ((symbolp elem) (when (derived-mode-p elem) diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el index 96da914275b..767ad57c471 100644 --- a/lisp/emulation/viper.el +++ b/lisp/emulation/viper.el @@ -593,8 +593,8 @@ viper-mode )) (viper-set-expert-level 'dont-change-unless))) - (or (apply #'derived-mode-p viper-emacs-state-mode-list) ; don't switch to Vi - (apply #'derived-mode-p viper-insert-state-mode-list) ; don't switch + (or (derived-mode-p viper-emacs-state-mode-list) ; don't switch to Vi + (derived-mode-p viper-insert-state-mode-list) ; don't switch (viper-change-state-to-vi)) )) @@ -607,9 +607,9 @@ viper-mode ;; that are not listed in viper-vi-state-mode-list (defun viper-this-major-mode-requires-vi-state (mode) (let ((major-mode mode)) - (cond ((apply #'derived-mode-p viper-vi-state-mode-list) t) - ((apply #'derived-mode-p viper-emacs-state-mode-list) nil) - ((apply #'derived-mode-p viper-insert-state-mode-list) nil) + (cond ((derived-mode-p viper-vi-state-mode-list) t) + ((derived-mode-p viper-emacs-state-mode-list) nil) + ((derived-mode-p viper-insert-state-mode-list) nil) (t (and (eq (key-binding "a") 'self-insert-command) (eq (key-binding " ") 'self-insert-command)))))) diff --git a/lisp/help-fns.el b/lisp/help-fns.el index e723d97cfc2..a8c60946121 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -2240,7 +2240,7 @@ help-fns--list-local-commands (not (get sym 'byte-obsolete-info)) ;; Ignore everything bound. (not (where-is-internal sym nil t)) - (apply #'derived-mode-p (command-modes sym))) + (derived-mode-p (command-modes sym))) (push sym functions)))) (with-temp-buffer (when functions diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el index 3f6e1e68e5b..0afed5276f5 100644 --- a/lisp/progmodes/bug-reference.el +++ b/lisp/progmodes/bug-reference.el @@ -467,10 +467,10 @@ bug-reference-mode (defun bug-reference--try-setup-gnus-article () (when (and bug-reference-mode ;; Only if enabled in article buffers. (derived-mode-p - 'gnus-article-mode - ;; Apparently, gnus-article-prepare-hook is run in the - ;; summary buffer... - 'gnus-summary-mode) + '(gnus-article-mode + ;; Apparently, `gnus-article-prepare-hook' is run in the + ;; summary buffer... + gnus-summary-mode)) gnus-article-buffer gnus-original-article-buffer (buffer-live-p (get-buffer gnus-article-buffer)) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 70717a90caa..a56ce26fc79 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -135,7 +135,7 @@ c-ts-mode--indent-style-setter res) (let ((buffer (car buffers))) (with-current-buffer buffer - (if (derived-mode-p 'c-ts-mode 'c++-ts-mode) + (if (derived-mode-p '(c-ts-mode c++-ts-mode)) (loop (append res (list buffer)) (cdr buffers)) (loop res (cdr buffers)))))))) @@ -193,7 +193,7 @@ c-ts-mode-set-style To set the default indent style globally, use `c-ts-mode-set-global-style'." (interactive (list (c-ts-mode--prompt-for-style))) - (if (not (derived-mode-p 'c-ts-mode 'c++-ts-mode)) + (if (not (derived-mode-p '(c-ts-mode c++-ts-mode))) (user-error "The current buffer is not in `c-ts-mode' nor `c++-ts-mode'") (setq-local c-ts-mode-indent-style style) (setq treesit-simple-indent-rules diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 3afdc59a67e..7ae4bcea1e1 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1006,9 +1006,10 @@ gdb (gud-def gud-pp (gud-call (concat - "pp " (if (eq (buffer-local-value - 'major-mode (window-buffer)) 'speedbar-mode) - (gdb-find-watch-expression) "%e")) arg) + "pp " (if (eq (buffer-local-value 'major-mode (window-buffer)) + 'speedbar-mode) + (gdb-find-watch-expression) "%e")) + arg) nil "Print the Emacs s-expression.") (define-key gud-minor-mode-map [left-margin mouse-1] @@ -4586,7 +4587,8 @@ gdb-locals-mode-map (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-registers-buffer - gdb-thread-number) t))) + gdb-thread-number) + t))) map)) (define-derived-mode gdb-locals-mode gdb-parent-mode "Locals" @@ -4706,7 +4708,8 @@ gdb-registers-mode-map (gdb-set-window-buffer (gdb-get-buffer-create 'gdb-locals-buffer - gdb-thread-number) t))) + gdb-thread-number) + t))) (define-key map "f" #'gdb-registers-toggle-filter) map)) @@ -5106,7 +5109,7 @@ gdb-function-buffer-p not including main command buffer (the one where you type GDB commands) or source buffers (that display program source code)." (with-current-buffer buffer - (derived-mode-p 'gdb-parent-mode 'gdb-inferior-io-mode))) + (derived-mode-p '(gdb-parent-mode gdb-inferior-io-mode)))) (defun gdb--buffer-type (buffer) "Return the type of BUFFER if it is a function buffer. diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index d9eccacc48b..f60cc9372eb 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el @@ -6892,7 +6892,7 @@ idlwave-one-key-select ;; Display prompt and wait for quick reply (message "%s[%s]" prompt (mapconcat (lambda(x) (char-to-string (car x))) - keys-alist "")) + keys-alist)) (if (sit-for delay) ;; No quick reply: Show help (save-window-excursion @@ -7958,7 +7958,7 @@ idlwave-fix-keywords ;; If this is the OBJ_NEW function, try to figure out the class and use ;; the keywords from the corresponding INIT method. (if (and (equal (upcase name) "OBJ_NEW") - (derived-mode-p 'idlwave-mode 'idlwave-shell-mode)) + (derived-mode-p '(idlwave-mode idlwave-shell-mode))) (let* ((bos (save-excursion (idlwave-beginning-of-statement) (point))) (string (buffer-substring bos (point))) (case-fold-search t) diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el index ba0cbc8b066..b983c671cd9 100644 --- a/lisp/progmodes/tcl.el +++ b/lisp/progmodes/tcl.el @@ -1340,7 +1340,7 @@ tcl-current-word If FLAG is nil, just uses `current-word'. Otherwise scans backward for most likely Tcl command word." (if (and flag - (derived-mode-p 'tcl-mode 'inferior-tcl-mode)) + (derived-mode-p '(tcl-mode inferior-tcl-mode))) (condition-case nil (save-excursion ;; Look backward for first word actually in alist. @@ -1575,7 +1575,7 @@ tcl-quote (if (memq char '(?\[ ?\] ?{ ?} ?\\ ?\" ?$ ?\s ?\;)) (concat "\\" (char-to-string char)) (char-to-string char))) - string "")) + string)) diff --git a/lisp/simple.el b/lisp/simple.el index de6eed3fe8f..2e2d73e9bf4 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2427,9 +2427,7 @@ command-completion-with-modes-p "Say whether MODES are in action in BUFFER. This is the case if either the major mode is derived from one of MODES, or (if one of MODES is a minor mode), if it is switched on in BUFFER." - (or (apply #'provided-mode-derived-p - (buffer-local-value 'major-mode buffer) - modes) + (or (provided-mode-derived-p (buffer-local-value 'major-mode buffer) modes) ;; It's a minor mode. (seq-intersection modes (buffer-local-value 'local-minor-modes buffer) diff --git a/lisp/so-long.el b/lisp/so-long.el index e5f7b81e717..d91002e873a 100644 --- a/lisp/so-long.el +++ b/lisp/so-long.el @@ -1716,7 +1716,7 @@ so-long--set-auto-mode (not so-long--inhibited) (not so-long--calling) (or (eq so-long-target-modes t) - (apply #'derived-mode-p so-long-target-modes)) + (derived-mode-p so-long-target-modes)) (setq so-long-detected-p (funcall so-long-predicate)) ;; `so-long' should be called; but only if and when the buffer is ;; displayed in a window. Long lines in invisible buffers are generally diff --git a/lisp/transient.el b/lisp/transient.el index 52c21871548..dd2b4e0db0b 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -1959,10 +1959,11 @@ transient--do-suffix-p (if-not-mode (not (if (atom if-not-mode) (eq major-mode if-not-mode) (memq major-mode if-not-mode)))) - (if-derived (if (atom if-derived) + (if-derived (if (or (atom if-derived) (>= emacs-major-version 30)) (derived-mode-p if-derived) (apply #'derived-mode-p if-derived))) - (if-not-derived (not (if (atom if-not-derived) + (if-not-derived (not (if (or (atom if-not-derived) + (>= emacs-major-version 30)) (derived-mode-p if-not-derived) (apply #'derived-mode-p if-not-derived)))) (t default))) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index d768af678c3..1bd9ecb2193 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -1084,7 +1084,7 @@ vc-deduce-backend ((derived-mode-p 'log-edit-mode) log-edit-vc-backend) ((derived-mode-p 'diff-mode) diff-vc-backend) ((or (null vc-deduce-backend-nonvc-modes) - (apply #'derived-mode-p vc-deduce-backend-nonvc-modes)) + (derived-mode-p vc-deduce-backend-nonvc-modes)) (ignore-errors (vc-responsible-backend default-directory))) (vc-mode (vc-backend buffer-file-name)))) diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 86fc179396e..f4095c99089 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -1026,8 +1026,8 @@ whitespace-enable-predicate ((eq whitespace-global-modes t)) ((listp whitespace-global-modes) (if (eq (car-safe whitespace-global-modes) 'not) - (not (apply #'derived-mode-p (cdr whitespace-global-modes))) - (apply #'derived-mode-p whitespace-global-modes))) + (not (derived-mode-p (cdr whitespace-global-modes))) + (derived-mode-p whitespace-global-modes))) (t nil)) ;; ...we have a display (not running a batch job) (not noninteractive) diff --git a/lisp/window.el b/lisp/window.el index 06d5cfc0077..0c5ccf167dc 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -8054,10 +8054,8 @@ display-buffer-reuse-mode-window (dolist (window windows) (let ((mode? (with-current-buffer (window-buffer window) - (cond ((memq major-mode allowed-modes) - 'same) - ((apply #'derived-mode-p allowed-modes) - 'derived))))) + (cond ((memq major-mode allowed-modes) 'same) + ((derived-mode-p allowed-modes) 'derived))))) (when (and mode? (not (and inhibit-same-window-p (eq window curwin)))) -- 2.42.0 --=-=-=-- From unknown Sun Jun 22 07:49:27 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Stefan Monnier Subject: bug#67034: closed (Re: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg) Message-ID: References: X-Gnu-PR-Message: they-closed 67034 X-Gnu-PR-Package: emacs Reply-To: 67034@debbugs.gnu.org Date: Thu, 23 Nov 2023 17:01:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1700758862-31809-1" This is a multi-part message in MIME format... ------------=_1700758862-31809-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #67034: 30.0.50; Make `derived-mode-p` take a single arg which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 67034@debbugs.gnu.org. --=20 67034: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D67034 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1700758862-31809-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 67034-done) by debbugs.gnu.org; 23 Nov 2023 17:00:46 +0000 Received: from localhost ([127.0.0.1]:35018 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6D4I-0007hX-3B for submit@debbugs.gnu.org; Thu, 23 Nov 2023 12:00:46 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:62492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r6D4G-0007ST-EJ for 67034-done@debbugs.gnu.org; Thu, 23 Nov 2023 12:00:44 -0500 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id D21AA80781; Thu, 23 Nov 2023 12:00:34 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1700758834; bh=MFCtcbbWUqbkdZO12yYD2AbfMEaOoOria8pyZQj/ows=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=eWJH2Qdtrf4mpMWmRZmbtaP+62Zy8S5qSEBSQvwY2TI8kJOPtmt+4isVcZnMNyYpo cd4DI1O8liMn2WDFfV26wyJLN713cjEr+hPZeq84L8fNMu9fX99wmiFPkDfeEcFwRb m4tUGuynN5mA0Iy8l/UCZG3nT2/LSYFCgFHBMxck8zu3yqoLTDhqCK+q2I2QK58fyp iEI7elRCSf/C0JhAy9lOPRT2VDery2Fy02f/Hy2FHGF4o9h/2YrGcrphcmI6Te+xrV S1lJlD9A1lDByE+lv1hViq+UsRdEUHeKSdVnH0xQ9yY7LthDR2b4+G/0py6oUYnaoi KsIaV85IgoJCg== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 055888025F; Thu, 23 Nov 2023 12:00:34 -0500 (EST) Received: from alfajor (modemcable005.21-80-70.mc.videotron.ca [70.80.21.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D68EF1202E0; Thu, 23 Nov 2023 12:00:33 -0500 (EST) From: Stefan Monnier To: Eli Zaretskii Subject: Re: bug#67034: 30.0.50; Make `derived-mode-p` take a single arg In-Reply-To: (Stefan Monnier's message of "Fri, 17 Nov 2023 16:18:39 -0500") Message-ID: References: <83y1ewokhr.fsf@gnu.org> Date: Thu, 23 Nov 2023 12:00:33 -0500 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.239 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 67034-done Cc: 67034-done@debbugs.gnu.org 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 (---) Pushed, thanks, Stefan ------------=_1700758862-31809-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 10 Nov 2023 03:59:20 +0000 Received: from localhost ([127.0.0.1]:49278 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1Ifv-0008IT-Ps for submit@debbugs.gnu.org; Thu, 09 Nov 2023 22:59:20 -0500 Received: from lists.gnu.org ([2001:470:142::17]:40034) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r1Ifs-0008ID-Ra for submit@debbugs.gnu.org; Thu, 09 Nov 2023 22:59:19 -0500 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 1r1IfA-0001La-1l for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 22:58:32 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r1If8-0000BY-87 for bug-gnu-emacs@gnu.org; Thu, 09 Nov 2023 22:58:31 -0500 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CCD711000AD for ; Thu, 9 Nov 2023 22:58:27 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1699588707; bh=sHckZheSuMiGB0ASZmYzivqvRZaTaDs2IEku+qrSigs=; h=From:To:Subject:Date:From; b=mJm0y2mMGMp66w1Ov/iWpMfIx1dN5Hcd6fQ+oT7QYohnbNNA2YZk5pWb5BNXU20qt TzA1YTqKQOcZAonhCBZ6uCoY9ThnVBpqgWdZhuR6qVVpi7aIHDcsb8Z3B1kU7tDtqi ODjKQliCxsrnyYE+hCHRzYoCAQEsA2+q4WKgKPuBxOXOFzhndmQy9tMv5B4iqXUb8U 8LMuQgXKvYzv7M8C78GxWFlk/6jCnpjzIjp7EJDyXgvRaRNH6rBwQLW2WV3dbk7Ok1 oNZ8lZY5ECxtNUCy8hQKvNOxmEIhYyuZAVxppcGtTB5HA+iGa2S7uENVRX3S6xT2ZA vipNYb/P5uKLw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 14579100061 for ; Thu, 9 Nov 2023 22:58:27 -0500 (EST) Received: from pastel (unknown [45.72.227.120]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id ED7D91203DD for ; Thu, 9 Nov 2023 22:58:26 -0500 (EST) From: Stefan Monnier To: bug-gnu-emacs@gnu.org Subject: 30.0.50; Make `derived-mode-p` take a single arg Date: Thu, 09 Nov 2023 22:58:26 -0500 Message-ID: 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.135 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 T_SCC_BODY_TEXT_LINE -0.01 - X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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: 0.0 (/) X-Debbugs-Envelope-To: submit 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 (-) Package: Emacs Version: 30.0.50 Looking at uses of `derived-mode-p`, I can't find a single use case where it wouldn't be preferable for it to take a single argument instead of `&rest`: all the calls are either passing a single argument anyway, or passing a fixed list of modes. So making `derived-mode-p` take a single arg (which we'd allow to be either a mode or a list of modes) would not make any real difference to the callers (it would even be more convenient since it could often avoid the use of `apply`), and in return we'd save allocating the `&rest` list. Same for `provided-mode-derived-p`. And yes, I plead guilty for the `&rest` of `derived-mode-p`. Seemed like a good idea at the time :-( Draft patch below. Stefan diff --git a/lisp/subr.el b/lisp/subr.el index d4173b4daba..cd6407ef4b2 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2678,11 +2678,17 @@ while-let ;; PUBLIC: find if the current mode derives from another. -(defun provided-mode-derived-p (mode &rest modes) +(defun provided-mode-derived-p (mode &optional parent &rest modes) "Non-nil if MODE is derived from one of MODES. Uses the `derived-mode-parent' property of the symbol to trace backwards. If you just want to check `major-mode', use `derived-mode-p'." - (declare (side-effect-free t)) + (declare (side-effect-free t) + (advertised-calling-convention (mode parent) "30.1")) + (setq modes (if (not (listp parent)) + (cons parent modes) + ;; New calling convention can't use MODES at the same time. + (cl-assert (null modes)) + parent)) (while (and (not (memq mode modes)) @@ -2693,11 +2699,19 @@ provided-mode-derived-p (and (symbolp alias) alias))))))) mode) -(defun derived-mode-p (&rest modes) - "Non-nil if the current major mode is derived from one of MODES. -Uses the `derived-mode-parent' property of the symbol to trace backwards." - (declare (side-effect-free t)) - (apply #'provided-mode-derived-p major-mode modes)) +(defun derived-mode-p (&optional mode &rest modes) + "Non-nil if the current major mode is derived from MODE. +MODE can also be a list of modes, in which case we check if major mode +is derived from one of them. +It also supports an obsolete `&rest MODES' calling convention." + (declare (side-effect-free t) + (advertised-calling-convention (mode) "30.1")) + (provided-mode-derived-p major-mode + (if (not (listp mode)) (cons mode modes) + ;; New calling convention can't use MODES + ;; at the same time. + (cl-assert (null modes)) + mode))) (defvar-local major-mode--suspended nil) (put 'major-mode--suspended 'permanent-local t) ------------=_1700758862-31809-1--