emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] A call of (org-end-of-meta-data t) goes too far in a heading with only whitespace
@ 2024-10-05  6:52 Benjamin McMillan
  2024-10-12 11:45 ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin McMillan @ 2024-10-05  6:52 UTC (permalink / raw)
  To: emacs-orgmode

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

Specifically, a call to (org-end-of-meta-data t) with point at the > on the
following tree will go all the way to the next heading.
In contrast, a call to just (org-end-of-meta-data), without the FULL flag,
will go to the beginning of heading content, as expected.
* >heading


* another heading


The issue arises from the code for skipping clock lines, which does so by
checking if point is looking at (concat "[ \t]*$" "\\|" org-clock-line-re).
I'm not sure of the intention of the first alternative, the "[ \t]*$", but
it matches an empty line, and so the loop advances point to the next line,
until reaching the next heading in the case above.
Removing that from the regexp appears to fix the issue.

If this change is fine, then I am happy to provide a patch.
Thanks,
Ben

[-- Attachment #2: Type: text/html, Size: 937 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] A call of (org-end-of-meta-data t) goes too far in a heading with only whitespace
  2024-10-05  6:52 [BUG] A call of (org-end-of-meta-data t) goes too far in a heading with only whitespace Benjamin McMillan
@ 2024-10-12 11:45 ` Ihor Radchenko
  2024-10-17 11:55   ` Benjamin McMillan
  0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-10-12 11:45 UTC (permalink / raw)
  To: Benjamin McMillan; +Cc: emacs-orgmode

Benjamin McMillan <mcmillanbb@gmail.com> writes:

> Specifically, a call to (org-end-of-meta-data t) with point at the > on the
> following tree will go all the way to the next heading.
> In contrast, a call to just (org-end-of-meta-data), without the FULL flag,
> will go to the beginning of heading content, as expected.
> * >heading
>
>
> * another heading

This is intentional.

We have a test:

  ;; With option argument, skip empty lines, regular drawers and
  ;; clocking lines.
  (should
   (org-test-with-temp-text "* Headline\n\nContents"
     (org-end-of-meta-data t)
     (looking-at "Contents")))

May you please elaborate why you consider the current behavior to be a bug?

-- 
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] 4+ messages in thread

* Re: [BUG] A call of (org-end-of-meta-data t) goes too far in a heading with only whitespace
  2024-10-12 11:45 ` Ihor Radchenko
@ 2024-10-17 11:55   ` Benjamin McMillan
  2024-10-17 17:58     ` Ihor Radchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin McMillan @ 2024-10-17 11:55 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

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

My understanding is that org-end-of-meta-data should put point at the start
of the 'real' contents of a heading. Meaning the first point where I might
start making notes under a heading.

This expectation isn't matched in the example I give (which is different
from the mentioned test). In my example, there is a heading, then several
blank lines, then another heading at the same level as the first. A call to
(end-of-meta-data t) goes all the way to the second heading, which surely
should not count as contents of the first heading. For me, expected
behavior is somewhere inside the contents of the heading.

I presume the test is to capture desired behavior when
org-blank-before-new-entry is true?
If that's correct, then when org-blank-before-new-entry is true, maybe a
call of (end-of-meta-data t) should skip to two lines after the metadata
(possibly adding lines if necessary?)
In contrast, I disable org-blank-before-new-entry, and want point to go
literally to the end of meta data, even if I have some blanks before
existing contents.

I apologize if this seems nitpicky, but the structured nature of an org
document allows for extremely accurate motion commands, and use of
end-of-meta-data is an important part of that.
(And apologies Ihor for resending this to you, I managed to not click
reply-all the first time around.)

On Sat, Oct 12, 2024 at 8:43 PM Ihor Radchenko <yantar92@posteo.net> wrote:

> Benjamin McMillan <mcmillanbb@gmail.com> writes:
>
> > Specifically, a call to (org-end-of-meta-data t) with point at the > on
> the
> > following tree will go all the way to the next heading.
> > In contrast, a call to just (org-end-of-meta-data), without the FULL
> flag,
> > will go to the beginning of heading content, as expected.
> > * >heading
> >
> >
> > * another heading
>
> This is intentional.
>
> We have a test:
>
>   ;; With option argument, skip empty lines, regular drawers and
>   ;; clocking lines.
>   (should
>    (org-test-with-temp-text "* Headline\n\nContents"
>      (org-end-of-meta-data t)
>      (looking-at "Contents")))
>
> May you please elaborate why you consider the current behavior to be a bug?
>
> --
> 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: 3222 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] A call of (org-end-of-meta-data t) goes too far in a heading with only whitespace
  2024-10-17 11:55   ` Benjamin McMillan
@ 2024-10-17 17:58     ` Ihor Radchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-10-17 17:58 UTC (permalink / raw)
  To: Benjamin McMillan; +Cc: emacs-orgmode

Benjamin McMillan <mcmillanbb@gmail.com> writes:

> My understanding is that org-end-of-meta-data should put point at the start
> of the 'real' contents of a heading. Meaning the first point where I might
> start making notes under a heading.

Nope. It should "Skip planning line and properties drawer in current
entry.", as per docstring. In other words, after the
metadata. Sometimes, "after metadata" is on the next headline.

For example, when headline has no contents at all:
* Heading 1
* Immediately heading 2

> I presume the test is to capture desired behavior when
> org-blank-before-new-entry is true?

I doubt so. But I do not know exact reason.

> If that's correct, then when org-blank-before-new-entry is true, maybe a
> call of (end-of-meta-data t) should skip to two lines after the metadata
> (possibly adding lines if necessary?)

> In contrast, I disable org-blank-before-new-entry, and want point to go
> literally to the end of meta data, even if I have some blanks before
> existing contents.

Surely not. (1) I still see not reason to break the existing behavior (and
annoy users used to the existing one); (2) metadata is often followed by
actual text in entry - org-blank-before-new-entry makes 0 sense in such
scenarios; (3) org-end-of-metadata must not edit the buffer. It would be
unexpected.

> I apologize if this seems nitpicky, but the structured nature of an org
> document allows for extremely accurate motion commands, and use of
> end-of-meta-data is an important part of that.

You are free to move back if you are using `org-end-of-meta-data' from
Elisp. This will be just as accurate.

For now, I see no bug in your report. Everything works as per docstring.
Canceled.

I suspect that the problem you are really trying to solve is not with
`org-end-of-meta-data', but with some other function/command that is
using it. If I am right, we may better discuss that problem.

-- 
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] 4+ messages in thread

end of thread, other threads:[~2024-10-17 17:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-05  6:52 [BUG] A call of (org-end-of-meta-data t) goes too far in a heading with only whitespace Benjamin McMillan
2024-10-12 11:45 ` Ihor Radchenko
2024-10-17 11:55   ` Benjamin McMillan
2024-10-17 17:58     ` Ihor Radchenko

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