-
-
Notifications
You must be signed in to change notification settings - Fork 167
Use Enter key for different actions (like in emacs) #301
-
Hello everyone!
Just thought about sharing the code I've written to make some org actions more easily doable. Using this code, you'll be able to do things like toggling checkboxes, advancing headline TODO states, opening links and opening dates inside the agenda just by pressing the "Enter" key.
This better emulates what happens when you press "Enter" on emacs in an org file.
This is a little bit too long to fit inside this post, but I've made a gist about it:
Gist file
Let me know what you think 🙂
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
Replies: 2 comments 5 replies
-
I like it :) one thing that comes to mind: what about headlines that have links in them?
Beta Was this translation helpful? Give feedback.
All reactions
-
I'm happy to see that you're enjoining it!
That is indeed a problem with the current script. I'm editing it right now to allow easier customization and help with the problem, but I think that with links, we're out of luck, since treesitter doesn't recognize them 😕
Beta Was this translation helpful? Give feedback.
All reactions
-
Unfortunately I'm not very well versed with the org grammar or treesitter in general (yet). Would it actually make sense to add links to the grammar?
Beta Was this translation helpful? Give feedback.
All reactions
-
I'm not well versed in it too, actually, but I'm having fun doing some of this scripting. I think it does make sense to have it recognized by the treesitter parser, since it already recognizes things like dates, checkboxes (and i mean the actual [ ]
, not just the whole list item). If links could be recognized by treesitter there could be interesting uses of that feature. However, as first stated, I'm not knowledgable about treesitter, so I could be wrong
Beta Was this translation helpful? Give feedback.
All reactions
-
I've uploaded a new version of this script that fixes that problem. I know I shouldn't, but I used a "private" function that is exported in "orgmode.org.mappings" that checks if the thing under the cursor is a link. It does it through lua patterns (regex).
I decided to do it this way, because treesitter-org thinks that links should not be included inside treesitter grammar: emiasims/tree-sitter-org#25
Beta Was this translation helpful? Give feedback.
All reactions
-
I've improved the script to allow for easier customization. The new "type_to_action" table is in a specific order, the code will execute the action of the first type it can find as ordered inside the list. This means that, if you have multiple possible actions on a specific position, you can decide which one should be executed by putting it higher inside the list. Be aware that this relies on the treesitter parser, which might not always correctly evaluate the syntax.
The gist link is the same as in the first post
Beta Was this translation helpful? Give feedback.
All reactions
-
@andreadev-it same for this feature, feel free to open a PR 👍
Beta Was this translation helpful? Give feedback.