greghendershott / racket-mode

Emacs major and minor modes for Racket: edit, REPL, check-syntax, debug, profile, packages, and more.
https://www.racket-mode.com/
GNU General Public License v3.0
681 stars 93 forks source link

uncomment-region-function for #; sexp comments #217

Open stchang opened 8 years ago

stchang commented 8 years ago

UPDATE: This description is no longer true. See next comment.

Not sure if anything can be done about this, but I thought it was interesting behavior.

Using emacs M-x uncomment to remove a #; removes the comment, but also deletes the closing parens. For example:

#;(define (f x) x)

becomes

(define (f x) x
stchang commented 8 years ago

Realized I was using an old version of racket-mode, sorry. Updated, and the current behavior is that trying to M-x uncomment a #; does nothing. Is that the intended behavior?

greghendershott commented 8 years ago

Not to nit-pick but just to confirm, I think you mean M-x uncomment-region?

Currently uncomment-region doesn't work because a sexp comment is only drawn (font-locked) as a comment. The expression text has the usual Emacs syntax, not comment syntax.[^1] Therefore things like uncomment-region won't see it as a comment. Even if it did, uncomment-region by default probably wouldn't know to remove the #;. And probably not how to deal with nested sexp comments.

There is an uncomment-region-function which racket-mode could redefine to attempt to do all these special things. I'll try to find time to take a look.

(FWIW, it looks like uncomment-region also is a no-op in clojure-mode for #_ sexp comments.)


[^1]: Why? So you can still navigate the sexp. AFAICT sexp comments odd that way: You want them to act like comments except when you don't want them to. :)

stchang commented 8 years ago

Whoops, yes I meant M-x uncomment-region.

And I think the current behavior is reasonable so I'm ok with closing this issue as "no plan to implement".

greghendershott commented 8 years ago

OK. I'll keep it open. But tag as a feature not a bug. And not assign it to me (for now).