From 14acf626fe1fef25a854cf0df772b2899bf26a3c Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 1 Feb 2024 15:29:21 +0100 Subject: [PATCH] org: Fontify whole table rows with `org-table-row' face * lisp/org-faces.el (org-table-row): New face. * lisp/org.el (org-set-font-lock-defaults): Use ~org-table-row~ face to fontify the whole table rows, including indentation and newlines. * etc/ORG-NEWS (Org mode now fontifies whole table lines (including newline) according to ~org-table~ face): Announce the change. --- etc/ORG-NEWS | 17 +++++++++++++++++ lisp/org-faces.el | 4 ++++ lisp/org.el | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index ad5a0684f..9847083b3 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -13,6 +13,23 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.7 (not released yet) ** Important announcements and breaking changes +*** Org mode now fontifies whole table lines (including newline) according to ~org-table~ face + +Previously, leading indentation and trailing newline in table rows +were not fontified using ~org-table~ face. ~default~ face was used instead. +This made it impossible to scale line height when ~org-table~ face has +smaller height than default (Emacs calculates line height using the tallest face). + +Now, new ~org-table-row~ face is used on the whole table row lines, +including indentation and the final newline. This face, by default, +inherits from ~org-table~ face. + +If the new behavior is not desired, ~org-table-row~ face can be +changed to inherit from ~default~ face. + +~org-table~ takes precedence over ~org-table-row~ for the parts of +table rows without indentation and newline. + *** =ox-latex=: ~org-latex-line-break-safe~ is deprecated ~org-latex-line-break-safe~ constant was previously introduced to deal diff --git a/lisp/org-faces.el b/lisp/org-faces.el index 4d8ad7118..0e20de51a 100644 --- a/lisp/org-faces.el +++ b/lisp/org-faces.el @@ -389,6 +389,10 @@ changes." "Face used for tables." :group 'org-faces) +(defface org-table-row '((t :inherit org-table)) + "Face used to fontify whole table rows (including newlines and indentation)." + :group 'org-faces) + (defface org-table-header '((t :inherit org-table :background "LightGray" :foreground "Black")) diff --git a/lisp/org.el b/lisp/org.el index 2e53d98d3..2f8a9a9ca 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5849,7 +5849,8 @@ needs to be inserted at a specific position in the font-lock sequence.") (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) ;; Table lines - '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" + '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)\n?" + (0 'org-table-row t) (1 'org-table t)) ;; Table internals '("^[ \t]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t))