diff options
| author | Stefan Monnier | 2007-07-10 19:54:43 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2007-07-10 19:54:43 +0000 |
| commit | 47ccb9932969a69ba424464047e56c9bf77b33fb (patch) | |
| tree | 0aa3463ca90a4ecd721a35487eb43b58056f5b3c | |
| parent | cc213f24d734e938cf975d8dd57a3ef244307529 (diff) | |
| download | emacs-47ccb9932969a69ba424464047e56c9bf77b33fb.tar.gz emacs-47ccb9932969a69ba424464047e56c9bf77b33fb.zip | |
*** empty log message ***
| -rw-r--r-- | lisp/subr.el | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 3804624b0b9..185b9031d27 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -510,6 +510,7 @@ Don't call this function; it is for internal use only." | |||
| 510 | (if (integerp b) (< a b) | 510 | (if (integerp b) (< a b) |
| 511 | t) | 511 | t) |
| 512 | (if (integerp b) t | 512 | (if (integerp b) t |
| 513 | ;; string< also accepts symbols. | ||
| 513 | (string< a b)))))) | 514 | (string< a b)))))) |
| 514 | (dolist (p list) | 515 | (dolist (p list) |
| 515 | (funcall function (car p) (cdr p)))) | 516 | (funcall function (car p) (cdr p)))) |
| @@ -2485,6 +2486,29 @@ If BODY finishes, `while-no-input' returns whatever value BODY produced." | |||
| 2485 | (or (input-pending-p) | 2486 | (or (input-pending-p) |
| 2486 | ,@body)))))) | 2487 | ,@body)))))) |
| 2487 | 2488 | ||
| 2489 | (defmacro condition-case-no-debug (var bodyform &rest handlers) | ||
| 2490 | "Like `condition-case' except that it does not catch anything when debugging. | ||
| 2491 | More specifically if `debug-on-error' is set, then it does not catch any signal." | ||
| 2492 | (declare (debug condition-case) (indent 2)) | ||
| 2493 | (let ((bodysym (make-symbol "body"))) | ||
| 2494 | `(let ((,bodysym (lambda () ,bodyform))) | ||
| 2495 | (if debug-on-error | ||
| 2496 | (funcall ,bodysym) | ||
| 2497 | (condition-case ,var | ||
| 2498 | (funcall ,bodysym) | ||
| 2499 | ,@handlers))))) | ||
| 2500 | |||
| 2501 | (defmacro with-demoted-errors (&rest body) | ||
| 2502 | "Run BODY and demote any errors to simple messages. | ||
| 2503 | If `debug-on-error' is non-nil, run BODY without catching its errors. | ||
| 2504 | This is to be used around code which is not expected to signal an error | ||
| 2505 | but which should be robust in the unexpected case that an error is signalled." | ||
| 2506 | (declare (debug t) (indent 0)) | ||
| 2507 | (let ((err (make-symbol "err"))) | ||
| 2508 | `(condition-case-no-debug ,err | ||
| 2509 | (progn ,@body) | ||
| 2510 | (error (message "Error: %s" ,err) nil)))) | ||
| 2511 | |||
| 2488 | (defmacro combine-after-change-calls (&rest body) | 2512 | (defmacro combine-after-change-calls (&rest body) |
| 2489 | "Execute BODY, but don't call the after-change functions till the end. | 2513 | "Execute BODY, but don't call the after-change functions till the end. |
| 2490 | If BODY makes changes in the buffer, they are recorded | 2514 | If BODY makes changes in the buffer, they are recorded |
| @@ -2519,6 +2543,20 @@ The value returned is the value of the last form in BODY." | |||
| 2519 | 2543 | ||
| 2520 | ;;;; Constructing completion tables. | 2544 | ;;;; Constructing completion tables. |
| 2521 | 2545 | ||
| 2546 | (defun complete-with-action (action table string pred) | ||
| 2547 | "Perform completion ACTION. | ||
| 2548 | STRING is the string to complete. | ||
| 2549 | TABLE is the completion table, which should not be a function. | ||
| 2550 | PRED is a completion predicate. | ||
| 2551 | ACTION can be one of nil, t or `lambda'." | ||
| 2552 | ;; (assert (not (functionp table))) | ||
| 2553 | (funcall | ||
| 2554 | (cond | ||
| 2555 | ((null action) 'try-completion) | ||
| 2556 | ((eq action t) 'all-completions) | ||
| 2557 | (t 'test-completion)) | ||
| 2558 | string table pred)) | ||
| 2559 | |||
| 2522 | (defmacro dynamic-completion-table (fun) | 2560 | (defmacro dynamic-completion-table (fun) |
| 2523 | "Use function FUN as a dynamic completion table. | 2561 | "Use function FUN as a dynamic completion table. |
| 2524 | FUN is called with one argument, the string for which completion is required, | 2562 | FUN is called with one argument, the string for which completion is required, |
| @@ -2540,10 +2578,7 @@ that can be used as the ALIST argument to `try-completion' and | |||
| 2540 | (with-current-buffer (let ((,win (minibuffer-selected-window))) | 2578 | (with-current-buffer (let ((,win (minibuffer-selected-window))) |
| 2541 | (if (window-live-p ,win) (window-buffer ,win) | 2579 | (if (window-live-p ,win) (window-buffer ,win) |
| 2542 | (current-buffer))) | 2580 | (current-buffer))) |
| 2543 | (cond | 2581 | (complete-with-action ,mode (,fun ,string) ,string ,predicate))))) |
| 2544 | ((eq ,mode t) (all-completions ,string (,fun ,string) ,predicate)) | ||
| 2545 | ((not ,mode) (try-completion ,string (,fun ,string) ,predicate)) | ||
| 2546 | (t (test-completion ,string (,fun ,string) ,predicate))))))) | ||
| 2547 | 2582 | ||
| 2548 | (defmacro lazy-completion-table (var fun) | 2583 | (defmacro lazy-completion-table (var fun) |
| 2549 | ;; We used to have `&rest args' where `args' were evaluated late (at the | 2584 | ;; We used to have `&rest args' where `args' were evaluated late (at the |