From unknown Tue Jun 24 17:29:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6542: 24.0.50; menu-bar-make-toggle Resent-From: "Drew Adams" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jun 2010 17:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 6542 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 6542@debbugs.gnu.org X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.12779199973446 (code B ref -1); Wed, 30 Jun 2010 17:47:02 +0000 Received: (at submit) by debbugs.gnu.org; 30 Jun 2010 17:46:37 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OU1Mq-0000tX-JT for submit@debbugs.gnu.org; Wed, 30 Jun 2010 13:46:36 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OU1Mo-0000tR-SS for submit@debbugs.gnu.org; Wed, 30 Jun 2010 13:46:35 -0400 Received: from lists.gnu.org ([199.232.76.165]:36219) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OU1Mk-0002Iq-9q for submit@debbugs.gnu.org; Wed, 30 Jun 2010 13:46:30 -0400 Received: from [140.186.70.92] (port=55983 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OU1Mi-0006YD-Pp for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2010 13:46:29 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OU1Mh-000413-Iw for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2010 13:46:28 -0400 Received: from rcsinet10.oracle.com ([148.87.113.121]:59472) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OU1Mh-00040m-AY for bug-gnu-emacs@gnu.org; Wed, 30 Jun 2010 13:46:27 -0400 Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o5UHkOJd009352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 30 Jun 2010 17:46:26 GMT Received: from acsmt354.oracle.com (acsmt354.oracle.com [141.146.40.154]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o5U5PVZj008253 for ; Wed, 30 Jun 2010 17:46:23 GMT Received: from abhmt001.oracle.com by acsmt354.oracle.com with ESMTP id 370760351277919963; Wed, 30 Jun 2010 10:46:03 -0700 Received: from dradamslap1 (/130.35.178.194) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 30 Jun 2010 10:46:03 -0700 From: "Drew Adams" Date: Wed, 30 Jun 2010 10:46:04 -0700 Message-ID: <3FC643B342BD48B0B4B04A92BF15FDD6@us.oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcsYfBxJPGspH7z9S2G+HFdl/FQpLA== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5931 X-Source-IP: acsmt354.oracle.com [141.146.40.154] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090209.4C2B82F0.007A:SCFMA4539814,ss=1,fgs=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -6.3 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) 1. Please a doc string. In particular, the use of BODY is not obvious. 2. Please add the ability to use additional keywords, such as :keys, :enable, and :visible. Consider, for example, being able to list an option that only makes sense to toggle when some minor mode is enabled. You would want to be able to specify `:enable foo-mode' or `:visible foo-mode', where `foo-mode' is the minor-mode variable. In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600) of 2010-06-21 on 3249CTO Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (4.4) --no-opt --cflags -Ic:/xpm/include' From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 06 14:14:08 2014 Received: (at control) by debbugs.gnu.org; 6 Jul 2014 18:14:08 +0000 Received: from localhost ([127.0.0.1]:45136 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X3qwx-00059L-TT for submit@debbugs.gnu.org; Sun, 06 Jul 2014 14:14:08 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:34246 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X3qww-00059C-2R for control@debbugs.gnu.org; Sun, 06 Jul 2014 14:14:07 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1X3qwv-0007IX-SB for control@debbugs.gnu.org; Sun, 06 Jul 2014 14:14:05 -0400 Date: Sun, 06 Jul 2014 14:14:05 -0400 Message-Id: Subject: control message for bug 6542 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -5.7 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 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: -5.7 (-----) merge 17193 6542 From unknown Tue Jun 24 17:29:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6542: bug#17954: 24.4.50; [patch] `menu-bar-make-toggle' should allow for keywords Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Apr 2016 22:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6542 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Drew Adams Cc: 17954@debbugs.gnu.org, 6542@debbugs.gnu.org Received: via spool by 6542-submit@debbugs.gnu.org id=B6542.146179474029894 (code B ref 6542); Wed, 27 Apr 2016 22:06:02 +0000 Received: (at 6542) by debbugs.gnu.org; 27 Apr 2016 22:05:40 +0000 Received: from localhost ([127.0.0.1]:50882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avXaW-0007m4-6p for submit@debbugs.gnu.org; Wed, 27 Apr 2016 18:05:40 -0400 Received: from hermes.netfonds.no ([80.91.224.195]:51276) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1avXaU-0007lt-Cf; Wed, 27 Apr 2016 18:05:38 -0400 Received: from cm-84.215.1.64.getinternet.no ([84.215.1.64] helo=mouse) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1avXaR-0004Oo-9S; Thu, 28 Apr 2016 00:05:37 +0200 From: Lars Ingebrigtsen References: <9e5b6c5f-0dd9-44ef-b997-3cc032e7a107@default> Date: Thu, 28 Apr 2016 00:05:35 +0200 In-Reply-To: <9e5b6c5f-0dd9-44ef-b997-3cc032e7a107@default> (Drew Adams's message of "Sat, 5 Jul 2014 22:28:37 -0700 (PDT)") Message-ID: <8760v2so5s.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 0.0 (/) Drew Adams writes: > It cannot accept keywords in the normal way because it defines BODY as > an &rest parameter. This mistake should be corrected, making for an > incompatible change unfortunately, in order to allow a KEYWORDS &rest > parameter. > > BODY is seldom used. In the Emacs Lisp sources, there are only these > two occurrences of `menu-bar-make-toggle' that use BODY: > `toggle-save-place-globally' and `toggle-uniquify-buffer-names'. They > would just need to wrap the current BODY code in an explicit `progn'. I don't think such an incompatible change would be appropriate. > Of course, there may be 3rd-party code that uses parameter BODY. The > only way I can think of to be sensitive to that breakage is to use a new > macro name and code, and deprecate the old name `menu-bar-make-toggle'. > Perhaps this incompatible change could be tolerated, since BODY is rare > and the adaptation for any existing code is trivial (wrap with `progn'). And having two macros that do the same wouldn't be very appropriate, either... I think it would make more sense to extend the HELP parameter to be a list, and then it could be the keyword list. Your code as a patch included below. diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index cc7233e..ca40e94 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -629,31 +629,44 @@ menu-bar-make-mm-toggle :button (:toggle . (and (default-boundp ',fname) (default-value ',fname))))) -(defmacro menu-bar-make-toggle (name variable doc message help &rest body) +(defmacro menu-bar-make-toggle (command variable item-name message help + &optional setting-sexp &rest keywords) + "Define a menu-bar toggle command. +COMMAND (a symbol) is the toggle command to define. +VARIABLE (a symbol) is the variable to set. +ITEM-NAME (a string) is the menu-item name. +MESSAGE is a format string for the toggle message, with %s for the new + status. +HELP (a string) is the `:help' tooltip text and the doc string first + line (minus final period) for the command. +SETTING-SEXP is a Lisp sexp that sets VARIABLE, or it is nil meaning + set it according to its `defcustom' or using `set-default'. +KEYWORDS is a plist for `menu-item' for keywords other than `:help'." `(progn - (defun ,name (&optional interactively) + (defun ,command (&optional interactively) ,(concat "Toggle whether to " (downcase (substring help 0 1)) - (substring help 1) ". + (substring help 1) ". In an interactive call, record this option as a candidate for saving by \"Save Options\" in Custom buffers.") (interactive "p") - (if ,(if body `(progn . ,body) - `(progn + (if ,(if setting-sexp + `,setting-sexp + `(progn (custom-load-symbol ',variable) (let ((set (or (get ',variable 'custom-set) 'set-default)) (get (or (get ',variable 'custom-get) 'default-value))) (funcall set ',variable (not (funcall get ',variable)))))) - (message ,message "enabled globally") - (message ,message "disabled globally")) - ;; The function `customize-mark-as-set' must only be called when - ;; a variable is set interactively, as the purpose is to mark it as - ;; a candidate for "Save Options", and we do not want to save options - ;; the user have already set explicitly in his init file. - (if interactively (customize-mark-as-set ',variable))) - '(menu-item ,doc ,name - :help ,help - :button (:toggle . (and (default-boundp ',variable) - (default-value ',variable)))))) + (message ,message "enabled globally") + (message ,message "disabled globally")) + ;; `customize-mark-as-set' must only be called when a variable is set + ;; interactively, because the purpose is to mark the variable as a + ;; candidate for `Save Options', and we do not want to save options that + ;; the user has already set explicitly in the init file. + (when interactively (customize-mark-as-set ',variable))) + '(menu-item ,item-name ,command :help ,help + :button (:toggle . (and (default-boundp ',variable) + (default-value ',variable))) + ,@keywords))) ;; Function for setting/saving default font. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From unknown Tue Jun 24 17:29:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#6542: bug#17954: 24.4.50; [patch] `menu-bar-make-toggle' should allow for keywords Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Sep 2020 16:25:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6542 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Drew Adams Cc: 17954@debbugs.gnu.org, 6542@debbugs.gnu.org Received: via spool by 6542-submit@debbugs.gnu.org id=B6542.160053269024638 (code B ref 6542); Sat, 19 Sep 2020 16:25:03 +0000 Received: (at 6542) by debbugs.gnu.org; 19 Sep 2020 16:24:50 +0000 Received: from localhost ([127.0.0.1]:47892 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJffO-0006PJ-8p for submit@debbugs.gnu.org; Sat, 19 Sep 2020 12:24:50 -0400 Received: from quimby.gnus.org ([95.216.78.240]:45638) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJffL-0006Ox-Rl; Sat, 19 Sep 2020 12:24:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: 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=DUNA5xdT2owhjmCW4btT8Mg+bODK/UxkLp1dvvtLVP4=; b=bbtwZzgd6rfSRPkVl0dwV6VjS8 5UA05VN9yatSGsJJ43n6Z9YD+9V4LBIxlX6xoEvf7i7i2fK6EjmKtDaLTcavvQe+756iRnEJLGu7A AfzkP1/orrAJjhQ3IwGh3nxE6Td5ifyXFQvBGAwL+cI9i7mz6djlR6qFoejIhQNB4lTI=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJffC-0000It-ME; Sat, 19 Sep 2020 18:24:41 +0200 From: Lars Ingebrigtsen References: <9e5b6c5f-0dd9-44ef-b997-3cc032e7a107@default> X-Now-Playing: Frankie Goes To Hollywood's _Welcome To The Pleasuredome_: "War" Date: Sat, 19 Sep 2020 18:24:37 +0200 In-Reply-To: <9e5b6c5f-0dd9-44ef-b997-3cc032e7a107@default> (Drew Adams's message of "Sat, 5 Jul 2014 22:28:37 -0700 (PDT)") Message-ID: <87d02hohtm.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Drew Adams writes: > `menu-bar-make-toggle' handles no keywords. It takes the value of > :help as an explicit argument (without keyword), but it does not pass > along :keys, :active, :enable, etc. to `menu-item'. It sho [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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 (-) Drew Adams writes: > `menu-bar-make-toggle' handles no keywords. It takes the value of > :help as an explicit argument (without keyword), but it does not pass > along :keys, :active, :enable, etc. to `menu-item'. It should. > > It cannot accept keywords in the normal way because it defines BODY as > an &rest parameter. This mistake should be corrected, making for an > incompatible change unfortunately, in order to allow a KEYWORDS &rest > parameter. > > BODY is seldom used. In the Emacs Lisp sources, there are only these > two occurrences of `menu-bar-make-toggle' that use BODY: > `toggle-save-place-globally' and `toggle-uniquify-buffer-names'. They > would just need to wrap the current BODY code in an explicit `progn'. I've now applied your patch, but renamed the resulting macro to menu-bar-make-toggle-command, while the former name is now an obsolete wrapper macro. I've also adjusted all in-tree callers. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Sat Sep 19 12:24:56 2020 Received: (at control) by debbugs.gnu.org; 19 Sep 2020 16:24:56 +0000 Received: from localhost ([127.0.0.1]:47897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJffT-0006Ph-Ow for submit@debbugs.gnu.org; Sat, 19 Sep 2020 12:24:56 -0400 Received: from quimby.gnus.org ([95.216.78.240]:45656) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJffR-0006P7-Ai for control@debbugs.gnu.org; Sat, 19 Sep 2020 12:24:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding: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=d5blUCbl9A8GbrZxBYOOyng96/5P3mREr0fkOImgC6c=; b=idl6gGcOhnW8ofNIOHEaaFk2Wf lEIidacpK8hmsW2SKFklh38AmFzG+fNW22ZsKUmm8WIazbw629b7yjYbKCze7FaLnmP16AT53hAx/ H/C47A56uz6r8eS4Dz1KhXvx+fEcpmyc3+DTTbo4gwNJAmgTuEVuHK1eEeV0ljYS+H5I=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJffJ-0000JC-Li for control@debbugs.gnu.org; Sat, 19 Sep 2020 18:24:47 +0200 Date: Sat, 19 Sep 2020 18:24:44 +0200 Message-Id: <87bli1ohtf.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #6542 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 6542 fixed close 6542 28.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (-) tags 6542 fixed close 6542 28.1 quit