* [PATCH] Ensure org-table-header displays without cursor inside table
@ 2024-04-05 14:20 Lei Zhe
2024-04-05 18:39 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: Lei Zhe @ 2024-04-05 14:20 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 311 bytes --]
Hi org-mode community,
The patch ensures the header of an org-table displays without the cursor
inside the table when org-table-header-line-mode is enabled.
BTW, this is my first patch for org-mode, so please correct me if there
are any issues with it.
Also, I've done the paperwork before.
Regards,
Zhe Lei
[-- Attachment #1.2: Type: text/html, Size: 456 bytes --]
[-- Attachment #2: 0001-Ensure-org-table-header-displays-without-cursor-insi.patch --]
[-- Type: application/octet-stream, Size: 905 bytes --]
From 78a41e6d8367b8e70ca6a9b81ba20c0a86e01ce1 Mon Sep 17 00:00:00 2001
From: llcc <lzhes43@gmail.com>
Date: Fri, 5 Apr 2024 22:07:12 +0800
Subject: [PATCH] Ensure org-table-header displays without cursor inside table
---
lisp/org-table.el | 1 +
1 file changed, 1 insertion(+)
diff --git a/lisp/org-table.el b/lisp/org-table.el
index bd8d59f45..5475b6d42 100644
--- a/lisp/org-table.el
+++ b/lisp/org-table.el
@@ -494,6 +494,7 @@ This may be useful when columns have been shrunk."
(redisplay)
(let* ((ws (window-start))
(beg (save-excursion
+ (goto-char ws)
(goto-char (org-table-begin))
(while (or (org-at-table-hline-p)
(looking-at-p ".*|\\s-+<[rcl]?\\([0-9]+\\)?>"))
base-commit: e9c288dfaccc2960e5b6889e6aabea700ad4e05a
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Ensure org-table-header displays without cursor inside table
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>
0 siblings, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2024-04-05 18:39 UTC (permalink / raw)
To: Lei Zhe; +Cc: emacs-orgmode
Lei Zhe <lzhes43@gmail.com> writes:
> The patch ensures the header of an org-table displays without the cursor
> inside the table when org-table-header-line-mode is enabled.
>
> BTW, this is my first patch for org-mode, so please correct me if there
> are any issues with it.
> Also, I've done the paperwork before.
Thanks for the patch!
May you please explain in more details what problem you are trying to
solve?
> (beg (save-excursion
> + (goto-char ws)
> (goto-char (org-table-begin))
> (while (or (org-at-table-hline-p)
> (looking-at-p ".*|\\s-+<[rcl]?\\([0-9]+\\)?>"))
Moving point to WS and then immediately to the beginning of the table
makes no difference. So, your patch does nothing.
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Fwd: [PATCH] Ensure org-table-header displays without cursor inside table
[not found] ` <CALjq+LYwpu+Chej9ZbDV=qYGKhnTvBBeTgVvw3QV7dm-WB0WTQ@mail.gmail.com>
@ 2024-04-06 0:29 ` Lei Zhe
2024-04-06 12:36 ` Ihor Radchenko
1 sibling, 0 replies; 7+ messages in thread
From: Lei Zhe @ 2024-04-06 0:29 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]
> 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, resolves the
above problem.
Regards,
Zhe Lei
On Sat, Apr 6, 2024 at 2:40 AM Ihor Radchenko <yantar92@posteo.net> wrote:
> Lei Zhe <lzhes43@gmail.com> writes:
>
> > The patch ensures the header of an org-table displays without the cursor
> > inside the table when org-table-header-line-mode is enabled.
> >
> > BTW, this is my first patch for org-mode, so please correct me if there
> > are any issues with it.
> > Also, I've done the paperwork before.
>
> Thanks for the patch!
> May you please explain in more details what problem you are trying to
> solve?
>
> > (beg (save-excursion
> > + (goto-char ws)
> > (goto-char (org-table-begin))
> > (while (or (org-at-table-hline-p)
> > (looking-at-p
> ".*|\\s-+<[rcl]?\\([0-9]+\\)?>"))
>
> Moving point to WS and then immediately to the beginning of the table
> makes no difference. So, your patch does nothing.
>
> --
> 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>
>
[-- Attachment #2: Type: text/html, Size: 2948 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Ensure org-table-header displays without cursor inside table
[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
2024-04-12 9:23 ` Bastien Guerry
1 sibling, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2024-04-06 12:36 UTC (permalink / raw)
To: Lei Zhe, Bastien; +Cc: emacs-orgmode
[-- 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>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Ensure org-table-header displays without cursor inside table
2024-04-06 12:36 ` Ihor Radchenko
@ 2024-04-12 9:23 ` Bastien Guerry
2024-04-12 18:05 ` Ihor Radchenko
0 siblings, 1 reply; 7+ messages in thread
From: Bastien Guerry @ 2024-04-12 9:23 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Lei Zhe, emacs-orgmode
Ihor Radchenko <yantar92@posteo.net> writes:
> P.S. Bastien, may your please check Lei Zhe's copyright status?
Yes, I confirm Lei Zhe copyright status is okay.
--
Bastien Guerry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Ensure org-table-header displays without cursor inside table
2024-04-12 9:23 ` Bastien Guerry
@ 2024-04-12 18:05 ` Ihor Radchenko
2024-04-12 23:53 ` Lei Zhe
0 siblings, 1 reply; 7+ messages in thread
From: Ihor Radchenko @ 2024-04-12 18:05 UTC (permalink / raw)
To: Bastien Guerry; +Cc: Lei Zhe, emacs-orgmode
Bastien Guerry <bzg@gnu.org> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> P.S. Bastien, may your please check Lei Zhe's copyright status?
>
> Yes, I confirm Lei Zhe copyright status is okay.
Applied, onto bugfix. I amended the commit author field to contain the
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5128460f9
full name.
Lei Zhe, you are now listed as an Org contributor. Thank you!
https://git.sr.ht/~bzg/worg/commit/104102ff
--
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>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Ensure org-table-header displays without cursor inside table
2024-04-12 18:05 ` Ihor Radchenko
@ 2024-04-12 23:53 ` Lei Zhe
0 siblings, 0 replies; 7+ messages in thread
From: Lei Zhe @ 2024-04-12 23:53 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Bastien Guerry, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 857 bytes --]
Great, thanks.
On Sat, Apr 13, 2024 at 2:04 AM Ihor Radchenko <yantar92@posteo.net> wrote:
> Bastien Guerry <bzg@gnu.org> writes:
>
> > Ihor Radchenko <yantar92@posteo.net> writes:
> >
> >> P.S. Bastien, may your please check Lei Zhe's copyright status?
> >
> > Yes, I confirm Lei Zhe copyright status is okay.
>
> Applied, onto bugfix. I amended the commit author field to contain the
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5128460f9
> full name.
>
> Lei Zhe, you are now listed as an Org contributor. Thank you!
> https://git.sr.ht/~bzg/worg/commit/104102ff
>
> --
> 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>
>
[-- Attachment #2: Type: text/html, Size: 1783 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-04-12 23:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-04-12 9:23 ` Bastien Guerry
2024-04-12 18:05 ` Ihor Radchenko
2024-04-12 23:53 ` Lei Zhe
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).