[ Adding Org mailing list back to CC. Please use "Reply All" to keep the conversation public ]
Lei Zhe <lzhe...@gmail.com> writes: >> May you please explain in more details what problem you are trying to >> solve? > Sure. I've identified an issue on the master branch where, if the cursor is > not inside the table at WS, `org-table-begin' in > `org-table-header-set-header' > gets the beginning position of the next table in the buffer. > so `(pos-visible-in-window-p beg)' returns true, causing the header overlay > of the table at WS to not display. > >> Moving point to WS and then immediately to the beginning of the table >> makes no difference. So, your patch does nothing. > Moving point to WS ensures`org-table-begin' to get the beginning position > of the table at WS, regardless of the cursor position, which resolves the > above problem. Thanks for the explanation. Now the patch makes more sense. I am attaching a modified version of the patch with updated commit message and a code comment added explaining why we need to move to WS. P.S. Bastien, may your please check Lei Zhe's copyright status?
>From e26d940c4d5463d65a25a40ad5a7bd0a57538a3a Mon Sep 17 00:00:00 2001 Message-ID: <e26d940c4d5463d65a25a40ad5a7bd0a57538a3a.1712406934.git.yanta...@posteo.net> From: llcc <lzhe...@gmail.com> Date: Fri, 5 Apr 2024 22:07:12 +0800 Subject: [PATCH] org-table-header-line-mode: Fix when cursor is outside table * lisp/org-table.el (org-table-header-set-header): Display table header even when the point is below the table, as long as the table is visible at the top of the window. --- lisp/org-table.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lisp/org-table.el b/lisp/org-table.el index bd8d59f45..f0e9c2682 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -494,6 +494,11 @@ (defun org-table-header-set-header () (redisplay) (let* ((ws (window-start)) (beg (save-excursion + ;; Check table at window start, not at point. + ;; Point might be after the table, or at + ;; another table located below the one visible + ;; on top. + (goto-char ws) (goto-char (org-table-begin)) (while (or (org-at-table-hline-p) (looking-at-p ".*|\\s-+<[rcl]?\\([0-9]+\\)?>")) -- 2.44.0
-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>