diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/emacs-lisp/timer.el | 41 | ||||
| -rw-r--r-- | lisp/simple.el | 18 |
3 files changed, 46 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 62d7cc449ab..10570c2a878 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2011-10-13 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * simple.el (what-cursor-position): Fix the display of the | ||
| 4 | character info for LRE, LRO, RLE, and RLO characters by appending | ||
| 5 | an invisible PDF. | ||
| 6 | |||
| 7 | 2011-10-13 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 8 | |||
| 9 | * emacs-lisp/timer.el (with-timeout): Make sure we cancel the timer | ||
| 10 | even in case of error; add debug spec; simplify data flow. | ||
| 11 | (with-timeout-handler): Remove. | ||
| 12 | |||
| 1 | 2011-10-12 Michael Albinus <michael.albinus@gmx.de> | 13 | 2011-10-12 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 14 | ||
| 3 | Fix Bug#6019, Bug#9315. | 15 | Fix Bug#6019, Bug#9315. |
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index 0e007ff7176..706c6fd0ba3 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el | |||
| @@ -402,10 +402,6 @@ This function returns a timer object which you can use in `cancel-timer'." | |||
| 402 | (timer-activate-when-idle timer t) | 402 | (timer-activate-when-idle timer t) |
| 403 | timer)) | 403 | timer)) |
| 404 | 404 | ||
| 405 | (defun with-timeout-handler (tag) | ||
| 406 | "This is the timer function used for the timer made by `with-timeout'." | ||
| 407 | (throw tag 'timeout)) | ||
| 408 | |||
| 409 | (defvar with-timeout-timers nil | 405 | (defvar with-timeout-timers nil |
| 410 | "List of all timers used by currently pending `with-timeout' calls.") | 406 | "List of all timers used by currently pending `with-timeout' calls.") |
| 411 | 407 | ||
| @@ -417,24 +413,27 @@ event (such as keyboard input, input from subprocesses, or a certain time); | |||
| 417 | if the program loops without waiting in any way, the timeout will not | 413 | if the program loops without waiting in any way, the timeout will not |
| 418 | be detected. | 414 | be detected. |
| 419 | \n(fn (SECONDS TIMEOUT-FORMS...) BODY)" | 415 | \n(fn (SECONDS TIMEOUT-FORMS...) BODY)" |
| 420 | (declare (indent 1)) | 416 | (declare (indent 1) (debug ((form body) body))) |
| 421 | (let ((seconds (car list)) | 417 | (let ((seconds (car list)) |
| 422 | (timeout-forms (cdr list))) | 418 | (timeout-forms (cdr list)) |
| 423 | `(let ((with-timeout-tag (cons nil nil)) | 419 | (timeout (make-symbol "timeout"))) |
| 424 | with-timeout-value with-timeout-timer | 420 | `(let ((-with-timeout-value- |
| 425 | (with-timeout-timers with-timeout-timers)) | 421 | (catch ',timeout |
| 426 | (if (catch with-timeout-tag | 422 | (let* ((-with-timeout-timer- |
| 427 | (progn | 423 | (run-with-timer ,seconds nil |
| 428 | (setq with-timeout-timer | 424 | (lambda () (throw ',timeout ',timeout)))) |
| 429 | (run-with-timer ,seconds nil | 425 | (with-timeout-timers |
| 430 | 'with-timeout-handler | 426 | (cons -with-timeout-timer- with-timeout-timers))) |
| 431 | with-timeout-tag)) | 427 | (unwind-protect |
| 432 | (push with-timeout-timer with-timeout-timers) | 428 | ,@body |
| 433 | (setq with-timeout-value (progn . ,body)) | 429 | (cancel-timer -with-timeout-timer-)))))) |
| 434 | nil)) | 430 | ;; It is tempting to avoid the `if' altogether and instead run |
| 435 | (progn . ,timeout-forms) | 431 | ;; timeout-forms in the timer, just before throwing `timeout'. |
| 436 | (cancel-timer with-timeout-timer) | 432 | ;; But that would mean that timeout-forms are run in the deeper |
| 437 | with-timeout-value)))) | 433 | ;; dynamic context of the timer, with inhibit-quit set etc... |
| 434 | (if (eq -with-timeout-value- ',timeout) | ||
| 435 | (progn ,@timeout-forms) | ||
| 436 | -with-timeout-value-)))) | ||
| 438 | 437 | ||
| 439 | (defun with-timeout-suspend () | 438 | (defun with-timeout-suspend () |
| 440 | "Stop the clock for `with-timeout'. Used by debuggers. | 439 | "Stop the clock for `with-timeout'. Used by debuggers. |
diff --git a/lisp/simple.el b/lisp/simple.el index af6d855d9c0..6d0e7543549 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1050,6 +1050,16 @@ In addition, with prefix argument, show details about that character | |||
| 1050 | in *Help* buffer. See also the command `describe-char'." | 1050 | in *Help* buffer. See also the command `describe-char'." |
| 1051 | (interactive "P") | 1051 | (interactive "P") |
| 1052 | (let* ((char (following-char)) | 1052 | (let* ((char (following-char)) |
| 1053 | ;; If the character is one of LRE, LRO, RLE, RLO, it will | ||
| 1054 | ;; start a directional embedding, which could completely | ||
| 1055 | ;; disrupt the rest of the line (e.g., RLO will display the | ||
| 1056 | ;; rest of the line right-to-left). So we put an invisible | ||
| 1057 | ;; PDF character after these characters, to end the | ||
| 1058 | ;; embedding, which eliminates any effects on the rest of the | ||
| 1059 | ;; line. | ||
| 1060 | (pdf (if (memq char '(?\x202a ?\x202b ?\x202d ?\x202e)) | ||
| 1061 | (propertize (string ?\x202c) 'invisible t) | ||
| 1062 | "")) | ||
| 1053 | (beg (point-min)) | 1063 | (beg (point-min)) |
| 1054 | (end (point-max)) | 1064 | (end (point-max)) |
| 1055 | (pos (point)) | 1065 | (pos (point)) |
| @@ -1109,18 +1119,18 @@ in *Help* buffer. See also the command `describe-char'." | |||
| 1109 | ;; We show the detailed information about CHAR. | 1119 | ;; We show the detailed information about CHAR. |
| 1110 | (describe-char (point))) | 1120 | (describe-char (point))) |
| 1111 | (if (or (/= beg 1) (/= end (1+ total))) | 1121 | (if (or (/= beg 1) (/= end (1+ total))) |
| 1112 | (message "Char: %s %s point=%d of %d (%d%%) <%d-%d> column=%d%s" | 1122 | (message "Char: %s%s %s point=%d of %d (%d%%) <%d-%d> column=%d%s" |
| 1113 | (if (< char 256) | 1123 | (if (< char 256) |
| 1114 | (single-key-description char) | 1124 | (single-key-description char) |
| 1115 | (buffer-substring-no-properties (point) (1+ (point)))) | 1125 | (buffer-substring-no-properties (point) (1+ (point)))) |
| 1116 | encoding-msg pos total percent beg end col hscroll) | 1126 | pdf encoding-msg pos total percent beg end col hscroll) |
| 1117 | (message "Char: %s %s point=%d of %d (%d%%) column=%d%s" | 1127 | (message "Char: %s%s %s point=%d of %d (%d%%) column=%d%s" |
| 1118 | (if enable-multibyte-characters | 1128 | (if enable-multibyte-characters |
| 1119 | (if (< char 128) | 1129 | (if (< char 128) |
| 1120 | (single-key-description char) | 1130 | (single-key-description char) |
| 1121 | (buffer-substring-no-properties (point) (1+ (point)))) | 1131 | (buffer-substring-no-properties (point) (1+ (point)))) |
| 1122 | (single-key-description char)) | 1132 | (single-key-description char)) |
| 1123 | encoding-msg pos total percent col hscroll)))))) | 1133 | pdf encoding-msg pos total percent col hscroll)))))) |
| 1124 | 1134 | ||
| 1125 | ;; Initialize read-expression-map. It is defined at C level. | 1135 | ;; Initialize read-expression-map. It is defined at C level. |
| 1126 | (let ((m (make-sparse-keymap))) | 1136 | (let ((m (make-sparse-keymap))) |