GNU bug report logs - #75079
Default parser for treesit-explore

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Wed, 25 Dec 2024 08:12:02 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Default parser for treesit-explore
Date: Wed, 25 Dec 2024 09:56:20 +0200
[Message part 1 (text/plain, inline)]
Currently loading the desktop is disrupted by the prompt
that asks for a parser name when treesit-explore-mode
was enabled in a buffer before.  The second part of the
following patch fixes this by omitting treesit-explore-mode.

But anyway it's very tedious to select the single parser
every time when enabling treesit-explore-mode.  So the
first part of this patch avoids this unnecessary selection:

[treesit-explorer-switch-parser.patch (text/x-diff, inline)]
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 464b7e688be..5428e84fa5a 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3911,8 +3911,10 @@ treesit-explorer-switch-parser
   (interactive
    (list (let* ((parser-alist
                  (treesit--explorer-generate-parser-alist))
-                (parser-name (completing-read
-                              "Parser: " (mapcar #'car parser-alist))))
+                (parser-name (if (= (length parser-alist) 1)
+                                 (car parser-alist)
+                               (completing-read
+                                "Parser: " (mapcar #'car parser-alist)))))
            (alist-get parser-name parser-alist
                       nil nil #'equal))))
   (unless treesit-explore-mode
@@ -3952,7 +3954,13 @@ treesit-explore-mode
           (unless (memq 'treesit--explorer-tree-mode
                         desktop-modes-not-to-save)
             (push 'treesit--explorer-tree-mode
-                  desktop-modes-not-to-save))))
+                  desktop-modes-not-to-save)))
+        ;; Tell `desktop-save' to not save minor mode.
+        (when (boundp 'desktop-minor-mode-table)
+          (unless (member '(treesit-explore-mode nil)
+                          desktop-minor-mode-table)
+            (push '(treesit-explore-mode nil)
+                  desktop-minor-mode-table))))
     ;; Turn off explore mode.
     (remove-hook 'post-command-hook
                  #'treesit--explorer-post-command t)

This bug report was last modified 173 days ago.

Previous Next


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