emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* source-block 'uncomment-region' comments out a second time
@ 2019-04-22 10:49 Daniel Herzig
  2019-04-22 17:05 ` Berry, Charles
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Herzig @ 2019-04-22 10:49 UTC (permalink / raw)
  To: Emacs-Orgmode

Hi all!

I found a minor problem when editing source code blocks. I am on
Org-Mode 8.2.10 that comes with Emacs 25.1.1 on Debian.

My source code block looks something like:

#+BEGIN_SRC sh :shebang abc :tangle xyz
do this
do that
and that
#+END_SRC

If I enter the block with C-c ' and comment out a region like:

do this
do that

with M-x comment-region, everything works as expected, i.e.:

# do this
# do that

From outside the source-code editor it looks like this now (indentation ignored):

#+BEGIN_SRC sh :shebang abc :tangle xyz
# do this
# do that
and that
#+END_SRC

Sometimes I like to make changes to the code without entering the block
with C-c ' -- but if I mark:

# do this
# do that

from outside and hit M-x uncomment-region, my source-code block turns
into this:

#+BEGIN_SRC sh :shebang abc :tangle xyz
# # do this
# # do that
and that
#+END_SRC

I just tried -- it does not make a difference which command I use on the
region (comment-region or uncomment-region) from outside, it will
comment out as often as I use one of them (IF I just tried 3 levels). Inside the C-c ' environment
everything is top and working as expected.

It's clear that this kind of workflow is not intended, and I usually
work inside C-c ' for obvious reasions.  I just pointing at it, as in
this case 'comment-region' and 'uncomment-region' seem to do the same,
which is somewhat unexpected.

Best regards,
Daniel




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source-block 'uncomment-region' comments out a second time
  2019-04-22 10:49 source-block 'uncomment-region' comments out a second time Daniel Herzig
@ 2019-04-22 17:05 ` Berry, Charles
  2019-04-24 15:45   ` Daniel Herzig
  0 siblings, 1 reply; 5+ messages in thread
From: Berry, Charles @ 2019-04-22 17:05 UTC (permalink / raw)
  To: Daniel Herzig; +Cc: Emacs-Orgmode



> On Apr 22, 2019, at 3:49 AM, Daniel Herzig <daniel.herzig@outlook.at> wrote:
> 
> I found a minor problem when editing source code blocks. I am on
> Org-Mode 8.2.10 that comes with Emacs 25.1.1 on Debian.

With more modern versions (9.2.3, for example), the behavior you describe does not occur.

viz., (un)commenting is language aware in the org buffer (as well as in the edit buffer).

HTH,

Chuck

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source-block 'uncomment-region' comments out a second time
  2019-04-22 17:05 ` Berry, Charles
@ 2019-04-24 15:45   ` Daniel Herzig
  2019-04-24 18:05     ` Berry, Charles
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Herzig @ 2019-04-24 15:45 UTC (permalink / raw)
  To: Berry, Charles; +Cc: Emacs-Orgmode

Hi!

"Berry, Charles" <ccberry@ucsd.edu> writes:

>> On Apr 22, 2019, at 3:49 AM, Daniel Herzig <daniel.herzig@outlook.at> wrote:
>> 
>> I found a minor problem when editing source code blocks. I am on
>> Org-Mode 8.2.10 that comes with Emacs 25.1.1 on Debian.
>
> With more modern versions (9.2.3, for example), the behavior you describe does not occur.
>
> viz., (un)commenting is language aware in the org buffer (as well as in the edit buffer).
>
> HTH,
>
> Chuck

Thanks for your hint. 

I just upgraded to 9.2.3 through org/elpa -- but the situation seems to have
gotten even worse in my case.  Not only (un)comment-region in a
source-code block of the main .org-file (not inside the edit-buffer) still do the
same thing (commenting *OUT*) -- now the commands even comment out the
first part of the next line after the marked region, resulting in
tearing this line apart.

Anyway, I'll stick with the new version, as code-highlighting is way
better than in 8.2.10 (and keep un/commenting a thing for the
edit-buffer solely).

Cheers,
Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source-block 'uncomment-region' comments out a second time
  2019-04-24 15:45   ` Daniel Herzig
@ 2019-04-24 18:05     ` Berry, Charles
  2019-04-24 18:42       ` Daniel Herzig
  0 siblings, 1 reply; 5+ messages in thread
From: Berry, Charles @ 2019-04-24 18:05 UTC (permalink / raw)
  To: Daniel Herzig; +Cc: Emacs-Orgmode

My bad. See inline.

> On Apr 24, 2019, at 8:45 AM, Daniel Herzig <daniel.herzig@outlook.at> wrote:
> 
> Hi!
> 
> "Berry, Charles" <ccberry@ucsd.edu> writes:
> 
>>> On Apr 22, 2019, at 3:49 AM, Daniel Herzig <daniel.herzig@outlook.at> wrote:
>>> 
>>> I found a minor problem when editing source code blocks. I am on
>>> Org-Mode 8.2.10 that comes with Emacs 25.1.1 on Debian.
>> 
>> With more modern versions (9.2.3, for example), the behavior you describe does not occur.
>> 


I should have said M-; behaves as you would expect.

But it runs `org-comment-dwim' when in an org-mode buffer.

Outside of org-mode it runs `comment-dwim' which calls on `(un)comment-region'.


>> viz., (un)commenting is language aware in the org buffer (as well as in the edit buffer).
>> 
>> HTH,
>> 
>> Chuck
> 
> Thanks for your hint. 
> 
> I just upgraded to 9.2.3 through org/elpa -- but the situation seems to have
> gotten even worse in my case.  Not only (un)comment-region in a
> source-code block of the main .org-file (not inside the edit-buffer) still do the
> same thing (commenting *OUT*) -- now the commands even comment out the
> first part of the next line after the marked region, resulting in
> tearing this line apart.
> 

Right. I confirm this.

So the advice is to use `org-comment-dwim' (which silently does `comment-dim' in an edit buffer).

HTH,

Chuck

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: source-block 'uncomment-region' comments out a second time
  2019-04-24 18:05     ` Berry, Charles
@ 2019-04-24 18:42       ` Daniel Herzig
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Herzig @ 2019-04-24 18:42 UTC (permalink / raw)
  To: Berry, Charles; +Cc: Emacs-Orgmode

M-; is definitely what I've been searching for!

Thanks for the advice,
Daniel


"Berry, Charles" <ccberry@ucsd.edu> writes:

> My bad. See inline.
>
>> On Apr 24, 2019, at 8:45 AM, Daniel Herzig <daniel.herzig@outlook.at> wrote:
>> 
>> Hi!
>> 
>> "Berry, Charles" <ccberry@ucsd.edu> writes:
>> 
>>>> On Apr 22, 2019, at 3:49 AM, Daniel Herzig <daniel.herzig@outlook.at> wrote:
>>>> 
>>>> I found a minor problem when editing source code blocks. I am on
>>>> Org-Mode 8.2.10 that comes with Emacs 25.1.1 on Debian.
>>> 
>>> With more modern versions (9.2.3, for example), the behavior you describe does not occur.
>>> 
>
>
> I should have said M-; behaves as you would expect.
>
> But it runs `org-comment-dwim' when in an org-mode buffer.
>
> Outside of org-mode it runs `comment-dwim' which calls on `(un)comment-region'.
>
>
>>> viz., (un)commenting is language aware in the org buffer (as well as in the edit buffer).
>>> 
>>> HTH,
>>> 
>>> Chuck
>> 
>> Thanks for your hint. 
>> 
>> I just upgraded to 9.2.3 through org/elpa -- but the situation seems to have
>> gotten even worse in my case.  Not only (un)comment-region in a
>> source-code block of the main .org-file (not inside the edit-buffer) still do the
>> same thing (commenting *OUT*) -- now the commands even comment out the
>> first part of the next line after the marked region, resulting in
>> tearing this line apart.
>> 
>
> Right. I confirm this.
>
> So the advice is to use `org-comment-dwim' (which silently does `comment-dim' in an edit buffer).
>
> HTH,
>
> Chuck

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-24 18:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-22 10:49 source-block 'uncomment-region' comments out a second time Daniel Herzig
2019-04-22 17:05 ` Berry, Charles
2019-04-24 15:45   ` Daniel Herzig
2019-04-24 18:05     ` Berry, Charles
2019-04-24 18:42       ` Daniel Herzig

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).