mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
org-src: Preserve tab characters unrelated to indentation
* lisp/org-src.el (org-edit-src-code): Always preserve tabs not related to indentation. * testing/lisp/test-org-src.el (test-org-src/preserve-tabs): New test.
This commit is contained in:
parent
348890f79b
commit
50a18201c7
|
@ -851,13 +851,12 @@ name of the sub-editing buffer."
|
|||
`(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)))))
|
||||
(while (not (eobp))
|
||||
(unless (looking-at "[ \t]*$")
|
||||
(indent-line-to (+ (org-get-indentation)
|
||||
org-edit-src-content-indentation)))
|
||||
(forward-line))))
|
||||
(org-escape-code-in-region (point-min) (point-max))))
|
||||
(and code (org-unescape-code-in-string code)))
|
||||
;; Finalize buffer.
|
||||
|
|
|
@ -98,5 +98,40 @@ blah
|
|||
#+end_src
|
||||
")))))
|
||||
|
||||
(ert-deftest test-org-src/preserve-tabs ()
|
||||
"Editing block preserve tab characters."
|
||||
;; With `org-src-preserve-indentation' set to nil.
|
||||
(should
|
||||
(equal "
|
||||
#+begin_src emacs-lisp
|
||||
This is a tab: .
|
||||
#+end_src"
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
#+begin_src emacs-lisp
|
||||
<point>This is a tab: .
|
||||
#+end_src"
|
||||
(let ((org-edit-src-content-indentation 2)
|
||||
(org-src-preserve-indentation nil))
|
||||
(org-edit-special)
|
||||
(org-edit-src-exit)
|
||||
(buffer-string)))))
|
||||
;; With `org-src-preserve-indentation' set to t.
|
||||
(should
|
||||
(equal "
|
||||
#+begin_src emacs-lisp
|
||||
This is a tab: .
|
||||
#+end_src"
|
||||
(org-test-with-temp-text
|
||||
"
|
||||
#+begin_src emacs-lisp
|
||||
<point>This is a tab: .
|
||||
#+end_src"
|
||||
(let ((org-edit-src-content-indentation 2)
|
||||
(org-src-preserve-indentation t))
|
||||
(org-edit-special)
|
||||
(org-edit-src-exit)
|
||||
(buffer-string))))))
|
||||
|
||||
(provide 'test-org-src)
|
||||
;;; test-org-src.el ends here
|
||||
|
|
Loading…
Reference in a new issue