kopoli / robot-mode

Emacs major mode for editing Robot Framework files.
GNU General Public License v3.0
8 stars 3 forks source link

Feature request: Next/prev/jump to/fold test case #14

Open amittendulkar opened 1 month ago

amittendulkar commented 1 month ago

I am a beginner in Lisp and Emacs. However, I have used RobotFramework extensively.

I think the below enhancements will make your package richer,

Maybe some of these things are already possible indirectly (through other Emacs packages/features). Please do let me know otherwise.

kopoli commented 1 month ago

Thanks for reporting these! This kind of movement/toggling is indeed a a good feature to have.

Move to previous/next test case (e.g. C-c C-p and C-c C-n) Jump to test case title (e.g. C-c C-j if you are willing to associate another key binding to split line)

For both of these the C-M-a keybinding (beginning-of-defun) moves either to the test case title, or when at the test case title, it moves to the previous test case title.

For the other direction, C-M-e keybinding (end-of-defun) moves forward to the next test case title.

Fold/unfold test case (e.g. C-c @ C-c similar to Elpy)

With folding, the mode defines the outline-regexp variable that is used for folding test cases. The function that does it is e.g. the outline-toggle-children (other related functions are outline-hide-subtree and outline-show-subtree, if direct hiding/showing is needed). Unfortunately the toggle function does not have default keybinding, but you can set one for yourself.

amittendulkar commented 1 month ago

Thanks for your tips. Do you think supporting M-x imenu will be beneficial for jumping to keywords and test cases? I feel it will be a good way to jump to specific test cases. I will change the title of the issue for imenu support if you think it makes sense (else I will close the issue).

kopoli commented 1 month ago

It seems that adding imenu support for the mode just needs the imenu-generic-expression variable defined: https://www.gnu.org/software/emacs/manual/html_node/elisp/Imenu.html#index-imenu_002dgeneric_002dexpression

Probably the imenu would match to the defined keywords in a file.

amittendulkar commented 1 month ago

Do you want to include the suggested definition in the documentation and close this?

kopoli commented 1 month ago

I added a preliminary support for imenu. It's slightly more complex I would want it to be, but appears to work with some testing. (I don't personally use imenu, so I might be missing something).

Could you test if it behaves correctly on your setup ?

amittendulkar commented 1 month ago

It is working perfectly for me. Thanks. Please go ahead and merge.