[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if and only if an Error message
From: |
Michael Heerdegen |
Subject: |
Re: if and only if an Error message |
Date: |
Sun, 20 Jul 2014 03:42:20 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.92 (gnu/linux) |
Emanuel Berg <embe8573@student.uu.se> writes:
> But put it this way: how do I find out a variable isn't
> a user option?
Yes, C-h v. User options are these variables that can be "customized".
> (setq error-buffer-name "*Errors*")
>
> ;; inhibit the debugger -
> ;; try this if nothing else: a wonderful thing to not
> ;; have it hop out over half the screen for something
> ;; that can be communicated in a few words
> (setq debug-on-error nil)
> (setq eval-expression-debug-on-error nil)
>
> ;; this does three things, see the comments
> (defun say-and-log-error (data _ fun)
> (let*((error-str (format "%S in %S" data fun))
> (error-buffer (get-buffer-create error-buffer-name))
> (error-win (get-buffer-window error-buffer)) )
> (message error-str) ; echo the error message
> (with-current-buffer error-buffer
> (goto-char (point-max))
> (insert error-str "\n") ) ; log it
> (if error-win
> (with-selected-window error-win ; move focus of error window
> (goto-char (point-max)) ; if available
> (recenter -1)) ))) ; (is there a better way?)
>
> ;; use it instead of the default one
> (setq command-error-function
> (lambda (&rest args)
> (apply #'say-and-log-error args)) )
>
> ;; show the error buffer
> (defun show-errors ()
> (interactive)
> (switch-to-buffer (get-buffer-create error-buffer-name))
> (goto-char (point-max)) ; the same situation: the last line of data
> (recenter -1) ) ; should be on the last window line
> ; whenever possible
>
> ; test here:
> ; (message 'error-as-not-string)
Looks good.
Maybe also call `discard-input' as `command-error-default-function'
does.
And (message "%s" error-str).
^^^^
Have fun,
Michael.
- Re: if and only if an Error message, (continued)
- Message not available
- Re: if and only if an Error message, Emanuel Berg, 2014/07/19
- Re: if and only if an Error message, Michael Heerdegen, 2014/07/19
- Message not available
- Re: if and only if an Error message, Emanuel Berg, 2014/07/19
- Re: if and only if an Error message, Michael Heerdegen, 2014/07/19
- Re: if and only if an Error message, Michael Heerdegen, 2014/07/19
- Message not available
- Re: if and only if an Error message, Emanuel Berg, 2014/07/19
- Re: if and only if an Error message, Michael Heerdegen, 2014/07/19
- Re: if and only if an Error message, Michael Heerdegen, 2014/07/19
- Message not available
- Re: if and only if an Error message, Emanuel Berg, 2014/07/19
- RE: if and only if an Error message, Drew Adams, 2014/07/19
- Re: if and only if an Error message,
Michael Heerdegen <=
- Message not available
- Re: if and only if an Error message, Emanuel Berg, 2014/07/20
- Re: if and only if an Error message, Michael Heerdegen, 2014/07/21
- Message not available
- Re: if and only if an Error message, Emanuel Berg, 2014/07/21
- avoiding global variables (was: Re: if and only if an Error message), Emanuel Berg, 2014/07/20
- Re: avoiding global variables, Thien-Thi Nguyen, 2014/07/21
- Message not available
- Re: avoiding global variables, Emanuel Berg, 2014/07/21
- Message not available
- Re: Emacs hangs with 100pc CPU during query-replace, Emanuel Berg, 2014/07/18
- Re: Emacs hangs with 100pc CPU during query-replace, Thorsten Jolitz, 2014/07/19
- Re: Emacs hangs with 100pc CPU during query-replace, Eli Zaretskii, 2014/07/19
- Re: Emacs hangs with 100pc CPU during query-replace, Michael Heerdegen, 2014/07/19