From 731d16f9e9b3f555e234146d943409b13d79378a Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 29 Feb 2024 14:23:37 +0300 Subject: [PATCH] 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 Link: https://orgmode.org/list/1709041784097.2987395179.620232376@gmail.com --- lisp/org-table.el | 4 +++- testing/lisp/test-org-table.el | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lisp/org-table.el b/lisp/org-table.el index 67fffc23e..f390594d1 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -5519,7 +5519,9 @@ The table is taken from the parameter TXT, or from the buffer at point." (unless (eolp) (setq p (1+ p))) p) (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))) table) (forward-line)) diff --git a/testing/lisp/test-org-table.el b/testing/lisp/test-org-table.el index 6ee790894..bfe5c3284 100644 --- a/testing/lisp/test-org-table.el +++ b/testing/lisp/test-org-table.el @@ -1849,7 +1849,21 @@ See also `test-org-table/copy-field'." (should (org-test-with-temp-text "|---|---------|\n|---|---|-----|" (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 |" + (org-table-align) + (buffer-string))) + " +| a | b | +|---+---| +| [[c][c]] | d |"))) (ert-deftest test-org-table/align-buffer-tables () "Align all tables when updating buffer."