Ihor Radchenko <[email protected]> writes:

> "J.D. Smith" <[email protected]> writes:
>
>>> That is only commented out for the purposes of 'invisible stickiness.
>>> But we can limit stickiness to 'cursor-sensor-functions by setting the
>>> value of 'rear-nonsticky to a list of properties.
>>
>> I don't follow you here.  Beyond cursor-sensor-functions, we do in fact
>> need to add 'invisible non-stickiness at visible-beg/end locations, to
>> achieve normal point adjustment driven movement on each side.  On v31+,
>> the latter (visible-end) is already done for us by:
>
> I see. I thought that you only need this for 'cursor-sensor-functions.
> I am a bit confused why you need read-nonsticky for invisible.
> It is commented now and does not cause any issues. Does org-inside
> change anything in this regard?

Yes.  It's a subtle point related to point adjustment (emphasis added).

| 22.6 Adjusting Point After Commands
| ===================================
| 
| This _point adjustment_ follows the following general rules: first, the
| adjustment should not change the overall direction of the command;
| second if the command moved point, the adjustment tries to ensure the
| cursor is also moved; third, Emacs prefers the edges of an intangible
| sequence and [among those edges it prefers the non sticky ones], such
| that newly inserted text is visible.

Try these in a tmp buffer:

#1
 (insert "\n " (propertize "*" 'invisible 'tmp) "VISIBLE"  (propertize "*" 
'invisible 'tmp) " after")
#2
 (insert "\n " (propertize "*" 'invisible 'tmp 'rear-nonsticky '(invisible)) 
"VISIBLE-RNS"
  (propertize "*" 'invisible 'tmp 'rear-nonsticky '(invisible))  " after")

Move point around near the visible text boundary from both directions
for the two cases and inspect (point).  You will find that only #2
allows the "one apparent cursor position, different (point) values"
behavior we make use of.  #1 will simply not allow point to land on
certain buffer positions.  E.g. the "adjacent, but outside" position at
the end of the visible text will be wholly inaccessible in #1.

#2 works like org-inside.  As you move to the "boundary point of
 ambiguity":

- approach from inside: stay inside
- approach from outside: stay outside

>> Are you proposing to uncomment the line in org.el:
>>
>>  ;; (org-rear-nonsticky-at (match-end 3))
>>
>> That would remove the need for #2, not the others.  Or something else?
>
> I am proposing
> (add-text-properties (1- pos) pos (delq 'invisible (list 'rear-nonsticky 
> org-nonsticky-props)))

I see.  So effectively org-rear-nonsticky-at for everything _but_
'invisible.  For the reasons described above, this will not work: we
need rns+=invisible to achieve the necessary point adjustment behavior.
It's the important member of 'org-nonsticky-props for us.

> The reason that line is commented is the problem discussed in the linked
> bug report where M-b behaves differently depending on whether we hide or
> do not hide emphasis markers.

We need it possibly for the same reason others saw adding it as inducing
a bug (it alter point adjustment behavior)!  Of course we are working
with hidden markers consistently.

Reply via email to