unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@online.de>
To: emacs-devel@gnu.org
Cc: Thorsten Jolitz <tjolitz@gmail.com>
Subject: Re: awesome feature (yet to be added?)
Date: Sat, 31 May 2014 08:26:36 +0200	[thread overview]
Message-ID: <5389761C.9010803@online.de> (raw)
In-Reply-To: <87ppivne52.fsf@gmail.com>

On 30.05.2014 23:35, Thorsten Jolitz wrote:
> Davis Herring <herring@lanl.gov> 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




  parent reply	other threads:[~2014-05-31  6:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-03 18:47 awesome feature (yet to be added?) Bric
2014-05-04  1:23 ` Bric
2014-05-04 11:12   ` Stephen Berman
2014-05-04 18:33   ` Andreas Röhler
2014-05-06  2:32 ` Le Wang
2014-05-06  2:45   ` Davis Herring
2014-05-06  8:19     ` Stephen J. Turnbull
2014-05-06 22:27     ` Robert Thorpe
2014-05-30 21:35     ` Thorsten Jolitz
2014-05-31  1:30       ` Stefan Monnier
2014-05-31 10:46         ` Thorsten Jolitz
2014-06-09 11:01         ` Thorsten Jolitz
2014-06-09 15:30           ` Stefan Monnier
2014-05-31  6:26       ` Andreas Röhler [this message]
2014-05-31 10:52         ` Thorsten Jolitz
2014-05-31 17:20           ` Andreas Röhler
2014-05-31 20:04             ` Thorsten Jolitz
2014-06-01  7:00               ` Andreas Röhler

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=5389761C.9010803@online.de \
    --to=andreas.roehler@online.de \
    --cc=emacs-devel@gnu.org \
    --cc=tjolitz@gmail.com \
    /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 public inbox

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

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).