From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.devel Subject: Re: awesome feature (yet to be added?) Date: Sat, 31 May 2014 08:26:36 +0200 Message-ID: <5389761C.9010803@online.de> References: <112075085.1028629.1399142864865.open-xchange@email.1and1.com> <53684CB6.1050601@lanl.gov> <87ppivne52.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1401517643 10184 80.91.229.3 (31 May 2014 06:27:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 31 May 2014 06:27:23 +0000 (UTC) Cc: Thorsten Jolitz To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 31 08:27:16 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 1Wqcl8-0005aI-HB for ged-emacs-devel@m.gmane.org; Sat, 31 May 2014 08:27:14 +0200 Original-Received: from localhost ([::1]:58302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wqcl7-0002Zn-Vd for ged-emacs-devel@m.gmane.org; Sat, 31 May 2014 02:27:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wqckz-0002Q3-7t for emacs-devel@gnu.org; Sat, 31 May 2014 02:27:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wqckt-00007L-44 for emacs-devel@gnu.org; Sat, 31 May 2014 02:27:05 -0400 Original-Received: from mout.kundenserver.de ([212.227.126.130]:54699) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wqcks-00006d-Pt for emacs-devel@gnu.org; Sat, 31 May 2014 02:26:59 -0400 Original-Received: from [192.168.178.32] (brln-4d0ca57b.pool.mediaWays.net [77.12.165.123]) by mrelayeu.kundenserver.de (node=mreue003) with ESMTP (Nemesis) id 0MgJSU-1XEBFO2Z3W-00NgXw; Sat, 31 May 2014 08:26:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Icedove/24.5.0 In-Reply-To: <87ppivne52.fsf@gmail.com> X-Provags-ID: V02:K0:aU4geRb5/p1U4J4WRELtcwOq1prKr5JMs/f+mx5wWBO uQuvy2Dtzo8v2KG1pIgT57LjWAPQsQaXvn0lwIfPj6jbQXEPOR 25eKEmKKqhBS26pfUDhkngpH2RIErQNGssCe6qnaTX8pKVeds1 S5gmp3TFcWnSMv4rChqsQIoWd0uQwgi0geJt212c/LsoMjW/VR x1Ua2bOKySuUHmi56Djd19SGBjINayUF9KFVW31Cn+dN8ap8IT zeD5DG0JtbVZ9McBZ7h5kjePtTFbHGooBWzqAzxhk6vi+rLhz7 tMdVggWgwb+/v/Wt6vQQbNRL+NvWUzEADFFwfM3TZIyaPhROoX +6U/twuaDHeeYXmLgfzERg11AXQjgHjWJrxGm+Nqs X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 212.227.126.130 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:172205 Archived-At: On 30.05.2014 23:35, Thorsten Jolitz wrote: > 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? > AFAIU instrumenting `comment-dwim' should provide all you need here. Grüße, Andreas