[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17954: 24.4.50; [patch] `menu-bar-make-toggle' should allow for keyw
bug#17954: 24.4.50; [patch] `menu-bar-make-toggle' should allow for keywords
Sat, 5 Jul 2014 22:28:37 -0700 (PDT)
`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
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
(defmacro bmkp-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
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'."
(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.")
(if ,(if setting-sexp
(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"))
;; `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)
In GNU Emacs 220.127.116.11 (i686-pc-mingw32)
of 2014-06-28 on ODIEONE
Bzr revision: 117431 address@hidden
Windowing system distributor `Microsoft Corp.', version 6.1.7601
--enable-checking=yes,glyphs 'CFLAGS=-O0 -g3'
|[Prev in Thread]
||[Next in Thread]|
- bug#17954: 24.4.50; [patch] `menu-bar-make-toggle' should allow for keywords,
Drew Adams <=