unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#75141: [PATCH] Add button navigation to treesit-explorer
@ 2024-12-27 13:54 Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2025-01-04 11:57 ` Eli Zaretskii
  2025-01-04 21:17 ` Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 5+ messages in thread
From: Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-27 13:54 UTC (permalink / raw)
  To: 75141

[-- Attachment #1: Type: text/plain, Size: 562 bytes --]


Greetings,

Currently, the only way to navigate through treesit-explorer is by the
use of C-n and C-p. Since this buffer is full of buttons, I decided to
add button navigation to it.

This patch adds button navigation to treesit-explorer, for the following
keys:

* forward-button
- f
- n
- TAB

* backward-button
- b
- p
- <backtab>

* Points of discussion

Maybe that's too many keys? The only ones I think that don't really fit
that much are "f" and "b", because they can also go down, but there's no
harm in having extra keys.

Regards,

--
Gabriel Santos


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Add button navigation to treesit-explorer --]
[-- Type: text/x-patch, Size: 1135 bytes --]

From d78745581bdf7daf77602eb0bd06b6bdccc3c3c6 Mon Sep 17 00:00:00 2001
From: Gabriel Santos <gabrielsantosdesouza@disroot.org>
Date: Fri, 27 Dec 2024 10:43:20 -0300
Subject: [PATCH] Add button navigation to treesit-explorer

* lisp/treesit.el (treesit--explorer-tree-mode-map):
Define it as a child of special-mode-map, adding multiple
keys for button navigation.
---
 lisp/treesit.el | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index eb3e26fff7e..9925f8ee014 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3907,6 +3907,17 @@ covers point.  PARSER-NAME are unique."
   "Mode for displaying syntax trees for `treesit-explore-mode'."
   nil)
 
+(defvar-keymap treesit--explorer-tree-mode-map
+  :doc "Keymap for the treesit tree explorer.
+Navigates from button to button."
+  :parent special-mode-map
+  "n" #'forward-button
+  "p" #'backward-button
+  "f" #'forward-button
+  "b" #'backward-button
+  "TAB" #'forward-button
+  "<backtab>" #'backward-button)
+
 (defun treesit-explorer-switch-parser (parser)
   "Switch explorer to use PARSER."
   (interactive
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#75141: [PATCH] Add button navigation to treesit-explorer
  2024-12-27 13:54 bug#75141: [PATCH] Add button navigation to treesit-explorer Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2025-01-04 11:57 ` Eli Zaretskii
  2025-01-04 20:02   ` Yuan Fu
  2025-01-04 21:17 ` Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2025-01-04 11:57 UTC (permalink / raw)
  To: Gabriel Santos, Yuan Fu; +Cc: 75141

> Date: Fri, 27 Dec 2024 10:54:04 -0300
> From:  Gabriel Santos via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Greetings,
> 
> Currently, the only way to navigate through treesit-explorer is by the
> use of C-n and C-p. Since this buffer is full of buttons, I decided to
> add button navigation to it.
> 
> This patch adds button navigation to treesit-explorer, for the following
> keys:
> 
> * forward-button
> - f
> - n
> - TAB
> 
> * backward-button
> - b
> - p
> - <backtab>
> 
> * Points of discussion
> 
> Maybe that's too many keys? The only ones I think that don't really fit
> that much are "f" and "b", because they can also go down, but there's no
> harm in having extra keys.

Thanks.

Yuan, any comments?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#75141: [PATCH] Add button navigation to treesit-explorer
  2025-01-04 11:57 ` Eli Zaretskii
@ 2025-01-04 20:02   ` Yuan Fu
  2025-01-04 20:25     ` Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Yuan Fu @ 2025-01-04 20:02 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 75141, Gabriel Santos



> On Jan 4, 2025, at 3:57 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> Date: Fri, 27 Dec 2024 10:54:04 -0300
>> From:  Gabriel Santos via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>> 
>> Greetings,
>> 
>> Currently, the only way to navigate through treesit-explorer is by the
>> use of C-n and C-p. Since this buffer is full of buttons, I decided to
>> add button navigation to it.
>> 
>> This patch adds button navigation to treesit-explorer, for the following
>> keys:
>> 
>> * forward-button
>> - f
>> - n
>> - TAB
>> 
>> * backward-button
>> - b
>> - p
>> - <backtab>
>> 
>> * Points of discussion
>> 
>> Maybe that's too many keys? The only ones I think that don't really fit
>> that much are "f" and "b", because they can also go down, but there's no
>> harm in having extra keys.
> 
> Thanks.
> 
> Yuan, any comments?

Sounds good! Though would using both f/b and n/p for the same thing a bit wasteful? Maybe we can start with n/p TAB/<backtab>?

Yuan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#75141: [PATCH] Add button navigation to treesit-explorer
  2025-01-04 20:02   ` Yuan Fu
@ 2025-01-04 20:25     ` Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 0 replies; 5+ messages in thread
From: Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-04 20:25 UTC (permalink / raw)
  To: Yuan Fu, Eli Zaretskii; +Cc: 75141

>Sounds good! Though would using both f/b and n/p for the same thing a bit wasteful? Maybe we can start with n/p TAB/<backtab>?

Yes, that seems to be best, I'll update the patch now.

--
Gabriel Santos





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#75141: [PATCH] Add button navigation to treesit-explorer
  2024-12-27 13:54 bug#75141: [PATCH] Add button navigation to treesit-explorer Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2025-01-04 11:57 ` Eli Zaretskii
@ 2025-01-04 21:17 ` Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
  1 sibling, 0 replies; 5+ messages in thread
From: Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2025-01-04 21:17 UTC (permalink / raw)
  To: 75141; +Cc: Eli Zaretskii, Yuan Fu

[-- Attachment #1: Type: text/plain, Size: 74 bytes --]


Here is the updated patch, with "f" and "b" removed.

--
Gabriel Santos


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Add button navigation to treesit-explorer --]
[-- Type: text/x-patch, Size: 1078 bytes --]

From 1224d220985edd9de0731b26c0be96eb9f6b35a1 Mon Sep 17 00:00:00 2001
From: Gabriel Santos <gabrielsantosdesouza@disroot.org>
Date: Fri, 27 Dec 2024 10:43:20 -0300
Subject: [PATCH] Add button navigation to treesit-explorer

* lisp/treesit.el (treesit--explorer-tree-mode-map):
Define it as a child of special-mode-map,
adding keys for button navigation.
---
 lisp/treesit.el | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lisp/treesit.el b/lisp/treesit.el
index e643eb48654..ef27a370bc2 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -4041,6 +4041,16 @@ covers point.  PARSER-NAME are unique."
   "Mode for displaying syntax trees for `treesit-explore-mode'."
   nil)
 
+(defvar-keymap treesit--explorer-tree-mode-map
+  :doc "Keymap for the treesit tree explorer.
+
+Navigates from button to button."
+  :parent special-mode-map
+  "n" #'forward-button
+  "p" #'backward-button
+  "TAB" #'forward-button
+  "<backtab>" #'backward-button)
+
 (defun treesit-explorer-switch-parser (parser)
   "Switch explorer to use PARSER."
   (interactive
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-04 21:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-27 13:54 bug#75141: [PATCH] Add button navigation to treesit-explorer Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-04 11:57 ` Eli Zaretskii
2025-01-04 20:02   ` Yuan Fu
2025-01-04 20:25     ` Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors
2025-01-04 21:17 ` Gabriel Santos via Bug reports for GNU Emacs, the Swiss army knife of text editors

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).