GNU bug report logs - #34939
Some minibuffer behaviour is annoying

Previous Next

Package: emacs;

Reported by: pinkanon pinkanon <pinkanon.pinkanon <at> yandex.ru>

Date: Thu, 21 Mar 2019 19:20:04 UTC

Severity: wishlist

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Juri Linkov <juri <at> linkov.net>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: pinkanon pinkanon <pinkanon.pinkanon <at> yandex.ru>, 34939 <at> debbugs.gnu.org
Subject: bug#34939: Some minibuffer behaviour is annoying
Date: Thu, 30 May 2019 00:53:46 +0300
[Message part 1 (text/plain, inline)]
>>> So um, what's the best way to make this behavior the default?
>>
>> This is a nice behavior but the problem is that overriding
>> command-error-function also removes other useful default features
>> such as logging error messages to the *Messages* buffer
>> (see more at ‘print_error_message’).
>
> Could we first print it and then call minibuffer-message?

Here is a complete 1-to-1 rewrite of the C function ‘print_error_message’
in Lisp that now can be used for more user-friendly displaying error messages
in the minibuffer:
[minibuffer-error-function.patch (text/x-diff, inline)]
diff --git a/lisp/simple.el b/lisp/simple.el
index 4454791ad2..5f5c6b1a59 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2440,6 +2440,45 @@ minibuffer-history-isearch-pop-state
   (goto-history-element hist-pos))
 
 
+(add-hook 'minibuffer-setup-hook 'minibuffer-error-initialize)
+
+(defun minibuffer-error-initialize ()
+  "Set up minibuffer error processing."
+  (setq-local command-error-function 'minibuffer-error-function))
+
+(defun minibuffer-error-function (data context caller)
+  "Display output error messages in the active minibuffer.
+Its arguments are the same as in `command-error-default-function'."
+  (discard-input)
+  (ding)
+  (let* ((errname (car data))
+         errmsg file-error tail text
+         (sep ": "))
+    (cond
+     ((eq errname 'error)
+      (setq data (cdr data))
+      (when (consp data) (setq data nil))
+      (setq errmsg (car data)))
+     (t
+      (setq errmsg (substitute-command-keys (get errname 'error-message))
+            file-error (memq 'file-error (get errname 'error-conditions)))))
+    (setq tail (cdr-safe data))
+    (when (and file-error (consp tail))
+      (setq errmsg (car tail)
+            tail (cdr tail)))
+    (setq text (if (stringp errmsg) errmsg "peculiar error"))
+    (while tail
+      (setq text (concat text sep))
+      (if (or file-error (eq errname 'end-of-file) (eq errname 'user-error))
+          (setq text (concat text (format "%s" (car tail))))
+        (setq text (concat text (format "%S" (car tail)))))
+      (setq sep ", ")
+      (setq tail (cdr tail)))
+    (let ((inhibit-message t))
+      (message "%s%s" (if caller (format "%s: " caller) "") text))
+    (minibuffer-message (concat context text))))
+
+
 ;Put this on C-x u, so we can force that rather than C-_ into startup msg
 (define-obsolete-function-alias 'advertised-undo 'undo "23.2")
 

This bug report was last modified 5 years and 347 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.