"J.D. Smith" <[email protected]> writes: >> Maybe it can also be a basis to have multiple ways to handle >> invisible boundaries - cursor change, org-appear-like reveal of the link >> at point, relealing the whole line. > > I think that would be possible. How stable is org's font-locking code? > I don't know how org-appear works, but this new cursor-sensor approach > has the advantage of just requiring another property to be added during > font-locking — no live property edits required.
Org's font-locking code does not change much, but it will be eventually completely rewritten. I had some experiments earlier with using org-fold to hide parts of links, but that did not work very well and got reverted. However, the specific invisibility properties applied should be fairly stable. > Presumably an alternate cursor-sensor function could instead temporarily > remove/restore the invisible properties at point when you enter/exit, > but when you make edits, font lock will come calling again... > Actually there is one trick I thought of to make an edit-free "appear" > flavor that would work in the same way: > > 1. Hide entity/link/keyword/etc. markers using a custom `invisible' > symbol, e.g. `org-hide', which is on the `buffer-invisibility-spec'. > > 2. When entering text flanked by hidden boundaries, apply an overlay > which specifies another bogus `invisible' symbol, like `org-nada', > one that is /not/ on the `buffer-invisibility-spec' list. Can simply specify 'invisible nil. > I think that would work pretty nicely. In fact, you could have one, the > other, or both features (cursor change + unhide). I can work something > up soon. Is there a release version I should be targeting? The next release will be Org 10.0. > Simple demo with both features: > > (setq-local buffer-invisibility-spec '(org-hide) > my/ov (make-overlay 0 0 nil nil t)) > (overlay-put my/ov 'invisible 'org-nada) > (cursor-sensor-mode 1) > > (defun my/appear-sensor (_win _pos type) > (if (eq type 'entered) > (let ((beg (1- (previous-single-property-change (1+ (point)) > 'cursor-sensor-functions))) > (end (next-single-property-change (1- (point)) > 'cursor-sensor-functions))) > (move-overlay my/ov beg end) > (setq cursor-type 'bar)) > (setq cursor-type 'box) > (move-overlay my/ov 0 0))) > > (let* ((star (propertize "*" 'invisible 'org-hide 'rear-nonsticky > '(invisible))) > (ent (propertize (concat "FOO" star) 'cursor-sensor-functions > '(my/appear-sensor)))) > (dotimes (_ 3) (insert "\n" "Some " star ent " or another"))) This feels weird: 1. Only one star gets revealed 2. Moving -> out of the emphasis followed by <- feels not right -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>
