I make a change to function which copies contents of source code
block to temporary buffer, applies fontification through the means of
relevant major mode and transcribes text-properties back to org-buffer
so that they are applied on top of code in affected source code block.
Primary reason for this change is to fix the problem which I describe as
This function is not 100% compatible with a org-edit-src facility,
which provides an option to have indentation added to the code inside
the block after using command `org-edit-src-code' to edit it. This
command also handles removal of indentation upon insertion of the code
in temporary buffer where editing of the code will in relevant
This behavior indicates presence of indentation to be irrelevant
outside the context of org-buffer, and in some instances
(e.g. diff-mode) presence of indentation may render the code
incompatible with semantics of it's language.
Here's a couple of points which guided me to implement the change in
this particular way:
Section of code which mirrors the fontification from temporary to
org-buffer updates variable `start' for each fontified segment, allowing
it to remain relevant as a value which, when added to the position of
point in temporary buffer, will find position of that point mirrored
upon source block in org-buffer. This variable follows same principle if
`org-src-preserve-indentation' option is enabled.
Segments of text fontified to be spanning several lines are broken in
fashion that forces section to end at the newline and continue after the
indentation. This approach prevents indentation characters to be colored
in chaotic fashion when changes in background are used for
fontification, e.g. diff-mode with standard emacs theme.
lisp/org-src.el | 9 +++++++++
1 file changed, 9 insertions(+)