help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to hide emacs 26 warnings buffer ?


From: Emanuel Berg
Subject: Re: how to hide emacs 26 warnings buffer ?
Date: Mon, 23 Apr 2018 05:53:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Zhang Jun wrote:

> I've switched to emacs 26.0.91 from 25,
>
> when I editing a file, emacs will create
> '#file# backup file, but I don't have write
> permission to the directory, emacs26 will
> display a *warnings* buffer, I don't like
> this buffer, prefer the warning message in
> mini-buffer.

Indeed: when you look into the tiger's eyes,
you see ONLY your own feelings!

;; This file: http://user.it.uu.se/~embe8573/emacs-init/error.el

(require 'cl-lib)

;; inhibit the debugger --
;; so not to have the debugger hop out
;; over half the screen for something that can be
;; communicated in 2-3 few words in the echo area
(setq debug-on-error                 nil)
(setq eval-expression-debug-on-error nil)

;; ignore a couple of common "errors"
(setq debug-ignored-errors
      '(
        beginning-of-buffer
        beginning-of-line
        buffer-read-only
        end-of-buffer
        end-of-file
        end-of-line
        file-supersession
        text-read-only
        quit
        ))

(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)

(provide 'error)

-- 
underground experts united
http://user.it.uu.se/~embe8573


reply via email to

[Prev in Thread] Current Thread [Next in Thread]