unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Problem with removing comments
@ 2007-12-18  9:09 Markus Grunwald
  2007-12-18 15:20 ` Tyler Smith
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Grunwald @ 2007-12-18  9:09 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-18 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-18  9:09 Problem with removing comments Markus Grunwald
2007-12-18 15:20 ` Tyler Smith

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).