Hello there!
I would like to see macro like below, defined somewhere in (S)XEmacs
distribution:
(defmacro define-toggle-variable (var value doc &rest args)
"Define new toggle variable.
VAR is either a symbol, or list of two symbols in form
(VARNAME FUNCNAME), where VARNAME specifies name for variable and
FUNCNAME specifies name for toggle command.
VALUE, DOC and ARGS are same as for `defcustom'.
ARGS may content additional :message keyword of boolean value.
If value for :message keyword is non-nil then display message in echo
area when toggling value."
(let ((funame (or (and (listp var) (cadr var)) var))
(var (or (and (listp var) (car var)) var))
(msg (plist-get args :message)))
(setq args (plist-remprop args :message))
`(progn
(defcustom ,var ,value ,doc
:type 'boolean ,ļ¼ args)
(defun ,funame (arg)
,(format "Toggle `%s' on or off." var)
(interactive "_P")
(customize-set-variable
',var (if (null arg)
(not ,var)
(> (prefix-numeric-value arg) 0)))
,(when msg
`(message "%S is %s" ',var (if ,var "ON"
"OFF")))))))
this macro simplifies definition of toggle variables/commands. For
example:
(define-toggle-variable (debug-on-error toggle-debug-on-error) nil
"Toggle debugger on error."
:message t)
or
(define-toggle-variable
(whitespace-check-buffer-trailing whitespace-toggle-trailing-check) nil
"Toggle checking for trailing space in buffer."
:message nil
:set (lambda (s v)
(set s v)
(message "Will%s check for trailing space in buffer."
(if v "" " not"))
(when v (whitespace-buffer-trailing))))
What do you think guys, do we need that stuff? And if we do, what is
the best place to put it in?
Thanks!
--
lg
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta