unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: if and only if an Error message
Date: Sun, 20 Jul 2014 03:42:20 +0200	[thread overview]
Message-ID: <87fvhwx0ub.fsf@web.de> (raw)
In-Reply-To: 87lhrpd0wq.fsf@debian.uxu

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.




  parent reply	other threads:[~2014-07-20  1:42 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 22:21 Emacs hangs with 100pc CPU during query-replace Thorsten Jolitz
2014-07-19  0:30 ` Michael Heerdegen
     [not found] ` <mailman.5641.1405730121.1147.help-gnu-emacs@gnu.org>
2014-07-19  1:16   ` Emanuel Berg
2014-07-19  1:36     ` Michael Heerdegen
2014-07-19  1:41       ` Michael Heerdegen
     [not found]       ` <mailman.5647.1405734322.1147.help-gnu-emacs@gnu.org>
2014-07-19  1:57         ` Emanuel Berg
2014-07-19  3:42           ` if and only if an Error message (was: Re: Emacs hangs with 100pc CPU during query-replace) Emanuel Berg
2014-07-19  4:00             ` if and only if an Error message Michael Heerdegen
     [not found]             ` <mailman.5654.1405742487.1147.help-gnu-emacs@gnu.org>
2014-07-19  4:10               ` Emanuel Berg
2014-07-19  4:38                 ` Michael Heerdegen
     [not found]                 ` <mailman.5655.1405744730.1147.help-gnu-emacs@gnu.org>
2014-07-19  4:49                   ` Emanuel Berg
2014-07-19  5:05                     ` Michael Heerdegen
2014-07-19  5:11                     ` Michael Heerdegen
     [not found]                     ` <mailman.5656.1405746345.1147.help-gnu-emacs@gnu.org>
2014-07-19  5:12                       ` Emanuel Berg
2014-07-19  5:49                         ` Michael Heerdegen
2014-07-19  6:01                           ` Michael Heerdegen
     [not found]                         ` <mailman.5660.1405749012.1147.help-gnu-emacs@gnu.org>
2014-07-19 11:48                           ` Emanuel Berg
2014-07-19 17:55                             ` Drew Adams
2014-07-20  1:42                             ` Michael Heerdegen [this message]
     [not found]                             ` <mailman.5724.1405820570.1147.help-gnu-emacs@gnu.org>
2014-07-20 21:38                               ` Emanuel Berg
2014-07-21  8:51                                 ` Michael Heerdegen
     [not found]                                 ` <mailman.5803.1405932728.1147.help-gnu-emacs@gnu.org>
2014-07-21 14:12                                   ` Emanuel Berg
2014-07-20 22:48                             ` avoiding global variables (was: Re: if and only if an Error message) Emanuel Berg
2014-07-21  5:01                               ` avoiding global variables Thien-Thi Nguyen
     [not found]                               ` <mailman.5793.1405918685.1147.help-gnu-emacs@gnu.org>
2014-07-21 14:10                                 ` Emanuel Berg
     [not found]     ` <mailman.5645.1405733824.1147.help-gnu-emacs@gnu.org>
2014-07-19  1:52       ` Emacs hangs with 100pc CPU during query-replace Emanuel Berg
2014-07-19  8:02     ` Thorsten Jolitz
2014-07-19  8:18       ` Eli Zaretskii
2014-07-19  8:27       ` Michael Heerdegen
2014-07-19  8:49         ` Thorsten Jolitz
2014-07-19  9:06         ` Thorsten Jolitz
2014-07-19 10:27           ` Eli Zaretskii
2014-07-19 11:29             ` Thorsten Jolitz
2014-07-19 10:33           ` Eli Zaretskii
2014-07-19 11:30             ` Thorsten Jolitz
     [not found]         ` <<871tth1zw9.fsf@gmail.com>
     [not found]           ` <<83iomt63uf.fsf@gnu.org>
2014-07-19 17:51             ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fvhwx0ub.fsf@web.de \
    --to=michael_heerdegen@web.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).