aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2000-04-28 11:53:43 +0000
committerGerd Moellmann2000-04-28 11:53:43 +0000
commitc94f4677169587f105e3ee894a19d734a7187546 (patch)
tree55db8983f6e059c1122b6b9849cce5c5063f274e
parent030106ca73e8167d4d569f6d1615d58189bbffca (diff)
downloademacs-c94f4677169587f105e3ee894a19d734a7187546.tar.gz
emacs-c94f4677169587f105e3ee894a19d734a7187546.zip
*** empty log message ***
-rw-r--r--etc/NEWS23
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/subr.el55
3 files changed, 66 insertions, 16 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 720277d0437..4881906f90b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1150,12 +1150,25 @@ so I will know I still need to look at it -- rms.
1150** The function `add-minor-mode' simplifies the definition of minor 1150** The function `add-minor-mode' simplifies the definition of minor
1151modes. 1151modes.
1152 1152
1153- Function: add-minor-mode SYMBOL NAME MAP 1153- Function: add-minor-mode TOGGLE NAME &optional KEYMAP AFTER TOGGLE-FUN
1154 1154
1155Register a new minor mode. SYMBOL is the name of a buffer-local 1155Register a new minor mode.
1156variable that is toggled on or off to say whether the minor mode is 1156
1157active or not. NAME is the string that will appear in the mode line 1157TOGGLE is a symbol which is the name of a buffer-local variable that
1158when the minor mode is active. MAP is the keymap for the minor mode. 1158is toggled on or off to say whether the minor mode is active or not.
1159
1160NAME specifies what will appear in the mode line when the minor mode
1161is active. NAME should be either a string starting with a space, or a
1162symbol whose value is such a string.
1163
1164Optional KEYMAP is the keymap for the minor mode that will be added
1165to `minor-mode-map-alist'.
1166
1167Optional AFTER specifies that TOGGLE should be added after AFTER
1168in `minor-mode-alist'.
1169
1170Optional TOGGLE-FUN is there for compatiblity with other Emacssen.
1171It is currently not used.
1159 1172
1160** The function `shell-command' now sets the default directory of the 1173** The function `shell-command' now sets the default directory of the
1161`*Shell Command Output*' buffer to the default directory of the buffer 1174`*Shell Command Output*' buffer to the default directory of the buffer
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c4c132ea87b..b7cddec1f4f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12000-04-28 Gerd Moellmann <gerd@gnu.org>
2
3 * subr.el (add-minor-mode): Rewritten.
4
12000-04-28 Kenichi Handa <handa@etl.go.jp> 52000-04-28 Kenichi Handa <handa@etl.go.jp>
2 6
3 * mail/sendmail.el (sendmail-send-it): Set 7 * mail/sendmail.el (sendmail-send-it): Set
diff --git a/lisp/subr.el b/lisp/subr.el
index ebaaaf4d1fd..03e215a2230 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1486,18 +1486,51 @@ If DIR-FLAG is non-nil, create a new empty directory instead of a file."
1486 file)) 1486 file))
1487 1487
1488 1488
1489(defun add-minor-mode (symbol name &optional map) 1489(defun add-minor-mode (toggle name &optional keymap after toggle-fun)
1490 "Register a new minor mode. 1490 "Register a new minor mode.
1491SYMBOL is the name of a buffer-local variable that is toggled on 1491
1492or off to say whether the minor mode is active or not. NAME is the 1492TOGGLE is a symbol which is the name of a buffer-local variable that
1493string that will appear in the mode line when the minor mode is 1493is toggled on or off to say whether the minor mode is active or not.
1494active. Optional MAP is the keymap for the minor mode." 1494
1495 (make-local-variable symbol) 1495NAME specifies what will appear in the mode line when the minor mode
1496 (set symbol t) 1496is active. NAME should be either a string starting with a space, or a
1497 (unless (assq symbol minor-mode-alist) 1497symbol whose value is such a string.
1498 (add-to-list 'minor-mode-alist (list symbol name))) 1498
1499 (when (and map (not (assq symbol minor-mode-map-alist))) 1499Optional KEYMAP is the keymap for the minor mode that will be added
1500 (add-to-list 'minor-mode-map-alist (cons symbol map)))) 1500to `minor-mode-map-alist'.
1501
1502Optional AFTER specifies that TOGGLE should be added after AFTER
1503in `minor-mode-alist'.
1504
1505Optional TOGGLE-FUN is there for compatiblity with other Emacssen.
1506It is currently not used."
1507 (make-local-variable toggle)
1508 (set toggle t)
1509
1510 (when name
1511 (let ((existing (assq toggle minor-mode-alist))
1512 (name (if (symbolp name) (symbol-value name) name)))
1513 (cond ((null existing)
1514 (let ((tail minor-mode-alist) found)
1515 (while (and tail (not found))
1516 (if (eq after (caar tail))
1517 (setq found tail)
1518 (setq tail (cdr tail))))
1519 (if found
1520 (let ((rest (cdr found)))
1521 (setcdr found nil)
1522 (nconc found (list toggle name) rest))
1523 (setq minor-mode-alist (cons (list toggle name)
1524 minor-mode-alist)))))
1525 (t
1526 (setcdr existing (list name))))))
1527
1528 (when keymap
1529 (let ((existing (assq toggle minor-mode-map-alist)))
1530 (if existing
1531 (setcdr existing keymap)
1532 (setq minor-mode-map-alist (cons (cons toggle keymap)
1533 minor-mode-map-alist))))))
1501 1534
1502 1535
1503;;; subr.el ends here 1536;;; subr.el ends here