From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: "João Távora" <joaotavora@gmail.com>
Cc: 44629@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only
Date: Tue, 17 Nov 2020 20:15:54 +0000 [thread overview]
Message-ID: <87pn4b68p1.fsf@tcd.ie> (raw)
In-Reply-To: <CALDnm526_zNhkwFOUKVY+A7_J6wE3==XLChuRDU8xCRudwCy0Q@mail.gmail.com> ("João Távora"'s message of "Sun, 15 Nov 2020 23:14:19 +0000")
[-- Attachment #1: Type: text/plain, Size: 1500 bytes --]
tags 44629 + patch
quit
João Távora <joaotavora@gmail.com> writes:
> On Sun, Nov 15, 2020 at 9:52 PM Basil L. Contovounesios <contovob@tcd.ie> wrote:
>
>> The selectivity is that I want the "View mode: ..." message to appear
>> most of the time, except not when Eglot is doing background processing.
>
> Exactly. Or any type of background processing, for that matter.
> So, if this is a principle, the check for `this-command`, as I proposed
> it in a patch,should suffice
This initially felt a bit heavy-handed (since view-mode-enter is called
in various places), so I was hesitant to go with it, but upon further
consideration I couldn't think of a better way.
For example, binding inhibit-message or set-message-function in
eglot--format-markup may avoid spamming the echo area, but it may also
inadvertently clear the echo area of other messages during Eglot usage,
and still spams *Messages*.
The point is that view-mode-enter shouldn't call message under all
circumstances, and this-command seems like an accurate enough condition.
> This doesn't change the fact that jsonrpc.el's use of `read-only-mode`
> should probably be replaced by a simple setting of buffer-read-only,
> but it could avoid the change to eglot when it calls `gfm-view-mode`.
> Though maybe that change could be there, too.
See my thoughts above on why Eglot needn't be changed in this regard.
How's the attached patch for view.el and jsonrpc.el?
Thanks,
--
Basil
[-- Attachment #2: 0001-Avoid-spamming-view-mode-enter-help-message.patch --]
[-- Type: text/x-diff, Size: 4670 bytes --]
From ea8079ee38f752c412d700a7675d8937466c2b14 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 16 Nov 2020 14:40:57 +0000
Subject: [PATCH] Avoid spamming view-mode-enter help message
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
By default, entering view-mode echoes a usage message. This is
particularly helpful with non-nil view-read-only, to notify the user
that view-mode has been enabled. It is less useful and more spammy,
however, if view-mode is (possibly inadvertently) entered from some
non-interactive code running in the background, such as when a major
mode is enabled in a temporary buffer for text formatting
purposes (bug#44629).
* lisp/jsonrpc.el (jsonrpc-events-buffer, initialize-instance): Use
buffer-read-only in place of read-only-mode for non-interactive use.
* lisp/view.el (view-mode-enter): Inhibit help message if either
view-inhibit-help-message is non-nil, or view-mode-enter was called
from an interactive command. Suggested by João Távora
<joaotavora@gmail.com>.
---
lisp/jsonrpc.el | 27 +++++++++++++--------------
lisp/view.el | 9 +++++++--
2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index 7de6baeb00..e1b832c407 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -138,18 +138,15 @@ jsonrpc-lambda
(defun jsonrpc-events-buffer (connection)
"Get or create JSONRPC events buffer for CONNECTION."
- (let* ((probe (jsonrpc--events-buffer connection))
- (buffer (or (and (buffer-live-p probe)
- probe)
- (let ((buffer (get-buffer-create
- (format "*%s events*"
- (jsonrpc-name connection)))))
- (with-current-buffer buffer
- (buffer-disable-undo)
- (read-only-mode t)
- (setf (jsonrpc--events-buffer connection) buffer))
- buffer))))
- buffer))
+ (let ((probe (jsonrpc--events-buffer connection)))
+ (if (buffer-live-p probe)
+ probe
+ (with-current-buffer
+ (get-buffer-create (format "*%s events*" (jsonrpc-name connection)))
+ (buffer-disable-undo)
+ (setq buffer-read-only t)
+ (setf (jsonrpc--events-buffer connection)
+ (current-buffer))))))
(defun jsonrpc-forget-pending-continuations (connection)
"Stop waiting for responses from the current JSONRPC CONNECTION."
@@ -404,7 +401,7 @@ initialize-instance
(ignore-errors (kill-buffer hidden-name))
(rename-buffer hidden-name)
(process-put proc 'jsonrpc-stderr (current-buffer))
- (read-only-mode t))))
+ (setq buffer-read-only t))))
(setf (jsonrpc--process conn) proc)
(set-process-buffer proc (get-buffer-create (format " *%s output*" name)))
(set-process-filter proc #'jsonrpc--process-filter)
@@ -412,7 +409,9 @@ initialize-instance
(with-current-buffer (process-buffer proc)
(buffer-disable-undo)
(set-marker (process-mark proc) (point-min))
- (let ((inhibit-read-only t)) (erase-buffer) (read-only-mode t)))
+ (let ((inhibit-read-only t))
+ (erase-buffer))
+ (setq buffer-read-only t))
(process-put proc 'jsonrpc-connection conn)))
(cl-defmethod jsonrpc-connection-send ((connection jsonrpc-process-connection)
diff --git a/lisp/view.el b/lisp/view.el
index 204e28c2a2..6f576f8c04 100644
--- a/lisp/view.el
+++ b/lisp/view.el
@@ -88,7 +88,9 @@ view-exits-all-viewing-windows
:group 'view)
(defcustom view-inhibit-help-message nil
- "Non-nil inhibits the help message shown upon entering View mode."
+ "Non-nil inhibits the help message shown upon entering View mode.
+This setting takes effect only when View mode is entered via an
+interactive command; otherwise the help message is not shown."
:type 'boolean
:group 'view
:version "22.1")
@@ -559,7 +561,10 @@ view-mode-enter
(unless view-mode
(view-mode 1)
- (unless view-inhibit-help-message
+ (when (and (not view-inhibit-help-message)
+ ;; Avoid spamming the echo area if `view-mode' is entered
+ ;; non-interactively, e.g., in a temporary buffer (bug#44629).
+ this-command)
(message "%s"
(substitute-command-keys "\
View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit.")))))
--
2.29.2
next prev parent reply other threads:[~2020-11-17 20:15 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-14 10:58 bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only Basil L. Contovounesios
2020-11-14 11:15 ` Basil L. Contovounesios
2020-11-14 12:02 ` Eli Zaretskii
2020-11-14 12:26 ` Basil L. Contovounesios
2020-11-14 14:46 ` Eli Zaretskii
2020-11-14 15:13 ` João Távora
2020-11-15 20:27 ` Juri Linkov
2020-11-15 21:52 ` Basil L. Contovounesios
2020-11-15 23:14 ` João Távora
2020-11-17 20:15 ` Basil L. Contovounesios [this message]
2020-11-17 20:21 ` Basil L. Contovounesios
2020-11-17 22:55 ` João Távora
2020-11-28 21:27 ` Basil L. Contovounesios
2020-11-29 10:36 ` Lars Ingebrigtsen
2020-12-03 15:26 ` Basil L. Contovounesios
2020-11-16 9:14 ` Juri Linkov
2020-11-14 13:47 ` João Távora
2020-11-14 17:13 ` Basil L. Contovounesios
2020-11-15 9:55 ` João Távora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pn4b68p1.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=44629@debbugs.gnu.org \
--cc=joaotavora@gmail.com \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).