* emacs-lisp/easy-mmode.el (define-minor-mode): Add :variable keyword.
* emacs-lisp/cl-macs.el (terminal-parameter, eq): Add setf method.
* international/iso-ascii.el (iso-ascii-mode):
* frame.el (auto-raise-mode, auto-lower-mode):
* composite.el (global-auto-composition-mode): Use define-minor-mode.
\f
* Lisp changes in Emacs 24.1
+** define-minor-mode accepts a new keyword :variable.
+
** delete-file now accepts an optional second arg, FORCE, which says
to always delete and ignore the value of delete-by-moving-to-trash.
+2010-05-05 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * emacs-lisp/easy-mmode.el (define-minor-mode): Add :variable keyword.
+ * emacs-lisp/cl-macs.el (terminal-parameter, eq): Add setf method.
+ * international/iso-ascii.el (iso-ascii-mode):
+ * frame.el (auto-raise-mode, auto-lower-mode):
+ * composite.el (global-auto-composition-mode): Use define-minor-mode.
+
2010-05-04 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-methods): Remove "-q" from `tramp-login-args'
Auto Composition mode in all buffers (this is the default).")
;;;###autoload
-(defun global-auto-composition-mode (&optional arg)
+(define-minor-mode global-auto-composition-mode
"Toggle Auto-Composition mode in every possible buffer.
With prefix arg, turn Global-Auto-Composition mode on if and only if arg
is positive.
See `auto-composition-mode' for more information on Auto-Composition mode."
- (interactive "P")
- (setq-default auto-composition-mode
- (if arg
- (or (not (integerp arg)) (> arg 0))
- (not (default-value 'auto-composition-mode)))))
+ :variable (default-value 'auto-composition-mode))
+
(defalias 'toggle-auto-composition 'auto-composition-mode)
\f
(defsetf frame-visible-p cl-set-frame-visible-p)
(defsetf frame-width set-screen-width t)
(defsetf frame-parameter set-frame-parameter t)
+(defsetf terminal-parameter set-terminal-parameter)
(defsetf getenv setenv t)
(defsetf get-register set-register)
(defsetf global-key-binding global-set-key)
(defsetf x-get-secondary-selection x-own-secondary-selection t)
(defsetf x-get-selection x-own-selection t)
+;; This is a hack that allows (setf (eq a 7) B) to mean either
+;; (setq a 7) or (setq a nil) depending on whether B is nil or not.
+;; This is useful when you have control over the PLACE but not over
+;; the VALUE, as is the case in define-minor-mode's :variable.
+(defsetf eq (a b) (v) `(setf ,a (if ,v ,b (not ,b))))
+
;;; More complex setf-methods.
-;;; These should take &environment arguments, but since full arglists aren't
-;;; available while compiling cl-macs, we fake it by referring to the global
-;;; variable cl-macro-environment directly.
+;; These should take &environment arguments, but since full arglists aren't
+;; available while compiling cl-macs, we fake it by referring to the global
+;; variable cl-macro-environment directly.
(define-setf-method apply (func arg1 &rest rest)
(or (and (memq (car-safe func) '(quote function function*))
:lighter SPEC Same as the LIGHTER argument.
:keymap MAP Same as the KEYMAP argument.
:require SYM Same as in `defcustom'.
+:variable PLACE The location (as can be used with `setf') to use instead
+ of the variable MODE to store the state of the mode.
For example, you could write
(define-minor-mode foo-mode \"If enabled, foo on you!\"
(type nil)
(extra-args nil)
(extra-keywords nil)
+ (variable nil)
+ (modefun mode)
(require t)
(hook (intern (concat mode-name "-hook")))
(hook-on (intern (concat mode-name "-on-hook")))
(:type (setq type (list :type (pop body))))
(:require (setq require (pop body)))
(:keymap (setq keymap (pop body)))
+ (:variable (setq variable (setq mode (pop body))))
(t (push keyw extra-keywords) (push (pop body) extra-keywords))))
(setq keymap-sym (if (and keymap (symbolp keymap)) keymap
`(progn
;; Define the variable to enable or disable the mode.
- ,(if (not globalp)
- `(progn
- (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled.
+ ,(cond
+ ;; If :variable is specified, then the var will be
+ ;; declared elsewhere.
+ (variable nil)
+ ((not globalp)
+ `(progn
+ (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled.
Use the command `%s' to change this variable." pretty-name mode))
- (make-variable-buffer-local ',mode))
-
+ (make-variable-buffer-local ',mode)))
+ (t
(let ((base-doc-string
(concat "Non-nil if %s is enabled.
See the command `%s' for a description of this minor mode."
,@group
,@type
,@(unless (eq require t) `(:require ,require))
- ,@(nreverse extra-keywords))))
+ ,@(nreverse extra-keywords)))))
;; The actual function.
- (defun ,mode (&optional arg ,@extra-args)
+ (defun ,modefun (&optional arg ,@extra-args)
,(or doc
(format (concat "Toggle %s on or off.
Interactively, with no prefix argument, toggle the mode.
;; repeat-command still does the toggling correctly.
(interactive (list (or current-prefix-arg 'toggle)))
(let ((,last-message (current-message)))
- (setq ,mode
- (if (eq arg 'toggle)
- (not ,mode)
- ;; A nil argument also means ON now.
- (> (prefix-numeric-value arg) 0)))
+ (,(if (symbolp mode) 'setq 'setf) ,mode
+ (if (eq arg 'toggle)
+ (not ,mode)
+ ;; A nil argument also means ON now.
+ (> (prefix-numeric-value arg) 0)))
,@body
;; The on/off hooks are here for backward compatibility only.
(run-hooks ',hook (if ,mode ',hook-on ',hook-off))
(t (error "Invalid keymap %S" ,keymap))))
,(format "Keymap for `%s'." mode-name)))
- (add-minor-mode ',mode ',lighter
- ,(if keymap keymap-sym
- `(if (boundp ',keymap-sym) ,keymap-sym))))))
+ ,(unless variable
+ `(add-minor-mode ',mode ',lighter
+ ,(if keymap keymap-sym
+ `(if (boundp ',keymap-sym) ,keymap-sym)))))))
\f
;;;
;;; make global minor mode
;;; Commentary:
;;; Code:
+(eval-when-compile (require 'cl))
(defvar frame-creation-function-alist
(list (cons nil
(modify-frame-parameters (selected-frame)
(list (cons 'border-color color-name))))
-(defun auto-raise-mode (arg)
+(define-minor-mode auto-raise-mode
"Toggle whether or not the selected frame should auto-raise.
With ARG, turn auto-raise mode on if and only if ARG is positive.
Note that this controls Emacs's own auto-raise feature.
Some window managers allow you to enable auto-raise for certain windows.
You can use that for Emacs windows if you wish, but if you do,
that is beyond the control of Emacs and this command has no effect on it."
- (interactive "P")
- (if (null arg)
- (setq arg
- (if (cdr (assq 'auto-raise (frame-parameters (selected-frame))))
- -1 1)))
- (if (> arg 0)
- (raise-frame (selected-frame)))
- (modify-frame-parameters (selected-frame)
- (list (cons 'auto-raise (> arg 0)))))
+ :variable (frame-parameter nil 'auto-raise)
+ (if (frame-parameter nil 'auto-raise)
+ (raise-frame)))
-(defun auto-lower-mode (arg)
+(define-minor-mode auto-lower-mode
"Toggle whether or not the selected frame should auto-lower.
With ARG, turn auto-lower mode on if and only if ARG is positive.
Note that this controls Emacs's own auto-lower feature.
Some window managers allow you to enable auto-lower for certain windows.
You can use that for Emacs windows if you wish, but if you do,
that is beyond the control of Emacs and this command has no effect on it."
- (interactive "P")
- (if (null arg)
- (setq arg
- (if (cdr (assq 'auto-lower (frame-parameters (selected-frame))))
- -1 1)))
- (modify-frame-parameters (selected-frame)
- (list (cons 'auto-lower (> arg 0)))))
+ :variable (frame-parameter nil 'auto-lower))
+
(defun set-frame-name (name)
"Set the name of the selected frame to NAME.
When called interactively, prompt for the name of the frame.
;;; Code:
(require 'disp-table)
+(eval-when-compile (require 'cl))
(defgroup iso-ascii nil
"Set up char tables for ISO 8859/1 on ASCII terminals."
(iso-ascii-display 254 "th") ; small thorn, Icelandic
(iso-ascii-display 255 "\"y") ; small y with diaeresis or umlaut mark
-(defun iso-ascii-mode (arg)
+(define-minor-mode iso-ascii-mode
"Toggle ISO-ASCII mode."
- (interactive "P")
- (unless arg
- (setq arg (eq standard-display-table iso-ascii-standard-display-table)))
- (setq standard-display-table
- (if arg
- iso-ascii-display-table
- iso-ascii-standard-display-table)))
+ :variable (eq standard-display-table iso-ascii-display-table)
+ (unless standard-display-table
+ (setq standard-display-table iso-ascii-standard-display-table)))
(provide 'iso-ascii)
not possible without parsing. Thus assignment statement become just
the leftover unidentified statements containing an equal sign.")
+;; FIXME: This var seems to only ever be set, but never actually used!
(defvar idlwave-fill-function 'auto-fill-function
"IDL mode auto fill function.")