* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only @ 2020-11-14 10:58 Basil L. Contovounesios 2020-11-14 11:15 ` Basil L. Contovounesios 2020-11-14 13:47 ` João Távora 0 siblings, 2 replies; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-14 10:58 UTC (permalink / raw) To: 44629; +Cc: joão távora X-Debbugs-Cc: "João Távora" <joaotavora@gmail.com> Severity: minor With Eglot, gfm-view-mode, and non-nil view-read-only, the echo area becomes quite congested. Here's an example that assumes you have previously installed the eglot (GNU ELPA) and markdown-mode (MELPA) packages using a vanilla package.el configuration, as well as pyls, the default Python language server that Eglot expects: 0. emacs -Q 1. (setq view-read-only t) C-j 2. M-x package-initialize RET 3. C-x C-f /tmp/foo.py RET 4. Enter the following Python: def foo(): bar = 1 5. M-x eglot RET (and wait for things to settle down) 6. M-x flymake-goto-next-error RET (and wait for things to settle down) The echo area is now taken over by the view-mode-enter message "View mode: type C-h for help, h for commands, q to quit." This message also appears at various other stages of editing, but when hovering over variables or flymake errors it seems to be the last one standing in the echo area. This happens because eglot--format-markup calls gfm-view-mode, which in turn enables read-only-mode, which in turn calls view-mode-enter. I can't disable this by setting view-read-only or view-inhibit-help-message locally, since Eglot does its doc processing in a different buffer. Perhaps Eglot could/should bind view-inhibit-help-message around gfm-view-mode? Any other ideas? Thanks, -- Basil In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2020-11-11 built on thunk Repository revision: e7b4f465e8b2ec1c8d54a611db7eca44ae350711 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12008000 System Description: Debian GNU/Linux bullseye/sid Configured using: 'configure 'CC=ccache gcc' 'CFLAGS=-O2 -march=native' --config-cache --prefix=/home/blc/.local --with-x-toolkit=lucid --with-file-notification=yes --with-x' Configured features: XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 Important settings: value of $LANG: en_IE.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Python Minor modes in effect: eglot--managed-mode: t flymake-mode: t shell-dirtrack-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils markdown-mode color noutline outline cl-extra view vc-mtn vc-hg vc-git diff-mode easy-mmode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc vc-dispatcher eglot array filenotify jsonrpc ert pp ewoc debug backtrace help-mode find-func xref flymake-proc flymake thingatpt warnings compile text-property-search pcase project imenu python tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat shell pcomplete parse-time iso8601 time-date ls-lisp format-spec comint ring ansi-color finder-inf tex-site debian-el edmacro kmacro rx w3m-load info package easymenu browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo x-toolkit x multi-tty make-network-process emacs) ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 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 13:47 ` João Távora 1 sibling, 1 reply; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-14 11:15 UTC (permalink / raw) To: 44629; +Cc: João Távora "Basil L. Contovounesios" <contovob@tcd.ie> writes: > The echo area is now taken over by the view-mode-enter message > "View mode: type C-h for help, h for commands, q to quit." > > This message also appears at various other stages of editing, but when > hovering over variables or flymake errors it seems to be the last one > standing in the echo area. > > This happens because eglot--format-markup calls gfm-view-mode, which in > turn enables read-only-mode, which in turn calls view-mode-enter. > > I can't disable this by setting view-read-only or > view-inhibit-help-message locally, since Eglot does its doc processing > in a different buffer. > > Perhaps Eglot could/should bind view-inhibit-help-message around > gfm-view-mode? Any other ideas? I tried advising eglot--format-markup to bind view-inhibit-help-message, which gets rid of the most annoying messages, but some still seem to emanate from jsonrpc, which calls read-only-mode in jsonrpc-events-buffer and initialize-instance. I'd rather not have to rely on advising internal functions, but maybe I can't have my cake and eat it, too. ;) -- Basil ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 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-15 20:27 ` Juri Linkov 0 siblings, 2 replies; 19+ messages in thread From: Eli Zaretskii @ 2020-11-14 12:02 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: joaotavora, 44629 > From: "Basil L. Contovounesios" <contovob@tcd.ie> > Date: Sat, 14 Nov 2020 11:15:48 +0000 > Cc: João Távora <joaotavora@gmail.com> > > "Basil L. Contovounesios" <contovob@tcd.ie> writes: > > > Perhaps Eglot could/should bind view-inhibit-help-message around > > gfm-view-mode? Any other ideas? > > I tried advising eglot--format-markup to bind view-inhibit-help-message, > which gets rid of the most annoying messages, but some still seem to > emanate from jsonrpc, which calls read-only-mode in > jsonrpc-events-buffer and initialize-instance. I'd rather not have to > rely on advising internal functions, but maybe I can't have my cake and > eat it, too. ;) Can what you want be achieved by setting set-message-function to something suitable? ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-14 12:02 ` Eli Zaretskii @ 2020-11-14 12:26 ` Basil L. Contovounesios 2020-11-14 14:46 ` Eli Zaretskii 2020-11-15 20:27 ` Juri Linkov 1 sibling, 1 reply; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-14 12:26 UTC (permalink / raw) To: Eli Zaretskii; +Cc: joaotavora, 44629 Eli Zaretskii <eliz@gnu.org> writes: >> From: "Basil L. Contovounesios" <contovob@tcd.ie> >> Date: Sat, 14 Nov 2020 11:15:48 +0000 >> Cc: João Távora <joaotavora@gmail.com> >> >> "Basil L. Contovounesios" <contovob@tcd.ie> writes: >> >> > Perhaps Eglot could/should bind view-inhibit-help-message around >> > gfm-view-mode? Any other ideas? >> >> I tried advising eglot--format-markup to bind view-inhibit-help-message, >> which gets rid of the most annoying messages, but some still seem to >> emanate from jsonrpc, which calls read-only-mode in >> jsonrpc-events-buffer and initialize-instance. I'd rather not have to >> rely on advising internal functions, but maybe I can't have my cake and >> eat it, too. ;) > > Can what you want be achieved by setting set-message-function to > something suitable? I don't have a preference for one or the other approach, but I'm not sure how that would be much different to binding view-inhibit-help-message. The problem in both cases is that eglot and jsonrpc internally make calls, either directly or indirectly, to read-only-mode, which can be noisy. I'd like read-only-mode to remain noisy (via view-read-only) in all other cases, if possible, such as when visiting a read-only file. How can the use of set-message-function distinguish between calls to read-only-mode from internal Eglot plumbing, vs those from e.g. find-file? The only clean approaches off the top of my head are: a) inhibit these messages in one way or another around calls to gfm-view-mode/read-only-mode in eglot/jsonrpc; b) disable view-read-only and/or enable view-inhibit-help-message in my configuration. -- Basil ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-14 12:26 ` Basil L. Contovounesios @ 2020-11-14 14:46 ` Eli Zaretskii 2020-11-14 15:13 ` João Távora 0 siblings, 1 reply; 19+ messages in thread From: Eli Zaretskii @ 2020-11-14 14:46 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: joaotavora, 44629 > From: "Basil L. Contovounesios" <contovob@tcd.ie> > Cc: 44629@debbugs.gnu.org, joaotavora@gmail.com > Date: Sat, 14 Nov 2020 12:26:28 +0000 > > The only clean approaches off the top of my head are: > > a) inhibit these messages in one way or another around calls to > gfm-view-mode/read-only-mode in eglot/jsonrpc; Bind inhibit-message to non-nil around the calls to these? ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-14 14:46 ` Eli Zaretskii @ 2020-11-14 15:13 ` João Távora 0 siblings, 0 replies; 19+ messages in thread From: João Távora @ 2020-11-14 15:13 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Basil L. Contovounesios, 44629 [-- Attachment #1: Type: text/plain, Size: 645 bytes --] Maybe, for gfm-view-mode, but in general I think I should just stop using read-only-mode, and set buffer-read-only instead. João On Sat, Nov 14, 2020 at 2:46 PM Eli Zaretskii <eliz@gnu.org> wrote: > > From: "Basil L. Contovounesios" <contovob@tcd.ie> > > Cc: 44629@debbugs.gnu.org, joaotavora@gmail.com > > Date: Sat, 14 Nov 2020 12:26:28 +0000 > > > > The only clean approaches off the top of my head are: > > > > a) inhibit these messages in one way or another around calls to > > gfm-view-mode/read-only-mode in eglot/jsonrpc; > > Bind inhibit-message to non-nil around the calls to these? > -- João Távora [-- Attachment #2: Type: text/html, Size: 1253 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-14 12:02 ` Eli Zaretskii 2020-11-14 12:26 ` Basil L. Contovounesios @ 2020-11-15 20:27 ` Juri Linkov 2020-11-15 21:52 ` Basil L. Contovounesios 1 sibling, 1 reply; 19+ messages in thread From: Juri Linkov @ 2020-11-15 20:27 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Basil L. Contovounesios, joaotavora, 44629 > Can what you want be achieved by setting set-message-function to > something suitable? Inhibiting messages selectively was discussed in bug#42865 where I forgot that this is indeed easily implementable with the help of set-message-function, e.g.: (defcustom inhibit-message-regexp "^View mode: type" "Regexp to inhibit messages." :type 'regexp) (defun inhibit-message-function (message) (string-match-p inhibit-message-regexp message)) (setq set-message-function 'inhibit-message-function) ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 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-16 9:14 ` Juri Linkov 0 siblings, 2 replies; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-15 21:52 UTC (permalink / raw) To: Juri Linkov; +Cc: joaotavora, 44629 Juri Linkov <juri@linkov.net> writes: >> Can what you want be achieved by setting set-message-function to >> something suitable? > > Inhibiting messages selectively was discussed in bug#42865 > where I forgot that this is indeed easily implementable > with the help of set-message-function, e.g.: > > (defcustom inhibit-message-regexp "^View mode: type" > "Regexp to inhibit messages." > :type 'regexp) > > (defun inhibit-message-function (message) > (string-match-p inhibit-message-regexp message)) > > (setq set-message-function 'inhibit-message-function) The selectivity is that I want the "View mode: ..." message to appear most of the time, except not when Eglot is doing background processing. I therefore don't see how this set-message-function is any different to the other ways of silencing the message that were already mentioned in this thread. There are many ways of silencing the message, but they have to be installed somewhere non-globally. I'll try to write a patch for that tomorrow if no-one else beats me to it. Thanks, -- Basil ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 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 2020-11-16 9:14 ` Juri Linkov 1 sibling, 1 reply; 19+ messages in thread From: João Távora @ 2020-11-15 23:14 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: 44629, Juri Linkov [-- Attachment #1: Type: text/plain, Size: 675 bytes --] 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 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. João [-- Attachment #2: Type: text/html, Size: 911 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-15 23:14 ` João Távora @ 2020-11-17 20:15 ` Basil L. Contovounesios 2020-11-17 20:21 ` Basil L. Contovounesios ` (2 more replies) 0 siblings, 3 replies; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-17 20:15 UTC (permalink / raw) To: João Távora; +Cc: 44629, Juri Linkov [-- 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 ^ permalink raw reply related [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-17 20:15 ` Basil L. Contovounesios @ 2020-11-17 20:21 ` Basil L. Contovounesios 2020-11-17 22:55 ` João Távora 2020-11-29 10:36 ` Lars Ingebrigtsen 2 siblings, 0 replies; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-17 20:21 UTC (permalink / raw) To: João Távora; +Cc: 44629, Juri Linkov "Basil L. Contovounesios" <contovob@tcd.ie> writes: > How's the attached patch for view.el and jsonrpc.el? I forgot to ask - if this goes in, does it need calling out in etc/NEWS? I wouldn't have thought so, but I'm not against it, either. -- Basil ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-17 20:15 ` Basil L. Contovounesios 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 2 siblings, 1 reply; 19+ messages in thread From: João Távora @ 2020-11-17 22:55 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: 44629, Juri Linkov "Basil L. Contovounesios" <contovob@tcd.ie> writes: >> 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. They make sense. > How's the attached patch for view.el and jsonrpc.el? Looks good, and the mini-refactoring in jsonrpc.el is also welcome. IMO, this doesn't need to be called out in NEWS. But let's hear from Lars. João ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-17 22:55 ` João Távora @ 2020-11-28 21:27 ` Basil L. Contovounesios 0 siblings, 0 replies; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-28 21:27 UTC (permalink / raw) To: João Távora; +Cc: 44629, Juri Linkov João Távora <joaotavora@gmail.com> writes: > "Basil L. Contovounesios" <contovob@tcd.ie> writes: > >> How's the attached patch for view.el and jsonrpc.el? > > Looks good, and the mini-refactoring in jsonrpc.el is also welcome. > > IMO, this doesn't need to be called out in NEWS. But let's hear from > Lars. I'll wait a few more days for comments/objections before pushing. Thanks, -- Basil ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-17 20:15 ` Basil L. Contovounesios 2020-11-17 20:21 ` Basil L. Contovounesios 2020-11-17 22:55 ` João Távora @ 2020-11-29 10:36 ` Lars Ingebrigtsen 2020-12-03 15:26 ` Basil L. Contovounesios 2 siblings, 1 reply; 19+ messages in thread From: Lars Ingebrigtsen @ 2020-11-29 10:36 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: João Távora, 44629, Juri Linkov "Basil L. Contovounesios" <contovob@tcd.ie> writes: > How's the attached patch for view.el and jsonrpc.el? [...] > 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). I've only skimmed the code, but this makes sense to me. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-29 10:36 ` Lars Ingebrigtsen @ 2020-12-03 15:26 ` Basil L. Contovounesios 0 siblings, 0 replies; 19+ messages in thread From: Basil L. Contovounesios @ 2020-12-03 15:26 UTC (permalink / raw) To: Lars Ingebrigtsen; +Cc: João Távora, 44629-done, Juri Linkov tags 44629 fixed close 44629 28.1 quit Lars Ingebrigtsen <larsi@gnus.org> writes: > "Basil L. Contovounesios" <contovob@tcd.ie> writes: > >> How's the attached patch for view.el and jsonrpc.el? > > [...] > >> 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). > > I've only skimmed the code, but this makes sense to me. Thanks, now pushed to master. Avoid spamming view-mode-enter help message 805d82197f 2020-12-03 15:22:00 +0000 https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=805d82197f050d1aba8fb796e604c55ce3d6333a -- Basil ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-15 21:52 ` Basil L. Contovounesios 2020-11-15 23:14 ` João Távora @ 2020-11-16 9:14 ` Juri Linkov 1 sibling, 0 replies; 19+ messages in thread From: Juri Linkov @ 2020-11-16 9:14 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: joaotavora, 44629 >> Inhibiting messages selectively was discussed in bug#42865 >> >> (defcustom inhibit-message-regexp "^View mode: type" >> "Regexp to inhibit messages." >> :type 'regexp) >> >> (defun inhibit-message-function (message) >> (string-match-p inhibit-message-regexp message)) >> >> (setq set-message-function 'inhibit-message-function) > > The selectivity is that I want the "View mode: ..." message to appear > most of the time, except not when Eglot is doing background processing. I agree - the primary intention was to use this for user customization in bug#42865. ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 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 13:47 ` João Távora 2020-11-14 17:13 ` Basil L. Contovounesios 1 sibling, 1 reply; 19+ messages in thread From: João Távora @ 2020-11-14 13:47 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: 44629 "Basil L. Contovounesios" <contovob@tcd.ie> writes: > X-Debbugs-Cc: "João Távora" <joaotavora@gmail.com> > Severity: minor Hi Basil, and thanks for X-Debbugs-CC'ing me in this message. This is indeed the way I hope to handle Eglot bugs in the future: via email and the Emacs bug tracker. > Perhaps Eglot could/should bind view-inhibit-help-message around > gfm-view-mode? Any other ideas? I'd have no problem with that, but as you've noted, it doesn't work when other modes also use `read-only-mode`. I think this is more of an Emacs echo-area congestion problem than an Eglot one. view-read-only seems a bit akward, I'd say, but it's been around such a long time that I won't argue for changing it. I'd say the fix here is for Eglot, jsonrpc.el and all all other code that needs to set a buffer read only for implementation purposes just sets the variable buffer-read-only. In fact, the docstring of read-only-mode hints at this: ... Do not call this from a Lisp program unless you really intend to do the same thing as the C-x C-q command, including possibly enabling or disabling View mode. ... I wasn't aware of caveat until just now. Alternatively, and very cautiously, we could also say that the echo area message issued by view-mode should only be displayed to the user if it's running interactively, i.e. if it's a direct synchronous consequence of an interactive command. That would exclude elisp code running asynchronously like jsonrpc.el's updating of the events buffer, and probably also the use that ElDoc clients make of `read-only-mode`. In fact, the docstring of called-interactively-p seems to indicate its main use is to cover these use cases. ... The only known proper use of `interactive' for KIND is in deciding whether to display a helpful message, or how to display it. ... In that spirit, maybe this could fix it? diff --git a/lisp/view.el b/lisp/view.el index 204e28c2a2..6233f3ba7d 100644 --- a/lisp/view.el +++ b/lisp/view.el @@ -559,7 +559,8 @@ view-mode-enter (unless view-mode (view-mode 1) - (unless view-inhibit-help-message + (unless (or view-inhibit-help-message + (not (called-interactively-p 'interactive))) (message "%s" (substitute-command-keys "\ View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit."))))) João ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 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 0 siblings, 1 reply; 19+ messages in thread From: Basil L. Contovounesios @ 2020-11-14 17:13 UTC (permalink / raw) To: João Távora; +Cc: 44629 João Távora <joaotavora@gmail.com> writes: [...] > I'd say the fix here is for Eglot, jsonrpc.el and all all other code > that needs to set a buffer read only for implementation purposes just > sets the variable buffer-read-only. In fact, the docstring of > read-only-mode hints at this: [...] > Alternatively, and very cautiously, we could also say that the echo area > message issued by view-mode should only be displayed to the user if it's > running interactively, i.e. if it's a direct synchronous consequence of > an interactive command. That would exclude elisp code running > asynchronously like jsonrpc.el's updating of the events buffer, and > probably also the use that ElDoc clients make of `read-only-mode`. [...] > In that spirit, maybe this could fix it? > > diff --git a/lisp/view.el b/lisp/view.el > index 204e28c2a2..6233f3ba7d 100644 > --- a/lisp/view.el > +++ b/lisp/view.el > @@ -559,7 +559,8 @@ view-mode-enter > > (unless view-mode > (view-mode 1) > - (unless view-inhibit-help-message > + (unless (or view-inhibit-help-message > + (not (called-interactively-p 'interactive))) > (message "%s" > (substitute-command-keys "\ > View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit."))))) I don't think so, at least not in that exact manifestation, because view-mode-enter is seldom, if ever, called interactively. I.e. this will suppress the help message even when you visit a read-only file. So it's sounding like replacing read-only-mode with buffer-read-only, and an inhibit-message around gfm-view-mode, is indeed the way to go. Thanks, -- Basil ^ permalink raw reply [flat|nested] 19+ messages in thread
* bug#44629: 28.0.50; Eglot noisy with gfm-view-mode and view-read-only 2020-11-14 17:13 ` Basil L. Contovounesios @ 2020-11-15 9:55 ` João Távora 0 siblings, 0 replies; 19+ messages in thread From: João Távora @ 2020-11-15 9:55 UTC (permalink / raw) To: Basil L. Contovounesios; +Cc: 44629 "Basil L. Contovounesios" <contovob@tcd.ie> writes: > João Távora <joaotavora@gmail.com> writes: > > [...] > >> I'd say the fix here is for Eglot, jsonrpc.el and all all other code >> that needs to set a buffer read only for implementation purposes just >> sets the variable buffer-read-only. In fact, the docstring of >> read-only-mode hints at this: > > [...] > >> Alternatively, and very cautiously, we could also say that the echo area >> message issued by view-mode should only be displayed to the user if it's >> running interactively, i.e. if it's a direct synchronous consequence of >> an interactive command. That would exclude elisp code running >> asynchronously like jsonrpc.el's updating of the events buffer, and >> probably also the use that ElDoc clients make of `read-only-mode`. > > [...] > >> In that spirit, maybe this could fix it? >> >> diff --git a/lisp/view.el b/lisp/view.el >> index 204e28c2a2..6233f3ba7d 100644 >> --- a/lisp/view.el >> +++ b/lisp/view.el >> @@ -559,7 +559,8 @@ view-mode-enter >> >> (unless view-mode >> (view-mode 1) >> - (unless view-inhibit-help-message >> + (unless (or view-inhibit-help-message >> + (not (called-interactively-p 'interactive))) >> (message "%s" >> (substitute-command-keys "\ >> View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit."))))) > > I don't think so, at least not in that exact manifestation, because > view-mode-enter is seldom, if ever, called interactively. I.e. this > will suppress the help message even when you visit a read-only file. You're of course right. This is for the immediately "containing function", not for the "current stack". But 'this-command' could do the trick; diff --git a/lisp/view.el b/lisp/view.el index 204e28c2a2..2a0fc85cb8 100644 --- a/lisp/view.el +++ b/lisp/view.el @@ -559,7 +559,8 @@ view-mode-enter (unless view-mode (view-mode 1) - (unless view-inhibit-help-message + (unless (or view-inhibit-help-message + (not this-command)) (message "%s" (substitute-command-keys "\ View mode: type \\[help-command] for help, \\[describe-mode] for commands, \\[View-quit] to quit."))))) When I have this, and view-read-only set to t, C-x C-f'ing to /etc/fstab gets me the message but this: (run-with-timer 1 nil (lambda () (find-file "/etc/fstab"))) does not. Anyway, feel free to beat me to the patches to jsonrpc.el and Eglot (the former you can do directly on the tree, the latter can be done via GitHub, or just send me the patch here). João ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2020-12-03 15:26 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.