help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with removing comments


From: Tyler Smith
Subject: Re: Problem with removing comments
Date: 18 Dec 2007 15:20:36 GMT
User-agent: slrn/0.9.8.1pl1 (Debian)

On 2007-12-18, Markus Grunwald <address@hidden> wrote:
>
> What helped a bit was the documentation for comment-region: Now I can
> uncomment a region with C-u M-x comment-region. But I don't know how to
> "simulate" the "C-u" part in the "chb-uncomment-region-or-line" function.
> If that worked, I think everything should be ok...

I think you really do want comment-dwim, you just don't know it yet ;)
You can access comment-dwim with M-; so you can uncomment a line with
a few key strokes: "C-a C-spc C-e M-;" If that's too many key strokes,
it should be easy to wrap this in a function similar to what you've
tried, using either comment-dwim for a general case, or
uncomment-region for a function that only uncomments.

>From the help:

comment-dwim is an interactive compiled Lisp function in `newcomment.el'.
It is bound to M-;.
(comment-dwim arg)

Call the comment command you want (Do What I Mean).
If the region is active and `transient-mark-mode' is on, call
  `comment-region' (unless it only consists of comments, in which
  case it calls `uncomment-region').
Else, if the current line is empty, insert a comment and indent it.
Else if a prefix arg is specified, call `comment-kill'.
Else, call `comment-indent'.
You can configure `comment-style' to change the way regions are commented.

HTH,

Tyler

*Written from Emacs22, but I don't think this changed from Emacs21?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]