;; This file: http://user.it.uu.se/~embe8573/conf/emacs-init/error.el (require 'cl-macs) (when nil ;; inhibit the debugger -- try this if nothing else: ;; a wonderful thing not to have the debugger hop out ;; over half the screen for something that can be ;; communicated in 2-3 few words! (setq debug-on-error nil) (setq eval-expression-debug-on-error nil) ;; ignore a couple of common "errors" (setq debug-ignored-errors '(quit beginning-of-line end-of-line beginning-of-buffer end-of-buffer end-of-file buffer-read-only file-supersession) ) (defvar error-buffer-name "*Errors*" "Errors log buffer.") (defun say-and-log-error (data _ fun) "This error function communicates the errors in the echo area. It does so by means of a one-liner as to avoid being disruptive (while still offering condensed feedback, which often is enough). DATA is the error; FUN is where it occurred. The errors are logged in the buffer `error-buffer-name'. To list them, use `errors'. To use this function, set `command-error-function' to: \(lambda \(&rest args\) \(apply #'say-and-log-error args\)" (if (not (member (car data) debug-ignored-errors)) (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 "%s" error-str) ; echo the error message (with-current-buffer error-buffer (goto-char (point-max)) (insert error-str "\n") ) ; log it (discard-input) ))) (setq command-error-function (lambda (&rest args) (apply #'say-and-log-error args) )) (defun errors () "Visit the errors log buffer, `error-buffer-name'. See `say-and-log-error' for more on this." (interactive) (switch-to-buffer (get-buffer-create error-buffer-name)) (goto-char (point-max)) (recenter -1) ) ;; (/ 1 0) )