diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-09-25 11:19:07 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-09-25 11:19:07 -0700 |
commit | abcb2e62dae6aa26308f7ac9efc89247f89cbe65 (patch) | |
tree | fd2c052c3ec67555b0a92dc86da7ecba9b1ab3f6 /lisp/emacs-lisp | |
parent | 0bd61c212fe53fb843a10da9a2da88e110d3785a (diff) | |
parent | 49cd561dc62ea6b3fbedab7aef0f020733f4cf09 (diff) | |
download | emacs-abcb2e62dae6aa26308f7ac9efc89247f89cbe65.tar.gz emacs-abcb2e62dae6aa26308f7ac9efc89247f89cbe65.tar.bz2 emacs-abcb2e62dae6aa26308f7ac9efc89247f89cbe65.zip |
Merge from origin/emacs-26
49cd561dc6 * test/lisp/tramp-tests.el (tramp-test21-file-links): Spec...
b719f6b20b Loosen strict parsing requirement for desktop files
c7a0c13777 * lisp/xdg.el (xdg-thumb-uri): Fix doc string.
dc6b3560e5 Fix documentation of `make-frame' and related variables an...
3d3778d82a Accept new `always' value for option `buffer-offer-save'
638f64c40a Improve new NS scrolling variable names
d93301242f Document 'replace-buffer-contents' in the manual.
00e4e3e9d2 Fix undecorated frame resizing issues on NS (bug#28512)
820739bbb5 ; * doc/emacs/display.texi (Display Custom): Fix wording.
f2b2201594 ; Spelling and URL fixes
0e143b1fc5 Documentation improvements for 'display-line-numbers'
f656ccdb43 ; Fix typo
d64da52d57 Fix last change in bat-mode.el
908af46abd Fix restoring in GUI sessions desktop saved in TTY sessions
51cbd85454 Improve syntax highlighting in bat-mode
0273916618 Document the 'list-FOO' convention
d24ec58540 Expose viewing conditions in CAM02-UCS metric
a81d5a3d3f Revert "Set frame size to actual requested size (bug#18215)"
0bf066d4b2 Add tests for Edebug
68baca3ee1 Catch more messages in ert-with-message-capture
28e0c410c9 ; * lisp/mouse.el (secondary-selection-exist-p): Doc fix.
31e1d9ef2f Support setting region from secondary selection and vice v...
047f02f00f Fix new copy-directory bug with empty dirs
fbd15836af * doc/lispref/strings.texi (Formatting Strings): Improve i...
f16a8d5dbd Fix 2 testsuite tests for MS-Windows
965cffd89c Rename timer-list to list-timers
a5fec62b51 Provide native touchpad scrolling on macOS
7b3d1c6beb Fix MinGW64 build broken by recent MinGW64 import libraries
c83d0c5fdf Fix crashes in 'move-point-visually' in minibuffer windows
7f3d5f929d * src/emacs.c (usage_message): Don't mention 'find-file'.
6845282200 Fix a minor inaccuracy in the Emacs manual
74d7bb9498 Fix errors in flyspell-post-command-hook
40fdbb01d0 Work on Tramp's file-truename
1a01423b3c Fix bug with make-directory on MS-Windows root
066efb8666 Fix log-view-diff-common when point is after last entry
3f006b56cd Adapt fileio-tests--symlink-failure to Cygwin
ee512e9a82 Ignore buffers whose name begins with a space in save-some...
9e1b5bd92c Improve tramp-interrupt-process robustness
8d4223e61b Minor Tramp doc update
331d0e520f Fix gensym
466df76f7d Cleanup in files-tests.el
6359fe630a Remove old cl-assert calls in 'newline'
059184e645 Avoid crash with C-g C-g in GC
541006c536 Fix format-time-string %Z bug with negative tz
679e05eeb9 message-citation-line-format %Z is now tz name
4e8888d438 Use doc-view or pdf-tools on any window-system
5f28f0db73 Fix bug with min and max and NaNs
37b5e661d2 Fix recently-introduced copy-directory bug
6bbbc38b34 Merge from Gnulib
57249fb297 Fix compatibility problem in Tramp
411bec82c4 Avoid GCC 7 compilation warning in eval.c
34a6774daa ; Partially revert c3445aed5194
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/ert-x.el | 57 | ||||
-rw-r--r-- | lisp/emacs-lisp/subr-x.el | 2 | ||||
-rw-r--r-- | lisp/emacs-lisp/timer-list.el | 6 |
3 files changed, 49 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el index 6d9a7d9211a..71d46c11077 100644 --- a/lisp/emacs-lisp/ert-x.el +++ b/lisp/emacs-lisp/ert-x.el @@ -286,27 +286,60 @@ BUFFER defaults to current buffer. Does not modify BUFFER." (defmacro ert-with-message-capture (var &rest body) - "Execute BODY while collecting anything written with `message' in VAR. + "Execute BODY while collecting messages in VAR. -Capture all messages produced by `message' when it is called from -Lisp, and concatenate them separated by newlines into one string. +Capture messages issued by Lisp code and concatenate them +separated by newlines into one string. This includes messages +written by `message' as well as objects printed by `print', +`prin1' and `princ' to the echo area. Messages issued from C +code using the above mentioned functions will not be captured. This is useful for separating the issuance of messages by the code under test from the behavior of the *Messages* buffer." (declare (debug (symbolp body)) (indent 1)) - (let ((g-advice (gensym))) + (let ((g-message-advice (gensym)) + (g-print-advice (gensym)) + (g-collector (gensym))) `(let* ((,var "") - (,g-advice (lambda (func &rest args) - (if (or (null args) (equal (car args) "")) - (apply func args) - (let ((msg (apply #'format-message args))) - (setq ,var (concat ,var msg "\n")) - (funcall func "%s" msg)))))) - (advice-add 'message :around ,g-advice) + (,g-collector (lambda (msg) (setq ,var (concat ,var msg)))) + (,g-message-advice (ert--make-message-advice ,g-collector)) + (,g-print-advice (ert--make-print-advice ,g-collector))) + (advice-add 'message :around ,g-message-advice) + (advice-add 'prin1 :around ,g-print-advice) + (advice-add 'princ :around ,g-print-advice) + (advice-add 'print :around ,g-print-advice) (unwind-protect (progn ,@body) - (advice-remove 'message ,g-advice))))) + (advice-remove 'print ,g-print-advice) + (advice-remove 'princ ,g-print-advice) + (advice-remove 'prin1 ,g-print-advice) + (advice-remove 'message ,g-message-advice))))) + +(defun ert--make-message-advice (collector) + "Create around advice for `message' for `ert-collect-messages'. +COLLECTOR will be called with the message before it is passed +to the real `message'." + (lambda (func &rest args) + (if (or (null args) (equal (car args) "")) + (apply func args) + (let ((msg (apply #'format-message args))) + (funcall collector (concat msg "\n")) + (funcall func "%s" msg))))) + +(defun ert--make-print-advice (collector) + "Create around advice for print functions for `ert-collect-messages'. +The created advice function will just call the original function +unless the output is going to the echo area (when PRINTCHARFUN is +t or PRINTCHARFUN is nil and `standard-output' is t). If the +output is destined for the echo area, the advice function will +convert it to a string and pass it to COLLECTOR first." + (lambda (func object &optional printcharfun) + (if (not (eq t (or printcharfun standard-output))) + (funcall func object printcharfun) + (funcall collector (with-output-to-string + (funcall func object))) + (funcall func object printcharfun)))) (provide 'ert-x) diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el index 077ad22c75d..edba6550fa2 100644 --- a/lisp/emacs-lisp/subr-x.el +++ b/lisp/emacs-lisp/subr-x.el @@ -128,7 +128,7 @@ binding value is nil. If all are non-nil, the value of THEN is returned, or the last form in ELSE is returned. Each element of VARLIST is a list (SYMBOL VALUEFORM) which binds -SYMBOL to the value of VALUEFORM). An element can additionally +SYMBOL to the value of VALUEFORM. An element can additionally be of the form (VALUEFORM), which is evaluated and checked for nil; i.e. SYMBOL can be omitted if only the test result is of interest." diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el index 44a315f9806..69c67419835 100644 --- a/lisp/emacs-lisp/timer-list.el +++ b/lisp/emacs-lisp/timer-list.el @@ -25,7 +25,7 @@ ;;; Code: ;;;###autoload -(defun timer-list (&optional _ignore-auto _nonconfirm) +(defun list-timers (&optional _ignore-auto _nonconfirm) "List all timers in a buffer." (interactive) (pop-to-buffer-same-window (get-buffer-create "*timer-list*")) @@ -67,7 +67,7 @@ (goto-char (point-min))) ;; This command can be destructive if they don't know what they are ;; doing. Kids, don't try this at home! -;;;###autoload (put 'timer-list 'disabled "Beware: manually canceling timers can ruin your Emacs session.") +;;;###autoload (put 'list-timers 'disabled "Beware: manually canceling timers can ruin your Emacs session.") (defvar timer-list-mode-map (let ((map (make-sparse-keymap))) @@ -84,7 +84,7 @@ (setq bidi-paragraph-direction 'left-to-right) (setq truncate-lines t) (buffer-disable-undo) - (setq-local revert-buffer-function 'timer-list) + (setq-local revert-buffer-function #'list-timers) (setq buffer-read-only t) (setq header-line-format (format "%4s %10s %8s %s" |