aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-05-04 23:45:21 -0400
committerStefan Monnier2010-05-04 23:45:21 -0400
commit80ac5d4d34b34947df9b0088d81ec02aa10a93b5 (patch)
treead08364ee1613d99018bfd6cc42809ed3c1e08fa
parentf44379e7feb79dd734318706abe5a000cff34c9b (diff)
downloademacs-80ac5d4d34b34947df9b0088d81ec02aa10a93b5.tar.gz
emacs-80ac5d4d34b34947df9b0088d81ec02aa10a93b5.zip
Use define-minor-mode in more cases.
* term/tvi970.el (tvi970-set-keypad-mode): * simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode) (normal-erase-is-backspace-mode): * scroll-bar.el (scroll-bar-mode): Use it and define-minor-mode. (set-scroll-bar-mode-1): (Re)move to its sole caller. (get-scroll-bar-mode): New function. * emacs-lisp/cl-macs.el (eq): Handle a non-variable first arg.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/emacs-lisp/cl-loaddefs.el2
-rw-r--r--lisp/emacs-lisp/cl-macs.el12
-rw-r--r--lisp/scroll-bar.el22
-rw-r--r--lisp/simple.el44
-rw-r--r--lisp/term/tvi970.el13
6 files changed, 47 insertions, 56 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3edaea5d623..f2ebf07fd87 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,15 @@
12010-05-05 Stefan Monnier <monnier@iro.umontreal.ca> 12010-05-05 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 Use define-minor-mode in more cases.
4 * term/tvi970.el (tvi970-set-keypad-mode):
5 * simple.el (auto-fill-mode, overwrite-mode, binary-overwrite-mode)
6 (normal-erase-is-backspace-mode):
7 * scroll-bar.el (scroll-bar-mode): Use it and define-minor-mode.
8 (set-scroll-bar-mode-1): (Re)move to its sole caller.
9 (get-scroll-bar-mode): New function.
10 * emacs-lisp/cl-macs.el (eq): Handle a non-variable first arg.
11
12 Use define-minor-mode for less obvious cases.
3 * emacs-lisp/easy-mmode.el (define-minor-mode): Add :variable keyword. 13 * emacs-lisp/easy-mmode.el (define-minor-mode): Add :variable keyword.
4 * emacs-lisp/cl-macs.el (terminal-parameter, eq): Add setf method. 14 * emacs-lisp/cl-macs.el (terminal-parameter, eq): Add setf method.
5 * international/iso-ascii.el (iso-ascii-mode): 15 * international/iso-ascii.el (iso-ascii-mode):
diff --git a/lisp/emacs-lisp/cl-loaddefs.el b/lisp/emacs-lisp/cl-loaddefs.el
index bb5fd5037a1..e828325bd0e 100644
--- a/lisp/emacs-lisp/cl-loaddefs.el
+++ b/lisp/emacs-lisp/cl-loaddefs.el
@@ -282,7 +282,7 @@ Not documented
282;;;;;; flet progv psetq do-all-symbols do-symbols dotimes dolist 282;;;;;; flet progv psetq do-all-symbols do-symbols dotimes dolist
283;;;;;; do* do loop return-from return block etypecase typecase ecase 283;;;;;; do* do loop return-from return block etypecase typecase ecase
284;;;;;; case load-time-value eval-when destructuring-bind function* 284;;;;;; case load-time-value eval-when destructuring-bind function*
285;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "7fad7dd60f2f96ba90432f885015d61b") 285;;;;;; defmacro* defun* gentemp gensym) "cl-macs" "cl-macs.el" "0faa39d8f21ae59f2cc1baa835e28a5f")
286;;; Generated autoloads from cl-macs.el 286;;; Generated autoloads from cl-macs.el
287 287
288(autoload 'gensym "cl-macs" "\ 288(autoload 'gensym "cl-macs" "\
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index e48835adeb1..57870b19066 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1826,7 +1826,17 @@ Example:
1826;; (setq a 7) or (setq a nil) depending on whether B is nil or not. 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 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. 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)))) 1829(define-setf-method eq (place val)
1830 (let ((method (get-setf-method place cl-macro-environment))
1831 (val-temp (make-symbol "--eq-val--"))
1832 (store-temp (make-symbol "--eq-store--")))
1833 (list (append (nth 0 method) (list val-temp))
1834 (append (nth 1 method) (list val))
1835 (list store-temp)
1836 `(let ((,(car (nth 2 method))
1837 (if ,store-temp ,val-temp (not ,val-temp))))
1838 ,(nth 3 method) ,store-temp)
1839 `(eq ,(nth 4 method) ,val-temp))))
1830 1840
1831;;; More complex setf-methods. 1841;;; More complex setf-methods.
1832;; These should take &environment arguments, but since full arglists aren't 1842;; These should take &environment arguments, but since full arglists aren't
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 3f763fc59da..ebc00859137 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -29,6 +29,7 @@
29;;; Code: 29;;; Code:
30 30
31(require 'mouse) 31(require 'mouse)
32(eval-when-compile (require 'cl))
32 33
33 34
34;;;; Utilities. 35;;;; Utilities.
@@ -79,9 +80,6 @@ SIDE must be the symbol `left' or `right'."
79 "Non-nil means `set-scroll-bar-mode' should really do something. 80 "Non-nil means `set-scroll-bar-mode' should really do something.
80This is nil while loading `scroll-bar.el', and t afterward.") 81This is nil while loading `scroll-bar.el', and t afterward.")
81 82
82(defun set-scroll-bar-mode-1 (ignore value)
83 (set-scroll-bar-mode value))
84
85(defun set-scroll-bar-mode (value) 83(defun set-scroll-bar-mode (value)
86 "Set `scroll-bar-mode' to VALUE and put the new value into effect." 84 "Set `scroll-bar-mode' to VALUE and put the new value into effect."
87 (if scroll-bar-mode 85 (if scroll-bar-mode
@@ -107,27 +105,23 @@ Setting the variable with a customization buffer also takes effect."
107 ;; The default value for :initialize would try to use :set 105 ;; The default value for :initialize would try to use :set
108 ;; when processing the file in cus-dep.el. 106 ;; when processing the file in cus-dep.el.
109 :initialize 'custom-initialize-default 107 :initialize 'custom-initialize-default
110 :set 'set-scroll-bar-mode-1) 108 :set (lambda (sym val) (set-scroll-bar-mode val)))
111 109
112;; We just set scroll-bar-mode, but that was the default. 110;; We just set scroll-bar-mode, but that was the default.
113;; If it is set again, that is for real. 111;; If it is set again, that is for real.
114(setq scroll-bar-mode-explicit t) 112(setq scroll-bar-mode-explicit t)
115 113
116(defun scroll-bar-mode (&optional flag) 114(defun get-scroll-bar-mode () scroll-bar-mode)
115(defsetf get-scroll-bar-mode set-scroll-bar-mode)
116(define-minor-mode scroll-bar-mode
117 "Toggle display of vertical scroll bars on all frames. 117 "Toggle display of vertical scroll bars on all frames.
118This command applies to all frames that exist and frames to be 118This command applies to all frames that exist and frames to be
119created in the future. 119created in the future.
120With a numeric argument, if the argument is positive 120With a numeric argument, if the argument is positive
121turn on scroll bars; otherwise turn off scroll bars." 121turn on scroll bars; otherwise turn off scroll bars."
122 (interactive "P") 122 :variable (eq (get-scroll-bar-mode)
123 123 (or previous-scroll-bar-mode
124 ;; Tweedle the variable according to the argument. 124 default-frame-scroll-bars)))
125 (set-scroll-bar-mode (if (if (null flag)
126 (not scroll-bar-mode)
127 (setq flag (prefix-numeric-value flag))
128 (or (not (numberp flag)) (> flag 0)))
129 (or previous-scroll-bar-mode
130 default-frame-scroll-bars))))
131 125
132(defun toggle-scroll-bar (arg) 126(defun toggle-scroll-bar (arg)
133 "Toggle whether or not the selected frame has vertical scroll bars. 127 "Toggle whether or not the selected frame has vertical scroll bars.
diff --git a/lisp/simple.el b/lisp/simple.el
index 37ad0d81ca0..8e45ca4694d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -5149,7 +5149,7 @@ Some major modes set this.")
5149(put 'auto-fill-function 'safe-local-variable 'null) 5149(put 'auto-fill-function 'safe-local-variable 'null)
5150;; FIXME: turn into a proper minor mode. 5150;; FIXME: turn into a proper minor mode.
5151;; Add a global minor mode version of it. 5151;; Add a global minor mode version of it.
5152(defun auto-fill-mode (&optional arg) 5152(define-minor-mode auto-fill-mode
5153 "Toggle Auto Fill mode. 5153 "Toggle Auto Fill mode.
5154With ARG, turn Auto Fill mode on if and only if ARG is positive. 5154With ARG, turn Auto Fill mode on if and only if ARG is positive.
5155In Auto Fill mode, inserting a space at a column beyond `current-fill-column' 5155In Auto Fill mode, inserting a space at a column beyond `current-fill-column'
@@ -5157,14 +5157,7 @@ automatically breaks the line at a previous space.
5157 5157
5158The value of `normal-auto-fill-function' specifies the function to use 5158The value of `normal-auto-fill-function' specifies the function to use
5159for `auto-fill-function' when turning Auto Fill mode on." 5159for `auto-fill-function' when turning Auto Fill mode on."
5160 (interactive "P") 5160 :variable (eq auto-fill-function normal-auto-fill-function))
5161 (prog1 (setq auto-fill-function
5162 (if (if (null arg)
5163 (not auto-fill-function)
5164 (> (prefix-numeric-value arg) 0))
5165 normal-auto-fill-function
5166 nil))
5167 (force-mode-line-update)))
5168 5161
5169;; This holds a document string used to document auto-fill-mode. 5162;; This holds a document string used to document auto-fill-mode.
5170(defun auto-fill-function () 5163(defun auto-fill-function ()
@@ -5263,7 +5256,7 @@ if long lines are truncated."
5263(defvar overwrite-mode-binary (purecopy " Bin Ovwrt") 5256(defvar overwrite-mode-binary (purecopy " Bin Ovwrt")
5264 "The string displayed in the mode line when in binary overwrite mode.") 5257 "The string displayed in the mode line when in binary overwrite mode.")
5265 5258
5266(defun overwrite-mode (arg) 5259(define-minor-mode overwrite-mode
5267 "Toggle overwrite mode. 5260 "Toggle overwrite mode.
5268With prefix argument ARG, turn overwrite mode on if ARG is positive, 5261With prefix argument ARG, turn overwrite mode on if ARG is positive,
5269otherwise turn it off. In overwrite mode, printing characters typed 5262otherwise turn it off. In overwrite mode, printing characters typed
@@ -5272,14 +5265,9 @@ it to the right. At the end of a line, such characters extend the line.
5272Before a tab, such characters insert until the tab is filled in. 5265Before a tab, such characters insert until the tab is filled in.
5273\\[quoted-insert] still inserts characters in overwrite mode; this 5266\\[quoted-insert] still inserts characters in overwrite mode; this
5274is supposed to make it easier to insert characters when necessary." 5267is supposed to make it easier to insert characters when necessary."
5275 (interactive "P") 5268 :variable (eq overwrite-mode 'overwrite-mode-textual))
5276 (setq overwrite-mode
5277 (if (if (null arg) (not overwrite-mode)
5278 (> (prefix-numeric-value arg) 0))
5279 'overwrite-mode-textual))
5280 (force-mode-line-update))
5281 5269
5282(defun binary-overwrite-mode (arg) 5270(define-minor-mode binary-overwrite-mode
5283 "Toggle binary overwrite mode. 5271 "Toggle binary overwrite mode.
5284With prefix argument ARG, turn binary overwrite mode on if ARG is 5272With prefix argument ARG, turn binary overwrite mode on if ARG is
5285positive, otherwise turn it off. In binary overwrite mode, printing 5273positive, otherwise turn it off. In binary overwrite mode, printing
@@ -5292,13 +5280,7 @@ replaces the text at the cursor, just as ordinary typing characters do.
5292Note that binary overwrite mode is not its own minor mode; it is a 5280Note that binary overwrite mode is not its own minor mode; it is a
5293specialization of overwrite mode, entered by setting the 5281specialization of overwrite mode, entered by setting the
5294`overwrite-mode' variable to `overwrite-mode-binary'." 5282`overwrite-mode' variable to `overwrite-mode-binary'."
5295 (interactive "P") 5283 :variable (eq overwrite-mode 'overwrite-mode-binary))
5296 (setq overwrite-mode
5297 (if (if (null arg)
5298 (not (eq overwrite-mode 'overwrite-mode-binary))
5299 (> (prefix-numeric-value arg) 0))
5300 'overwrite-mode-binary))
5301 (force-mode-line-update))
5302 5284
5303(define-minor-mode line-number-mode 5285(define-minor-mode line-number-mode
5304 "Toggle Line Number mode. 5286 "Toggle Line Number mode.
@@ -6438,7 +6420,7 @@ call `normal-erase-is-backspace-mode' (which see) instead."
6438 normal-erase-is-backspace) 6420 normal-erase-is-backspace)
6439 1 0))))) 6421 1 0)))))
6440 6422
6441(defun normal-erase-is-backspace-mode (&optional arg) 6423(define-minor-mode normal-erase-is-backspace-mode
6442 "Toggle the Erase and Delete mode of the Backspace and Delete keys. 6424 "Toggle the Erase and Delete mode of the Backspace and Delete keys.
6443 6425
6444With numeric ARG, turn the mode on if and only if ARG is positive. 6426With numeric ARG, turn the mode on if and only if ARG is positive.
@@ -6468,13 +6450,10 @@ probably not turn on this mode on a text-only terminal if you don't
6468have both Backspace, Delete and F1 keys. 6450have both Backspace, Delete and F1 keys.
6469 6451
6470See also `normal-erase-is-backspace'." 6452See also `normal-erase-is-backspace'."
6471 (interactive "P") 6453 :variable (eq (terminal-parameter
6472 (let ((enabled (or (and arg (> (prefix-numeric-value arg) 0)) 6454 nil 'normal-erase-is-backspace) 1)
6473 (not (or arg 6455 (let ((enabled (eq 1 (terminal-parameter
6474 (eq 1 (terminal-parameter 6456 nil 'normal-erase-is-backspace))))
6475 nil 'normal-erase-is-backspace)))))))
6476 (set-terminal-parameter nil 'normal-erase-is-backspace
6477 (if enabled 1 0))
6478 6457
6479 (cond ((or (memq window-system '(x w32 ns pc)) 6458 (cond ((or (memq window-system '(x w32 ns pc))
6480 (memq system-type '(ms-dos windows-nt))) 6459 (memq system-type '(ms-dos windows-nt)))
@@ -6510,7 +6489,6 @@ See also `normal-erase-is-backspace'."
6510 (keyboard-translate ?\C-h ?\C-h) 6489 (keyboard-translate ?\C-h ?\C-h)
6511 (keyboard-translate ?\C-? ?\C-?)))) 6490 (keyboard-translate ?\C-? ?\C-?))))
6512 6491
6513 (run-hooks 'normal-erase-is-backspace-hook)
6514 (if (called-interactively-p 'interactive) 6492 (if (called-interactively-p 'interactive)
6515 (message "Delete key deletes %s" 6493 (message "Delete key deletes %s"
6516 (if (eq 1 (terminal-parameter nil 'normal-erase-is-backspace)) 6494 (if (eq 1 (terminal-parameter nil 'normal-erase-is-backspace))
diff --git a/lisp/term/tvi970.el b/lisp/term/tvi970.el
index 389adcde6c4..4476165febc 100644
--- a/lisp/term/tvi970.el
+++ b/lisp/term/tvi970.el
@@ -28,6 +28,8 @@
28 28
29;;; Code: 29;;; Code:
30 30
31(eval-when-compile (require 'cl))
32
31(defvar tvi970-terminal-map 33(defvar tvi970-terminal-map
32 (let ((map (make-sparse-keymap))) 34 (let ((map (make-sparse-keymap)))
33 35
@@ -102,7 +104,7 @@
102 104
103 105
104;; Should keypad numbers send ordinary digits or distinct escape sequences? 106;; Should keypad numbers send ordinary digits or distinct escape sequences?
105(defun tvi970-set-keypad-mode (&optional arg) 107(define-minor-mode tvi970-set-keypad-mode
106 "Set the current mode of the TVI 970 numeric keypad. 108 "Set the current mode of the TVI 970 numeric keypad.
107In ``numeric keypad mode'', the number keys on the keypad act as 109In ``numeric keypad mode'', the number keys on the keypad act as
108ordinary digits. In ``alternate keypad mode'', the keys send distinct 110ordinary digits. In ``alternate keypad mode'', the keys send distinct
@@ -111,12 +113,9 @@ independent of the normal number keys.
111With no argument, toggle between the two possible modes. 113With no argument, toggle between the two possible modes.
112With a positive argument, select alternate keypad mode. 114With a positive argument, select alternate keypad mode.
113With a negative argument, select numeric keypad mode." 115With a negative argument, select numeric keypad mode."
114 (interactive "P") 116 :variable (terminal-parameter nil 'tvi970-keypad-numeric)
115 (let ((newval (if (null arg) 117 (send-string-to-terminal
116 (not (terminal-parameter nil 'tvi970-keypad-numeric)) 118 (if (terminal-parameter nil 'tvi970-keypad-numeric) "\e=" "\e>")))
117 (> (prefix-numeric-value arg) 0))))
118 (set-terminal-parameter nil 'tvi970-keypad-numeric newval)
119 (send-string-to-terminal (if newval "\e=" "\e>"))))
120 119
121;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0 120;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
122;;; tvi970.el ends here 121;;; tvi970.el ends here