diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2014-05-19 13:33:28 +0200 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2014-05-19 13:33:28 +0200 |
commit | f58201b1e1b0788098b1bbca45e06e015f5b0b7b (patch) | |
tree | c54abd8076a7d37e3eb3dd7bec6d76de5649a04d | |
parent | 3702dce1db942fde746025523829cde0f2db6dec (diff) | |
download | org-mode-f58201b1e1b0788098b1bbca45e06e015f5b0b7b.tar.gz |
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.
-rw-r--r-- | lisp/org.el | 6 | ||||
-rw-r--r-- | testing/lisp/test-org.el | 17 |
2 files changed, 12 insertions, 11 deletions
diff --git a/lisp/org.el b/lisp/org.el index c7f0d7f..0161436 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 e82b2fd..ce87226 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 |