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.

bright-star
  • 839
  • 9
  • 17
  • 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 05:54
  • @lawlist: Please post that as an an answer, which the OP can perhaps then accept. – Drew Dec 04 '15 at 17:49
  • 1
    Why hasn't `(setq warning-minimum-level :emergency)` been suggested as an answer? – viksit Jan 21 '17 at 22:41

2 Answers2

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

Constantine
  • 9,072
  • 1
  • 34
  • 49
  • 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 03 '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 03 '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 03 '16 at 19:43
  • 1
    @KaushalModi: it turns out that [`cmd_error()`](https://github.com/emacs-mirror/emacs/blob/99fa8c3dbf333f1e3fa7d6449d4b4428ce439ce1/src/keyboard.c#L941) 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 03 '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.

lawlist
  • 18,826
  • 5
  • 37
  • 118