emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Samuel Wales <samologist@gmail.com>
To: Omid <omidlink@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Behavior of Org mode Babel code snippets with respect to M-q (fill-paragraph) and C-/ (undo)
Date: Thu, 13 Feb 2014 17:21:24 -0700	[thread overview]
Message-ID: <CAJcAo8u7sqa_uCvvq27gGCarn6cMC3+Kqbvn7DVaxWnDX-tf4w@mail.gmail.com> (raw)
In-Reply-To: <CAJcAo8s=CSusDFyzv+cF4jztOnTGgcUrPV6C5FDuo6JwdykKGA@mail.gmail.com>

"[bug] [babel] babel corrupts undo history"

On 2/13/14, Samuel Wales <samologist@gmail.com> wrote:
> Undo not working is a bug.  I think we identified the bug on the
> mailing list, but the fix was never implemented, although I think an
> attempted fix was.
>
> I think it has to do with editing a source code block trying to do
> things with undo or undo-boundary.  The fix is probably to rip out all
> undo-related code there.
>
>
> On 2/5/14, Omid <omidlink@gmail.com> wrote:
>> Hello Nick,
>>
>> Thanks for your quick reply. The variable
>> org-edit-src-content-indentation does indeed have to do with the
>> indentation I was referring to. But it is relative. According to the
>> documentation, it sets the "Indentation for the content of a source
>> code block. This should be the number of spaces added to the
>> indentation of the #+begin line in order to compute the indentation of
>> the block content after editing it with M-x org-edit-src-code. Has no
>> effect if `org-src-preserve-indentation' is non-nil." I wonder if one
>> can set it to be zero as an absolute value, meaning that if the a line
>> of code in the source block starts at column n of the buffer, it is
>> left at column n after M-q.
>>
>> Regarding the behavior you observe, as I said I get that too from time
>> to time. In fact, doing M-q on my own example in a fresh Org mode
>> buffer, I now get what you get:
>>
>>   #+BEGIN_SRC f90 :results verbatim :exports both
>>   program main ! This is a very very very very very very very very very
>>   very very very very very very very long comment line. print *, "Hello,
>>   World!" end program main
>>   #+END_SRC
>>
>> I don't have any special settings for the f90 mode in my .emacs. In
>> fact, I have observed the same behavior for other languages too when
>> edited in an Org source block. The "destructive" nature of this
>> behavior is very special (C-/ (undo) doesn't work). Many a times, I
>> have tried refilling a line of comments and ended up with a huge mix
>> of code and comment that was impossible to undo (at least to the best
>> of my knowledge) and I had to either revert the change if I had the
>> file under version control, go to an auto backup file, or painfully and
>> manually separate the code and comments to get back the original code
>> block.
>>
>> Omid
>>
>>
>> On 02/05/2014 04:34 PM, Nick Dokos wrote:
>>> Omid <omidlink@gmail.com> writes:
>>>
>>>> Hello,
>>>>
>>>> I am using Org-mode version 8.2.5g (8.2.5g-elpa) in GNU Emacs 24.3.1.
>>>> I have two questions about the behavior of the fantastic Org
>>>> mode+Babel with respect to code and comments:
>>>>
>>>> Here is a minimal example:
>>>>
>>>>   #+BEGIN_SRC f90 :results verbatim :exports both
>>>> program main
>>>> ! This is a very very very very very very very very very very very very
>>>> very very very very long comment line.
>>>> print *, "Hello, World!"
>>>> end program main
>>>>   #+END_SRC
>>>>
>>>> Below is the code snippet after M-q (fill-paragraph) on the comment
>>>> line. The comment line has been refilled (intended behavior) but all
>>>> lines have been indented. This may also be an intended behavior; but
>>>>
>>>> FIRST QUESTION: Is there a way to disable this indentation upon M-Q in
>>>> Org Babel code snippets?
>>>>
>>>
>>> Try setting org-edit-src-content-indentation to 0. I'm not sure that
>>> it is going to work, but (based on rather flimsy numerological evidence,
>>> namely that its default value is 2 as is the indent below) it might.
>>>
>>>>   #+BEGIN_SRC f90 :results verbatim :exports both
>>>>     program main
>>>>     ! This is a very very very very very very very very very very very
>>>> very
>>>>     ! very very very very long comment line.
>>>>     print *, "Hello, World!"
>>>>     end program main
>>>>   #+END_SRC
>>>>
>>>
>>> BTW, I don't get this behavior but I don't use f90 mode, so I'm not sure
>>> whether there is some setup I'm missing. I get (with
>>> org-edit-src-content-indentation set to 0):
>>>
>>>   #+BEGIN_SRC f90 :results verbatim :exports both
>>>   program main ! This is a very very very very very very very very very
>>>   very very very very very very very long comment line.  print *,
>>>   "Hello, World!"  end program main
>>>   #+END_SRC
>>>
>>> Nick
>>>
>>>
>>>
>>
>>
>
>
> --
> The Kafka Pandemic: http://thekafkapandemic.blogspot.com
>
> The disease DOES progress.  MANY people have died from it.  ANYBODY can get
> it.
>
> Denmark: free Karina Hansen NOW.
>


-- 
The Kafka Pandemic: http://thekafkapandemic.blogspot.com

The disease DOES progress.  MANY people have died from it.  ANYBODY can get it.

Denmark: free Karina Hansen NOW.

  reply	other threads:[~2014-02-14  0:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16  1:19 Org mode export to HTML not working correctly with code blocks if block is after an item (-) and its delimiters are indented Omid
2013-10-16  2:41 ` Thorsten Jolitz
2013-10-16  2:53 ` Thorsten Jolitz
2013-10-16  3:12   ` Omid
2013-10-16 11:25 ` Nicolas Goaziou
2014-02-05 20:40 ` Behavior of Org mode Babel code snippets with respect to M-q (fill-paragraph) and C-/ (undo) Omid
2014-02-05 21:34   ` Nick Dokos
2014-02-05 23:02     ` Omid
2014-02-13 23:38       ` Samuel Wales
2014-02-14  0:21         ` Samuel Wales [this message]
2014-03-21  7:56           ` Bastien
2014-05-25 20:37   ` Is there a variable/way to change <div id="content"> to something else, e.g. <div class="container"> for use with Bootstrap CSS? Omid
2014-05-26  2:10     ` Eric Abrahamsen
2014-05-26  4:08       ` Omid
2014-05-26  4:26         ` Omid
2014-05-26  5:11           ` Eric Abrahamsen
2014-05-26  6:28             ` Omid

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.orgmode.org/

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

  git send-email \
    --in-reply-to=CAJcAo8u7sqa_uCvvq27gGCarn6cMC3+Kqbvn7DVaxWnDX-tf4w@mail.gmail.com \
    --to=samologist@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=omidlink@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/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).