* Delete comments in region
@ 2006-04-22 0:40 Denis Bueno
2006-04-22 1:05 ` Nikos Apostolakis
0 siblings, 1 reply; 6+ messages in thread
From: Denis Bueno @ 2006-04-22 0:40 UTC (permalink / raw)
I have a need, so I thought I'd query the list before writing something.
Does anyone have any elisp lying around that will, in any coding mode,
remove all the comments from the region?
I'd like to get away with not deleting the comments in the buffer manually.
Thanks in advance.
-Denis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Delete comments in region
2006-04-22 0:40 Denis Bueno
@ 2006-04-22 1:05 ` Nikos Apostolakis
2006-04-22 1:30 ` Denis Bueno
[not found] ` <mailman.755.1145669452.9609.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 6+ messages in thread
From: Nikos Apostolakis @ 2006-04-22 1:05 UTC (permalink / raw)
Denis Bueno <dbueno@gmail.com> writes:
> Does anyone have any elisp lying around that will, in any coding
> mode, remove all the comments from the region?
>
Isn't "M-x uncomment-region" or "M-x comment-dwim" good enough?
> -Denis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Delete comments in region
2006-04-22 1:05 ` Nikos Apostolakis
@ 2006-04-22 1:30 ` Denis Bueno
2006-04-22 2:53 ` Nikos Apostolakis
[not found] ` <mailman.755.1145669452.9609.help-gnu-emacs@gnu.org>
1 sibling, 1 reply; 6+ messages in thread
From: Denis Bueno @ 2006-04-22 1:30 UTC (permalink / raw)
Cc: help-gnu-emacs
Nikos Apostolakis wrote:
> Denis Bueno <dbueno@gmail.com> writes:
>
>> Does anyone have any elisp lying around that will, in any coding
>> mode, remove all the comments from the region?
>>
>
> Isn't "M-x uncomment-region" or "M-x comment-dwim" good enough?
>
I now see an ambiguity in my wording I didn't before.
I want to *zap* the comment entirely. Delete the comment syntax and the
text of the comment itself. Not just remove the comment syntax around
the comment text.
However, I figured out one way, but, it doesn't seem like the best way.
;; the following keys should all be entered in succession, but
;; they are commented for ease of viewing
C-x ( ; start macro
M-x kill-comment RET C-x )
;; Then, on the code whose comments need to be zapped:
C-x e e e e e e ;;; as many e's as necessary
-Denis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Delete comments in region
2006-04-22 1:30 ` Denis Bueno
@ 2006-04-22 2:53 ` Nikos Apostolakis
0 siblings, 0 replies; 6+ messages in thread
From: Nikos Apostolakis @ 2006-04-22 2:53 UTC (permalink / raw)
Denis Bueno <dbueno@gmail.com> writes:
> Nikos Apostolakis wrote:
>
> I want to *zap* the comment entirely. Delete the comment syntax and
> the text of the comment itself. Not just remove the comment syntax
> around the comment text.
>
Ah! I see.
> ;; the following keys should all be entered in succession, but
> ;; they are commented for ease of viewing
> C-x ( ; start macro
> M-x kill-comment RET C-x )
>
> ;; Then, on the code whose comments need to be zapped:
> C-x e e e e e e ;;; as many e's as necessary
How about
(defun nea-kill-all-comments-in-buffer ()
"Kill all comments in buffer."
(interactive)
(save-excursion
(beginning-of-buffer)
(kill-comment
(count-lines (point-min) (point-max)))))
Or slightly more general:
(defun nea-kill-all-comments-in-region (begin end)
"Kill all comments in region."
(interactive "r")
(save-excursion
(goto-char begin)
(kill-comment (count-lines begin end))))
Note that this is not really tested.
HTH,
Nikos
>
> -Denis
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Delete comments in region
[not found] ` <mailman.755.1145669452.9609.help-gnu-emacs@gnu.org>
@ 2006-04-22 20:30 ` liyer.vijay
0 siblings, 0 replies; 6+ messages in thread
From: liyer.vijay @ 2006-04-22 20:30 UTC (permalink / raw)
Denis Bueno wrote:
> Nikos Apostolakis wrote:
> > Denis Bueno <dbueno@gmail.com> writes:
> >
> >> Does anyone have any elisp lying around that will, in any coding
> >> mode, remove all the comments from the region?
> >>
> >
> > Isn't "M-x uncomment-region" or "M-x comment-dwim" good enough?
> >
>
> I now see an ambiguity in my wording I didn't before.
>
> I want to *zap* the comment entirely. Delete the comment syntax and the
> text of the comment itself. Not just remove the comment syntax around
> the comment text.
If you don't want to REMOVE them but just hide them you could take a
look at Hideshow minor mode which you can use by M-x hs-minor-mode RET
I has some fancy commands to hide/show certain comments.
Cheers
Vijay
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Delete comments in region
[not found] <mailman.750.1145666443.9609.help-gnu-emacs@gnu.org>
@ 2006-04-25 9:05 ` Mathias Dahl
0 siblings, 0 replies; 6+ messages in thread
From: Mathias Dahl @ 2006-04-25 9:05 UTC (permalink / raw)
Denis Bueno <dbueno@gmail.com> writes:
> I have a need, so I thought I'd query the list before writing something.
>
> Does anyone have any elisp lying around that will, in any coding mode,
> remove all the comments from the region?
>
> I'd like to get away with not deleting the comments in the buffer manually.
If the comments are always "prefix comments", as in Lisp (the example
below), you can try:
M-x flush-lines RET ^;; RET
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-04-25 9:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.750.1145666443.9609.help-gnu-emacs@gnu.org>
2006-04-25 9:05 ` Delete comments in region Mathias Dahl
2006-04-22 0:40 Denis Bueno
2006-04-22 1:05 ` Nikos Apostolakis
2006-04-22 1:30 ` Denis Bueno
2006-04-22 2:53 ` Nikos Apostolakis
[not found] ` <mailman.755.1145669452.9609.help-gnu-emacs@gnu.org>
2006-04-22 20:30 ` liyer.vijay
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).