Jens Schmidt <[email protected]> writes:

> On 2026-05-01  16:48, J.D. Smith wrote:
>
>> Please find branch feature/org-inside, which implements a new minor mode
>> to assist with precise editing of hidden-marker-wrapped text —
>> `org-inside-mode'.  This mode changes the appearance when point is
>> inside hidden markers text (for now, just `org-emphasis'), relieving the
>> ambiguity when point is adjacent to such text.> > Appearance change options 
>> include:
>
> Thanks for your work!  I have been toying around with something similar
> in my init file and I hope your approach is better ... so when I write
> "my mode" I refer to my experiments, "your mode" denotes what you have
> in feature/org-inside.
>
>
> - I get warnings when compiling with Emacs 28, which is my default
>   for *compiling* Org mode (but not for executing it):
>
>     Compiling single /home/jschmidt/work/org-mode/lisp/org-inside.el...
>
>     In toplevel form:
>     org-inside.el:135:1: Warning: variable ‘_’ not left unused
>     org-inside.el:145:1: Warning: variable ‘_’ not left unused
>     org-inside.el:153:1: Warning: variable ‘_’ not left unused
>
>     In end of data:
>     org-inside.el:110:12: Warning: the function ‘set-window-cursor-type’ is 
> not
>         known to be defined.
>     org-inside.el:104:24: Warning: the function ‘window-cursor-type’ is not 
> known
>         to be defined.

Thanks for your thoughts.  I'm sorry, I should have mentioned this
requires Emacs v30+.  I also didn't see what `org-inside-appearance'
settings you are using.

> Here is my reference Org mode document.  I denote point as "|" in
> further examples and regions as "[...]".
>
> -------------------------
> Foo =bar0 bar1 bar2= baz.
> -------------------------
>
> The visible display of that (or other examples), i.e. how it looks with
> invisible characters not being shown (aka. `org-copy-visible') I denote
> surrounded by equal signs thusly:
>
> =========================
> |Foo bar0 bar1 bar2 baz.
> =========================
>
> - When I switch on `o-i-m' at point-max in the reference example and
>   then move backward with C-b, I get in the *Message* buffer:
>
>     cursor-sensor--detect: (wrong-type-argument integer-or-marker-p nil) [4 
> times]

Can you `M-x toggle-debug-error' and report the backtrace?  Maybe just
buffer bounds.

>   when I move point near the trailing emph marker.
>
> - Ok, here is another thing I'd call a real bug.  But I need a different
>   example:
>
> -------------------------
> - Foo =bar0 bar1 of bar2= baz.
>
> - Foo =bar0 bar1 of bar2= baz.
> -------------------------
>
>   Place point at the second item bullet, then move backward (7 * C-b).
>   For me that results in:
>
> =========================
> - Foo bar0 bar1 of bar2=| baz.
>
> - Foo =bar0 bar1 of bar2 baz.
> =========================
>
>   And not in expected:
>
> =========================
> - Foo =bar0 bar1 of bar2=| baz.
>
> - Foo bar0 bar1 of bar2 baz.
> =========================
>
>   That is, your mode "focuses" the wrong/inverse region.

I repeated this experiment and it works entirely as expected, so I don't
understand what could be wrong on your end.  Maybe it's an emacs v28
thing (I don't have it to test).  But note, this is not a valid
configuration with visible markers for org-inside:

> - Foo =bar0 bar1 of bar2=| baz.

You perhaps meant:

> - Foo =bar0 bar1 of bar2|= baz.

?  In any case, could you try again with Emacs v30 and let me know if
things change?

> The following are not really bugs in your mode, but they will let me
> keep my mode around:
>
> - My mode kicks in one character before the leading emph marker and one
>   character after the trailing one.  So with my mode point being in the
>   region "[...]" shows the markers:

That means your mode kicks in when point is not *yet* inside, which
breaks the mode's invariant (see below).

>     Foo[ =bar0 bar1 bar2=] baz.
>
>   With your mode it's like this:
>
>     Foo =[bar0 bar1 bar2]= baz.
>
>   Obviously, I prefer my mode's behavior, since it lets me easily add
>   text on all sides of the markers.

But you can easily add text precisely outside the markers!  If point
appears adjacent and the markers do not appear, you can be confident you
are outside the markers.  Inside/Outside.  That's the mental model of
org-inside.  The reason why makes more sense when you just change the
cursor or add a face, like '(:face (:underline "magenta")).  I.e. do
this instead of showing the markers (which to me is pretty jarring since
I use visual line wrapping and text jumps around).

> - My mode is consistent when the markers are shown and hidden, yours not
>   always.  It shows markers if point is here:
>
>     Foo =[bar0 bar1 bar2]= baz.
>
>   But hides them if point is in this region:
>
>     Foo [=bar0 bar1 bar2= ]baz.
>
>   Where the "[" one is expected, the "]" one not.

My mode is fully consistent with the following invariant: it shows
markers *if an only if* point is _inside_ the hidden markers.  By inside
I mean a character added at that point would be part of the
marker-wrapped text.  Is that not what you are finding?

I admit I am having trouble parsing your descriptions, so I'm not sure
if you are experiencing real issues, or are perhaps just confused by
(intended) behavior that differs from what you are used to.

>   To clarify: I expect that the combo C-f C-b *before* the leading emph
>   marker shows and hides again the markers (which it does) and C-b C-f
>   *after* the leading emph marker also shows and hides the markers.
>   Which it does not, I need C-b C-f and a second C-f.

That is certainly not intended behavior, and should not be the
case.  Using [X] to denote point, I see:

  Foo [X][bar0 bar1 bar2] baz (outside: no markers; C-f)
  Foo =[X][bar0 bar1 bar2]= baz (inside: markers; C-b)
  Foo [X][bar0 bar1 bar2] baz (outside: no markers; C-f)
  Foo =[X][bar0 bar1 bar2]= baz (inside: markers)

and similar on the RHS.  I'm not clear from your description if you are
seeing anything different.

Reply via email to