Mercurial > emacs
comparison lisp/subr.el @ 90199:bb71c6cf2009
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-67
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 447-458)
- Update from CVS
- Update from CVS: lisp/subr.el (add-to-ordered-list): Doc fix.
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 83-85)
- Merge from emacs--cvs-trunk--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 30 Jun 2005 00:31:46 +0000 |
parents | b7da78284d4c 7f964f8f5c85 |
children | f9a65d7ebd29 |
comparison
equal
deleted
inserted
replaced
90198:97f6c3a96df1 | 90199:bb71c6cf2009 |
---|---|
935 (if (equal hook-value '(t)) | 935 (if (equal hook-value '(t)) |
936 (kill-local-variable hook) | 936 (kill-local-variable hook) |
937 (set hook hook-value)))))) | 937 (set hook hook-value)))))) |
938 | 938 |
939 (defun add-to-list (list-var element &optional append) | 939 (defun add-to-list (list-var element &optional append) |
940 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. | 940 "Add ELEMENT to the value of LIST-VAR if it isn't there yet. |
941 The test for presence of ELEMENT is done with `equal'. | 941 The test for presence of ELEMENT is done with `equal'. |
942 If ELEMENT is added, it is added at the beginning of the list, | 942 If ELEMENT is added, it is added at the beginning of the list, |
943 unless the optional argument APPEND is non-nil, in which case | 943 unless the optional argument APPEND is non-nil, in which case |
944 ELEMENT is added at the end. | 944 ELEMENT is added at the end. |
945 | 945 |
957 (append (symbol-value list-var) (list element)) | 957 (append (symbol-value list-var) (list element)) |
958 (cons element (symbol-value list-var)))))) | 958 (cons element (symbol-value list-var)))))) |
959 | 959 |
960 | 960 |
961 (defun add-to-ordered-list (list-var element &optional order) | 961 (defun add-to-ordered-list (list-var element &optional order) |
962 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. | 962 "Add ELEMENT to the value of LIST-VAR if it isn't there yet. |
963 The test for presence of ELEMENT is done with `eq'. | 963 The test for presence of ELEMENT is done with `eq'. |
964 | 964 |
965 The resulting list is reordered so that the elements are in the | 965 The resulting list is reordered so that the elements are in the |
966 order given by each element's numeric list order. Elements | 966 order given by each element's numeric list order. Elements |
967 without a numeric list order are placed at the end of the list. | 967 without a numeric list order are placed at the end of the list. |
968 | 968 |
969 If the third optional argument ORDER is non-nil, set the | 969 If the third optional argument ORDER is a number (integer or |
970 element's list order to the given value. | 970 float), set the element's list order to the given value. If |
971 ORDER is nil or omitted, do not change the numeric order of | |
972 ELEMENT. If ORDER has any other value, remove the numeric order | |
973 of ELEMENT if it has one. | |
971 | 974 |
972 The list order for each element is stored in LIST-VAR's | 975 The list order for each element is stored in LIST-VAR's |
973 `list-order' property. | 976 `list-order' property. |
974 | 977 |
975 The return value is the new value of LIST-VAR." | 978 The return value is the new value of LIST-VAR." |
1715 ,@body)) | 1718 ,@body)) |
1716 | 1719 |
1717 (defmacro with-selected-window (window &rest body) | 1720 (defmacro with-selected-window (window &rest body) |
1718 "Execute the forms in BODY with WINDOW as the selected window. | 1721 "Execute the forms in BODY with WINDOW as the selected window. |
1719 The value returned is the value of the last form in BODY. | 1722 The value returned is the value of the last form in BODY. |
1720 This does not alter the buffer list ordering. | 1723 |
1721 This function saves and restores the selected window, as well as | 1724 This macro saves and restores the current buffer, since otherwise |
1725 its normal operation could potentially make a different | |
1726 buffer current. It does not alter the buffer list ordering. | |
1727 | |
1728 This macro saves and restores the selected window, as well as | |
1722 the selected window in each frame. If the previously selected | 1729 the selected window in each frame. If the previously selected |
1723 window of some frame is no longer live at the end of BODY, that | 1730 window of some frame is no longer live at the end of BODY, that |
1724 frame's selected window is left alone. If the selected window is | 1731 frame's selected window is left alone. If the selected window is |
1725 no longer live, then whatever window is selected at the end of | 1732 no longer live, then whatever window is selected at the end of |
1726 BODY remains selected. | 1733 BODY remains selected. |
1732 ;; select-window changes frame-selected-window for whatever | 1739 ;; select-window changes frame-selected-window for whatever |
1733 ;; frame that window is in. | 1740 ;; frame that window is in. |
1734 (save-selected-window-alist | 1741 (save-selected-window-alist |
1735 (mapcar (lambda (frame) (list frame (frame-selected-window frame))) | 1742 (mapcar (lambda (frame) (list frame (frame-selected-window frame))) |
1736 (frame-list)))) | 1743 (frame-list)))) |
1737 (unwind-protect | 1744 (save-current-buffer |
1738 (progn (select-window ,window 'norecord) | 1745 (unwind-protect |
1739 ,@body) | 1746 (progn (select-window ,window 'norecord) |
1740 (dolist (elt save-selected-window-alist) | 1747 ,@body) |
1741 (and (frame-live-p (car elt)) | 1748 (dolist (elt save-selected-window-alist) |
1742 (window-live-p (cadr elt)) | 1749 (and (frame-live-p (car elt)) |
1743 (set-frame-selected-window (car elt) (cadr elt)))) | 1750 (window-live-p (cadr elt)) |
1744 (if (window-live-p save-selected-window-window) | 1751 (set-frame-selected-window (car elt) (cadr elt)))) |
1745 (select-window save-selected-window-window 'norecord))))) | 1752 (if (window-live-p save-selected-window-window) |
1753 (select-window save-selected-window-window 'norecord)))))) | |
1746 | 1754 |
1747 (defmacro with-temp-file (file &rest body) | 1755 (defmacro with-temp-file (file &rest body) |
1748 "Create a new buffer, evaluate BODY there, and write the buffer to FILE. | 1756 "Create a new buffer, evaluate BODY there, and write the buffer to FILE. |
1749 The value returned is the value of the last form in BODY. | 1757 The value returned is the value of the last form in BODY. |
1750 See also `with-temp-buffer'." | 1758 See also `with-temp-buffer'." |