Skip to content

Toggle ignore reader forms #583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 26, 2021
Merged

Conversation

yuhan0
Copy link
Contributor

@yuhan0 yuhan0 commented Feb 22, 2021

Closes #567, #411

Adds 3 new interactive commands:
clojure-toggle-ignore, clojure-toggle-ignore-surrounding-form, and clojure-toggle-defun

I added a bunch of tests which should demonstrate how the commands work.
No default keybindings added yet, I'm not sure if this should count as a "refactoring" and go under the C-c C-r prefix?

Note about naming: the clojure.org guide calls it "discard" (https://clojure.org/guides/weird_characters), but I've seen it mostly referred to as the "ignore" form elsewhere.


Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):

  • The commits are consistent with our contribution guidelines.
  • You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've run M-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • You've updated the readme (if adding/changing user-visible functionality).

Thanks!

@bbatsov
Copy link
Member

bbatsov commented Feb 22, 2021

No default keybindings added yet, I'm not sure if this should count as a "refactoring" and go under the C-c C-r prefix?

I don't think that's a refactoring, so no need to use the C-c C-r keymap.

@yuhan0
Copy link
Contributor Author

yuhan0 commented Feb 23, 2021

Do you have suggestions for good default keybindings? I personally use evil-mode with the mappings
<leader>it -> clojure-toggle-ignore
<leader>is -> clojure-toggle-ignore-surrounding-form (C-u for ignore-defun)

Just realised that the existing family of "refactorings" clojure-cycle-*, clojure-convert-collection-* have a similar scope to this, perhaps I should rename them cycle-ignore instead of toggle-ignore and have it go under the refactor map?

C-c C-r d / C-c C-r D is available (D for discard)
or maybe something involving C-_ or C--

@bbatsov
Copy link
Member

bbatsov commented Feb 23, 2021

If something has only two states - I think that "toggle" is a better name than "cycle". As for the keybinding - perhaps something with # or _ in it? Haven't looked in the keymap soon, but I assume we don't have a lot of good options left.

@yuhan0
Copy link
Contributor Author

yuhan0 commented Feb 24, 2021

If something has only two states - I think that "toggle" is a better name than "cycle".

Agreed, it was more about consistency with the existing command names (clojure-cycle-if toggles between two states if and if-not, clojure-cycle-privacy between defn and defn-, etc.)

As for the keybinding - perhaps something with # or _ in it? Haven't looked in the keymap soon, but I assume we don't have a lot of good options left.

I find having to switching from the Ctrl to Shift key for a # or _ quite awkward, but I don't use native emacs bindings regularly, so maybe I'll leave this to your judgement :)

@bbatsov
Copy link
Member

bbatsov commented Feb 25, 2021

I've noticed we actually have almost no top-level keybindings so you certainly have some options. Or you can just add them to the menu and people can decide if they want to bind those. I don't have brilliant suggestions, plus I doubt people are going to use such command that much, so perhaps we're overthinking this.

@yuhan0
Copy link
Contributor Author

yuhan0 commented Feb 26, 2021

Ok, I added them to the menu and the refactor map under C-c C-r - and C-c C-r _ respectively.
I personally use these commands more often than any other refactoring, so it's probably just a matter of workflow style (seeing as it's been requested and reinvented several times now)

@bbatsov bbatsov merged commit cccddea into clojure-emacs:master Feb 26, 2021
@bbatsov
Copy link
Member

bbatsov commented Feb 26, 2021

Fair enough. Thanks for tackling this! We can always adjust the keybindings down the road.

@yuhan0 yuhan0 mentioned this pull request Feb 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: command(s) for inserting/deleting #_ ignore forms
2 participants