[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: source blocks mangled when edited
From: |
Samuel Wales |
Subject: |
Re: source blocks mangled when edited |
Date: |
Sun, 30 May 2021 21:21:43 -0700 |
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