Mercurial > emacs
comparison lisp/subr.el @ 90601:a1a25ac6c88a
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 427-436)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 134-136)
- Merge from emacs--devo--0
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-110
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 14 Sep 2006 09:24:00 +0000 |
parents | 858cb33ae39d b70548506872 |
children | bb0e318b7c53 |
comparison
equal
deleted
inserted
replaced
90600:84dd84b43e1b | 90601:a1a25ac6c88a |
---|---|
1083 (set-default hook hook-value) | 1083 (set-default hook hook-value) |
1084 (if (equal hook-value '(t)) | 1084 (if (equal hook-value '(t)) |
1085 (kill-local-variable hook) | 1085 (kill-local-variable hook) |
1086 (set hook hook-value)))))) | 1086 (set hook hook-value)))))) |
1087 | 1087 |
1088 (defun add-to-list (list-var element &optional append) | 1088 (defun add-to-list (list-var element &optional append compare-fn) |
1089 "Add ELEMENT to the value of LIST-VAR if it isn't there yet. | 1089 "Add ELEMENT to the value of LIST-VAR if it isn't there yet. |
1090 The test for presence of ELEMENT is done with `equal'. | 1090 The test for presence of ELEMENT is done with `equal', |
1091 or with COMPARE-FN if that's non-nil. | |
1091 If ELEMENT is added, it is added at the beginning of the list, | 1092 If ELEMENT is added, it is added at the beginning of the list, |
1092 unless the optional argument APPEND is non-nil, in which case | 1093 unless the optional argument APPEND is non-nil, in which case |
1093 ELEMENT is added at the end. | 1094 ELEMENT is added at the end. |
1094 | 1095 |
1095 The return value is the new value of LIST-VAR. | 1096 The return value is the new value of LIST-VAR. |
1097 If you want to use `add-to-list' on a variable that is not defined | 1098 If you want to use `add-to-list' on a variable that is not defined |
1098 until a certain package is loaded, you should put the call to `add-to-list' | 1099 until a certain package is loaded, you should put the call to `add-to-list' |
1099 into a hook function that will be run only after loading the package. | 1100 into a hook function that will be run only after loading the package. |
1100 `eval-after-load' provides one way to do this. In some cases | 1101 `eval-after-load' provides one way to do this. In some cases |
1101 other hooks, such as major mode hooks, can do the job." | 1102 other hooks, such as major mode hooks, can do the job." |
1102 (if (member element (symbol-value list-var)) | 1103 (if (if compare-fn |
1104 (let (present) | |
1105 (dolist (elt (symbol-value list-var)) | |
1106 (if (funcall compare-fn element elt) | |
1107 (setq present t))) | |
1108 present) | |
1109 (member element (symbol-value list-var))) | |
1103 (symbol-value list-var) | 1110 (symbol-value list-var) |
1104 (set list-var | 1111 (set list-var |
1105 (if append | 1112 (if append |
1106 (append (symbol-value list-var) (list element)) | 1113 (append (symbol-value list-var) (list element)) |
1107 (cons element (symbol-value list-var)))))) | 1114 (cons element (symbol-value list-var)))))) |
1731 | 1738 |
1732 \(fn SECONDS &optional NODISP)" | 1739 \(fn SECONDS &optional NODISP)" |
1733 (when (or obsolete (numberp nodisp)) | 1740 (when (or obsolete (numberp nodisp)) |
1734 (setq seconds (+ seconds (* 1e-3 nodisp))) | 1741 (setq seconds (+ seconds (* 1e-3 nodisp))) |
1735 (setq nodisp obsolete)) | 1742 (setq nodisp obsolete)) |
1736 (if noninteractive | 1743 (cond |
1737 (progn (sleep-for seconds) t) | 1744 (noninteractive |
1738 (unless nodisp (redisplay)) | 1745 (sleep-for seconds) |
1739 (or (<= seconds 0) | 1746 t) |
1740 (let ((read (read-event nil nil seconds))) | 1747 ((input-pending-p) |
1741 (or (null read) | 1748 nil) |
1742 (progn (push read unread-command-events) nil)))))) | 1749 ((<= seconds 0) |
1750 (or nodisp (redisplay))) | |
1751 (t | |
1752 (or nodisp (redisplay)) | |
1753 (let ((read (read-event nil nil seconds))) | |
1754 (or (null read) | |
1755 (progn (push read unread-command-events) | |
1756 nil)))))) | |
1743 | 1757 |
1744 ;;; Atomic change groups. | 1758 ;;; Atomic change groups. |
1745 | 1759 |
1746 (defmacro atomic-change-group (&rest body) | 1760 (defmacro atomic-change-group (&rest body) |
1747 "Perform BODY as an atomic change group. | 1761 "Perform BODY as an atomic change group. |
2385 (declare (debug t) (indent 0)) | 2399 (declare (debug t) (indent 0)) |
2386 (let ((catch-sym (make-symbol "input"))) | 2400 (let ((catch-sym (make-symbol "input"))) |
2387 `(with-local-quit | 2401 `(with-local-quit |
2388 (catch ',catch-sym | 2402 (catch ',catch-sym |
2389 (let ((throw-on-input ',catch-sym)) | 2403 (let ((throw-on-input ',catch-sym)) |
2390 (or (not (sit-for 0 0 t)) | 2404 (or (input-pending-p) |
2391 ,@body)))))) | 2405 ,@body)))))) |
2392 | 2406 |
2393 (defmacro combine-after-change-calls (&rest body) | 2407 (defmacro combine-after-change-calls (&rest body) |
2394 "Execute BODY, but don't call the after-change functions till the end. | 2408 "Execute BODY, but don't call the after-change functions till the end. |
2395 If BODY makes changes in the buffer, they are recorded | 2409 If BODY makes changes in the buffer, they are recorded |
2396 and the functions on `after-change-functions' are called several times | 2410 and the functions on `after-change-functions' are called several times |