Mercurial > emacs
comparison lisp/subr.el @ 90573:858cb33ae39d
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 357-381)
- Merge from gnus--rel--5.10
- Update from CVS
- Merge from erc--emacs--21
* gnus--rel--5.10 (patch 116-122)
- Update from CVS
- Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-98
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 03 Aug 2006 11:45:23 +0000 |
parents | 8a8e69664178 0d8b226a4a76 |
children | a1a25ac6c88a |
comparison
equal
deleted
inserted
replaced
90572:ab9b8d043c39 | 90573:858cb33ae39d |
---|---|
106 (defmacro unless (cond &rest body) | 106 (defmacro unless (cond &rest body) |
107 "If COND yields nil, do BODY, else return nil." | 107 "If COND yields nil, do BODY, else return nil." |
108 (declare (indent 1) (debug t)) | 108 (declare (indent 1) (debug t)) |
109 (cons 'if (cons cond (cons nil body)))) | 109 (cons 'if (cons cond (cons nil body)))) |
110 | 110 |
111 (defvar --dolist-tail-- nil | |
112 "Temporary variable used in `dolist' expansion.") | |
113 | |
111 (defmacro dolist (spec &rest body) | 114 (defmacro dolist (spec &rest body) |
112 "Loop over a list. | 115 "Loop over a list. |
113 Evaluate BODY with VAR bound to each car from LIST, in turn. | 116 Evaluate BODY with VAR bound to each car from LIST, in turn. |
114 Then evaluate RESULT to get return value, default nil. | 117 Then evaluate RESULT to get return value, default nil. |
115 | 118 |
116 \(fn (VAR LIST [RESULT]) BODY...)" | 119 \(fn (VAR LIST [RESULT]) BODY...)" |
117 (declare (indent 1) (debug ((symbolp form &optional form) body))) | 120 (declare (indent 1) (debug ((symbolp form &optional form) body))) |
118 (let ((temp (make-symbol "--dolist-temp--"))) | 121 ;; It would be cleaner to create an uninterned symbol, |
122 ;; but that uses a lot more space when many functions in many files | |
123 ;; use dolist. | |
124 (let ((temp '--dolist-tail--)) | |
119 `(let ((,temp ,(nth 1 spec)) | 125 `(let ((,temp ,(nth 1 spec)) |
120 ,(car spec)) | 126 ,(car spec)) |
121 (while ,temp | 127 (while ,temp |
122 (setq ,(car spec) (car ,temp)) | 128 (setq ,(car spec) (car ,temp)) |
123 (setq ,temp (cdr ,temp)) | 129 ,@body |
124 ,@body) | 130 (setq ,temp (cdr ,temp))) |
125 ,@(if (cdr (cdr spec)) | 131 ,@(if (cdr (cdr spec)) |
126 `((setq ,(car spec) nil) ,@(cdr (cdr spec))))))) | 132 `((setq ,(car spec) nil) ,@(cdr (cdr spec))))))) |
133 | |
134 (defvar --dotimes-limit-- nil | |
135 "Temporary variable used in `dotimes' expansion.") | |
127 | 136 |
128 (defmacro dotimes (spec &rest body) | 137 (defmacro dotimes (spec &rest body) |
129 "Loop a certain number of times. | 138 "Loop a certain number of times. |
130 Evaluate BODY with VAR bound to successive integers running from 0, | 139 Evaluate BODY with VAR bound to successive integers running from 0, |
131 inclusive, to COUNT, exclusive. Then evaluate RESULT to get | 140 inclusive, to COUNT, exclusive. Then evaluate RESULT to get |
132 the return value (nil if RESULT is omitted). | 141 the return value (nil if RESULT is omitted). |
133 | 142 |
134 \(fn (VAR COUNT [RESULT]) BODY...)" | 143 \(fn (VAR COUNT [RESULT]) BODY...)" |
135 (declare (indent 1) (debug dolist)) | 144 (declare (indent 1) (debug dolist)) |
136 (let ((temp (make-symbol "--dotimes-temp--")) | 145 ;; It would be cleaner to create an uninterned symbol, |
146 ;; but that uses a lot more space when many functions in many files | |
147 ;; use dotimes. | |
148 (let ((temp '--dotimes-limit--) | |
137 (start 0) | 149 (start 0) |
138 (end (nth 1 spec))) | 150 (end (nth 1 spec))) |
139 `(let ((,temp ,end) | 151 `(let ((,temp ,end) |
140 (,(car spec) ,start)) | 152 (,(car spec) ,start)) |
141 (while (< ,(car spec) ,temp) | 153 (while (< ,(car spec) ,temp) |
1723 (setq nodisp obsolete)) | 1735 (setq nodisp obsolete)) |
1724 (if noninteractive | 1736 (if noninteractive |
1725 (progn (sleep-for seconds) t) | 1737 (progn (sleep-for seconds) t) |
1726 (unless nodisp (redisplay)) | 1738 (unless nodisp (redisplay)) |
1727 (or (<= seconds 0) | 1739 (or (<= seconds 0) |
1728 (let ((timer (timer-create)) | 1740 (let ((read (read-event nil nil seconds))) |
1729 (echo-keystrokes 0)) | 1741 (or (null read) |
1730 (if (catch 'sit-for-timeout | 1742 (progn (push read unread-command-events) nil)))))) |
1731 (timer-set-time timer (timer-relative-time | |
1732 (current-time) seconds)) | |
1733 (timer-set-function timer 'with-timeout-handler | |
1734 '(sit-for-timeout)) | |
1735 (timer-activate timer) | |
1736 (push (read-event) unread-command-events) | |
1737 nil) | |
1738 t | |
1739 (cancel-timer timer) | |
1740 nil))))) | |
1741 | 1743 |
1742 ;;; Atomic change groups. | 1744 ;;; Atomic change groups. |
1743 | 1745 |
1744 (defmacro atomic-change-group (&rest body) | 1746 (defmacro atomic-change-group (&rest body) |
1745 "Perform BODY as an atomic change group. | 1747 "Perform BODY as an atomic change group. |
2529 (match-end num))))) | 2531 (match-end num))))) |
2530 | 2532 |
2531 (defun looking-back (regexp &optional limit greedy) | 2533 (defun looking-back (regexp &optional limit greedy) |
2532 "Return non-nil if text before point matches regular expression REGEXP. | 2534 "Return non-nil if text before point matches regular expression REGEXP. |
2533 Like `looking-at' except matches before point, and is slower. | 2535 Like `looking-at' except matches before point, and is slower. |
2534 LIMIT if non-nil speeds up the search by specifying how far back the | 2536 LIMIT if non-nil speeds up the search by specifying a minimum |
2535 match can start. | 2537 starting position, to avoid checking matches that would start |
2538 before LIMIT. | |
2536 | 2539 |
2537 If GREEDY is non-nil, extend the match backwards as far as possible, | 2540 If GREEDY is non-nil, extend the match backwards as far as possible, |
2538 stopping when a single additional previous character cannot be part | 2541 stopping when a single additional previous character cannot be part |
2539 of a match for REGEXP." | 2542 of a match for REGEXP." |
2540 (let ((start (point)) | 2543 (let ((start (point)) |