emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Omid <omidlink@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Behavior of Org mode Babel code snippets with respect to M-q (fill-paragraph) and C-/ (undo)
Date: Wed, 05 Feb 2014 15:40:50 -0500	[thread overview]
Message-ID: <52F2A1D2.4030802@gmail.com> (raw)
In-Reply-To: <525DE996.2000408@gmail.com>

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?

  #+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 a C-/ (undo). Note that the
indentation and the refill which were done by the last command above
(M-q) are not being undone. The text in the comment is being removed
which I believe means that the previous (self-insert-command)'s that
created the text are being undone. This is very undesirable since even
a user who is aware of this behavior may by mistake issue the command
M-q, have the code snippet formatted in an undesirable way (e.g.,
sometimes new lines are not respected and code and comments get mixed
up), without any immediate way to undo this reformatting.

SECOND QUESTION: How can one get the usual (undo) behavior in a Babel
code snippet?

  #+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 v comment line.
    print *, "Hello, World!"
    end program main
  #+END_SRC

Please note that these edits are done in the Org mode buffer directly.
If I switch to the native language mode using C-c ' things work as
expected.

Thanks,
Omid

  parent reply	other threads:[~2014-02-05 20:41 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 ` Omid [this message]
2014-02-05 21:34   ` Behavior of Org mode Babel code snippets with respect to M-q (fill-paragraph) and C-/ (undo) Nick Dokos
2014-02-05 23:02     ` Omid
2014-02-13 23:38       ` Samuel Wales
2014-02-14  0:21         ` Samuel Wales
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=52F2A1D2.4030802@gmail.com \
    --to=omidlink@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).