all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: weber <hugows@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Swapping comments and code in the region
Date: Fri, 22 Aug 2008 05:51:08 -0700 (PDT)	[thread overview]
Message-ID: <df6a313c-6a4a-4dea-84e6-bc3eca0eb427@k13g2000hse.googlegroups.com> (raw)
In-Reply-To: mailman.17303.1219387442.18990.help-gnu-emacs@gnu.org

On Aug 22, 8:44 pm, Nick Sandow <njs...@internode.on.net> wrote:
> Hi,
>
> I think it would be handy to have a function that made comments into
> code, and code into comments.
>
> That is, if the region consisted of the following 2 lines:
>
> foo();
> // bar();
>
> ...they would become:
>
> // foo();
> bar();
>
> Does anyone know of a package or command out there that does this?
>
> Thanks

Something like this does the trick here:

(defun comment-invert-region (beg end)
  (interactive "r")
  (goto-char beg)
  (while (< (point-at-eol) end)
	(comment-or-uncomment-region (point-at-bol) (1+ (point-at-eol)))
	(forward-line 1)))

Cheers,
HUgo


       reply	other threads:[~2008-08-22 12:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.17303.1219387442.18990.help-gnu-emacs@gnu.org>
2008-08-22 12:51 ` weber [this message]
2008-08-23 12:10   ` Swapping comments and code in the region Glauber Alex Dias Prado
2008-09-09 21:09 ` Xah
2008-08-22 23:44 Nick Sandow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df6a313c-6a4a-4dea-84e6-bc3eca0eb427@k13g2000hse.googlegroups.com \
    --to=hugows@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.