diff options
| author | Stefan Monnier | 2010-05-04 22:08:25 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2010-05-04 22:08:25 -0400 |
| commit | f44379e7feb79dd734318706abe5a000cff34c9b (patch) | |
| tree | 79b74dc4cb121d4a3bb18fd9725c33f5b1c030a3 | |
| parent | 80f00217abd2736464207704bf92eb5a93f84b90 (diff) | |
| download | emacs-f44379e7feb79dd734318706abe5a000cff34c9b.tar.gz emacs-f44379e7feb79dd734318706abe5a000cff34c9b.zip | |
Use define-minor-mode for less obvious cases.
* 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.
| -rw-r--r-- | etc/NEWS | 2 | ||||
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/composite.el | 9 | ||||
| -rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 13 | ||||
| -rw-r--r-- | lisp/emacs-lisp/easy-mmode.el | 40 | ||||
| -rw-r--r-- | lisp/frame.el | 26 | ||||
| -rw-r--r-- | lisp/international/iso-ascii.el | 13 | ||||
| -rw-r--r-- | lisp/progmodes/idlwave.el | 1 |
8 files changed, 62 insertions, 50 deletions
| @@ -186,6 +186,8 @@ Secret Service API requires D-Bus for communication. | |||
| 186 | 186 | ||
| 187 | * Lisp changes in Emacs 24.1 | 187 | * Lisp changes in Emacs 24.1 |
| 188 | 188 | ||
| 189 | ** define-minor-mode accepts a new keyword :variable. | ||
| 190 | |||
| 189 | ** delete-file now accepts an optional second arg, FORCE, which says | 191 | ** delete-file now accepts an optional second arg, FORCE, which says |
| 190 | to always delete and ignore the value of delete-by-moving-to-trash. | 192 | to always delete and ignore the value of delete-by-moving-to-trash. |
| 191 | 193 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 11648ed1abd..3edaea5d623 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2010-05-05 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/easy-mmode.el (define-minor-mode): Add :variable keyword. | ||
| 4 | * emacs-lisp/cl-macs.el (terminal-parameter, eq): Add setf method. | ||
| 5 | * international/iso-ascii.el (iso-ascii-mode): | ||
| 6 | * frame.el (auto-raise-mode, auto-lower-mode): | ||
| 7 | * composite.el (global-auto-composition-mode): Use define-minor-mode. | ||
| 8 | |||
| 1 | 2010-05-04 Michael Albinus <michael.albinus@gmx.de> | 9 | 2010-05-04 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 10 | ||
| 3 | * net/tramp.el (tramp-methods): Remove "-q" from `tramp-login-args' | 11 | * net/tramp.el (tramp-methods): Remove "-q" from `tramp-login-args' |
diff --git a/lisp/composite.el b/lisp/composite.el index 2b65839b93f..2204b351a36 100644 --- a/lisp/composite.el +++ b/lisp/composite.el | |||
| @@ -764,16 +764,13 @@ You can use `global-auto-composition-mode' to turn on | |||
| 764 | Auto Composition mode in all buffers (this is the default).") | 764 | Auto Composition mode in all buffers (this is the default).") |
| 765 | 765 | ||
| 766 | ;;;###autoload | 766 | ;;;###autoload |
| 767 | (defun global-auto-composition-mode (&optional arg) | 767 | (define-minor-mode global-auto-composition-mode |
| 768 | "Toggle Auto-Composition mode in every possible buffer. | 768 | "Toggle Auto-Composition mode in every possible buffer. |
| 769 | With prefix arg, turn Global-Auto-Composition mode on if and only if arg | 769 | With prefix arg, turn Global-Auto-Composition mode on if and only if arg |
| 770 | is positive. | 770 | is positive. |
| 771 | See `auto-composition-mode' for more information on Auto-Composition mode." | 771 | See `auto-composition-mode' for more information on Auto-Composition mode." |
| 772 | (interactive "P") | 772 | :variable (default-value 'auto-composition-mode)) |
| 773 | (setq-default auto-composition-mode | 773 | |
| 774 | (if arg | ||
| 775 | (or (not (integerp arg)) (> arg 0)) | ||
| 776 | (not (default-value 'auto-composition-mode))))) | ||
| 777 | (defalias 'toggle-auto-composition 'auto-composition-mode) | 774 | (defalias 'toggle-auto-composition 'auto-composition-mode) |
| 778 | 775 | ||
| 779 | 776 | ||
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 7d8108bcd87..e48835adeb1 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el | |||
| @@ -1769,6 +1769,7 @@ Example: | |||
| 1769 | (defsetf frame-visible-p cl-set-frame-visible-p) | 1769 | (defsetf frame-visible-p cl-set-frame-visible-p) |
| 1770 | (defsetf frame-width set-screen-width t) | 1770 | (defsetf frame-width set-screen-width t) |
| 1771 | (defsetf frame-parameter set-frame-parameter t) | 1771 | (defsetf frame-parameter set-frame-parameter t) |
| 1772 | (defsetf terminal-parameter set-terminal-parameter) | ||
| 1772 | (defsetf getenv setenv t) | 1773 | (defsetf getenv setenv t) |
| 1773 | (defsetf get-register set-register) | 1774 | (defsetf get-register set-register) |
| 1774 | (defsetf global-key-binding global-set-key) | 1775 | (defsetf global-key-binding global-set-key) |
| @@ -1821,10 +1822,16 @@ Example: | |||
| 1821 | (defsetf x-get-secondary-selection x-own-secondary-selection t) | 1822 | (defsetf x-get-secondary-selection x-own-secondary-selection t) |
| 1822 | (defsetf x-get-selection x-own-selection t) | 1823 | (defsetf x-get-selection x-own-selection t) |
| 1823 | 1824 | ||
| 1825 | ;; This is a hack that allows (setf (eq a 7) B) to mean either | ||
| 1826 | ;; (setq a 7) or (setq a nil) depending on whether B is nil or not. | ||
| 1827 | ;; This is useful when you have control over the PLACE but not over | ||
| 1828 | ;; the VALUE, as is the case in define-minor-mode's :variable. | ||
| 1829 | (defsetf eq (a b) (v) `(setf ,a (if ,v ,b (not ,b)))) | ||
| 1830 | |||
| 1824 | ;;; More complex setf-methods. | 1831 | ;;; More complex setf-methods. |
| 1825 | ;;; These should take &environment arguments, but since full arglists aren't | 1832 | ;; These should take &environment arguments, but since full arglists aren't |
| 1826 | ;;; available while compiling cl-macs, we fake it by referring to the global | 1833 | ;; available while compiling cl-macs, we fake it by referring to the global |
| 1827 | ;;; variable cl-macro-environment directly. | 1834 | ;; variable cl-macro-environment directly. |
| 1828 | 1835 | ||
| 1829 | (define-setf-method apply (func arg1 &rest rest) | 1836 | (define-setf-method apply (func arg1 &rest rest) |
| 1830 | (or (and (memq (car-safe func) '(quote function function*)) | 1837 | (or (and (memq (car-safe func) '(quote function function*)) |
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index bebff6adae8..238f2fa551a 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el | |||
| @@ -116,6 +116,8 @@ BODY contains code to execute each time the mode is activated or deactivated. | |||
| 116 | :lighter SPEC Same as the LIGHTER argument. | 116 | :lighter SPEC Same as the LIGHTER argument. |
| 117 | :keymap MAP Same as the KEYMAP argument. | 117 | :keymap MAP Same as the KEYMAP argument. |
| 118 | :require SYM Same as in `defcustom'. | 118 | :require SYM Same as in `defcustom'. |
| 119 | :variable PLACE The location (as can be used with `setf') to use instead | ||
| 120 | of the variable MODE to store the state of the mode. | ||
| 119 | 121 | ||
| 120 | For example, you could write | 122 | For example, you could write |
| 121 | (define-minor-mode foo-mode \"If enabled, foo on you!\" | 123 | (define-minor-mode foo-mode \"If enabled, foo on you!\" |
| @@ -147,6 +149,8 @@ For example, you could write | |||
| 147 | (type nil) | 149 | (type nil) |
| 148 | (extra-args nil) | 150 | (extra-args nil) |
| 149 | (extra-keywords nil) | 151 | (extra-keywords nil) |
| 152 | (variable nil) | ||
| 153 | (modefun mode) | ||
| 150 | (require t) | 154 | (require t) |
| 151 | (hook (intern (concat mode-name "-hook"))) | 155 | (hook (intern (concat mode-name "-hook"))) |
| 152 | (hook-on (intern (concat mode-name "-on-hook"))) | 156 | (hook-on (intern (concat mode-name "-on-hook"))) |
| @@ -167,6 +171,7 @@ For example, you could write | |||
| 167 | (:type (setq type (list :type (pop body)))) | 171 | (:type (setq type (list :type (pop body)))) |
| 168 | (:require (setq require (pop body))) | 172 | (:require (setq require (pop body))) |
| 169 | (:keymap (setq keymap (pop body))) | 173 | (:keymap (setq keymap (pop body))) |
| 174 | (:variable (setq variable (setq mode (pop body)))) | ||
| 170 | (t (push keyw extra-keywords) (push (pop body) extra-keywords)))) | 175 | (t (push keyw extra-keywords) (push (pop body) extra-keywords)))) |
| 171 | 176 | ||
| 172 | (setq keymap-sym (if (and keymap (symbolp keymap)) keymap | 177 | (setq keymap-sym (if (and keymap (symbolp keymap)) keymap |
| @@ -187,12 +192,16 @@ For example, you could write | |||
| 187 | 192 | ||
| 188 | `(progn | 193 | `(progn |
| 189 | ;; Define the variable to enable or disable the mode. | 194 | ;; Define the variable to enable or disable the mode. |
| 190 | ,(if (not globalp) | 195 | ,(cond |
| 191 | `(progn | 196 | ;; If :variable is specified, then the var will be |
| 192 | (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled. | 197 | ;; declared elsewhere. |
| 198 | (variable nil) | ||
| 199 | ((not globalp) | ||
| 200 | `(progn | ||
| 201 | (defvar ,mode ,init-value ,(format "Non-nil if %s is enabled. | ||
| 193 | Use the command `%s' to change this variable." pretty-name mode)) | 202 | Use the command `%s' to change this variable." pretty-name mode)) |
| 194 | (make-variable-buffer-local ',mode)) | 203 | (make-variable-buffer-local ',mode))) |
| 195 | 204 | (t | |
| 196 | (let ((base-doc-string | 205 | (let ((base-doc-string |
| 197 | (concat "Non-nil if %s is enabled. | 206 | (concat "Non-nil if %s is enabled. |
| 198 | See the command `%s' for a description of this minor mode." | 207 | See the command `%s' for a description of this minor mode." |
| @@ -207,10 +216,10 @@ or call the function `%s'.")))) | |||
| 207 | ,@group | 216 | ,@group |
| 208 | ,@type | 217 | ,@type |
| 209 | ,@(unless (eq require t) `(:require ,require)) | 218 | ,@(unless (eq require t) `(:require ,require)) |
| 210 | ,@(nreverse extra-keywords)))) | 219 | ,@(nreverse extra-keywords))))) |
| 211 | 220 | ||
| 212 | ;; The actual function. | 221 | ;; The actual function. |
| 213 | (defun ,mode (&optional arg ,@extra-args) | 222 | (defun ,modefun (&optional arg ,@extra-args) |
| 214 | ,(or doc | 223 | ,(or doc |
| 215 | (format (concat "Toggle %s on or off. | 224 | (format (concat "Toggle %s on or off. |
| 216 | Interactively, with no prefix argument, toggle the mode. | 225 | Interactively, with no prefix argument, toggle the mode. |
| @@ -221,11 +230,11 @@ With zero or negative ARG turn mode off. | |||
| 221 | ;; repeat-command still does the toggling correctly. | 230 | ;; repeat-command still does the toggling correctly. |
| 222 | (interactive (list (or current-prefix-arg 'toggle))) | 231 | (interactive (list (or current-prefix-arg 'toggle))) |
| 223 | (let ((,last-message (current-message))) | 232 | (let ((,last-message (current-message))) |
| 224 | (setq ,mode | 233 | (,(if (symbolp mode) 'setq 'setf) ,mode |
| 225 | (if (eq arg 'toggle) | 234 | (if (eq arg 'toggle) |
| 226 | (not ,mode) | 235 | (not ,mode) |
| 227 | ;; A nil argument also means ON now. | 236 | ;; A nil argument also means ON now. |
| 228 | (> (prefix-numeric-value arg) 0))) | 237 | (> (prefix-numeric-value arg) 0))) |
| 229 | ,@body | 238 | ,@body |
| 230 | ;; The on/off hooks are here for backward compatibility only. | 239 | ;; The on/off hooks are here for backward compatibility only. |
| 231 | (run-hooks ',hook (if ,mode ',hook-on ',hook-off)) | 240 | (run-hooks ',hook (if ,mode ',hook-on ',hook-off)) |
| @@ -256,9 +265,10 @@ With zero or negative ARG turn mode off. | |||
| 256 | (t (error "Invalid keymap %S" ,keymap)))) | 265 | (t (error "Invalid keymap %S" ,keymap)))) |
| 257 | ,(format "Keymap for `%s'." mode-name))) | 266 | ,(format "Keymap for `%s'." mode-name))) |
| 258 | 267 | ||
| 259 | (add-minor-mode ',mode ',lighter | 268 | ,(unless variable |
| 260 | ,(if keymap keymap-sym | 269 | `(add-minor-mode ',mode ',lighter |
| 261 | `(if (boundp ',keymap-sym) ,keymap-sym)))))) | 270 | ,(if keymap keymap-sym |
| 271 | `(if (boundp ',keymap-sym) ,keymap-sym))))))) | ||
| 262 | 272 | ||
| 263 | ;;; | 273 | ;;; |
| 264 | ;;; make global minor mode | 274 | ;;; make global minor mode |
diff --git a/lisp/frame.el b/lisp/frame.el index 0628db7ee38..7456db4021c 100644 --- a/lisp/frame.el +++ b/lisp/frame.el | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | ;;; Commentary: | 24 | ;;; Commentary: |
| 25 | 25 | ||
| 26 | ;;; Code: | 26 | ;;; Code: |
| 27 | (eval-when-compile (require 'cl)) | ||
| 27 | 28 | ||
| 28 | (defvar frame-creation-function-alist | 29 | (defvar frame-creation-function-alist |
| 29 | (list (cons nil | 30 | (list (cons nil |
| @@ -1132,37 +1133,26 @@ To get the frame's current border color, use `frame-parameters'." | |||
| 1132 | (modify-frame-parameters (selected-frame) | 1133 | (modify-frame-parameters (selected-frame) |
| 1133 | (list (cons 'border-color color-name)))) | 1134 | (list (cons 'border-color color-name)))) |
| 1134 | 1135 | ||
| 1135 | (defun auto-raise-mode (arg) | 1136 | (define-minor-mode auto-raise-mode |
| 1136 | "Toggle whether or not the selected frame should auto-raise. | 1137 | "Toggle whether or not the selected frame should auto-raise. |
| 1137 | With ARG, turn auto-raise mode on if and only if ARG is positive. | 1138 | With ARG, turn auto-raise mode on if and only if ARG is positive. |
| 1138 | Note that this controls Emacs's own auto-raise feature. | 1139 | Note that this controls Emacs's own auto-raise feature. |
| 1139 | Some window managers allow you to enable auto-raise for certain windows. | 1140 | Some window managers allow you to enable auto-raise for certain windows. |
| 1140 | You can use that for Emacs windows if you wish, but if you do, | 1141 | You can use that for Emacs windows if you wish, but if you do, |
| 1141 | that is beyond the control of Emacs and this command has no effect on it." | 1142 | that is beyond the control of Emacs and this command has no effect on it." |
| 1142 | (interactive "P") | 1143 | :variable (frame-parameter nil 'auto-raise) |
| 1143 | (if (null arg) | 1144 | (if (frame-parameter nil 'auto-raise) |
| 1144 | (setq arg | 1145 | (raise-frame))) |
| 1145 | (if (cdr (assq 'auto-raise (frame-parameters (selected-frame)))) | ||
| 1146 | -1 1))) | ||
| 1147 | (if (> arg 0) | ||
| 1148 | (raise-frame (selected-frame))) | ||
| 1149 | (modify-frame-parameters (selected-frame) | ||
| 1150 | (list (cons 'auto-raise (> arg 0))))) | ||
| 1151 | 1146 | ||
| 1152 | (defun auto-lower-mode (arg) | 1147 | (define-minor-mode auto-lower-mode |
| 1153 | "Toggle whether or not the selected frame should auto-lower. | 1148 | "Toggle whether or not the selected frame should auto-lower. |
| 1154 | With ARG, turn auto-lower mode on if and only if ARG is positive. | 1149 | With ARG, turn auto-lower mode on if and only if ARG is positive. |
| 1155 | Note that this controls Emacs's own auto-lower feature. | 1150 | Note that this controls Emacs's own auto-lower feature. |
| 1156 | Some window managers allow you to enable auto-lower for certain windows. | 1151 | Some window managers allow you to enable auto-lower for certain windows. |
| 1157 | You can use that for Emacs windows if you wish, but if you do, | 1152 | You can use that for Emacs windows if you wish, but if you do, |
| 1158 | that is beyond the control of Emacs and this command has no effect on it." | 1153 | that is beyond the control of Emacs and this command has no effect on it." |
| 1159 | (interactive "P") | 1154 | :variable (frame-parameter nil 'auto-lower)) |
| 1160 | (if (null arg) | 1155 | |
| 1161 | (setq arg | ||
| 1162 | (if (cdr (assq 'auto-lower (frame-parameters (selected-frame)))) | ||
| 1163 | -1 1))) | ||
| 1164 | (modify-frame-parameters (selected-frame) | ||
| 1165 | (list (cons 'auto-lower (> arg 0))))) | ||
| 1166 | (defun set-frame-name (name) | 1156 | (defun set-frame-name (name) |
| 1167 | "Set the name of the selected frame to NAME. | 1157 | "Set the name of the selected frame to NAME. |
| 1168 | When called interactively, prompt for the name of the frame. | 1158 | When called interactively, prompt for the name of the frame. |
diff --git a/lisp/international/iso-ascii.el b/lisp/international/iso-ascii.el index 268f4c89900..bbfc494a46d 100644 --- a/lisp/international/iso-ascii.el +++ b/lisp/international/iso-ascii.el | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | ;;; Code: | 33 | ;;; Code: |
| 34 | 34 | ||
| 35 | (require 'disp-table) | 35 | (require 'disp-table) |
| 36 | (eval-when-compile (require 'cl)) | ||
| 36 | 37 | ||
| 37 | (defgroup iso-ascii nil | 38 | (defgroup iso-ascii nil |
| 38 | "Set up char tables for ISO 8859/1 on ASCII terminals." | 39 | "Set up char tables for ISO 8859/1 on ASCII terminals." |
| @@ -162,15 +163,11 @@ | |||
| 162 | (iso-ascii-display 254 "th") ; small thorn, Icelandic | 163 | (iso-ascii-display 254 "th") ; small thorn, Icelandic |
| 163 | (iso-ascii-display 255 "\"y") ; small y with diaeresis or umlaut mark | 164 | (iso-ascii-display 255 "\"y") ; small y with diaeresis or umlaut mark |
| 164 | 165 | ||
| 165 | (defun iso-ascii-mode (arg) | 166 | (define-minor-mode iso-ascii-mode |
| 166 | "Toggle ISO-ASCII mode." | 167 | "Toggle ISO-ASCII mode." |
| 167 | (interactive "P") | 168 | :variable (eq standard-display-table iso-ascii-display-table) |
| 168 | (unless arg | 169 | (unless standard-display-table |
| 169 | (setq arg (eq standard-display-table iso-ascii-standard-display-table))) | 170 | (setq standard-display-table iso-ascii-standard-display-table))) |
| 170 | (setq standard-display-table | ||
| 171 | (if arg | ||
| 172 | iso-ascii-display-table | ||
| 173 | iso-ascii-standard-display-table))) | ||
| 174 | 171 | ||
| 175 | (provide 'iso-ascii) | 172 | (provide 'iso-ascii) |
| 176 | 173 | ||
diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index e6228286a19..402893c5946 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el | |||
| @@ -1370,6 +1370,7 @@ list order matters since matching an assignment statement exactly is | |||
| 1370 | not possible without parsing. Thus assignment statement become just | 1370 | not possible without parsing. Thus assignment statement become just |
| 1371 | the leftover unidentified statements containing an equal sign.") | 1371 | the leftover unidentified statements containing an equal sign.") |
| 1372 | 1372 | ||
| 1373 | ;; FIXME: This var seems to only ever be set, but never actually used! | ||
| 1373 | (defvar idlwave-fill-function 'auto-fill-function | 1374 | (defvar idlwave-fill-function 'auto-fill-function |
| 1374 | "IDL mode auto fill function.") | 1375 | "IDL mode auto fill function.") |
| 1375 | 1376 | ||