diff options
author | Miles Bader <miles@gnu.org> | 2005-07-14 08:02:00 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2005-07-14 08:02:00 +0000 |
commit | bacb9790f594207469f22ed9f3e8085ab76e5e2b (patch) | |
tree | b1cee62715d6cd2797f3122e4f058d7bc18ceef6 /lisp/emacs-lisp | |
parent | d3e4babdd1267fb5690a17949196640a47c6f159 (diff) | |
parent | ead25b5cabbe092711864eae13a76437e6a65ce1 (diff) | |
download | emacs-bacb9790f594207469f22ed9f3e8085ab76e5e2b.tar.gz emacs-bacb9790f594207469f22ed9f3e8085ab76e5e2b.tar.bz2 emacs-bacb9790f594207469f22ed9f3e8085ab76e5e2b.zip |
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-69
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 474-484)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 88-91)
- Merge from emacs--cvs-trunk--0
- Update FSF's address in GPL notices
- Update from CVS
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 41 | ||||
-rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 8 | ||||
-rw-r--r-- | lisp/emacs-lisp/debug.el | 89 | ||||
-rw-r--r-- | lisp/emacs-lisp/easy-mmode.el | 8 | ||||
-rw-r--r-- | lisp/emacs-lisp/edebug.el | 59 | ||||
-rw-r--r-- | lisp/emacs-lisp/timer.el | 32 |
6 files changed, 157 insertions, 80 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 05e97a7485f..6aff16143b3 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3353,11 +3353,14 @@ That command is designed for interactive use only" fn)) (defmacro byte-compile-maybe-guarded (condition &rest body) "Execute forms in BODY, potentially guarded by CONDITION. -CONDITION is the test in an `if' form or in a `cond' clause. -BODY is to compile the first arm of the if or the body of the -cond clause. If CONDITION is of the form `(foundp 'foo)' +CONDITION is a variable whose value is a test in an `if' or `cond'. +BODY is the code to compile first arm of the if or the body of the +cond clause. If CONDITION's value is of the form `(foundp 'foo)' or `(boundp 'foo)', the relevant warnings from BODY about foo -being undefined will be suppressed." +being undefined will be suppressed. + +If CONDITION's value is `(featurep 'xemacs)', that suppresses all +warnings during execution of BODY." (declare (indent 1) (debug t)) `(let* ((fbound (if (eq 'fboundp (car-safe ,condition)) @@ -3375,13 +3378,17 @@ being undefined will be suppressed." (byte-compile-bound-variables (if bound (cons bound byte-compile-bound-variables) - byte-compile-bound-variables))) - (progn ,@body) - ;; Maybe remove the function symbol from the unresolved list. - (if fbound - (setq byte-compile-unresolved-functions - (delq (assq fbound byte-compile-unresolved-functions) - byte-compile-unresolved-functions))))) + byte-compile-bound-variables)) + (byte-compile-warnings + (if (equal ,condition '(featurep 'xemacs)) + nil byte-compile-warnings))) + (unwind-protect + (progn ,@body) + ;; Maybe remove the function symbol from the unresolved list. + (if fbound + (setq byte-compile-unresolved-functions + (delq (assq fbound byte-compile-unresolved-functions) + byte-compile-unresolved-functions)))))) (defun byte-compile-if (form) (byte-compile-form (car (cdr form))) @@ -3422,12 +3429,12 @@ being undefined will be suppressed." (if (null (cdr clause)) ;; First clause is a singleton. (byte-compile-goto-if t for-effect donetag) - (setq nexttag (byte-compile-make-tag)) - (byte-compile-goto 'byte-goto-if-nil nexttag) - (byte-compile-maybe-guarded (car clause) - (byte-compile-body (cdr clause) for-effect)) - (byte-compile-goto 'byte-goto donetag) - (byte-compile-out-tag nexttag))))) + (setq nexttag (byte-compile-make-tag)) + (byte-compile-goto 'byte-goto-if-nil nexttag) + (byte-compile-maybe-guarded (car clause) + (byte-compile-body (cdr clause) for-effect)) + (byte-compile-goto 'byte-goto donetag) + (byte-compile-out-tag nexttag))))) ;; Last clause (let ((guard (car clause))) (and (cdr clause) (not (eq guard t)) diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 6562f04ca1d..6534af050f3 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -317,12 +317,12 @@ This should be set in an Emacs Lisp file's local variables." "List of words (not capitalized) which should be capitalized.") (defvar checkdoc-proper-noun-regexp - (let ((expr "\\<\\(") + (let ((expr "\\_<\\(") (l checkdoc-proper-noun-list)) (while l (setq expr (concat expr (car l) (if (cdr l) "\\|" "")) l (cdr l))) - (concat expr "\\)\\>")) + (concat expr "\\)\\_>")) "Regular expression derived from `checkdoc-proper-noun-regexp'.") (defvar checkdoc-common-verbs-regexp nil @@ -2326,10 +2326,10 @@ Code:, and others referenced in the style guide." (save-excursion (goto-char (point-max)) (if (not (re-search-backward - (concat "^;;;[ \t]+" fn "\\(" (regexp-quote fe) + (concat "^;;;[ \t]+" (regexp-quote fn) "\\(" (regexp-quote fe) "\\)?[ \t]+ends here[ \t]*$" "\\|^;;;[ \t]+ End of file[ \t]+" - fn "\\(" (regexp-quote fe) "\\)?") + (regexp-quote fn) "\\(" (regexp-quote fe) "\\)?") nil t)) (if (checkdoc-y-or-n-p "No identifiable footer! Add one? ") (progn diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 94cca83a61d..4f968c60b5e 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -150,7 +150,8 @@ first will be printed into the backtrace buffer." (debugger-outer-standard-input standard-input) (debugger-outer-standard-output standard-output) (debugger-outer-inhibit-redisplay inhibit-redisplay) - (debugger-outer-cursor-in-echo-area cursor-in-echo-area)) + (debugger-outer-cursor-in-echo-area cursor-in-echo-area) + (debugger-with-timeout-suspend (with-timeout-suspend))) ;; Set this instead of binding it, so that `q' ;; will not restore it. (setq overriding-terminal-local-map nil) @@ -235,6 +236,7 @@ first will be printed into the backtrace buffer." ;; Drew Adams. --Stef (quit-window)))) (kill-buffer debugger-buffer)) + (with-timeout-unsuspend debugger-with-timeout-suspend) (set-match-data debugger-outer-match-data))) ;; Put into effect the modified values of these variables ;; in case the user set them with the `e' command. @@ -312,11 +314,17 @@ That buffer should be current already." ;; After any frame that uses eval-buffer, ;; insert a line that states the buffer position it's reading at. (save-excursion - (while (re-search-forward "^ eval-buffer(" nil t) - (end-of-line) - (insert (format "\n ;;; Reading at buffer position %d" - (with-current-buffer (nth 2 (backtrace-frame (debugger-frame-number))) - (point)))))) + (let ((tem eval-buffer-list)) + (while (and tem + (re-search-forward "^ eval-\\(buffer\\|region\\)(" nil t)) + (end-of-line) + (insert (format " ; Reading at buffer position %d" + ;; This will get the wrong result + ;; if there are two nested eval-region calls + ;; for the same buffer. That's not a very useful case. + (with-current-buffer (car tem) + (point)))) + (pop tem)))) (debugger-make-xrefs)) (defun debugger-make-xrefs (&optional buffer) @@ -591,10 +599,35 @@ Applies to the frame whose line point is on in the backtrace." (define-key map "e" 'debugger-eval-expression) (define-key map " " 'next-line) (define-key map "R" 'debugger-record-expression) - (define-key map "\C-m" 'help-follow) + (define-key map "\C-m" 'debug-help-follow) (define-key map [mouse-2] 'push-button) map)) +(put 'debugger-mode 'mode-class 'special) + +(defun debugger-mode () + "Mode for backtrace buffers, selected in debugger. +\\<debugger-mode-map> +A line starts with `*' if exiting that frame will call the debugger. +Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'. + +When in debugger due to frame being exited, +use the \\[debugger-return-value] command to override the value +being returned from that frame. + +Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control +which functions will enter the debugger when called. + +Complete list of commands: +\\{debugger-mode-map}" + (kill-all-local-variables) + (setq major-mode 'debugger-mode) + (setq mode-name "Debugger") + (setq truncate-lines t) + (set-syntax-table emacs-lisp-mode-syntax-table) + (use-local-map debugger-mode-map) + (run-mode-hooks 'debugger-mode-hook)) + (defcustom debugger-record-buffer "*Debugger-record*" "*Buffer name for expression values, for \\[debugger-record-expression]." :type 'string @@ -620,30 +653,26 @@ Applies to the frame whose line point is on in the backtrace." (buffer-substring (line-beginning-position 0) (line-end-position 0))))) -(put 'debugger-mode 'mode-class 'special) - -(defun debugger-mode () - "Mode for backtrace buffers, selected in debugger. -\\<debugger-mode-map> -A line starts with `*' if exiting that frame will call the debugger. -Type \\[debugger-frame] or \\[debugger-frame-clear] to set or remove the `*'. +(defun debug-help-follow (&optional pos) + "Follow cross-reference at POS, defaulting to point. -When in debugger due to frame being exited, -use the \\[debugger-return-value] command to override the value -being returned from that frame. - -Use \\[debug-on-entry] and \\[cancel-debug-on-entry] to control -which functions will enter the debugger when called. - -Complete list of commands: -\\{debugger-mode-map}" - (kill-all-local-variables) - (setq major-mode 'debugger-mode) - (setq mode-name "Debugger") - (setq truncate-lines t) - (set-syntax-table emacs-lisp-mode-syntax-table) - (use-local-map debugger-mode-map) - (run-mode-hooks 'debugger-mode-hook)) +For the cross-reference format, see `help-make-xrefs'." + (interactive "d") + (require 'help-mode) + (unless pos + (setq pos (point))) + (unless (push-button pos) + ;; check if the symbol under point is a function or variable + (let ((sym + (intern + (save-excursion + (goto-char pos) (skip-syntax-backward "w_") + (buffer-substring (point) + (progn (skip-syntax-forward "w_") + (point))))))) + (when (or (boundp sym) (fboundp sym) (facep sym)) + (switch-to-buffer-other-window (generate-new-buffer "*Help*")) + (help-do-xref pos #'help-xref-interned (list sym)))))) ;; When you change this, you may also need to change the number of ;; frames that the debugger skips. diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el index 4c232b2882c..3b4662277b6 100644 --- a/lisp/emacs-lisp/easy-mmode.el +++ b/lisp/emacs-lisp/easy-mmode.el @@ -142,6 +142,7 @@ For example, you could write (let* ((mode-name (symbol-name mode)) (pretty-name (easy-mmode-pretty-mode-name mode lighter)) (globalp nil) + (initialize nil) (group nil) (extra-args nil) (extra-keywords nil) @@ -159,6 +160,7 @@ For example, you could write (:lighter (setq lighter (pop body))) (:global (setq globalp (pop body))) (:extra-args (setq extra-args (pop body))) + (:initialize (setq initialize (list :initialize (pop body)))) (:group (setq group (nconc group (list :group (pop body))))) (:require (setq require (pop body))) (:keymap (setq keymap (pop body))) @@ -167,6 +169,10 @@ For example, you could write (setq keymap-sym (if (and keymap (symbolp keymap)) keymap (intern (concat mode-name "-map")))) + (unless initialize + (setq initialize + '(:initialize 'custom-initialize-default))) + (unless group ;; We might as well provide a best-guess default group. (setq group @@ -196,7 +202,7 @@ See the command `%s' for a description of this minor-mode.")) `(defcustom ,mode ,init-value ,(format base-doc-string pretty-name mode mode) :set 'custom-set-minor-mode - :initialize 'custom-initialize-default + ,@initialize ,@group :type 'boolean ,@(cond diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index fe0453519df..1a592709819 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -2374,18 +2374,19 @@ MSG is printed after `::::} '." (defun edebug-slow-before (edebug-before-index) - ;; Debug current function given BEFORE position. - ;; Called from functions compiled with edebug-eval-top-level-form. - ;; Return the before index. - (setcar edebug-offset-indices edebug-before-index) - - ;; Increment frequency count - (aset edebug-freq-count edebug-before-index - (1+ (aref edebug-freq-count edebug-before-index))) - - (if (or (not (memq edebug-execution-mode '(Go-nonstop next))) - (edebug-input-pending-p)) - (edebug-debugger edebug-before-index 'before nil)) + (unless edebug-active + ;; Debug current function given BEFORE position. + ;; Called from functions compiled with edebug-eval-top-level-form. + ;; Return the before index. + (setcar edebug-offset-indices edebug-before-index) + + ;; Increment frequency count + (aset edebug-freq-count edebug-before-index + (1+ (aref edebug-freq-count edebug-before-index))) + + (if (or (not (memq edebug-execution-mode '(Go-nonstop next))) + (edebug-input-pending-p)) + (edebug-debugger edebug-before-index 'before nil))) edebug-before-index) (defun edebug-fast-before (edebug-before-index) @@ -2393,22 +2394,24 @@ MSG is printed after `::::} '." ) (defun edebug-slow-after (edebug-before-index edebug-after-index edebug-value) - ;; Debug current function given AFTER position and VALUE. - ;; Called from functions compiled with edebug-eval-top-level-form. - ;; Return VALUE. - (setcar edebug-offset-indices edebug-after-index) - - ;; Increment frequency count - (aset edebug-freq-count edebug-after-index - (1+ (aref edebug-freq-count edebug-after-index))) - (if edebug-test-coverage (edebug-update-coverage)) - - (if (and (eq edebug-execution-mode 'Go-nonstop) - (not (edebug-input-pending-p))) - ;; Just return result. + (if edebug-active edebug-value - (edebug-debugger edebug-after-index 'after edebug-value) - )) + ;; Debug current function given AFTER position and VALUE. + ;; Called from functions compiled with edebug-eval-top-level-form. + ;; Return VALUE. + (setcar edebug-offset-indices edebug-after-index) + + ;; Increment frequency count + (aset edebug-freq-count edebug-after-index + (1+ (aref edebug-freq-count edebug-after-index))) + (if edebug-test-coverage (edebug-update-coverage)) + + (if (and (eq edebug-execution-mode 'Go-nonstop) + (not (edebug-input-pending-p))) + ;; Just return result. + edebug-value + (edebug-debugger edebug-after-index 'after edebug-value) + ))) (defun edebug-fast-after (edebug-before-index edebug-after-index edebug-value) ;; Do nothing but return the value. @@ -2533,6 +2536,7 @@ MSG is printed after `::::} '." ;; Uses local variables of edebug-enter, edebug-before, edebug-after ;; and edebug-debugger. (let ((edebug-active t) ; for minor mode alist + (edebug-with-timeout-suspend (with-timeout-suspend)) edebug-stop ; should we enter recursive-edit (edebug-point (+ edebug-def-mark (aref (nth 2 edebug-data) edebug-offset-index))) @@ -2759,6 +2763,7 @@ MSG is printed after `::::} '." (set-buffer current-buffer)) ;; ... nothing more. ) + (with-timeout-unsuspend edebug-with-timeout-suspend) ;; Reset global variables to outside values in case they were changed. (setq overlay-arrow-position edebug-outside-o-a-p diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el index e207766701c..27f14a6d3ad 100644 --- a/lisp/emacs-lisp/timer.el +++ b/lisp/emacs-lisp/timer.el @@ -404,6 +404,9 @@ This function returns a timer object which you can use in `cancel-timer'." ;;;###autoload (put 'with-timeout 'lisp-indent-function 1) +(defvar with-timeout-timers nil + "List of all timers used by currently pending `with-timeout' calls.") + ;;;###autoload (defmacro with-timeout (list &rest body) "Run BODY, but if it doesn't finish in SECONDS seconds, give up. @@ -416,19 +419,46 @@ be detected. (let ((seconds (car list)) (timeout-forms (cdr list))) `(let ((with-timeout-tag (cons nil nil)) - with-timeout-value with-timeout-timer) + with-timeout-value with-timeout-timer + (with-timeout-timers with-timeout-timers)) (if (catch with-timeout-tag (progn (setq with-timeout-timer (run-with-timer ,seconds nil 'with-timeout-handler with-timeout-tag)) + (push with-timeout-timer with-timeout-timers) (setq with-timeout-value (progn . ,body)) nil)) (progn . ,timeout-forms) (cancel-timer with-timeout-timer) with-timeout-value)))) +(defun with-timeout-suspend () + "Stop the clock for `with-timeout'. Used by debuggers. +The idea is that the time you spend in the debugger should not +count against these timeouts. + +The value is a list that the debugger can pass to `with-timeout-unsuspend' +when it exits, to make these timers start counting again." + (mapcar (lambda (timer) + (cancel-timer timer) + (list timer + (time-subtract + ;; The time that this timer will go off. + (list (aref timer 1) (aref timer 2) (aref timer 3)) + (current-time)))) + with-timeout-timers)) + +(defun with-timeout-unsuspend (timer-spec-list) + "Restart the clock for `with-timeout'. +The argument should be a value previously returned by `with-timeout-suspend'." + (dolist (elt timer-spec-list) + (let ((timer (car elt)) + (delay (cadr elt))) + (timer-set-time timer (time-add (current-time) delay)) + (timer-activate timer)))) + (defun y-or-n-p-with-timeout (prompt seconds default-value) "Like (y-or-n-p PROMPT), with a timeout. If the user does not answer after SECONDS seconds, return DEFAULT-VALUE." |