From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#17954: 24.4.50; [patch] `menu-bar-make-toggle' should allow for keywords Date: Sat, 5 Jul 2014 22:28:37 -0700 (PDT) Message-ID: <9e5b6c5f-0dd9-44ef-b997-3cc032e7a107@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1404624640 11082 80.91.229.3 (6 Jul 2014 05:30:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Jul 2014 05:30:40 +0000 (UTC) To: 17954@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jul 06 07:30:31 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X3f1x-0004cK-Mz for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Jul 2014 07:30:29 +0200 Original-Received: from localhost ([::1]:44766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3f1x-0003ci-7X for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Jul 2014 01:30:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3f1j-0003cN-63 for bug-gnu-emacs@gnu.org; Sun, 06 Jul 2014 01:30:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X3f1Y-0002Sa-Rk for bug-gnu-emacs@gnu.org; Sun, 06 Jul 2014 01:30:15 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53334) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3f1Y-0002SN-PP for bug-gnu-emacs@gnu.org; Sun, 06 Jul 2014 01:30:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X3f1X-00067N-Vo for bug-gnu-emacs@gnu.org; Sun, 06 Jul 2014 01:30:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 06 Jul 2014 05:30:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 17954 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.140462456423421 (code B ref -1); Sun, 06 Jul 2014 05:30:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Jul 2014 05:29:24 +0000 Original-Received: from localhost ([127.0.0.1]:44484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X3f0t-00065g-Vw for submit@debbugs.gnu.org; Sun, 06 Jul 2014 01:29:24 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46975) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X3f0r-00065R-Cx for submit@debbugs.gnu.org; Sun, 06 Jul 2014 01:29:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X3f0b-00027X-Nf for submit@debbugs.gnu.org; Sun, 06 Jul 2014 01:29:15 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:50553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3f0b-00027T-L1 for submit@debbugs.gnu.org; Sun, 06 Jul 2014 01:29:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3f0S-0003RW-SL for bug-gnu-emacs@gnu.org; Sun, 06 Jul 2014 01:29:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X3f0K-00024A-4m for bug-gnu-emacs@gnu.org; Sun, 06 Jul 2014 01:28:56 -0400 Original-Received: from userp1040.oracle.com ([156.151.31.81]:25232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X3f0J-00023y-UN for bug-gnu-emacs@gnu.org; Sun, 06 Jul 2014 01:28:48 -0400 Original-Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s665Skg9019897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Jul 2014 05:28:47 GMT Original-Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s665Sj6g006742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 6 Jul 2014 05:28:45 GMT Original-Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s665SjbG006734 for ; Sun, 6 Jul 2014 05:28:45 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6691.5000 (x86)] X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:91234 Archived-At: `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'. 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'). Here is one possible definition (with a doc string and better parameter names): (defmacro bmkp-menu-bar-make-toggle (command variable item-name message hel= p &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 ,command (&optional interactively) ,(concat "Toggle whether to " (downcase (substring help 0 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 setting-sexp `,setting-sexp `(progn =09=09 (custom-load-symbol ',variable) =09=09 (let ((set (or (get ',variable 'custom-set) 'set-default)) =09=09 (get (or (get ',variable 'custom-get) 'default-value))) =09=09 (funcall set ',variable (not (funcall get ',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 t= hat ;; 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))) In GNU Emacs 24.4.50.1 (i686-pc-mingw32) of 2014-06-28 on ODIEONE Bzr revision: 117431 rgm@gnu.org-20140628015517-eku6hj8mpgcvfnso Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --prefix=3D/c/Devel/emacs/snapshot/trunk --enable-checking=3Dyes,glyphs 'CFLAGS=3D-O0 -g3' LDFLAGS=3D-Lc:/Devel/emacs/lib 'CPPFLAGS=3D-DGC_MCHECK=3D1 -Ic:/Devel/emacs/include''