GNU logs - #68217, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#68217: 30.0.50; Fix for eglot--format-markup to handle bad markdown
Resent-From: Gary Oberbrunner <garyo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 02 Jan 2024 18:29:01 +0000
Resent-Message-ID: <handler.68217.B.170422013414772 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 68217
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 68217 <at> debbugs.gnu.org
Cc: jblevins@HIDDEN, =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= <joaotavora@HIDDEN>
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.170422013414772
          (code B ref -1); Tue, 02 Jan 2024 18:29:01 +0000
Received: (at submit) by debbugs.gnu.org; 2 Jan 2024 18:28:54 +0000
Received: from localhost ([127.0.0.1]:51265 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rKjVU-0003qB-D8
	for submit <at> debbugs.gnu.org; Tue, 02 Jan 2024 13:28:54 -0500
Received: from lists.gnu.org ([2001:470:142::17]:57322)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <garyo@HIDDEN>) id 1rKjVO-0003pu-Td
 for submit <at> debbugs.gnu.org; Tue, 02 Jan 2024 13:28:50 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <garyo@HIDDEN>)
 id 1rKjVG-0005UL-Nv
 for bug-gnu-emacs@HIDDEN; Tue, 02 Jan 2024 13:28:38 -0500
Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <garyo@HIDDEN>)
 id 1rKjVC-0003TK-Lt
 for bug-gnu-emacs@HIDDEN; Tue, 02 Jan 2024 13:28:38 -0500
Received: by mail-io1-xd2f.google.com with SMTP id
 ca18e2360f4ac-7bb0ab8e79fso306599739f.1
 for <bug-gnu-emacs@HIDDEN>; Tue, 02 Jan 2024 10:28:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=oberbrunner.com; s=google; t=1704220111; x=1704824911; darn=gnu.org;
 h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Jel7JfyCuzeWbfzakMSzq+pFsKb7BX91/GQBS5yxa9k=;
 b=frIhzPSnJkLE1MwaDqCQR9DQDrbchoFbXwth0UBDAvRW4o8LB7rf4ivrbiI+TuI/92
 n25XyiUGKaG4ZEVJxpccPdSVQcV5Ks7QKYfVW8XGrIM5KRrqstl2jtVqNsP7t4u7vD3G
 lqWy2lJHsSgqC1yVguD67fM1bQGCx1x8CD6TJUu2ppHYKhsOAHs7VIXl9+3hw55giO0/
 cMBoDHeRpHNOIsGtYeFQ9PNSDfMcnHq3KZ+x3EyXV670O7ELfbyIgxGeO6sBHXVxk2DC
 P+n7qzHUrAb+v2f67ov1foI9FCdJM0bcTqwyA+mYALR1T5mzxPjvTrs2D4sJSyTg84/V
 vD9w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1704220111; x=1704824911;
 h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=Jel7JfyCuzeWbfzakMSzq+pFsKb7BX91/GQBS5yxa9k=;
 b=n6DRttuGJBcnQTQzfZ0nepIjHwTOpEkr9rRm1DBrk/FQ9C6jFOZz0IWDfQFOi+xCxj
 4Wu2sN03D9rKzcctbxmNKHlQy4P/QcNTJ0TIOoTSkT7su+sw5MZReKR5twcDcTNOKnyz
 Ym+pdYiszs96Va0db3R5c6CYC746oGwbRzrwQz6/hqdNeI8Ii21DUVxS13HI32Nb53AK
 TTPqwLJdqcPK8+5iLazhyD+eujLymW39Gun5+quDfKUB4tCseX78uUXtN2vvOFhiNDrR
 x1kyF0X7oP9L738vy3ninMfv0ZBTXW+fE4X6JhyPSFsirZRhr26rW0cqDLGvHeWCX5br
 BSFA==
X-Gm-Message-State: AOJu0YzQjTzwURnBiQzPbyZvJtzzfSfHg8MZDRl7LL2U/2ERetNJ4d2I
 F/GMjYOFC2UljfgM7jcKCH/Uo0d44vRK45zBkTnnkhD0ozOk0Nvsdprf6lGnqz4=
X-Google-Smtp-Source: AGHT+IEj+k4wHiLHiztyep/nWrjf7/CbQ2XxGt4EFmanSpXWFVcYvVGmTsND/ihlyzqyXuuB8NLYnE3qqLdef9fhl3g=
X-Received: by 2002:a5d:8555:0:b0:7bb:5c57:419d with SMTP id
 b21-20020a5d8555000000b007bb5c57419dmr9859074ios.25.1704220110724; Tue, 02
 Jan 2024 10:28:30 -0800 (PST)
MIME-Version: 1.0
From: Gary Oberbrunner <garyo@HIDDEN>
Date: Tue, 2 Jan 2024 13:28:16 -0500
Message-ID: <CAFChFygDVPR=HkysX_oEGrApb6nHrGDt7xNbzP0wgPer7ygguQ@HIDDEN>
Content-Type: multipart/alternative; boundary="00000000000051e0ea060dfaaa50"
Received-SPF: pass client-ip=2607:f8b0:4864:20::d2f;
 envelope-from=garyo@HIDDEN; helo=mail-io1-xd2f.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--00000000000051e0ea060dfaaa50
Content-Type: text/plain; charset="UTF-8"

With most recent eglot and emacs (as of a couple of days ago) I'm
getting an error in my python-mode buffers. While eglot is trying to
show hover info, it gets a treesit error.

I'm using eldoc and treesit a bunch of other stuff so I'm not sure where
the real bug is. But basically it looks like treesit is trying to
fontify a temp python-mode buffer that just contains

  (class) openfx

and getting an error. Markdown mode is involved too (see the stack
trace). I think the simplest solution is to ignore errors while
fontifying the temp buffer, and I believe joaotavora agrees.

The markup arg passed to eglot--format-markup is:

  (:kind "markdown" :value "```python\n(class) openfx\n```")

I'm using pyright-langserver as the LSP server; I expect it is
returning malformed markup or something that eglot doesn't expect.

I note that the following patch appears to fix it for me:

modified   eglot.el
@@ -1813,7 +1813,9 @@ Doubles as an indicator of snippet support."
             (message-log-max nil)
             match)
         (ignore-errors (delay-mode-hooks (funcall mode)))
-        (font-lock-ensure)
+        (condition-case-unless-debug oops
+            (font-lock-ensure)
+          (error (eglot--warn (error-message-string oops))))
         (goto-char (point-min))
         (let ((inhibit-read-only t))
           (when (fboundp 'text-property-search-forward) ;; FIXME: use
compat

See https://github.com/joaotavora/eglot/discussions/1345 for more details.

The stack trace looks like this:

Debugger entered--Lisp error: (treesit-query-error "Node type error at" 271
"[\"as\" \"assert\" \"async\" \"await\" \"break\" \"case\" \"class\"
\"continue\" \"def\" \"del\" \"elif\" \"else\" \"except\" \"exec\"
\"finally\" \"for\" \"from\" \"global\" \"if\" \"import\" \"lambda\"
\"match\" \"nonlocal\" \"pass\" \"print\" \"raise\" \"return\" \"try\"
\"while\" \"with\" \"yield\" \"and\" \"in\" \"is\" \"not\" \"or\" \"not
in\"] @font-lock-keyword-face ((identifier) @font-lock-keyword-face (#match
\"\\\\`self\\\\'\" @font-lock-keyword-face))" "Debug the query with
`treesit-query-validate'")
  treesit--font-lock-fontify-region-1(#<treesit-node module in 1-17>
#<treesit-compiled-query> 1 17 nil nil)
  treesit-font-lock-fontify-region(1 17 nil)
  font-lock-fontify-syntactically-region(1 17 nil)
  font-lock-default-fontify-region(1 17 nil)
  font-lock-fontify-region(1 17)
  #f(compiled-function (beg end) #<bytecode -0x147d5368d5be984b>)(1 17)
  font-lock-ensure()
  (save-current-buffer (set-buffer (get-buffer-create (concat "
markdown-code-fontification:" (symbol-name lang-mode)))) (let
((inhibit-modification-hooks nil)) (delete-region (point-min) (point-max))
(insert string " ")) (if (eq major-mode lang-mode) nil (funcall lang-mode))
(font-lock-ensure) (setq pos (point-min)) (while (setq next
(next-single-property-change pos 'face)) (let ((val (get-text-property pos
'face))) (if val (progn (put-text-property (+ start (1- pos)) (1- (+ start
next)) 'face val markdown-buffer)))) (setq pos next)))
  (let ((string (buffer-substring-no-properties start end)) (modified
(buffer-modified-p)) (markdown-buffer (current-buffer)) pos next)
(remove-text-properties start end '(face nil)) (save-current-buffer
(set-buffer (get-buffer-create (concat " markdown-code-fontification:"
(symbol-name lang-mode)))) (let ((inhibit-modification-hooks nil))
(delete-region (point-min) (point-max)) (insert string " ")) (if (eq
major-mode lang-mode) nil (funcall lang-mode)) (font-lock-ensure) (setq pos
(point-min)) (while (setq next (next-single-property-change pos 'face))
(let ((val (get-text-property pos 'face))) (if val (progn
(put-text-property (+ start ...) (1- ...) 'face val markdown-buffer))))
(setq pos next))) (add-text-properties start end '(font-lock-fontified t
fontified t font-lock-multiline t)) (set-buffer-modified-p modified))
  (progn (let ((string (buffer-substring-no-properties start end))
(modified (buffer-modified-p)) (markdown-buffer (current-buffer)) pos next)
(remove-text-properties start end '(face nil)) (save-current-buffer
(set-buffer (get-buffer-create (concat " markdown-code-fontification:"
(symbol-name lang-mode)))) (let ((inhibit-modification-hooks nil))
(delete-region (point-min) (point-max)) (insert string " ")) (if (eq
major-mode lang-mode) nil (funcall lang-mode)) (font-lock-ensure) (setq pos
(point-min)) (while (setq next (next-single-property-change pos 'face))
(let ((val (get-text-property pos ...))) (if val (progn (put-text-property
... ... ... val markdown-buffer)))) (setq pos next))) (add-text-properties
start end '(font-lock-fontified t fontified t font-lock-multiline t))
(set-buffer-modified-p modified)))
  (if (fboundp lang-mode) (progn (let ((string
(buffer-substring-no-properties start end)) (modified (buffer-modified-p))
(markdown-buffer (current-buffer)) pos next) (remove-text-properties start
end '(face nil)) (save-current-buffer (set-buffer (get-buffer-create
(concat " markdown-code-fontification:" (symbol-name lang-mode)))) (let
((inhibit-modification-hooks nil)) (delete-region (point-min) (point-max))
(insert string " ")) (if (eq major-mode lang-mode) nil (funcall lang-mode))
(font-lock-ensure) (setq pos (point-min)) (while (setq next
(next-single-property-change pos 'face)) (let ((val ...)) (if val (progn
...))) (setq pos next))) (add-text-properties start end
'(font-lock-fontified t fontified t font-lock-multiline t))
(set-buffer-modified-p modified))))
  (let ((lang-mode (if lang (markdown-get-lang-mode lang)
markdown-fontify-code-block-default-mode))) (if (fboundp lang-mode) (progn
(let ((string (buffer-substring-no-properties start end)) (modified
(buffer-modified-p)) (markdown-buffer (current-buffer)) pos next)
(remove-text-properties start end '(face nil)) (save-current-buffer
(set-buffer (get-buffer-create (concat " markdown-code-fontification:"
...))) (let ((inhibit-modification-hooks nil)) (delete-region (point-min)
(point-max)) (insert string " ")) (if (eq major-mode lang-mode) nil
(funcall lang-mode)) (font-lock-ensure) (setq pos (point-min)) (while (setq
next (next-single-property-change pos ...)) (let (...) (if val ...)) (setq
pos next))) (add-text-properties start end '(font-lock-fontified t
fontified t font-lock-multiline t)) (set-buffer-modified-p modified)))))
  markdown-fontify-code-block-natively("python" 11 26)
  (if (and markdown-fontify-code-blocks-natively (or (setq lang
(markdown-code-block-lang)) markdown-fontify-code-block-default-mode))
(markdown-fontify-code-block-natively lang start end) (add-text-properties
start end '(face markdown-pre-face)))
  (let* ((start (match-beginning 0)) (end (match-end 0)) (bol-prev (progn
(goto-char start) (if (bolp) (line-beginning-position 0)
(line-beginning-position)))) (eol-next (progn (goto-char end) (if (bolp)
(line-beginning-position 2) (line-beginning-position 3)))) lang) (if (and
markdown-fontify-code-blocks-natively (or (setq lang
(markdown-code-block-lang)) markdown-fontify-code-block-default-mode))
(markdown-fontify-code-block-natively lang start end) (add-text-properties
start end '(face markdown-pre-face))) (font-lock-append-text-property
bol-prev eol-next 'face 'markdown-code-face) (add-text-properties bol-prev
start '(invisible markdown-markup)) (add-text-properties end eol-next
'(invisible markdown-markup)))
  (progn (let* ((start (match-beginning 0)) (end (match-end 0)) (bol-prev
(progn (goto-char start) (if (bolp) (line-beginning-position 0)
(line-beginning-position)))) (eol-next (progn (goto-char end) (if (bolp)
(line-beginning-position 2) (line-beginning-position 3)))) lang) (if (and
markdown-fontify-code-blocks-natively (or (setq lang
(markdown-code-block-lang)) markdown-fontify-code-block-default-mode))
(markdown-fontify-code-block-natively lang start end) (add-text-properties
start end '(face markdown-pre-face))) (font-lock-append-text-property
bol-prev eol-next 'face 'markdown-code-face) (add-text-properties bol-prev
start '(invisible markdown-markup)) (add-text-properties end eol-next
'(invisible markdown-markup))))
  (unwind-protect (progn (let* ((start (match-beginning 0)) (end (match-end
0)) (bol-prev (progn (goto-char start) (if (bolp) (line-beginning-position
0) (line-beginning-position)))) (eol-next (progn (goto-char end) (if (bolp)
(line-beginning-position 2) (line-beginning-position 3)))) lang) (if (and
markdown-fontify-code-blocks-natively (or (setq lang
(markdown-code-block-lang)) markdown-fontify-code-block-default-mode))
(markdown-fontify-code-block-natively lang start end) (add-text-properties
start end '(face markdown-pre-face))) (font-lock-append-text-property
bol-prev eol-next 'face 'markdown-code-face) (add-text-properties bol-prev
start '(invisible markdown-markup)) (add-text-properties end eol-next
'(invisible markdown-markup)))) (set-match-data saved-match-data t))
  (let ((saved-match-data (match-data))) (unwind-protect (progn (let*
((start (match-beginning 0)) (end (match-end 0)) (bol-prev (progn
(goto-char start) (if ... ... ...))) (eol-next (progn (goto-char end) (if
... ... ...))) lang) (if (and markdown-fontify-code-blocks-natively (or
(setq lang ...) markdown-fontify-code-block-default-mode))
(markdown-fontify-code-block-natively lang start end) (add-text-properties
start end '(face markdown-pre-face))) (font-lock-append-text-property
bol-prev eol-next 'face 'markdown-code-face) (add-text-properties bol-prev
start '(invisible markdown-markup)) (add-text-properties end eol-next
'(invisible markdown-markup)))) (set-match-data saved-match-data t)))
  (save-excursion (let ((saved-match-data (match-data))) (unwind-protect
(progn (let* ((start (match-beginning 0)) (end (match-end 0)) (bol-prev
(progn ... ...)) (eol-next (progn ... ...)) lang) (if (and
markdown-fontify-code-blocks-natively (or ...
markdown-fontify-code-block-default-mode))
(markdown-fontify-code-block-natively lang start end) (add-text-properties
start end '...)) (font-lock-append-text-property bol-prev eol-next 'face
'markdown-code-face) (add-text-properties bol-prev start '(invisible
markdown-markup)) (add-text-properties end eol-next '(invisible
markdown-markup)))) (set-match-data saved-match-data t))))
  (progn (save-excursion (let ((saved-match-data (match-data)))
(unwind-protect (progn (let* ((start ...) (end ...) (bol-prev ...)
(eol-next ...) lang) (if (and markdown-fontify-code-blocks-natively ...)
(markdown-fontify-code-block-natively lang start end) (add-text-properties
start end ...)) (font-lock-append-text-property bol-prev eol-next 'face
'markdown-code-face) (add-text-properties bol-prev start '...)
(add-text-properties end eol-next '...))) (set-match-data saved-match-data
t)))) t)
  (if (funcall matcher last) (progn (save-excursion (let ((saved-match-data
(match-data))) (unwind-protect (progn (let* (... ... ... ... lang) (if ...
... ...) (font-lock-append-text-property bol-prev eol-next ... ...)
(add-text-properties bol-prev start ...) (add-text-properties end eol-next
...))) (set-match-data saved-match-data t)))) t))
  markdown-fontify-code-blocks-generic(markdown-match-gfm-code-blocks 29)
  markdown-fontify-gfm-code-blocks(29)
  font-lock-fontify-keywords-region(1 29 nil)
  font-lock-default-fontify-region(1 29 nil)
  font-lock-fontify-region(1 29)
  #f(compiled-function (beg end) #<bytecode -0x147d5368d5be984b>)(1 29)
  font-lock-ensure()
  (let ((inhibit-message t) (message-log-max nil) match) (condition-case
nil (progn (progn (make-local-variable 'delay-mode-hooks) (let
((delay-mode-hooks t)) (funcall mode)))) (error nil)) (font-lock-ensure)
(goto-char (point-min)) (let ((inhibit-read-only t)) (if (fboundp
'text-property-search-forward) (progn (while (setq match
(text-property-search-forward 'invisible)) (delete-region (let* (...)
(progn ... ...)) (let* (...) (progn ... ...))))))) (string-trim
(buffer-string)))
  (progn (set (make-local-variable 'markdown-fontify-code-blocks-natively)
t) (insert string) (let ((inhibit-message t) (message-log-max nil) match)
(condition-case nil (progn (progn (make-local-variable 'delay-mode-hooks)
(let ((delay-mode-hooks t)) (funcall mode)))) (error nil))
(font-lock-ensure) (goto-char (point-min)) (let ((inhibit-read-only t)) (if
(fboundp 'text-property-search-forward) (progn (while (setq match
(text-property-search-forward ...)) (delete-region (let* ... ...) (let* ...
...)))))) (string-trim (buffer-string))))
  (unwind-protect (progn (set (make-local-variable
'markdown-fontify-code-blocks-natively) t) (insert string) (let
((inhibit-message t) (message-log-max nil) match) (condition-case nil
(progn (progn (make-local-variable 'delay-mode-hooks) (let (...) (funcall
mode)))) (error nil)) (font-lock-ensure) (goto-char (point-min)) (let
((inhibit-read-only t)) (if (fboundp 'text-property-search-forward) (progn
(while (setq match ...) (delete-region ... ...))))) (string-trim
(buffer-string)))) (and (buffer-name temp-buffer) (kill-buffer
temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (set
(make-local-variable 'markdown-fontify-code-blocks-natively) t) (insert
string) (let ((inhibit-message t) (message-log-max nil) match)
(condition-case nil (progn (progn (make-local-variable ...) (let ... ...)))
(error nil)) (font-lock-ensure) (goto-char (point-min)) (let
((inhibit-read-only t)) (if (fboundp 'text-property-search-forward) (progn
(while ... ...)))) (string-trim (buffer-string)))) (and (buffer-name
temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*" t)))
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (set
(make-local-variable 'markdown-fontify-code-blocks-natively) t) (insert
string) (let ((inhibit-message t) (message-log-max nil) match)
(condition-case nil (progn (progn ... ...)) (error nil)) (font-lock-ensure)
(goto-char (point-min)) (let ((inhibit-read-only t)) (if (fboundp ...)
(progn ...))) (string-trim (buffer-string)))) (and (buffer-name
temp-buffer) (kill-buffer temp-buffer)))))
  (let ((string x614) (mode x616)) (let ((temp-buffer (generate-new-buffer
" *temp*" t))) (save-current-buffer (set-buffer temp-buffer)
(unwind-protect (progn (set (make-local-variable
'markdown-fontify-code-blocks-natively) t) (insert string) (let
((inhibit-message t) (message-log-max nil) match) (condition-case nil
(progn ...) (error nil)) (font-lock-ensure) (goto-char (point-min)) (let
(...) (if ... ...)) (string-trim (buffer-string)))) (and (buffer-name
temp-buffer) (kill-buffer temp-buffer))))))
  (progn (ignore (null x617)) (let ((string x614) (mode x616)) (let
((temp-buffer (generate-new-buffer " *temp*" t))) (save-current-buffer
(set-buffer temp-buffer) (unwind-protect (progn (set (make-local-variable
...) t) (insert string) (let (... ... match) (condition-case nil ... ...)
(font-lock-ensure) (goto-char ...) (let ... ...) (string-trim ...))) (and
(buffer-name temp-buffer) (kill-buffer temp-buffer)))))))
  (let* ((x616 (car-safe x615)) (x617 (cdr-safe x615))) (progn (ignore
(null x617)) (let ((string x614) (mode x616)) (let ((temp-buffer
(generate-new-buffer " *temp*" t))) (save-current-buffer (set-buffer
temp-buffer) (unwind-protect (progn (set ... t) (insert string) (let ...
... ... ... ... ...)) (and (buffer-name temp-buffer) (kill-buffer
temp-buffer))))))))
  (progn (ignore (consp x615)) (let* ((x616 (car-safe x615)) (x617
(cdr-safe x615))) (progn (ignore (null x617)) (let ((string x614) (mode
x616)) (let ((temp-buffer (generate-new-buffer " *temp*" t)))
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn ...
... ...) (and ... ...))))))))
  (let* ((x614 (car-safe val)) (x615 (cdr-safe val))) (progn (ignore (consp
x615)) (let* ((x616 (car-safe x615)) (x617 (cdr-safe x615))) (progn (ignore
(null x617)) (let ((string x614) (mode x616)) (let ((temp-buffer ...))
(save-current-buffer (set-buffer temp-buffer) (unwind-protect ...
...))))))))
  (progn (ignore (consp val)) (let* ((x614 (car-safe val)) (x615 (cdr-safe
val))) (progn (ignore (consp x615)) (let* ((x616 (car-safe x615)) (x617
(cdr-safe x615))) (progn (ignore (null x617)) (let ((string x614) (mode
x616)) (let (...) (save-current-buffer ... ...))))))))
  (let* ((val (if (stringp markup) (list markup 'gfm-view-mode) (list
(plist-get markup :value) (let* ((val ...)) (cond (... ...) (... ...) (t
...))))))) (progn (ignore (consp val)) (let* ((x614 (car-safe val)) (x615
(cdr-safe val))) (progn (ignore (consp x615)) (let* ((x616 (car-safe x615))
(x617 (cdr-safe x615))) (progn (ignore (null x617)) (let (... ...) (let ...
...))))))))
  eglot--format-markup((:kind "markdown" :value "```python\n(class)
openfx\n```"))
  mapconcat(eglot--format-markup ((:kind "markdown" :value
"```python\n(class) openfx\n```")) "\n")
  eglot--hover-info((:kind "markdown" :value "```python\n(class)
openfx\n```") (:start (:line 7 :character 6) :end (:line 7 :character


In GNU Emacs 30.0.50 (build 1, x86_64-w64-mingw32) of 2023-12-23 built
on fv-az1258-535Repository revision:
5c3ff1494b69bf45b99125f2423174222badfa43
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.22635
System Description: Microsoft Windows 10 Pro (v10.0.2009.22635.2915)

Configured using:
 'configure --prefix=/d/a/emacs-build/emacs-build/pkg/master-x86_64
'CFLAGS=-Ofast -fno-finite-math-only -fomit-frame-pointer -funroll-loops
-floop-parallelize-all -ftree-parallelize-loops=4 -march=skylake
-mtune=znver1' --with-native-compilation --with-zlib --with-xpm --with-xml2
--with-tree-sitter --with-tiff --with-rsvg --with-png --with-lcms2
--with-json --with-jpeg --with-harfbuzz --with-gnutls --with-gif
--with-cairo --without-dbus --with-compress-install'


-- 
Gary

--00000000000051e0ea060dfaaa50
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">With most recent eglot and emacs (as of a couple of days a=
go) I&#39;m<br>getting an error in my python-mode buffers. While eglot is t=
rying to<br>show hover info, it gets a treesit error.<br><br>I&#39;m using =
eldoc and treesit a bunch of other stuff so I&#39;m not sure where<br>the r=
eal bug is. But basically it looks like treesit is trying to<br>fontify a t=
emp python-mode buffer that just contains<br><br>=C2=A0 (class) openfx<br>=
=C2=A0<br>and getting an error. Markdown mode is involved too (see the stac=
k<br>trace). I think the simplest solution is to ignore errors while<br>fon=
tifying the temp buffer, and I believe joaotavora agrees.<br><br>The markup=
 arg passed to eglot--format-markup is:<br><br>=C2=A0 (:kind &quot;markdown=
&quot; :value &quot;```python\n(class) openfx\n```&quot;)<br><br>I&#39;m us=
ing pyright-langserver as the LSP server; I expect it is<br>returning malfo=
rmed markup or something that eglot doesn&#39;t expect.<br><br>I note that =
the following patch appears to fix it for me:<br><br>modified =C2=A0 eglot.=
el<br>@@ -1813,7 +1813,9 @@ Doubles as an indicator of snippet support.&quo=
t;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-log-max nil)=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0match)<br>=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0(ignore-errors (delay-mode-hooks (funcall mode)))<br>-=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0(font-lock-ensure)<br>+ =C2=A0 =C2=A0 =C2=A0 =
=C2=A0(condition-case-unless-debug oops<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0(font-lock-ensure)<br>+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(err=
or (eglot--warn (error-message-string oops))))<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0(goto-char (point-min))<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let=
 ((inhibit-read-only t))<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when =
(fboundp &#39;text-property-search-forward) ;; FIXME: use compat<br>=C2=A0<=
div>See <a href=3D"https://github.com/joaotavora/eglot/discussions/1345">ht=
tps://github.com/joaotavora/eglot/discussions/1345</a> for more=C2=A0detail=
s.</div><div><br>The stack trace looks like this:<br><br>Debugger entered--=
Lisp error: (treesit-query-error &quot;Node type error at&quot; 271 &quot;[=
\&quot;as\&quot; \&quot;assert\&quot; \&quot;async\&quot; \&quot;await\&quo=
t; \&quot;break\&quot; \&quot;case\&quot; \&quot;class\&quot; \&quot;contin=
ue\&quot; \&quot;def\&quot; \&quot;del\&quot; \&quot;elif\&quot; \&quot;els=
e\&quot; \&quot;except\&quot; \&quot;exec\&quot; \&quot;finally\&quot; \&qu=
ot;for\&quot; \&quot;from\&quot; \&quot;global\&quot; \&quot;if\&quot; \&qu=
ot;import\&quot; \&quot;lambda\&quot; \&quot;match\&quot; \&quot;nonlocal\&=
quot; \&quot;pass\&quot; \&quot;print\&quot; \&quot;raise\&quot; \&quot;ret=
urn\&quot; \&quot;try\&quot; \&quot;while\&quot; \&quot;with\&quot; \&quot;=
yield\&quot; \&quot;and\&quot; \&quot;in\&quot; \&quot;is\&quot; \&quot;not=
\&quot; \&quot;or\&quot; \&quot;not in\&quot;] @font-lock-keyword-face ((id=
entifier) @font-lock-keyword-face (#match \&quot;\\\\`self\\\\&#39;\&quot; =
@font-lock-keyword-face))&quot; &quot;Debug the query with `treesit-query-v=
alidate&#39;&quot;)<br>=C2=A0 treesit--font-lock-fontify-region-1(#&lt;tree=
sit-node module in 1-17&gt; #&lt;treesit-compiled-query&gt; 1 17 nil nil)<b=
r>=C2=A0 treesit-font-lock-fontify-region(1 17 nil)<br>=C2=A0 font-lock-fon=
tify-syntactically-region(1 17 nil)<br>=C2=A0 font-lock-default-fontify-reg=
ion(1 17 nil)<br>=C2=A0 font-lock-fontify-region(1 17)<br>=C2=A0 #f(compile=
d-function (beg end) #&lt;bytecode -0x147d5368d5be984b&gt;)(1 17)<br>=C2=A0=
 font-lock-ensure()<br>=C2=A0 (save-current-buffer (set-buffer (get-buffer-=
create (concat &quot; markdown-code-fontification:&quot; (symbol-name lang-=
mode)))) (let ((inhibit-modification-hooks nil)) (delete-region (point-min)=
 (point-max)) (insert string &quot; &quot;)) (if (eq major-mode lang-mode) =
nil (funcall lang-mode)) (font-lock-ensure) (setq pos (point-min)) (while (=
setq next (next-single-property-change pos &#39;face)) (let ((val (get-text=
-property pos &#39;face))) (if val (progn (put-text-property (+ start (1- p=
os)) (1- (+ start next)) &#39;face val markdown-buffer)))) (setq pos next))=
)<br>=C2=A0 (let ((string (buffer-substring-no-properties start end)) (modi=
fied (buffer-modified-p)) (markdown-buffer (current-buffer)) pos next) (rem=
ove-text-properties start end &#39;(face nil)) (save-current-buffer (set-bu=
ffer (get-buffer-create (concat &quot; markdown-code-fontification:&quot; (=
symbol-name lang-mode)))) (let ((inhibit-modification-hooks nil)) (delete-r=
egion (point-min) (point-max)) (insert string &quot; &quot;)) (if (eq major=
-mode lang-mode) nil (funcall lang-mode)) (font-lock-ensure) (setq pos (poi=
nt-min)) (while (setq next (next-single-property-change pos &#39;face)) (le=
t ((val (get-text-property pos &#39;face))) (if val (progn (put-text-proper=
ty (+ start ...) (1- ...) &#39;face val markdown-buffer)))) (setq pos next)=
)) (add-text-properties start end &#39;(font-lock-fontified t fontified t f=
ont-lock-multiline t)) (set-buffer-modified-p modified))<br>=C2=A0 (progn (=
let ((string (buffer-substring-no-properties start end)) (modified (buffer-=
modified-p)) (markdown-buffer (current-buffer)) pos next) (remove-text-prop=
erties start end &#39;(face nil)) (save-current-buffer (set-buffer (get-buf=
fer-create (concat &quot; markdown-code-fontification:&quot; (symbol-name l=
ang-mode)))) (let ((inhibit-modification-hooks nil)) (delete-region (point-=
min) (point-max)) (insert string &quot; &quot;)) (if (eq major-mode lang-mo=
de) nil (funcall lang-mode)) (font-lock-ensure) (setq pos (point-min)) (whi=
le (setq next (next-single-property-change pos &#39;face)) (let ((val (get-=
text-property pos ...))) (if val (progn (put-text-property ... ... ... val =
markdown-buffer)))) (setq pos next))) (add-text-properties start end &#39;(=
font-lock-fontified t fontified t font-lock-multiline t)) (set-buffer-modif=
ied-p modified)))<br>=C2=A0 (if (fboundp lang-mode) (progn (let ((string (b=
uffer-substring-no-properties start end)) (modified (buffer-modified-p)) (m=
arkdown-buffer (current-buffer)) pos next) (remove-text-properties start en=
d &#39;(face nil)) (save-current-buffer (set-buffer (get-buffer-create (con=
cat &quot; markdown-code-fontification:&quot; (symbol-name lang-mode)))) (l=
et ((inhibit-modification-hooks nil)) (delete-region (point-min) (point-max=
)) (insert string &quot; &quot;)) (if (eq major-mode lang-mode) nil (funcal=
l lang-mode)) (font-lock-ensure) (setq pos (point-min)) (while (setq next (=
next-single-property-change pos &#39;face)) (let ((val ...)) (if val (progn=
 ...))) (setq pos next))) (add-text-properties start end &#39;(font-lock-fo=
ntified t fontified t font-lock-multiline t)) (set-buffer-modified-p modifi=
ed))))<br>=C2=A0 (let ((lang-mode (if lang (markdown-get-lang-mode lang) ma=
rkdown-fontify-code-block-default-mode))) (if (fboundp lang-mode) (progn (l=
et ((string (buffer-substring-no-properties start end)) (modified (buffer-m=
odified-p)) (markdown-buffer (current-buffer)) pos next) (remove-text-prope=
rties start end &#39;(face nil)) (save-current-buffer (set-buffer (get-buff=
er-create (concat &quot; markdown-code-fontification:&quot; ...))) (let ((i=
nhibit-modification-hooks nil)) (delete-region (point-min) (point-max)) (in=
sert string &quot; &quot;)) (if (eq major-mode lang-mode) nil (funcall lang=
-mode)) (font-lock-ensure) (setq pos (point-min)) (while (setq next (next-s=
ingle-property-change pos ...)) (let (...) (if val ...)) (setq pos next))) =
(add-text-properties start end &#39;(font-lock-fontified t fontified t font=
-lock-multiline t)) (set-buffer-modified-p modified)))))<br>=C2=A0 markdown=
-fontify-code-block-natively(&quot;python&quot; 11 26)<br>=C2=A0 (if (and m=
arkdown-fontify-code-blocks-natively (or (setq lang (markdown-code-block-la=
ng)) markdown-fontify-code-block-default-mode)) (markdown-fontify-code-bloc=
k-natively lang start end) (add-text-properties start end &#39;(face markdo=
wn-pre-face)))<br>=C2=A0 (let* ((start (match-beginning 0)) (end (match-end=
 0)) (bol-prev (progn (goto-char start) (if (bolp) (line-beginning-position=
 0) (line-beginning-position)))) (eol-next (progn (goto-char end) (if (bolp=
) (line-beginning-position 2) (line-beginning-position 3)))) lang) (if (and=
 markdown-fontify-code-blocks-natively (or (setq lang (markdown-code-block-=
lang)) markdown-fontify-code-block-default-mode)) (markdown-fontify-code-bl=
ock-natively lang start end) (add-text-properties start end &#39;(face mark=
down-pre-face))) (font-lock-append-text-property bol-prev eol-next &#39;fac=
e &#39;markdown-code-face) (add-text-properties bol-prev start &#39;(invisi=
ble markdown-markup)) (add-text-properties end eol-next &#39;(invisible mar=
kdown-markup)))<br>=C2=A0 (progn (let* ((start (match-beginning 0)) (end (m=
atch-end 0)) (bol-prev (progn (goto-char start) (if (bolp) (line-beginning-=
position 0) (line-beginning-position)))) (eol-next (progn (goto-char end) (=
if (bolp) (line-beginning-position 2) (line-beginning-position 3)))) lang) =
(if (and markdown-fontify-code-blocks-natively (or (setq lang (markdown-cod=
e-block-lang)) markdown-fontify-code-block-default-mode)) (markdown-fontify=
-code-block-natively lang start end) (add-text-properties start end &#39;(f=
ace markdown-pre-face))) (font-lock-append-text-property bol-prev eol-next =
&#39;face &#39;markdown-code-face) (add-text-properties bol-prev start &#39=
;(invisible markdown-markup)) (add-text-properties end eol-next &#39;(invis=
ible markdown-markup))))<br>=C2=A0 (unwind-protect (progn (let* ((start (ma=
tch-beginning 0)) (end (match-end 0)) (bol-prev (progn (goto-char start) (i=
f (bolp) (line-beginning-position 0) (line-beginning-position)))) (eol-next=
 (progn (goto-char end) (if (bolp) (line-beginning-position 2) (line-beginn=
ing-position 3)))) lang) (if (and markdown-fontify-code-blocks-natively (or=
 (setq lang (markdown-code-block-lang)) markdown-fontify-code-block-default=
-mode)) (markdown-fontify-code-block-natively lang start end) (add-text-pro=
perties start end &#39;(face markdown-pre-face))) (font-lock-append-text-pr=
operty bol-prev eol-next &#39;face &#39;markdown-code-face) (add-text-prope=
rties bol-prev start &#39;(invisible markdown-markup)) (add-text-properties=
 end eol-next &#39;(invisible markdown-markup)))) (set-match-data saved-mat=
ch-data t))<br>=C2=A0 (let ((saved-match-data (match-data))) (unwind-protec=
t (progn (let* ((start (match-beginning 0)) (end (match-end 0)) (bol-prev (=
progn (goto-char start) (if ... ... ...))) (eol-next (progn (goto-char end)=
 (if ... ... ...))) lang) (if (and markdown-fontify-code-blocks-natively (o=
r (setq lang ...) markdown-fontify-code-block-default-mode)) (markdown-font=
ify-code-block-natively lang start end) (add-text-properties start end &#39=
;(face markdown-pre-face))) (font-lock-append-text-property bol-prev eol-ne=
xt &#39;face &#39;markdown-code-face) (add-text-properties bol-prev start &=
#39;(invisible markdown-markup)) (add-text-properties end eol-next &#39;(in=
visible markdown-markup)))) (set-match-data saved-match-data t)))<br>=C2=A0=
 (save-excursion (let ((saved-match-data (match-data))) (unwind-protect (pr=
ogn (let* ((start (match-beginning 0)) (end (match-end 0)) (bol-prev (progn=
 ... ...)) (eol-next (progn ... ...)) lang) (if (and markdown-fontify-code-=
blocks-natively (or ... markdown-fontify-code-block-default-mode)) (markdow=
n-fontify-code-block-natively lang start end) (add-text-properties start en=
d &#39;...)) (font-lock-append-text-property bol-prev eol-next &#39;face &#=
39;markdown-code-face) (add-text-properties bol-prev start &#39;(invisible =
markdown-markup)) (add-text-properties end eol-next &#39;(invisible markdow=
n-markup)))) (set-match-data saved-match-data t))))<br>=C2=A0 (progn (save-=
excursion (let ((saved-match-data (match-data))) (unwind-protect (progn (le=
t* ((start ...) (end ...) (bol-prev ...) (eol-next ...) lang) (if (and mark=
down-fontify-code-blocks-natively ...) (markdown-fontify-code-block-nativel=
y lang start end) (add-text-properties start end ...)) (font-lock-append-te=
xt-property bol-prev eol-next &#39;face &#39;markdown-code-face) (add-text-=
properties bol-prev start &#39;...) (add-text-properties end eol-next &#39;=
...))) (set-match-data saved-match-data t)))) t)<br>=C2=A0 (if (funcall mat=
cher last) (progn (save-excursion (let ((saved-match-data (match-data))) (u=
nwind-protect (progn (let* (... ... ... ... lang) (if ... ... ...) (font-lo=
ck-append-text-property bol-prev eol-next ... ...) (add-text-properties bol=
-prev start ...) (add-text-properties end eol-next ...))) (set-match-data s=
aved-match-data t)))) t))<br>=C2=A0 markdown-fontify-code-blocks-generic(ma=
rkdown-match-gfm-code-blocks 29)<br>=C2=A0 markdown-fontify-gfm-code-blocks=
(29)<br>=C2=A0 font-lock-fontify-keywords-region(1 29 nil)<br>=C2=A0 font-l=
ock-default-fontify-region(1 29 nil)<br>=C2=A0 font-lock-fontify-region(1 2=
9)<br>=C2=A0 #f(compiled-function (beg end) #&lt;bytecode -0x147d5368d5be98=
4b&gt;)(1 29)<br>=C2=A0 font-lock-ensure()<br>=C2=A0 (let ((inhibit-message=
 t) (message-log-max nil) match) (condition-case nil (progn (progn (make-lo=
cal-variable &#39;delay-mode-hooks) (let ((delay-mode-hooks t)) (funcall mo=
de)))) (error nil)) (font-lock-ensure) (goto-char (point-min)) (let ((inhib=
it-read-only t)) (if (fboundp &#39;text-property-search-forward) (progn (wh=
ile (setq match (text-property-search-forward &#39;invisible)) (delete-regi=
on (let* (...) (progn ... ...)) (let* (...) (progn ... ...))))))) (string-t=
rim (buffer-string)))<br>=C2=A0 (progn (set (make-local-variable &#39;markd=
own-fontify-code-blocks-natively) t) (insert string) (let ((inhibit-message=
 t) (message-log-max nil) match) (condition-case nil (progn (progn (make-lo=
cal-variable &#39;delay-mode-hooks) (let ((delay-mode-hooks t)) (funcall mo=
de)))) (error nil)) (font-lock-ensure) (goto-char (point-min)) (let ((inhib=
it-read-only t)) (if (fboundp &#39;text-property-search-forward) (progn (wh=
ile (setq match (text-property-search-forward ...)) (delete-region (let* ..=
. ...) (let* ... ...)))))) (string-trim (buffer-string))))<br>=C2=A0 (unwin=
d-protect (progn (set (make-local-variable &#39;markdown-fontify-code-block=
s-natively) t) (insert string) (let ((inhibit-message t) (message-log-max n=
il) match) (condition-case nil (progn (progn (make-local-variable &#39;dela=
y-mode-hooks) (let (...) (funcall mode)))) (error nil)) (font-lock-ensure) =
(goto-char (point-min)) (let ((inhibit-read-only t)) (if (fboundp &#39;text=
-property-search-forward) (progn (while (setq match ...) (delete-region ...=
 ...))))) (string-trim (buffer-string)))) (and (buffer-name temp-buffer) (k=
ill-buffer temp-buffer)))<br>=C2=A0 (save-current-buffer (set-buffer temp-b=
uffer) (unwind-protect (progn (set (make-local-variable &#39;markdown-fonti=
fy-code-blocks-natively) t) (insert string) (let ((inhibit-message t) (mess=
age-log-max nil) match) (condition-case nil (progn (progn (make-local-varia=
ble ...) (let ... ...))) (error nil)) (font-lock-ensure) (goto-char (point-=
min)) (let ((inhibit-read-only t)) (if (fboundp &#39;text-property-search-f=
orward) (progn (while ... ...)))) (string-trim (buffer-string)))) (and (buf=
fer-name temp-buffer) (kill-buffer temp-buffer))))<br>=C2=A0 (let ((temp-bu=
ffer (generate-new-buffer &quot; *temp*&quot; t))) (save-current-buffer (se=
t-buffer temp-buffer) (unwind-protect (progn (set (make-local-variable &#39=
;markdown-fontify-code-blocks-natively) t) (insert string) (let ((inhibit-m=
essage t) (message-log-max nil) match) (condition-case nil (progn (progn ..=
. ...)) (error nil)) (font-lock-ensure) (goto-char (point-min)) (let ((inhi=
bit-read-only t)) (if (fboundp ...) (progn ...))) (string-trim (buffer-stri=
ng)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))<br>=C2=
=A0 (let ((string x614) (mode x616)) (let ((temp-buffer (generate-new-buffe=
r &quot; *temp*&quot; t))) (save-current-buffer (set-buffer temp-buffer) (u=
nwind-protect (progn (set (make-local-variable &#39;markdown-fontify-code-b=
locks-natively) t) (insert string) (let ((inhibit-message t) (message-log-m=
ax nil) match) (condition-case nil (progn ...) (error nil)) (font-lock-ensu=
re) (goto-char (point-min)) (let (...) (if ... ...)) (string-trim (buffer-s=
tring)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))<br>=
=C2=A0 (progn (ignore (null x617)) (let ((string x614) (mode x616)) (let ((=
temp-buffer (generate-new-buffer &quot; *temp*&quot; t))) (save-current-buf=
fer (set-buffer temp-buffer) (unwind-protect (progn (set (make-local-variab=
le ...) t) (insert string) (let (... ... match) (condition-case nil ... ...=
) (font-lock-ensure) (goto-char ...) (let ... ...) (string-trim ...))) (and=
 (buffer-name temp-buffer) (kill-buffer temp-buffer)))))))<br>=C2=A0 (let* =
((x616 (car-safe x615)) (x617 (cdr-safe x615))) (progn (ignore (null x617))=
 (let ((string x614) (mode x616)) (let ((temp-buffer (generate-new-buffer &=
quot; *temp*&quot; t))) (save-current-buffer (set-buffer temp-buffer) (unwi=
nd-protect (progn (set ... t) (insert string) (let ... ... ... ... ... ...)=
) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))))))<br>=C2=A0=
 (progn (ignore (consp x615)) (let* ((x616 (car-safe x615)) (x617 (cdr-safe=
 x615))) (progn (ignore (null x617)) (let ((string x614) (mode x616)) (let =
((temp-buffer (generate-new-buffer &quot; *temp*&quot; t))) (save-current-b=
uffer (set-buffer temp-buffer) (unwind-protect (progn ... ... ...) (and ...=
 ...))))))))<br>=C2=A0 (let* ((x614 (car-safe val)) (x615 (cdr-safe val))) =
(progn (ignore (consp x615)) (let* ((x616 (car-safe x615)) (x617 (cdr-safe =
x615))) (progn (ignore (null x617)) (let ((string x614) (mode x616)) (let (=
(temp-buffer ...)) (save-current-buffer (set-buffer temp-buffer) (unwind-pr=
otect ... ...))))))))<br>=C2=A0 (progn (ignore (consp val)) (let* ((x614 (c=
ar-safe val)) (x615 (cdr-safe val))) (progn (ignore (consp x615)) (let* ((x=
616 (car-safe x615)) (x617 (cdr-safe x615))) (progn (ignore (null x617)) (l=
et ((string x614) (mode x616)) (let (...) (save-current-buffer ... ...)))))=
)))<br>=C2=A0 (let* ((val (if (stringp markup) (list markup &#39;gfm-view-m=
ode) (list (plist-get markup :value) (let* ((val ...)) (cond (... ...) (...=
 ...) (t ...))))))) (progn (ignore (consp val)) (let* ((x614 (car-safe val)=
) (x615 (cdr-safe val))) (progn (ignore (consp x615)) (let* ((x616 (car-saf=
e x615)) (x617 (cdr-safe x615))) (progn (ignore (null x617)) (let (... ...)=
 (let ... ...))))))))<br>=C2=A0 eglot--format-markup((:kind &quot;markdown&=
quot; :value &quot;```python\n(class) openfx\n```&quot;))<br>=C2=A0 mapconc=
at(eglot--format-markup ((:kind &quot;markdown&quot; :value &quot;```python=
\n(class) openfx\n```&quot;)) &quot;\n&quot;)<br>=C2=A0 eglot--hover-info((=
:kind &quot;markdown&quot; :value &quot;```python\n(class) openfx\n```&quot=
;) (:start (:line 7 :character 6) :end (:line 7 :character =C2=A0<br><br>=
=C2=A0<br>In GNU Emacs 30.0.50 (build 1, x86_64-w64-mingw32) of 2023-12-23 =
built<br>on fv-az1258-535Repository revision: 5c3ff1494b69bf45b99125f242317=
4222badfa43<br>Repository branch: master<br>Windowing system distributor &#=
39;Microsoft Corp.&#39;, version 10.0.22635<br>System Description: Microsof=
t Windows 10 Pro (v10.0.2009.22635.2915)<br><br>Configured using:<br>=C2=A0=
&#39;configure --prefix=3D/d/a/emacs-build/emacs-build/pkg/master-x86_64 &#=
39;CFLAGS=3D-Ofast -fno-finite-math-only -fomit-frame-pointer -funroll-loop=
s -floop-parallelize-all -ftree-parallelize-loops=3D4 -march=3Dskylake -mtu=
ne=3Dznver1&#39; --with-native-compilation --with-zlib --with-xpm --with-xm=
l2 --with-tree-sitter --with-tiff --with-rsvg --with-png --with-lcms2 --wit=
h-json --with-jpeg --with-harfbuzz --with-gnutls --with-gif --with-cairo --=
without-dbus --with-compress-install&#39;<br><br><div><br></div><span class=
=3D"gmail_signature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_s=
ignature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div>Gary</di=
v></div></div></div></div>

--00000000000051e0ea060dfaaa50--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Gary Oberbrunner <garyo@HIDDEN>
Subject: bug#68217: Acknowledgement (30.0.50; Fix for eglot--format-markup
 to handle bad markdown)
Message-ID: <handler.68217.B.170422013414772.ack <at> debbugs.gnu.org>
References: <CAFChFygDVPR=HkysX_oEGrApb6nHrGDt7xNbzP0wgPer7ygguQ@HIDDEN>
X-Gnu-PR-Message: ack 68217
X-Gnu-PR-Package: emacs
Reply-To: 68217 <at> debbugs.gnu.org
Date: Tue, 02 Jan 2024 18:29:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 68217 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
68217: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D68217
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#68217: 30.0.50; Fix for eglot--format-markup to handle bad markdown
Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= <joaotavora@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 02 Jan 2024 22:12:03 +0000
Resent-Message-ID: <handler.68217.B68217.170423351325866 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 68217
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: Gary Oberbrunner <garyo@HIDDEN>, Yuan Fu <casouri@HIDDEN>
Cc: jblevins@HIDDEN, 68217 <at> debbugs.gnu.org
Received: via spool by 68217-submit <at> debbugs.gnu.org id=B68217.170423351325866
          (code B ref 68217); Tue, 02 Jan 2024 22:12:03 +0000
Received: (at 68217) by debbugs.gnu.org; 2 Jan 2024 22:11:53 +0000
Received: from localhost ([127.0.0.1]:51497 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rKmzI-0006j8-Nw
	for submit <at> debbugs.gnu.org; Tue, 02 Jan 2024 17:11:53 -0500
Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:56464)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joaotavora@HIDDEN>) id 1rKmzG-0006ip-7h
 for 68217 <at> debbugs.gnu.org; Tue, 02 Jan 2024 17:11:51 -0500
Received: by mail-lj1-x22b.google.com with SMTP id
 38308e7fff4ca-2cd0c17e42bso13567601fa.0
 for <68217 <at> debbugs.gnu.org>; Tue, 02 Jan 2024 14:11:47 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1704233501; x=1704838301; darn=debbugs.gnu.org;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:from:to:cc:subject:date
 :message-id:reply-to;
 bh=AAD9jeHiT+yxzTr9DdPx3JezkAahObKi+wDjqAkx1RY=;
 b=kTOFiwO9LeTpw9R9KkN/wc9GExYFv6nmLxTpujU/LH3smJ+jLdT5rIXzG7aoobLfEo
 6KueCf3t4ksQUjCrv8Fo3DnwQ+OZP0iwCvPw2zvNlObNRFlkEksclS9WcSeuDLreH0tJ
 ThKyRMbkcFqSm4v7C2laxw4FNb75vGLjTop5MjJQOLi1weu0xjcT9Q2ycyqFqMW6aptg
 wLZSCKZGCdkXDFqz+WcO5v1ROJDa84jFlXZtjMq6j7O3d/iGarC89LJ3KMlKWNlKtSJp
 g/AxNIVDmIbPY10lMhlGhzwR0SPkB8e7QcaH0zoPbSUCPAu8JUWYxReNgfaeX9w4P1yI
 iyQg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1704233501; x=1704838301;
 h=content-transfer-encoding:cc:to:subject:message-id:date:from
 :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=AAD9jeHiT+yxzTr9DdPx3JezkAahObKi+wDjqAkx1RY=;
 b=TN1brNXp+Bo3eei6tgCm4IOT1wytrPcXX4zaF8NaK8hSsL4gmR2eLLjI52LJba5TnO
 rWdXVmY9/F81mb9pBTeTa+qIKI11bKn3YQ0+GUAtopT33QxNAYBzULQ4aIuZzqGoEEvC
 D0YF3018mRslySNt2XuoSdQfvlO8ejg2FRfDhNuHaJwJMNa3A9kQeBit7cwp3XH3jerO
 FW8yVjwVZk8TFHvx4DY3xzpWqUwRUnZ3Ow8ajrakYXfiBD13QKjIP9cN/Q0+P4TyjtIO
 exJ3hyTcDz8kLHR9ZVRL3vsTatvQEJmP+p0AEbp1wrlq0ZJeJprtefkuHZ/V/IZUmgx/
 Q8Vw==
X-Gm-Message-State: AOJu0YzBp/VmQH1qtq27OdS7c5pWsSbirSgDFDc1KIFjajNrKUtHFRV+
 LzNx5h+O+uydbniU+y0CVZtBp6oa76apWipgzGM=
X-Google-Smtp-Source: AGHT+IHOaFGsGuLMMXn0h6qQAybJTSLj6XQ1M1YdP1h90/8JGaSzzSSb8EUV2LoLNysgefzj0nsvzOabCKKerkWmXUI=
X-Received: by 2002:a2e:870e:0:b0:2cc:5cf8:13d with SMTP id
 m14-20020a2e870e000000b002cc5cf8013dmr9441703lji.102.1704233500767; Tue, 02
 Jan 2024 14:11:40 -0800 (PST)
MIME-Version: 1.0
References: <CAFChFygDVPR=HkysX_oEGrApb6nHrGDt7xNbzP0wgPer7ygguQ@HIDDEN>
In-Reply-To: <CAFChFygDVPR=HkysX_oEGrApb6nHrGDt7xNbzP0wgPer7ygguQ@HIDDEN>
From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= <joaotavora@HIDDEN>
Date: Tue, 2 Jan 2024 22:11:29 +0000
Message-ID: <CALDnm52QkHT5N9jF67y2Qd4N3shRw02conTueKZx9VP-nmhDog@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On Tue, Jan 2, 2024 at 6:29=E2=80=AFPM Gary Oberbrunner <garyo@oberbrunner.=
com> wrote:
> The markup arg passed to eglot--format-markup is:
>
>   (:kind "markdown" :value "```python\n(class) openfx\n```")
>
> I'm using pyright-langserver as the LSP server; I expect it is
> returning malformed markup or something that eglot doesn't expect.

Just for a bit of context to readers, markdown-mode at least in
certain situations, uses Emacs major modes to achieve syntactic
fontification of markdown code blocks.

Here, I don't think it's malformed markdown per se, it's that between
the markdown code block that the server says is Python there seems
to be some odd Python snippet:

(class) fx

So yes, the server is returning something fishy, but the way we
react right now isn't reasonable.

For me, it seems likely that python-mode when invoked by
markdown-mode didn't care about this and fontified away (when
triggered with font-lock-ensure), but python-ts-mode doesn't
and signals this error.

It could be caused by markdown-mode defaulting to the (new?) TS
mode when fontifying such markup.  Why is it defaulting like that?
Maybe it's just doing what Emacs would do if the user visited a
Python file?

I think markdown-mode choosing the same mode  that Emacs would
choose for interactive operation is correct.  But I'd first like
to confirm it isn't doing this arbitrarily: in the recent
past, I've seen markdown-mode load up cc-mode when I'm not using
the TS mode by default.

Jason, can you confirm what the intended behaviour is?

Also, I think python-ts-mode is also correct to signal the error
when finding this odd form, at least when the fontification routines
are invoked non-interactively.

Yuan, can you confirm what the intended behaviour is?

> I note that the following patch appears to fix it for me:
>
> modified   eglot.el
> @@ -1813,7 +1813,9 @@ Doubles as an indicator of snippet support."
>              (message-log-max nil)
>              match)
>          (ignore-errors (delay-mode-hooks (funcall mode)))
> -        (font-lock-ensure)
> +        (condition-case-unless-debug oops
> +            (font-lock-ensure)
> +          (error (eglot--warn (error-message-string oops))))
>          (goto-char (point-min))
>          (let ((inhibit-read-only t))
>            (when (fboundp 'text-property-search-forward) ;; FIXME: use co=
mpat

Finally there is this muffling of the error unless debug-on-error is true.
I think this is the right thing to do, at least right now.  In
an alternate universe with a restart system, it would probably be more
elegantly solved, but that's what we have now.

Jo=C3=A3o





Last modified: Sat, 20 Jan 2024 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.