0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-29 18:36:26 +00:00

org-element: Do not alter indentation upon parsing

* lisp/org-element.el (org-element-src-block-parser):
(org-element-example-block-parser): Do not remove any indentation when
  parsing the element.
* testing/lisp/test-org-element.el (test-org-element/src-block-parser):
* testing/lisp/test-org-element.el (test-org-element/src-block-parser):
  Update test.

Properly handling indentation requires knowing about
`org-src-preserve-indentation''s value.  This is out of the scope of the
parser.
This commit is contained in:
Nicolas Goaziou 2016-02-09 23:19:20 +01:00
parent aa042455a7
commit 111905ff84
2 changed files with 7 additions and 40 deletions

View file

@ -1900,13 +1900,10 @@ containing `:begin', `:end', `:number-lines', `:preserve-indent',
;; Standard block parsing.
(begin (car affiliated))
(post-affiliated (point))
(block-ind (progn (skip-chars-forward " \t") (current-column)))
(contents-begin (progn (forward-line) (point)))
(value (org-remove-indentation
(org-unescape-code-in-string
(buffer-substring-no-properties
contents-begin contents-end))
block-ind))
(contents-begin (line-beginning-position 2))
(value (org-unescape-code-in-string
(buffer-substring-no-properties
contents-begin contents-end)))
(pos-before-blank (progn (goto-char contents-end)
(forward-line)
(point)))
@ -2406,14 +2403,10 @@ Assume point is at the beginning of the block."
(or (not switches)
(and retain-labels
(not (string-match "-k\\>" switches)))))
;; Indentation.
(block-ind (progn (skip-chars-forward " \t") (current-column)))
;; Retrieve code.
(value (org-remove-indentation
(org-unescape-code-in-string
(buffer-substring-no-properties
(progn (forward-line) (point)) contents-end))
block-ind))
(value (org-unescape-code-in-string
(buffer-substring-no-properties
(line-beginning-position 2) contents-end)))
(pos-before-blank (progn (goto-char contents-end)
(forward-line)
(point)))

View file

@ -699,19 +699,6 @@ Some other text
(org-test-with-temp-text
"#+BEGIN_EXAMPLE\n,* Headline\n ,#+keyword\nText\n#+END_EXAMPLE"
(org-element-property :value (org-element-at-point)))))
;; Remove block indentation according to block boundaries, unless
;; block contents are less indented than block boundaries.
(should
(equal " L1\nL2\n"
(org-test-with-temp-text " #+BEGIN_EXAMPLE\n L1\n L2\n #+END_EXAMPLE"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point))))))
(should
(equal
" L1\n L2\n"
(org-test-with-temp-text " #+BEGIN_EXAMPLE\n L1\n L2\n #+END_EXAMPLE"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point))))))
;; Handle non-empty blank line at the end of buffer.
(should
(org-test-with-temp-text "#+BEGIN_EXAMPLE\nC\n#+END_EXAMPLE\n "
@ -2058,19 +2045,6 @@ Outside list"
(org-test-with-temp-text
"#+BEGIN_SRC org\n,* Headline\n ,#+keyword\nText\n#+END_SRC"
(org-element-property :value (org-element-at-point)))))
;; Remove block indentation according to block boundaries, unless
;; block contents are less indented than block boundaries.
(should
(equal " L1\nL2\n"
(org-test-with-temp-text " #+BEGIN_SRC org\n L1\n L2\n #+END_SRC"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point))))))
(should
(equal
" L1\n L2\n"
(org-test-with-temp-text " #+BEGIN_SRC org\n L1\n L2\n #+END_SRC"
(let ((org-src-preserve-indentation t))
(org-element-property :value (org-element-at-point))))))
;; Handle non-empty blank line at the end of buffer.
(should
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\nC\n#+END_SRC\n "