GNU bug report logs -
#80152
31.0.50; [PATCH] Jsonrpc: add major mode for events buffers
Previous Next
To reply to this bug, email your comments to 80152 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80152; Package
emacs.
(Thu, 08 Jan 2026 09:15:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
João Távora <joaotavora <at> gmail.com>:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org.
(Thu, 08 Jan 2026 09:15:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi, Daniel
If you don't have objections, I'll push this patch to lisp/jsonrpc.el.
I chose jq because it is a fairly common external program. We could
also pretty print to a lisp list, but then posting the results on LSP
server forums might confuse non-Lispers somewhat. Let me know.
João
Author: João Távora <joaotavora <at> gmail.com>
Date: Thu Jan 8 09:01:21 2026 +0000
Jsonrpc: add major mode for events buffers
If the 'jq' program is installed, this dramatically simplifies debugging
LSP transcripts.
* lisp/jsonrpc.el (jsonrpc-events-jq-at-point): New function.
(jsonrpc-events-occur-at-point): New function.
(jsonrpc-events-mode-map): New variable.
(jsonrpc-events-mode): New major mode.
(jsonrpc-events-buffer): Use new mode.
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index d7bba4e389c..955a4f89009 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -208,6 +208,34 @@ jsonrpc-lambda
"jsonrpc-lambda-elem")))
`(lambda (,e) (apply (cl-function (lambda ,cl-lambda-list ,@body)) ,e))))
+(defun jsonrpc-events-jq-at-point ()
+ "Find first { in line, use forward-sexp to grab JSON, pipe through jq."
+ (interactive)
+ (save-excursion
+ (beginning-of-line)
+ (when (search-forward "{" (line-end-position) t)
+ (backward-char)
+ (let ((start (point)))
+ (forward-sexp)
+ (shell-command-on-region start (point) "jq" "*jq output*")))))
+
+(defun jsonrpc-events-occur-at-point ()
+ "Run occur on thing at point."
+ (interactive)
+ (occur (thing-at-point 'symbol)))
+
+(defvar jsonrpc-events-mode-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "RET") 'jsonrpc-events-jq-at-point)
+ (define-key map (kbd "C-c C-o") 'jsonrpc-events-occur-at-point)
+ map)
+ "Keymap for `jsonrpc-events-mode'.")
+
+(define-derived-mode jsonrpc-events-mode special-mode "JSONRPC-Events"
+ "Major mode for JSONRPC events buffers."
+ (buffer-disable-undo)
+ (setq buffer-read-only t))
+
(defun jsonrpc-events-buffer (connection)
"Get or create JSONRPC events buffer for CONNECTION."
(let ((probe (jsonrpc--events-buffer connection)))
@@ -215,8 +243,7 @@ jsonrpc-events-buffer
probe
(with-current-buffer
(get-buffer-create (format "*%s events*" (jsonrpc-name connection)))
- (buffer-disable-undo)
- (setq buffer-read-only t)
+ (jsonrpc-events-mode)
(setf (jsonrpc--events-buffer connection)
(current-buffer))))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80152; Package
emacs.
(Sun, 11 Jan 2026 19:12:01 GMT)
Full text and
rfc822 format available.
Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):
Hey João
This looks very useful, of course, go ahead! thanks!
On Thu, Jan 8, 2026 at 10:21 AM João Távora <joaotavora <at> gmail.com> wrote:
>
> Hi, Daniel
>
> If you don't have objections, I'll push this patch to lisp/jsonrpc.el.
> I chose jq because it is a fairly common external program. We could
> also pretty print to a lisp list, but then posting the results on LSP
> server forums might confuse non-Lispers somewhat. Let me know.
>
> João
>
> Author: João Távora <joaotavora <at> gmail.com>
> Date: Thu Jan 8 09:01:21 2026 +0000
>
> Jsonrpc: add major mode for events buffers
>
> If the 'jq' program is installed, this dramatically simplifies debugging
> LSP transcripts.
>
> * lisp/jsonrpc.el (jsonrpc-events-jq-at-point): New function.
> (jsonrpc-events-occur-at-point): New function.
> (jsonrpc-events-mode-map): New variable.
> (jsonrpc-events-mode): New major mode.
> (jsonrpc-events-buffer): Use new mode.
>
> diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
> index d7bba4e389c..955a4f89009 100644
> --- a/lisp/jsonrpc.el
> +++ b/lisp/jsonrpc.el
> @@ -208,6 +208,34 @@ jsonrpc-lambda
> "jsonrpc-lambda-elem")))
> `(lambda (,e) (apply (cl-function (lambda ,cl-lambda-list ,@body)) ,e))))
>
> +(defun jsonrpc-events-jq-at-point ()
> + "Find first { in line, use forward-sexp to grab JSON, pipe through jq."
> + (interactive)
> + (save-excursion
> + (beginning-of-line)
> + (when (search-forward "{" (line-end-position) t)
> + (backward-char)
> + (let ((start (point)))
> + (forward-sexp)
> + (shell-command-on-region start (point) "jq" "*jq output*")))))
> +
> +(defun jsonrpc-events-occur-at-point ()
> + "Run occur on thing at point."
> + (interactive)
> + (occur (thing-at-point 'symbol)))
> +
> +(defvar jsonrpc-events-mode-map
> + (let ((map (make-sparse-keymap)))
> + (define-key map (kbd "RET") 'jsonrpc-events-jq-at-point)
> + (define-key map (kbd "C-c C-o") 'jsonrpc-events-occur-at-point)
> + map)
> + "Keymap for `jsonrpc-events-mode'.")
> +
> +(define-derived-mode jsonrpc-events-mode special-mode "JSONRPC-Events"
> + "Major mode for JSONRPC events buffers."
> + (buffer-disable-undo)
> + (setq buffer-read-only t))
> +
> (defun jsonrpc-events-buffer (connection)
> "Get or create JSONRPC events buffer for CONNECTION."
> (let ((probe (jsonrpc--events-buffer connection)))
> @@ -215,8 +243,7 @@ jsonrpc-events-buffer
> probe
> (with-current-buffer
> (get-buffer-create (format "*%s events*" (jsonrpc-name connection)))
> - (buffer-disable-undo)
> - (setq buffer-read-only t)
> + (jsonrpc-events-mode)
> (setf (jsonrpc--events-buffer connection)
> (current-buffer))))))
>
Information forwarded
to
bug-gnu-emacs <at> gnu.org:
bug#80152; Package
emacs.
(Sun, 11 Jan 2026 22:26:02 GMT)
Full text and
rfc822 format available.
Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sun, Jan 11, 2026 at 7:11 PM Daniel Pettersson <daniel <at> dpettersson.net>
wrote:
> Hey João
>
> This looks very useful, of course, go ahead! thanks!
Heh, I already did :-) I took the liberty since I suspected you'd like it
João
[Message part 2 (text/html, inline)]
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.