From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Jolitz Newsgroups: gmane.emacs.devel Subject: Re: awesome feature (yet to be added?) Date: Fri, 30 May 2014 23:35:37 +0200 Message-ID: <87ppivne52.fsf@gmail.com> References: <112075085.1028629.1399142864865.open-xchange@email.1and1.com> <53684CB6.1050601@lanl.gov> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1401485774 3099 80.91.229.3 (30 May 2014 21:36:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 May 2014 21:36:14 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 30 23:36:07 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WqUT9-0006vZ-Bn for ged-emacs-devel@m.gmane.org; Fri, 30 May 2014 23:36:07 +0200 Original-Received: from localhost ([::1]:56696 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqUT8-0005tX-Sy for ged-emacs-devel@m.gmane.org; Fri, 30 May 2014 17:36:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqUT0-0005rD-JA for emacs-devel@gnu.org; Fri, 30 May 2014 17:36:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WqUSu-00017E-GP for emacs-devel@gnu.org; Fri, 30 May 2014 17:35:58 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:51504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WqUSu-000172-1C for emacs-devel@gnu.org; Fri, 30 May 2014 17:35:52 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WqUSs-0006dh-61 for emacs-devel@gnu.org; Fri, 30 May 2014 23:35:50 +0200 Original-Received: from g231224241.adsl.alicedsl.de ([92.231.224.241]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 May 2014 23:35:50 +0200 Original-Received: from tjolitz by g231224241.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 May 2014 23:35:50 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: g231224241.adsl.alicedsl.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:5qMM3N/SImQ7ZD3yMAqeMYiRSW8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172201 Archived-At: Davis Herring writes: >> Judging by the uptake. We are the only two to think this is useful. :) No, I would really like to see a generic `invert-comment' function in Emacs. My use case is outorg.el that converts programming language buffers (structured the outshine way, i.e. with outcommented Org-mode headers) temporarily to org-mode for text editing and then back to the programming major-mode. That means all the comment sections of the source file are uncommented when converting to Org, and outcommented again when converting back to the original major-mode. I do this linewise, and in fact outorg can't handle those special multiline comments like in C or Java. A robust generic (= major-mode agnostic) `invert-comment' function as part of Emacs that knows how to handle multiline comments too would come very handy. > I thought about implementing `invert-comment' a few years ago, but I > wasn't sure what to do about code like this: > > /* old_implementation_prepare (); */ > /* old_implementation_go (); */ > > new_implementation_prepare (); > /* The new implementation needs a buffer allocated. */ > char *p = malloc (new_implementation_size ()); > new_implementation_go (p); IMO such a function should only act on comments that start at the beginning of line, indented comments should remain untouched. > What to do about the actual comment embedded in the "new" code? > > x = foo () + /* bar () + */ baz (); > quux (x, x + 1); /* quux now accounts for bar internally */ > > What does it mean to toggle commented-ness here? Again, IMO these comments should remain untouched. E.g. when converting source files to org-mode, code section are enclosed in source-blocks #+begin_src lang x = foo () + /* bar () + */ baz (); quux (x, x + 1); /* quux now accounts for bar internally */ #+end_src and the embedded comments clearly belong to the code. > Your idea of markers likely works out better than "toggle the comments" > because of cases like these. It would indeed be very useful if there is a way to further act on the region/line that was inverted after the function has done its job. So returning start/end position, set markers or running a hook or so would be nice. There were quite a lot of proposals in this thread. Any chance that this is actually outdiscussed and included in Emacs any time soon? -- cheers, Thorsten