summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-05-29 09:55:56 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-05-29 09:55:56 +0200
commita33acf61917d8c72369297289031d8745e08e320 (patch)
tree42592c3c2db2bc6661fa7b8b4e8d3309897b4f4d
parent317886f53dd5d93b2ba89145866c64df77d4a93c (diff)
downloadorg-mode-a33acf61917d8c72369297289031d8745e08e320.tar.gz
org-src: Fix indentation rampage when editing src blocks
* lisp/org-src.el (org-edit-src-code): Do not add indentation at every edit when `org-src-preserve-indentation' is non-nil. Function taking care of indentation cannot check `org-src--preserve-indentation' since the variable is buffer-local and indentation happens in a temporary buffer. Reported-by: Rainer M Krug <Rainer@krugs.de> <http://permalink.gmane.org/gmane.emacs.orgmode/97927>
-rw-r--r--lisp/org-src.el20
1 files changed, 11 insertions, 9 deletions
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 47416ed..b1ee56f 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -834,15 +834,17 @@ name of the sub-editing buffer."
(org-src--construct-edit-buffer-name (buffer-name) lang))
lang-f
(and (null code)
- (lambda ()
- (unless org-src--preserve-indentation
- (untabify (point-min) (point-max))
- (when (> org-edit-src-content-indentation 0)
- (let ((ind (make-string org-edit-src-content-indentation ?\s)))
- (while (not (eobp))
- (unless (looking-at "[ \t]*$") (insert ind))
- (forward-line)))))
- (org-escape-code-in-region (point-min) (point-max))))
+ `(lambda ()
+ (unless ,(or org-src-preserve-indentation
+ (org-element-property :preserve-indent element))
+ (untabify (point-min) (point-max))
+ (when (> org-edit-src-content-indentation 0)
+ (let ((ind (make-string org-edit-src-content-indentation
+ ?\s)))
+ (while (not (eobp))
+ (unless (looking-at "[ \t]*$") (insert ind))
+ (forward-line)))))
+ (org-escape-code-in-region (point-min) (point-max))))
(and code (org-unescape-code-in-string code)))
;; Finalize buffer.
(org-set-local 'org-coderef-label-format