6

I see that I can do something like this:

(defun limit-warnings ()
  (set (make-local-variable 'warning-minimum-level) 'fatal))

(add-hook 'minibuffer-setup-hook 'disable-warnings)

(Sorry for syntax errors; I'm not very familiar with Lisp and the above is just an example.)

How do I combine that with warning options to disable warnings from only the minibuffer? (For example, the minibuffer doesn't need to tell me that I've hit the end of the buffer or that the M-x: prompt string is read-only.)

I tried describe-variable with warning-minimum-level and there was no such variable defined.

  • You want to look at the functions that use line-move-visual or line-move-1 or line-move -- within the library simple.el -- the error message occurs because the optional argument of noerror is not being used to suppress the error message. However, some functions depend upon that signal error to halt an ongoing function -- e.g., multiple-cursors mode depends upon that signal error to prevent a never ending loop. – lawlist Apr 26 '15 at 5:54
  • @lawlist: Please post that as an an answer, which the OP can perhaps then accept. – Drew Dec 4 '15 at 17:49
  • Why hasn't (setq warning-minimum-level :emergency) been suggested as an answer? – viksit Jan 21 '17 at 22:41
7

This is very similar to the question Is there a way to disable the “buffer is read-only” warning?, so a very similar answer seems appropriate.

You can disable these messages by setting command-error-function to a function that ignores signals buffer-read-only, beginning-of-buffer, and end-of-buffer.

(defun my-command-error-function (data context caller)
  "Ignore the buffer-read-only, beginning-of-buffer,
end-of-buffer signals; pass the rest to the default handler."
  (when (not (memq (car data) '(buffer-read-only
                                beginning-of-buffer
                                end-of-buffer)))
    (command-error-default-function data context caller)))

(setq command-error-function #'my-command-error-function)

(Tested using GNU Emacs 24.5.1.)

  • I believe a big warning disclaimer is in order? Would this cause the M-0 C-x e executions to go on in inf loop? I use that to keep repeating a kmacro from the current point to the end of the buffer (technically until there's an error). – Kaushal Modi Feb 3 '16 at 19:34
  • @KaushalModi: Nope. (Try for yourself: C-x ( C-n C-x ) M-0 C-x e would do.) command-error-function is called when there is an unhandled signal, and since end-of-buffer is caught by the kmacro execution code, command-error-function is not called. – Constantine Feb 3 '16 at 19:39
  • @KaushalModi: Hmm. I was wrong. It is called, but it still does not cause an infinite loop, it seems. (The old comment should remain as a reminder for me to test things before speaking up.) – Constantine Feb 3 '16 at 19:43
  • 1
    @KaushalModi: it turns out that cmd_error() in keyboard.c sets executing-kbd-macro to nil before command-error-function is called, so kmacros are stopped on error no matter what you do. – Constantine Feb 3 '16 at 20:01
2

You want to look at the functions that use line-move-visual / line-move-1 / line-move -- within the library simple.el. The error message occurs because the optional argument of noerror is not being used to suppress the error message.

However, some functions depend upon that signal error to halt an ongoing function -- e.g., the third-party optional library multiple-cursors depends upon that signal error to prevent a never ending loop.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.