diff options
| author | Juri Linkov | 2019-06-03 23:27:19 +0300 |
|---|---|---|
| committer | Juri Linkov | 2019-06-03 23:27:19 +0300 |
| commit | 2aae063055283ee64ecf339c812a1fe6d1cb106e (patch) | |
| tree | 8960dde95c069c045dbd3348b82f4eedf93a307f | |
| parent | 9d72d6a3a2fb23c6f7123c5aba2457dee93d9454 (diff) | |
| download | emacs-2aae063055283ee64ecf339c812a1fe6d1cb106e.tar.gz emacs-2aae063055283ee64ecf339c812a1fe6d1cb106e.zip | |
User-friendly display of error messages at the end of minibuffer
* lisp/simple.el (minibuffer-setup-hook): Add minibuffer-error-initialize.
(minibuffer-error-initialize, minibuffer-error-function): New functions.
(Bug#34939)
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/simple.el | 22 |
2 files changed, 28 insertions, 0 deletions
| @@ -471,6 +471,12 @@ its functions. | |||
| 471 | names match certain regular expressions as big. Ido won't attempt to | 471 | names match certain regular expressions as big. Ido won't attempt to |
| 472 | list the contents of such directories when completing file names. | 472 | list the contents of such directories when completing file names. |
| 473 | 473 | ||
| 474 | ** Minibuffer | ||
| 475 | |||
| 476 | --- | ||
| 477 | *** Minibuffer now uses 'minibuffer-message' to display error messages | ||
| 478 | at the end of the active minibuffer. | ||
| 479 | |||
| 474 | ** map.el | 480 | ** map.el |
| 475 | *** Now also understands plists. | 481 | *** Now also understands plists. |
| 476 | *** Now defined via generic functions that can be extended via 'cl-defmethod'. | 482 | *** Now defined via generic functions that can be extended via 'cl-defmethod'. |
diff --git a/lisp/simple.el b/lisp/simple.el index 4454791ad20..6bc3bc5304c 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -2440,6 +2440,28 @@ Go to the history element by the absolute history position HIST-POS." | |||
| 2440 | (goto-history-element hist-pos)) | 2440 | (goto-history-element hist-pos)) |
| 2441 | 2441 | ||
| 2442 | 2442 | ||
| 2443 | (add-hook 'minibuffer-setup-hook 'minibuffer-error-initialize) | ||
| 2444 | |||
| 2445 | (defun minibuffer-error-initialize () | ||
| 2446 | "Set up minibuffer error processing." | ||
| 2447 | (setq-local command-error-function 'minibuffer-error-function)) | ||
| 2448 | |||
| 2449 | (defun minibuffer-error-function (data context caller) | ||
| 2450 | "Display error messages in the active minibuffer. | ||
| 2451 | The same as `command-error-default-function' but display error messages | ||
| 2452 | at the end of the minibuffer using `minibuffer-message' to not obscure | ||
| 2453 | the minibuffer contents." | ||
| 2454 | (discard-input) | ||
| 2455 | (ding) | ||
| 2456 | (let ((string (error-message-string data))) | ||
| 2457 | ;; If we know from where the error was signaled, show it in | ||
| 2458 | ;; *Messages*. | ||
| 2459 | (let ((inhibit-message t)) | ||
| 2460 | (message "%s%s" (if caller (format "%s: " caller) "") string)) | ||
| 2461 | ;; Display an error message at the end of the minibuffer. | ||
| 2462 | (minibuffer-message (concat context string)))) | ||
| 2463 | |||
| 2464 | |||
| 2443 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg | 2465 | ;Put this on C-x u, so we can force that rather than C-_ into startup msg |
| 2444 | (define-obsolete-function-alias 'advertised-undo 'undo "23.2") | 2466 | (define-obsolete-function-alias 'advertised-undo 'undo "23.2") |
| 2445 | 2467 | ||