Skip to content

Conversation

@hupfdule
Copy link
Contributor

This commit introduces a new option g:bullets_change_style_on_level_change
to allow disabling the automatic change of bullet style when
promoting/demoting bullet items.

This commit introduces a new option `g:bullets_change_style_on_level_change`
to allow disabling the automatic change of bullet style when
promoting/demoting bullet items.

if !g:bullets_change_style_on_level_change
return
endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be better to put the code inside the relevant block (or move the change code into a function). Relying on early return isn't the cleanest solution, IMO.

At the very least, this needs to have a comment saying that the early return avoids xyz...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm, maybe I have misunderstood you, but in my opinion this is the relevant block. Everything after this change should not be executed if the flag ist set to 0. And relying on early return is exactly what is already done in the lines above (line 838). Therefore it fits the style of the method.

Yes, I thought about including a comment, but that comment would say something like "don't change the bullets style if the user requested it" which is quite obvious from the purpose of the method and the name of the option.

BUT: It seems that I misinterpreted the purpose of the g:bullets_outline_levels option. I was surprised to see that with the following setting:

  let g:bullets_outline_levels = ['ROM', 'num', 'std-']

bullets.vim still works when using items like:

A. test

a. test

* test

+ test

"Works" in a way that

  • bullets are automatically repeated on <CR> and
  • alphanumeric characters automatically increased in such a case.

It seems that the option g:bullets_outline_levels only specifies the characters to use for bullets when changing the style on a level change and does not specify which styles are valid at all. The valid styles seem to be hardcoded and g:bullets_outline_levels may even contain characters that are not contained in the hardcoded list of characters.
See for example:

https://github.com/dkarter/bullets.vim/blob/39d90278a20e754105a9b628f8b1bd430e5d5713/plugin/bullets.vim#L251

This list defines the following characters as valid bullet points:

  • -
  • * (with different amounts)
  • . (with different amounts)
  • #. (looks a bit strange to me; don't know where this is usually used)
  • +
  • \item (used in LaTeX)

So, if that is true, it seems to me that this PR is not necessary at all and the option it introduces would be the same as setting g:bullets_outline_levels = []. Am I correct here?

@harshad1
Copy link
Collaborator

harshad1 commented Mar 8, 2024

I am not sure what I was thinking when I posted that message about early returns... sorry.

I do have let g:bullets_outline_levels = [] set locally and it does seem to do what your changes achieve. Closing this now. Let me know if it should be reopened for some reason.

@harshad1 harshad1 closed this Mar 8, 2024
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.

2 participants