From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs 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 Message-ID: <87pn4b68p1.fsf@tcd.ie> References: <875z68p5mr.fsf@tcd.ie> <87v9e8i3yz.fsf@tcd.ie> <838sb4w3i7.fsf@gnu.org> <87zh3ifjrq.fsf@mail.linkov.net> <87tutqi8yv.fsf@tcd.ie> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18247"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 44629@debbugs.gnu.org, Juri Linkov To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 17 21:17:44 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kf7Q8-0004cG-8y for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Nov 2020 21:17:44 +0100 Original-Received: from localhost ([::1]:51044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kf7Q7-000810-9z for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Nov 2020 15:17:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kf7PS-0007hl-JX for bug-gnu-emacs@gnu.org; Tue, 17 Nov 2020 15:17:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49716) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kf7PS-0004wo-76 for bug-gnu-emacs@gnu.org; Tue, 17 Nov 2020 15:17:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kf7PS-00054x-1m for bug-gnu-emacs@gnu.org; Tue, 17 Nov 2020 15:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Nov 2020 20:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44629 X-GNU-PR-Package: emacs Original-Received: via spool by 44629-submit@debbugs.gnu.org id=B44629.160564416519424 (code B ref 44629); Tue, 17 Nov 2020 20:17:01 +0000 Original-Received: (at 44629) by debbugs.gnu.org; 17 Nov 2020 20:16:05 +0000 Original-Received: from localhost ([127.0.0.1]:33023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kf7OX-00053E-8U for submit@debbugs.gnu.org; Tue, 17 Nov 2020 15:16:05 -0500 Original-Received: from mail-wr1-f42.google.com ([209.85.221.42]:41424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kf7OV-00052c-6G for 44629@debbugs.gnu.org; Tue, 17 Nov 2020 15:16:04 -0500 Original-Received: by mail-wr1-f42.google.com with SMTP id 23so24616409wrc.8 for <44629@debbugs.gnu.org>; Tue, 17 Nov 2020 12:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=BCDNgUfS/qLzOGUaFRbl0RmGhbHn/9E8hHkfW0I9ClU=; b=RzBSh9u/KlHrExZoYID6a46LFlh1T/+tKK7moKLXONgcVx7BqINxos+yNjb9+N88da 0x4I12rZU2q7lccPd8KBBQeoICDpt5GnyNo2m8MY+rAuaQgBhQlNQumqpmQ8m5GtyZ1n hm42L8KJquSAAW7Ty+euYRp4hS5jxYKx2cfbzp4xiP0aO1Px49u1CFzwjxJp1xVZd/JU kIbkU/dcIr28/pd0pLm43WtChVT6iwCGUd5op5UG5H8bYnB1cwOEsuMU0nNUd90qXQ9U PvbPaR3VT89tOwqpL2MWMbMvHhpBOFhwVIwMzPcx1uQfcj62225mtka79Ezf6KEzNZwH dBBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=BCDNgUfS/qLzOGUaFRbl0RmGhbHn/9E8hHkfW0I9ClU=; b=QsH28/i+4kqXDcQ1+I6nTE18m2eDX/anC95Ftgd+PSyUUSzYT+aq1FMVT5yZfUeQAG yRz45HGItMRyHc961qn9vh/IVBsVJuJkmWty1KuScFglvTUrybkQcxySv/LCZL7g7ECY a2rlgAL2flWNirVzQzimSrqAYzae28GJrAP4f12RZzr6aztmxKD14tp2FEilKR2pv2An l13D4BemshnpZYq/jkaQiB4a958bzqPtJC2XYT48LpHI8nyuh+oZ0LkIJ040Nam54W+C JHpBXvWk7i4paSyQjHl36Twxy/PNIT3jilrUjPL7rKm1u0Tf1EBnZ4TyvqM4lASQ7bN6 4xdg== X-Gm-Message-State: AOAM533ZOZPeJmnD/3c1GNPrF0U7ywqmZGETaaeyfmUg9wutdAJL3GUD QLlwQWL4QK20W6jeD0uYAPvTDg== X-Google-Smtp-Source: ABdhPJz7ewALLX6mBWPtkaA2uyBGWNiqW9fFHegDVuthdZTGjQTZgGguyAMs7iQUzy57DcPEJGhOAw== X-Received: by 2002:adf:e5cb:: with SMTP id a11mr1261792wrn.15.1605644157293; Tue, 17 Nov 2020 12:15:57 -0800 (PST) Original-Received: from localhost ([2a02:8084:20e2:c380:92bd:1bfd:38fc:fae2]) by smtp.gmail.com with ESMTPSA id l24sm5261089wmi.7.2020.11.17.12.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 12:15:56 -0800 (PST) In-Reply-To: ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Sun, 15 Nov 2020 23:14:19 +0000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:193575 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 44629 + patch quit Jo=C3=A3o T=C3=A1vora writes: > On Sun, Nov 15, 2020 at 9:52 PM Basil L. Contovounesios = 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.=20=20 > 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`=20 > 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, --=20 Basil --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Avoid-spamming-view-mode-enter-help-message.patch Content-Transfer-Encoding: quoted-printable >From ea8079ee38f752c412d700a7675d8937466c2b14 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" 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=3DUTF-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=C3=A3o T=C3=A1vora . --- 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 =20 (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 connectio= n))) + (buffer-disable-undo) + (setq buffer-read-only t) + (setf (jsonrpc--events-buffer connection) + (current-buffer)))))) =20 (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*" nam= e))) (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))) =20 (cl-defmethod jsonrpc-connection-send ((connection jsonrpc-process-connect= ion) 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) =20 (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 =20 (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#4462= 9). + this-command) (message "%s" (substitute-command-keys "\ View mode: type \\[help-command] for help, \\[describe-mode] for commands,= \\[View-quit] to quit."))))) --=20 2.29.2 --=-=-=--