From f58201b1e1b0788098b1bbca45e06e015f5b0b7b Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 19 May 2014 13:33:28 +0200 Subject: [PATCH] Fix indentation in source blocks * lisp/org.el (org-indent-line): Indent source block contents according to line above when `org-src-tab-acts-natively' is nil. * testing/lisp/test-org.el (test-org/indent-line): Update test. --- lisp/org.el | 6 +++--- testing/lisp/test-org.el | 17 +++++++++-------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index c7f0d7fed..016143617 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -22371,6 +22371,7 @@ Also align node properties according to `org-property-format'." (org-element-property :begin element)))) 'noindent) ((and (eq type 'src-block) + org-src-tab-acts-natively (> (line-beginning-position) (org-element-property :post-affiliated element)) (< (line-beginning-position) @@ -22378,9 +22379,8 @@ Also align node properties according to `org-property-format'." (goto-char (org-element-property :end element)) (skip-chars-backward " \r\t\n") (line-beginning-position)))) - (if (not org-src-tab-acts-natively) 'noindent - (let ((org-src-strip-leading-and-trailing-blank-lines nil)) - (org-babel-do-key-sequence-in-edit-buffer (kbd "TAB"))))) + (let ((org-src-strip-leading-and-trailing-blank-lines nil)) + (org-babel-do-key-sequence-in-edit-buffer (kbd "TAB")))) (t (let ((column (org--get-expected-indentation element nil))) ;; Preserve current column. diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index e82b2fdc8..ce8722612 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -556,7 +556,8 @@ (org-indent-line) (org-get-indentation)))) ;; Within code part of a source block, use language major mode if - ;; `org-src-tab-acts-natively' is non-nil. Do nothing otherwise. + ;; `org-src-tab-acts-natively' is non-nil. Otherwise, indent + ;; according to line above. (should (= 6 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC" @@ -566,13 +567,13 @@ (org-indent-line)) (org-get-indentation)))) (should - (zerop - (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC" - (forward-line 2) - (let ((org-src-tab-acts-natively nil) - (org-edit-src-content-indentation 0)) - (org-indent-line)) - (org-get-indentation)))) + (= 1 + (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n (and A\nB)\n#+END_SRC" + (forward-line 2) + (let ((org-src-tab-acts-natively nil) + (org-edit-src-content-indentation 0)) + (org-indent-line)) + (org-get-indentation)))) ;; Otherwise, indent like the first non-blank line above. (should (zerop -- 2.11.4.GIT