emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Samuel Wales <samologist@gmail.com>
To: Michael Gauland <mikelygee@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: source blocks mangled when edited
Date: Sun, 30 May 2021 21:21:43 -0700	[thread overview]
Message-ID: <CAJcAo8tWpRqAWfpjifhe_b-yAB48bnREc+iZKNsFjqAQQfW53w@mail.gmail.com> (raw)
In-Reply-To: <e5e4e0cc-14a8-a9f8-6911-5244d77bab29@gmail.com>

idk if this will help as you probably know all of it already.  butg
you asked for any help so here goes.  i run maint, not master or any
emacs versions.  weird that you are missing 3 cols?

===

here are notes on my workaround which wfm in the meantime if you are
willing to do the same thing.  i was having trouble getting exported
indentation for example blocks.

;; fix default for source and example block indentation
;;
;; when you edit a source or data block, org will by default
;; remove some leading whitespace and then add 2 spaces, so the
;; whole block in org is indented by 2.
;;
;; (the deleted rectangle seems to be the maximum amount of
;; whitespace common to all lines in each block.)
;;
;; initial tabs get converted to spaces.  example blocks get
;; unindented during export incorrectly.  mistakes are possible.
;; this as non-nil prevents all that.  see led for more.
;;
;; we EITHER unindent all and set this non-nil, OR put up with
;; stripping of leading whitespace from blocks where we don't
;; want the indentation stripped.
;;
;; /i prefer t./ it is not possible in babel to indent without
;; having the special feature of removing the whitespace
;; rectangle.
;;
;; you can use -i to locally do t.  there isn't an arg that
;; locally does the reverse of -i.  i.e. to do nil.
;;
;; i have gotten comfortable with no indentation and imo it is a good
default for newcomers and does not surprise.
;;
;; source blocks might actually work without indentation even
;; with the default value, but then when you edit it indents.
(setq org-src-preserve-indentation t)
;; (setq org-src-preserve-indentation nil)
;;
;; only has effect if org-src-preserve-indentation is nil
;; (setq org-edit-src-content-indentation 0)


On 5/30/21, Michael Gauland <mikelygee@gmail.com> wrote:
> I've stared having trouble editing source blocks.    When I use C-c ' to
> edit block, the editing behaves as expected, but when I C-c ' to return
> to the main org file, the code is altered in strange ways.  I've had
> trouble coming up with a really small example, but the attached file
> seems to consistently demonstrate the problem, even when running emacs
> without my settings.
>
> The file has two identical source blocks. The first generally behaves
> fine, though some lines get extra indentation.
>
> The second suffers more serious distortions. For example, the first line
> changes from "digraph G {" to "aph G {".
>
> I've seen this with other types of code as well (at least SQL and json),
> so it's not specific to dot.
>
> I'm running emacs 26.1 on Debian 10.9, with org build from git.
>
> I'm not even sure how to start tracking this down. Any help would be
> greatly appreciated!
>
> Kind regards,
>
> Mike Gauland
>
>


-- 
The Kafka Pandemic

Please learn what misopathy is.
https://thekafkapandemic.blogspot.com/2013/10/why-some-diseases-are-wronged.html


  reply	other threads:[~2021-05-31  4:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31  3:39 Michael Gauland
2021-05-31  4:21 ` Samuel Wales [this message]
2021-05-31  8:01   ` Michael Gauland
2021-05-31  8:15 ` Sébastien Miquel
2021-05-31  8:54   ` Michael Gauland
2021-05-31  9:42     ` Sébastien Miquel
2021-05-31 10:02       ` Michael Gauland
2021-06-01  8:20         ` [PATCH] " Sébastien Miquel
2021-06-27 13:54           ` Nicolas Goaziou

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=CAJcAo8tWpRqAWfpjifhe_b-yAB48bnREc+iZKNsFjqAQQfW53w@mail.gmail.com \
    --to=samologist@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mikelygee@gmail.com \
    --subject='Re: source blocks mangled when edited' \
    /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

Code repositories for project(s) associated with this 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).