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:
>
>    - Changing the cursor type (e.g. box to bar).
>    - Temporarily un-hiding the hidden markers (à la `org-appear').
>    - Altering the face of the wrapped text itself (e.g. a special color
>      `:underline').
>
> These options can be combined freely.  The mode uses
> `cursor-sensor-functions', applied via font-lock, and a lazily created
> per-window overlay for unhiding/face alterations.  An additional hook
> `org-do-emphasis-hook' and a list of properties to clear
> `org-extra-unfontify-properties' support this from org's font-lock side.
>
> Give a try; feedback welcome.  One question is if this should be
> targeted for v31 only, in which case the
> `window-buffer-change-functions' are simpler.

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.

  Not sure whether Emacs 28 is still supported for Org mode, though.

All following tests done in something close to Emacs master with

  make EMACS=~/work/emacs-stable/src/emacs vanilla

Plus:

- (setq org-hide-emphasis-markers t)

- (setq org-inside-appearance '(:unhide t))

- M-x org-inside-mode

(Obviously, I'm mainly interested in auto-unhiding the emphasis
markers.  Which is also the only thing my mode really does, TBH.)

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]

  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.

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:

    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.

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

  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.

I have more ideas and comments if you're interested, but I thought above
is already quite enough.


Reply via email to