[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: awesome feature (yet to be added?)
From: |
Thorsten Jolitz |
Subject: |
Re: awesome feature (yet to be added?) |
Date: |
Fri, 30 May 2014 23:35:37 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Davis Herring <address@hidden> 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
- awesome feature (yet to be added?), Bric, 2014/05/03
- Re: awesome feature (yet to be added?), Bric, 2014/05/03
- Re: awesome feature (yet to be added?), Le Wang, 2014/05/05
- Re: awesome feature (yet to be added?), Davis Herring, 2014/05/05
- Re: awesome feature (yet to be added?), Andreas Röhler, 2014/05/31
- Re: awesome feature (yet to be added?), Thorsten Jolitz, 2014/05/31
- Re: awesome feature (yet to be added?), Andreas Röhler, 2014/05/31
- Re: awesome feature (yet to be added?), Thorsten Jolitz, 2014/05/31