* bug#75079: Default parser for treesit-explore
@ 2024-12-25 7:56 Juri Linkov
2024-12-25 8:36 ` Yuan Fu
2024-12-25 12:39 ` Eli Zaretskii
0 siblings, 2 replies; 5+ messages in thread
From: Juri Linkov @ 2024-12-25 7:56 UTC (permalink / raw)
To: 75079; +Cc: Yuan Fu
[-- Attachment #1: Type: text/plain, Size: 402 bytes --]
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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: treesit-explorer-switch-parser.patch --]
[-- Type: text/x-diff, Size: 1500 bytes --]
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)
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#75079: Default parser for treesit-explore
2024-12-25 7:56 bug#75079: Default parser for treesit-explore Juri Linkov
@ 2024-12-25 8:36 ` Yuan Fu
2024-12-25 17:54 ` Juri Linkov
2024-12-25 12:39 ` Eli Zaretskii
1 sibling, 1 reply; 5+ messages in thread
From: Yuan Fu @ 2024-12-25 8:36 UTC (permalink / raw)
To: Juri Linkov; +Cc: 75079
> On Dec 24, 2024, at 11:56 PM, Juri Linkov <juri@linkov.net> wrote:
>
> 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:
>
> 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)
Thanks Juri, have you applied the patch? If not, please feel free to do :-)
Yuan
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#75079: Default parser for treesit-explore
2024-12-25 8:36 ` Yuan Fu
@ 2024-12-25 17:54 ` Juri Linkov
2024-12-25 20:08 ` Yuan Fu
0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2024-12-25 17:54 UTC (permalink / raw)
To: Yuan Fu; +Cc: 75079
close 75079 31.0.50
thanks
>> On Dec 24, 2024, at 11:56 PM, Juri Linkov <juri@linkov.net> wrote:
>>
>> 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:
>
> Thanks Juri, have you applied the patch? If not, please feel free to do :-)
Now the patch is applied, after fulfilling Eli's request
to extend the comments.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#75079: Default parser for treesit-explore
2024-12-25 17:54 ` Juri Linkov
@ 2024-12-25 20:08 ` Yuan Fu
0 siblings, 0 replies; 5+ messages in thread
From: Yuan Fu @ 2024-12-25 20:08 UTC (permalink / raw)
To: Juri Linkov; +Cc: 75079
> On Dec 25, 2024, at 9:54 AM, Juri Linkov <juri@linkov.net> wrote:
>
> close 75079 31.0.50
> thanks
>
>>> On Dec 24, 2024, at 11:56 PM, Juri Linkov <juri@linkov.net> wrote:
>>>
>>> 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:
>>
>> Thanks Juri, have you applied the patch? If not, please feel free to do :-)
>
> Now the patch is applied, after fulfilling Eli's request
> to extend the comments.
Thank you!
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#75079: Default parser for treesit-explore
2024-12-25 7:56 bug#75079: Default parser for treesit-explore Juri Linkov
2024-12-25 8:36 ` Yuan Fu
@ 2024-12-25 12:39 ` Eli Zaretskii
1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-12-25 12:39 UTC (permalink / raw)
To: Juri Linkov; +Cc: casouri, 75079
> Cc: Yuan Fu <casouri@gmail.com>
> From: Juri Linkov <juri@linkov.net>
> Date: Wed, 25 Dec 2024 09:56:20 +0200
>
> @@ -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))))
That comment should explain _why_ we don't want desktop-save to save
this minor mode. Otherwise it just says what the code does, which is
not hard to understand by looking at the code.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-25 20:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-25 7:56 bug#75079: Default parser for treesit-explore Juri Linkov
2024-12-25 8:36 ` Yuan Fu
2024-12-25 17:54 ` Juri Linkov
2024-12-25 20:08 ` Yuan Fu
2024-12-25 12:39 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).