From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#34939: Some minibuffer behaviour is annoying Date: Thu, 30 May 2019 00:53:46 +0300 Organization: LINKOV.NET Message-ID: <877ea96i6t.fsf@mail.linkov.net> References: <1879851553195601@myt3-2475c4d2af83.qloud-c.yandex.net> <87a7hasuz4.fsf@mail.linkov.net> <87imtvd57d.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="113534"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: pinkanon pinkanon , 34939@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 29 23:57:20 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hW6ZT-000TQj-HG for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 May 2019 23:57:20 +0200 Original-Received: from localhost ([127.0.0.1]:59941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hW6ZS-0001dM-Hm for geb-bug-gnu-emacs@m.gmane.org; Wed, 29 May 2019 17:57:18 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hW6ZD-0001cX-VB for bug-gnu-emacs@gnu.org; Wed, 29 May 2019 17:57:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hW6ZC-0000KM-SW for bug-gnu-emacs@gnu.org; Wed, 29 May 2019 17:57:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hW6ZC-0000KB-JU for bug-gnu-emacs@gnu.org; Wed, 29 May 2019 17:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hW6ZC-00041U-H5 for bug-gnu-emacs@gnu.org; Wed, 29 May 2019 17:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 29 May 2019 21:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34939 X-GNU-PR-Package: emacs Original-Received: via spool by 34939-submit@debbugs.gnu.org id=B34939.155916702015456 (code B ref 34939); Wed, 29 May 2019 21:57:02 +0000 Original-Received: (at 34939) by debbugs.gnu.org; 29 May 2019 21:57:00 +0000 Original-Received: from localhost ([127.0.0.1]:60195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hW6ZA-00041E-6w for submit@debbugs.gnu.org; Wed, 29 May 2019 17:57:00 -0400 Original-Received: from bisque.maple.relay.mailchannels.net ([23.83.214.18]:64367) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hW6Z8-000413-1D for 34939@debbugs.gnu.org; Wed, 29 May 2019 17:56:59 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 5D25E5E23C5; Wed, 29 May 2019 21:56:56 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a6.g.dreamhost.com (100-96-85-75.trex.outbound.svc.cluster.local [100.96.85.75]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 79DFA5E2572; Wed, 29 May 2019 21:56:55 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a6.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.2); Wed, 29 May 2019 21:56:56 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Cellar-Interest: 7096e297284252f1_1559167016109_1935566507 X-MC-Loop-Signature: 1559167016108:351685638 X-MC-Ingress-Time: 1559167016108 Original-Received: from pdx1-sub0-mail-a6.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a6.g.dreamhost.com (Postfix) with ESMTP id B85D5802AC; Wed, 29 May 2019 14:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=g9dexxbszWC5UGJnqRwNyQiig9U=; b= AYXQdy/1G1dC29UnwsToX7LXeSM9L9BdpIQXG2cexTggiidE59TYaRxIMQ/FUHhJ c5dXyYFJ2Mo8TdgAsi+WewLUtYKg6Dx0qd+jIkXlEf4jxfYpUCfTHHH019EOFCX/ BvH3oZHdVeKqqf2Ex2h7odUGbuLMCuV7cSC1WrdYprU= Original-Received: from mail.jurta.org (m91-129-96-73.cust.tele2.ee [91.129.96.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a6.g.dreamhost.com (Postfix) with ESMTPSA id 769AC802A7; Wed, 29 May 2019 14:56:48 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a6 In-Reply-To: (Dmitry Gutov's message of "Mon, 27 May 2019 23:58:00 +0300") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduuddruddvkedgtdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesmhdtreertderjeenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrdeliedrjeefnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledrleeirdejfedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegughhuthhovheshigrnhguvgigrdhruhenucevlhhushhtvghrufhiiigvpedt X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159897 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>> 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 =E2=80=98print_error_message=E2=80=99). > > Could we first print it and then call minibuffer-message? Here is a complete 1-to-1 rewrite of the C function =E2=80=98print_error_= message=E2=80=99 in Lisp that now can be used for more user-friendly displaying error mess= ages in the minibuffer: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=minibuffer-error-function.patch 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") --=-=-=--