emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Lei Zhe <lzhes43@gmail.com>, Bastien <bzg@gnu.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Ensure org-table-header displays without cursor inside table
Date: Sat, 06 Apr 2024 12:36:01 +0000	[thread overview]
Message-ID: <87plv2pt1q.fsf@localhost> (raw)
In-Reply-To: <CALjq+LYwpu+Chej9ZbDV=qYGKhnTvBBeTgVvw3QV7dm-WB0WTQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

[ Adding Org mailing list back to CC. Please use "Reply All" to keep the
conversation public ]

Lei Zhe <lzhes43@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?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-table-header-line-mode-Fix-when-cursor-is-outsid.patch --]
[-- Type: text/x-patch, Size: 1332 bytes --]

From e26d940c4d5463d65a25a40ad5a7bd0a57538a3a Mon Sep 17 00:00:00 2001
Message-ID: <e26d940c4d5463d65a25a40ad5a7bd0a57538a3a.1712406934.git.yantar92@posteo.net>
From: llcc <lzhes43@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


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
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>

  parent reply	other threads:[~2024-04-06 12:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 14:20 [PATCH] Ensure org-table-header displays without cursor inside table Lei Zhe
2024-04-05 18:39 ` Ihor Radchenko
     [not found]   ` <CALjq+LYwpu+Chej9ZbDV=qYGKhnTvBBeTgVvw3QV7dm-WB0WTQ@mail.gmail.com>
2024-04-06  0:29     ` Fwd: " Lei Zhe
2024-04-06 12:36     ` Ihor Radchenko [this message]
2024-04-12  9:23       ` Bastien Guerry
2024-04-12 18:05         ` Ihor Radchenko
2024-04-12 23:53           ` Lei Zhe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87plv2pt1q.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=lzhes43@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).