remyferre / comment-dwim-2

A replacement for the emacs' built-in command `comment-dwim'
GNU General Public License v3.0
101 stars 5 forks source link

Avoid killing end-of-line comment when removing line comment #7

Closed tmarti2 closed 5 years ago

tmarti2 commented 5 years ago

Hi, first thanks for this package, really useful.

The only issue I have so far is when having something like that : image That's ocaml, comment are between "(* *)", and you can't comment only at start of a line like "//" in C. The first line is the original one, the 2nd is when commenting using "M-;" (comment-dwin-2) and last when uncommenting (with the same command).

My problem here is that instead of just uncommenting the line, it also remove the original comment. Is there a way to avoid that?

Thanks

remyferre commented 5 years ago

hey @tmarti2, sorry for the late reply

Killing end-of-line comments is the intended behavior, but you could override that default behavior like this:

(defun cd2/inline-comment-command () ; this is the function called when you repeat the command
  ;; do nothing (not killing the end-of-line comment)
  (setq this-command nil) ; This is just a trick so that the command can still be called indefinitely
)

does it solve your problem ?

tmarti2 commented 5 years ago

It works perfectly, thanks !