Ihor Radchenko <[email protected]> writes: > Ihor Radchenko <[email protected]> writes: > >> "J.D. Smith" <[email protected]> writes: >> >>> Perhaps finding the *topmost* emphasis/link ancestor is the right >>> approach; can anyone recommend a way to do that? >>> >>> Currently using: >>> >>> (when-let* ((ctx (org-element-context))) >>> (org-element-lineage ctx '( link bold code italic verbatim >>> underline strike-through) t)) >> >> topmost makes sense, especially considering the cursor shape. > > I have played a bit with nested emphasis like > [[foo][bar *baz* az]] and the defaults can make things a bit confusing > when editing the link description. Maybe there should be several cursor > shapes depending on the depth level? Although it is probably going to be > confusing.
Yeah I see: exactly the same ambiguity occurs "one level down". How deeply can emphasis/links/etc. be nested? An idea to solve this that picks up on the new "topmost behavior": use two overlays. The main overlay would cover the topmost entity and override the cursor-sensor to govern visibility and cursor type. The second overlay would be brought in (if face appearance changes are requested) to modify the face for the /innermost/ entity at point. In your example, you'd see `baz' underlined (only) when "inside" it, otherwise, the entire link would be underlined. For single depth elements, these overlays would obviously perfectly overlap. As an optimization, if the topmost is the innermost (max-depth=1), just one overlay would be brought in (as now). This would probably work conveniently only with emacs v31, which (as you discovered) provides the `moved' event to cursor-sensor functions, which we can use to update the "inner overlay" in real time. I'll give it a try and we can see how we like it. As far as the defaults, I've been using: '(org-inside-appearance '(:cursor bar :face (:underline "magenta") :unhide nil)) for a few weeks and generally like it. We'd need some appropriate org color or face.
