diff options
| author | Gerd Moellmann | 2000-04-28 11:53:43 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-04-28 11:53:43 +0000 |
| commit | c94f4677169587f105e3ee894a19d734a7187546 (patch) | |
| tree | 55db8983f6e059c1122b6b9849cce5c5063f274e | |
| parent | 030106ca73e8167d4d569f6d1615d58189bbffca (diff) | |
| download | emacs-c94f4677169587f105e3ee894a19d734a7187546.tar.gz emacs-c94f4677169587f105e3ee894a19d734a7187546.zip | |
*** empty log message ***
| -rw-r--r-- | etc/NEWS | 23 | ||||
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/subr.el | 55 |
3 files changed, 66 insertions, 16 deletions
| @@ -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 |
| 1151 | modes. | 1151 | modes. |
| 1152 | 1152 | ||
| 1153 | - Function: add-minor-mode SYMBOL NAME MAP | 1153 | - Function: add-minor-mode TOGGLE NAME &optional KEYMAP AFTER TOGGLE-FUN |
| 1154 | 1154 | ||
| 1155 | Register a new minor mode. SYMBOL is the name of a buffer-local | 1155 | Register a new minor mode. |
| 1156 | variable that is toggled on or off to say whether the minor mode is | 1156 | |
| 1157 | active or not. NAME is the string that will appear in the mode line | 1157 | TOGGLE is a symbol which is the name of a buffer-local variable that |
| 1158 | when the minor mode is active. MAP is the keymap for the minor mode. | 1158 | is toggled on or off to say whether the minor mode is active or not. |
| 1159 | |||
| 1160 | NAME specifies what will appear in the mode line when the minor mode | ||
| 1161 | is active. NAME should be either a string starting with a space, or a | ||
| 1162 | symbol whose value is such a string. | ||
| 1163 | |||
| 1164 | Optional KEYMAP is the keymap for the minor mode that will be added | ||
| 1165 | to `minor-mode-map-alist'. | ||
| 1166 | |||
| 1167 | Optional AFTER specifies that TOGGLE should be added after AFTER | ||
| 1168 | in `minor-mode-alist'. | ||
| 1169 | |||
| 1170 | Optional TOGGLE-FUN is there for compatiblity with other Emacssen. | ||
| 1171 | It 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 @@ | |||
| 1 | 2000-04-28 Gerd Moellmann <gerd@gnu.org> | ||
| 2 | |||
| 3 | * subr.el (add-minor-mode): Rewritten. | ||
| 4 | |||
| 1 | 2000-04-28 Kenichi Handa <handa@etl.go.jp> | 5 | 2000-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. |
| 1491 | SYMBOL is the name of a buffer-local variable that is toggled on | 1491 | |
| 1492 | or off to say whether the minor mode is active or not. NAME is the | 1492 | TOGGLE is a symbol which is the name of a buffer-local variable that |
| 1493 | string that will appear in the mode line when the minor mode is | 1493 | is toggled on or off to say whether the minor mode is active or not. |
| 1494 | active. Optional MAP is the keymap for the minor mode." | 1494 | |
| 1495 | (make-local-variable symbol) | 1495 | NAME specifies what will appear in the mode line when the minor mode |
| 1496 | (set symbol t) | 1496 | is active. NAME should be either a string starting with a space, or a |
| 1497 | (unless (assq symbol minor-mode-alist) | 1497 | symbol 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))) | 1499 | Optional KEYMAP is the keymap for the minor mode that will be added |
| 1500 | (add-to-list 'minor-mode-map-alist (cons symbol map)))) | 1500 | to `minor-mode-map-alist'. |
| 1501 | |||
| 1502 | Optional AFTER specifies that TOGGLE should be added after AFTER | ||
| 1503 | in `minor-mode-alist'. | ||
| 1504 | |||
| 1505 | Optional TOGGLE-FUN is there for compatiblity with other Emacssen. | ||
| 1506 | It 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 |