]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: be careful about gfm-view-mode read-only buffers
authorJoão Távora <joaotavora@gmail.com>
Fri, 7 Apr 2023 18:40:27 +0000 (19:40 +0100)
committerJoão Távora <joaotavora@gmail.com>
Fri, 7 Apr 2023 18:40:27 +0000 (19:40 +0100)
Although in most situations this doesn't error, it's only because of
the very wide binding of inhibit-read-only in jsonrpc--process-filter.
That binding will soon be narrowed, so better not rely on it.

Originally reported in
https://github.com/joaotavora/eglot/discussions/1202.

* lisp/progmodes/eglot.el (eglot--format-markup): Inhibit
read-only before touching buffer potentially in gfm-view-mode.

lisp/progmodes/eglot.el

index db57b122a94ee7d146507425ecb17d04b1ea68ec..da7e53730e73bf31e74ce718698597e6d8fc9a1d 100644 (file)
@@ -1672,9 +1672,10 @@ Doubles as an indicator of snippet support."
         (ignore-errors (delay-mode-hooks (funcall mode)))
         (font-lock-ensure)
         (goto-char (point-min))
-        (while (setq match (text-property-search-forward 'invisible))
-          (delete-region (prop-match-beginning match)
-                         (prop-match-end match)))
+        (let ((inhibit-read-only t))
+          (while (setq match (text-property-search-forward 'invisible))
+            (delete-region (prop-match-beginning match)
+                           (prop-match-end match))))
         (string-trim (buffer-string))))))
 
 (define-obsolete-variable-alias 'eglot-ignored-server-capabilites