ソースを参照

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>
Nicolas Goaziou 9 年 前
コミット
a33acf6191
1 ファイル変更11 行追加9 行削除
  1. 11 9
      lisp/org-src.el

+ 11 - 9
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