redguardtoo / evil-nerd-commenter

Comment/uncomment lines efficiently. Like Nerd Commenter in Vim
GNU General Public License v3.0
387 stars 32 forks source link

Uncommenting in Elm only works when comment characters are at beginning of line #127

Closed joncol closed 2 years ago

joncol commented 2 years ago

Hi! Thanks for the package!

When using this with Elm code I run into the problem that uncommenting doesn't work, unless the -- characters (that are used for comments in this language) are immediately at the beginning of a line. For instance, if commenting out something that is indented (4 spaces), the result will be something like:

    -- div [] [text "hello, world"]

When then trying to uncomment you instead get a double comment:

    -- -- div [] [text "hello, world"]

Any help with resolving this would be greatly appreciated!

redguardtoo commented 2 years ago

What's the major-mode for elm?

joncol commented 2 years ago

What's the major-mode for elm?

It's this one: https://melpa.org/#/elm-mode

redguardtoo commented 2 years ago

Can't reproduce the issue with elm v0.21.0 from stable.melpa.org. evil-nerd-commentter only calls builtin API without any extra setup on comment syntax. Looks it's elm-mode problem.

joncol commented 2 years ago

OK, I ran with a completely clean setup, only evil, evil-nerd-commenter, and elm-mode, and then the problem did not occur for me either. Let me try and figure out the root of the problem, and I'll close this with a comment.

joncol commented 2 years ago

OK, very strange: when I add the following to my setup, I get the problem described in this issue:

(use-package ox-hugo
  :after ox)

ox-hugo is a package used to be able to export to Hugo static blogs fromorg-mode. That's some spooky action at a distance from the looks of it. I don't know if you want me to close this issue, or if you want to dig deeper?

kaushalmodi commented 2 years ago

@joncol ox-hugo does not affect your major mode and related things like commenting/uncommenting in any way (and especially not outside an org-mode buffer!). It simply provides you with an Org exporter backend. I'd be really surprised if ox-hugo is actually what's causing this.

redguardtoo commented 2 years ago

OK, very strange: when I add the following to my setup, I get the problem described in this issue:

(use-package ox-hugo
  :after ox)

ox-hugo is a package used to be able to export to Hugo static blogs fromorg-mode. That's some spooky action at a distance from the looks of it. I don't know if you want me to close this issue, or if you want to dig deeper?

You can use emacs27 and elm-mode from stable.melpa.org.

Raise a issue to elm-mode team and give them details (Emacs version, elm-mode version, steps to reproduce).

joncol commented 2 years ago

@joncol ox-hugo does not affect your major mode and related things like commenting/uncommenting in any way (and especially not outside an org-mode buffer!). It simply provides you with an Org exporter backend. I'd be really surprised if ox-hugo is actually what's causing this.

Hi (and thanks for making ox-hugo!), yes it seems very weird. I have a pretty messy org-mode setup, so it could be something else that's interacting in a bad way with the commenting functionality. But for now, my problem is solved by disabling ox-hugo. Which is annoying, but these days I do more elm commenting than blogging anyways so... If I find the time, I could try and narrow it down further to create a minimal example that demonstrates the failure.

redguardtoo commented 2 years ago

Sure.

The comment syntax is controlled by a few flags in newcomment.el, likecomment-start, comment-start-skip, comment-end, comment-end-skip, comment-add ....

elm-mode developers might need this information for debugging.

joncol commented 2 years ago

Hmm, think I found the actual source of the problem now:

              ;; do not treat "-" as a word separator
              (modify-syntax-entry ?- "w")

I think this is what causes the problems. Do you think it's possible @redguardtoo ?

redguardtoo commented 2 years ago

sytnax table is usually set up by major mode. It's better ask the major mode author to fix the issue for you.