Sacha Chua <[email protected]> writes:
> Ihor Radchenko <[email protected]> writes:
>>> +(ert-deftest test-org/thing-at-point/sentence ()
>>> +  "Test that `thing-at-point' returns the sentence at point."
>>> +  (org-test-with-temp-text
>>> +   "This sentence is before the list.  There's one here.  This is a test:
>>> +
>>> +- Is this the first sentence?  There is another.
>>> +- This is the third sentence.
>>> +- Some
>>> +- are
>>> +- over several lines!
>> I am wondering whether it is correct to return sentence constructed from
>> multiple items.
>
> I'm happy to constrain it to the current item (which is how I personally
> think of it, too), but org-forward-sentence goes beyond item boundaries,
> so I felt like I should start by following the same semantics.

Same semantics sounds like a good thing, and org-forward-sentence should
in turn probably behave like forward-sentence, modulo Org syntax.

> For example, if you call org-forward-sentence from the beginning of
> "are" in the following list, you end up after the "!".
>
> - Some
> - are
> - over several lines!
> - Here is another sentence.
>
> I can imagine a situation when I want it to be limited to the current
> item, and when I want it to go beyond. For example, I originally came
> across this behavior when I was trying to split up sentences from both
> paragraphs and lists for practising a foreign language, and some of the
> list items were phrases instead of sentences, so it would make sense to
> keep the items separate. On the other hand, sometimes you just break up
> a sentence into several bullet points for readability, but you want to
> treat it as a single sentence logically.

I think this is the right behavior. If the user wants list items to be
treated as complete sentences, they can use end punctuation.

Perhaps this example is easier to think with, as it's unequivocally all
one sentence, though it spans three Org elements:

  Remember to bring
  - a raincoat
  - warm socks
  - a packed lunch
  with you on the hike.

In Org mode, with point somewhere on "- a raincoat",
org-forward-sentence will move point all the way to the end of the
sentence. That's a useful behavior here, and I think it's fine in
general too: If a user /wants/ list items to be treated as full
sentences, they can add end punctuation.

(List styles will differ between languages and style guides, and we
probably cannot cater to all of them, but this seems like a sane
heuristic, at least.)

The above example raises a different question, though: With point
somewhere on "Remember to bring", org-forward-sentence moves point only
to the end of that paragraph element, even though it has no end
punctuation (and isn't a complete sentence). However, it does not have
not have a problem including the paragraph element /after/ the list,
with or without a blank line between them. It would be satisfying if it
could handle the preceding one too.

(Outside Org mode, forward-sentence moves point all the way from the
beginning to the end of the sentence, probably because it doesn't know
what a list is anyway. It doesn't work if we set off the list with blank
lines, though.)

Regards,
Christian

Reply via email to