comparison lisp/subr.el @ 28794:2274787ba380

(add-minor-mode): Handle AFTER for keymaps. Don't set TOGGLE's value.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 03 May 2000 12:33:16 +0000
parents 6a79bbe8bf72
children 8a7623ffeeac
comparison
equal deleted inserted replaced
28793:e56af637f7a2 28794:2274787ba380
1500 to `minor-mode-map-alist'. 1500 to `minor-mode-map-alist'.
1501 1501
1502 Optional AFTER specifies that TOGGLE should be added after AFTER 1502 Optional AFTER specifies that TOGGLE should be added after AFTER
1503 in `minor-mode-alist'. 1503 in `minor-mode-alist'.
1504 1504
1505 Optional TOGGLE-FUN is there for compatiblity with other Emacssen. 1505 Optional TOGGLE-FUN is there for compatiblity with other Emacsen.
1506 It is currently not used." 1506 It is currently not used."
1507 (make-local-variable toggle) 1507 (make-local-variable toggle)
1508 (set toggle t)
1509 1508
1510 (when name 1509 (when name
1511 (let ((existing (assq toggle minor-mode-alist)) 1510 (let ((existing (assq toggle minor-mode-alist))
1512 (name (if (symbolp name) (symbol-value name) name))) 1511 (name (if (symbolp name) (symbol-value name) name)))
1513 (cond ((null existing) 1512 (cond ((null existing)
1517 (setq found tail) 1516 (setq found tail)
1518 (setq tail (cdr tail)))) 1517 (setq tail (cdr tail))))
1519 (if found 1518 (if found
1520 (let ((rest (cdr found))) 1519 (let ((rest (cdr found)))
1521 (setcdr found nil) 1520 (setcdr found nil)
1522 (nconc found (list toggle name) rest)) 1521 (nconc found (list (list toggle name)) rest))
1523 (setq minor-mode-alist (cons (list toggle name) 1522 (setq minor-mode-alist (cons (list toggle name)
1524 minor-mode-alist))))) 1523 minor-mode-alist)))))
1525 (t 1524 (t
1526 (setcdr existing (list name)))))) 1525 (setcdr existing (list name))))))
1527 1526
1528 (when keymap 1527 (when keymap
1529 (let ((existing (assq toggle minor-mode-map-alist))) 1528 (let ((existing (assq toggle minor-mode-map-alist)))
1530 (if existing 1529 (cond ((null existing)
1531 (setcdr existing keymap) 1530 (let ((tail minor-mode-map-alist) found)
1532 (setq minor-mode-map-alist (cons (cons toggle keymap) 1531 (while (and tail (not found))
1533 minor-mode-map-alist)))))) 1532 (if (eq after (caar tail))
1533 (setq found tail)
1534 (setq tail (cdr tail))))
1535 (if found
1536 (let ((rest (cdr found)))
1537 (setcdr found nil)
1538 (nconc found (list (cons toggle keymap)) rest))
1539 (setq minor-mode-map-alist (cons (cons toggle keymap)
1540 minor-mode-map-alist)))))
1541 (t
1542 (setcdr existing keymap))))))
1534 1543
1535 1544
1536 ;;; subr.el ends here 1545 ;;; subr.el ends here