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

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

Problem with removing comments


From: Markus Grunwald
Subject: Problem with removing comments
Date: 18 Dec 2007 09:09:32 GMT
User-agent: pan 0.119 (Karma Hunters)

Hello,

my transition from xemacs to emacs virtually done, thanks to this group :)
Now and then there is a minor problem that I can solve on my own, but this
one here puzzles me: I can't uncomment single lines of code with any of
the emacs functions... This is my setting:

comment-start's value is "//"
comment-padding's value is " "
comment-end's value is ""

;; Function to uncomment a region or a line. Got that some time ago:
(defun chb-uncomment-region-or-line ()
  (interactive)
  (let ((beg 0)
        (end 0))
    (if (region-exists-p)
        (setq beg (region-beginning)
              end (region-end))
      (save-excursion
        (beginning-of-line)
        (setq beg (point))
        (forward-line)
        (setq end (point))))
    (comment-region beg end -1)))

When I use this function on a commented line (no region marked) or a
commented region, I only get this in the *messages* buffer:
"uncomment-region: Beginning of buffer" and the comment is not changed. No
debugger messages.

So I thougt, maybe commenting works different in emacs and I read the info
file, "21.5.1 Comment Commands". Ok, so there a numerous ways to COMMENT a
line or a region and even a function to kill a comment (hmmm). Not much
help. comment-dwim doesn't do what I mean ;)

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...

Don't get me wrong: I know next to nothing about emacs and I willingly
admit that there may be better ways to do this - that's where I need your
help, please...

cu
Markus


reply via email to

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