org-table-to-lisp: Preserve text properties

* lisp/org-table.el (org-table-to-lisp): When parsing table, keep text
properties.  These text properties are required to calculate table
alignment with invisible text.
* testing/lisp/test-org-table.el (test-org-table/align): Add new test.

Reported-by: Kostadin Ninev <dinkonin@gmail.com>
Link: https://orgmode.org/list/1709041784097.2987395179.620232376@gmail.com
This commit is contained in:
Ihor Radchenko 2024-02-29 14:23:37 +03:00
parent c841be9656
commit 731d16f9e9
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 18 additions and 2 deletions

View File

@ -5519,7 +5519,9 @@ The table is taken from the parameter TXT, or from the buffer at point."
(unless (eolp) (setq p (1+ p))) (unless (eolp) (setq p (1+ p)))
p) p)
(skip-chars-backward " \t" q) (skip-chars-backward " \t" q)
(push (buffer-substring-no-properties q (point)) row))))) ;; Preserve text properties. They are used when
;; calculating cell width.
(push (buffer-substring q (point)) row)))))
(nreverse row))) (nreverse row)))
table) table)
(forward-line)) (forward-line))

View File

@ -1849,7 +1849,21 @@ See also `test-org-table/copy-field'."
(should (should
(org-test-with-temp-text "|-<point>--|---------|\n|---|---|-----|" (org-test-with-temp-text "|-<point>--|---------|\n|---|---|-----|"
(org-table-align) (org-table-align)
t))) t))
;; Adjust table width.
(should
(equal
(let ((org-link-descriptive t))
(org-test-with-temp-text "
| a | b |
|----------+---|
| [[c][c]] | d |<point>"
(org-table-align)
(buffer-string)))
"
| a | b |
|---+---|
| [[c][c]] | d |")))
(ert-deftest test-org-table/align-buffer-tables () (ert-deftest test-org-table/align-buffer-tables ()
"Align all tables when updating buffer." "Align all tables when updating buffer."