Skip to content

Commit 9dde824

Browse files
committed
org-table: Prevent Emacs from merging displayed separator spaces
* lisp/org-table.el (org-table-separator-space): Remove. (org-table--separator-space-pre): (org-table--separator-space-post): Use non-`eq' spaces as table cell boundaries. This way, Emacs display engine will not merge the two spaces with `eq' 'display properties in empty table cells. (org-table--make-shrinking-overlay): (org-table--align-field): Use the new constants for table alignment. Fixes https://debbugs.gnu.org/cgi/bugreport.cgi?bug=45915
1 parent ae2140b commit 9dde824

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lisp/org-table.el

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,23 @@ This works for both table types.")
570570
(concat "\\(" "@[-0-9I$]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\)")
571571
"Match a reference that needs translation, for reference display.")
572572

573-
(defconst org-table-separator-space
573+
(defconst org-table--separator-space-pre
574574
(propertize " " 'display '(space :relative-width 1))
575-
"Space used around fields when aligning the table.
575+
"Space used in front of fields when aligning the table.
576576
This space serves as a segment separator for the purposes of the
577-
bidirectional reordering.")
577+
bidirectional reordering.
578+
Note that `org-table--separator-space-pre' is not `eq' to
579+
`org-table--separator-space-post'. This is done to prevent Emacs from
580+
visually merging spaces in an empty table cell. See bug#45915.")
581+
582+
(defconst org-table--separator-space-post
583+
(propertize " " 'display '(space :relative-width 1.001))
584+
"Space used after fields when aligning the table.
585+
This space serves as a segment separator for the purposes of the
586+
bidirectional reordering.
587+
Note that `org-table--separator-space-pre' is not `eq' to
588+
`org-table--separator-space-post'. This is done to prevent Emacs from
589+
visually merging spaces in an empty table cell. See bug#45915.")
578590

579591

580592
;;; Internal Variables
@@ -3889,7 +3901,7 @@ mouse onto the overlay.
38893901
38903902
When optional argument PRE is non-nil, assume the overlay is
38913903
located at the beginning of the field, and prepend
3892-
`org-table-separator-space' to it. Otherwise, concatenate
3904+
`org-table--separator-space-pre' to it. Otherwise, concatenate
38933905
`org-table-shrunk-column-indicator' at its end.
38943906
38953907
Return the overlay."
@@ -3908,7 +3920,7 @@ Return the overlay."
39083920
;; Make sure overlays stays on top of table coordinates overlays.
39093921
;; See `org-table-overlay-coordinates'.
39103922
(overlay-put o 'priority 1)
3911-
(let ((d (if pre (concat org-table-separator-space display)
3923+
(let ((d (if pre (concat org-table--separator-space-pre display)
39123924
(concat display org-table-shrunk-column-indicator))))
39133925
(org-overlay-display o d 'org-table t))
39143926
o))
@@ -4321,11 +4333,11 @@ FIELD is a string. WIDTH is a number. ALIGN is either \"c\",
43214333
("r" (make-string spaces ?\s))
43224334
("c" (make-string (/ spaces 2) ?\s))))
43234335
(suffix (make-string (- spaces (length prefix)) ?\s)))
4324-
(concat org-table-separator-space
4336+
(concat org-table--separator-space-pre
43254337
prefix
43264338
field
43274339
suffix
4328-
org-table-separator-space)))
4340+
org-table--separator-space-post)))
43294341

43304342
(defun org-table-align ()
43314343
"Align the table at point by aligning all vertical bars."

0 commit comments

Comments
 (0)