Ihor Radchenko <[email protected]> writes:

Hello, Ihor, all!

>> +(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.
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.

Maybe both org-backward/forward-sentence and sentence-at-point should be
controlled by yet another variable, like a new
org-sentence-stops-at-element-limits that takes something like '(item
paragraph src-block) or can be nil? Or maybe it's better to just use the
item boundaries...

Also, does it make sense to remove the list prefix when returning
(sentence-at-point) so that we don't have dashes in the middle?
I can modify the patch to have that behavior if desired.

> Also, with your patch, try
>
> - Some
> - are<point>
> - over several lines!
> That will give unexpected result "are\n- over several lines!"

(org-backward-sentence) has the same behavior; it just goes to the
beginning of "are". Should I look into modifying how that works too, do
we want to keep the same behaviour, or do we want to treat the item
limits as the start or end of the sentence?

Sacha

Reply via email to