From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glauber Alex Dias Prado Newsgroups: gmane.emacs.help Subject: Re: Swapping comments and code in the region Date: Sat, 23 Aug 2008 09:10:31 -0300 Message-ID: <861w0ggceg.fsf@gmail.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1219493560 12013 80.91.229.12 (23 Aug 2008 12:12:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Aug 2008 12:12:40 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: weber Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 23 14:13:33 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KWrzJ-0003Fk-OR for geh-help-gnu-emacs@m.gmane.org; Sat, 23 Aug 2008 14:13:02 +0200 Original-Received: from localhost ([127.0.0.1]:43986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWryL-0001ab-Ph for geh-help-gnu-emacs@m.gmane.org; Sat, 23 Aug 2008 08:12:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWry5-0001Y0-Vj for help-gnu-emacs@gnu.org; Sat, 23 Aug 2008 08:11:46 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWry4-0001VQ-GI for help-gnu-emacs@gnu.org; Sat, 23 Aug 2008 08:11:45 -0400 Original-Received: from [199.232.76.173] (port=47904 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWry4-0001VF-CU for help-gnu-emacs@gnu.org; Sat, 23 Aug 2008 08:11:44 -0400 Original-Received: from wr-out-0506.google.com ([64.233.184.237]:52438) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KWry4-0005by-G1 for help-gnu-emacs@gnu.org; Sat, 23 Aug 2008 08:11:44 -0400 Original-Received: by wr-out-0506.google.com with SMTP id c30so893424wra.14 for ; Sat, 23 Aug 2008 05:11:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=yNs5+1bSAL+GHG88q1qChhTG/VemS73NOUQSXtC3hGE=; b=eeJlosxndjzhn2JUrJCd13Ligp2em7t8A5PmrBc7U0iqVk2byZtnRxwK6j/4wnpxbZ 9781PcvIccazlBW3C5z2rgjnP4EZ7fm78kdU1KbNgKJuA2RcL7N/P/r5zko2R+98vABz CwfNoVorj/M3N+eMGlpZ3KrFobiJPFMAX1eoI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; b=k/oKdmboT/ro1tLnVH+FoJNHNDleZykwSS97BKPWzjOaiY2JXE/0y9LB9MjwRAq6PJ OREQO8S57u23rmzTahwanOJVxJX1Vg95F43vaCDdJgEva2Shub/GbeHFYAd56tk0yjyl +sz2w4YFyr7Lplk+X6ga7RZMZNASGazw1Lc1A= Original-Received: by 10.90.65.14 with SMTP id n14mr2243497aga.99.1219493503368; Sat, 23 Aug 2008 05:11:43 -0700 (PDT) Original-Received: from navemae.yourcompany.com ( [201.26.103.137]) by mx.google.com with ESMTPS id 38sm2503340agd.18.2008.08.23.05.11.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 23 Aug 2008 05:11:42 -0700 (PDT) In-Reply-To: (weber's message of "Fri, 22 Aug 2008 05:51:08 -0700 (PDT)") User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:56905 Archived-At: weber writes: > On Aug 22, 8:44=C2=A0pm, Nick Sandow 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 There is also comment-dwim , not exactly this but allows for "toggling" of comments. Cheers, Glauber.