3

I'm trying to create a realtime/WYSIWYG editor for LaTeX fragments -- the general idea is that at each move of point / edit of the fragment, the overlay should update to reflect the newly changed fragment, including a cursor symbol indicating where point is now.

However, it's impossible to move point into an image overlay -- any command that would end up inside the overlaid region is preempted so that point ends up at the end of the overlay.

Is there any way to override this behavior so that point can be inside of the overlaid region? I know I can do this XWidgets but I would prefer that the solution be compatible with the built-in fragment preview mechanism that org offers, which uses overlays.

An example of the behavior that I'm talking about: Run the following function with some image, with point at 1:

(defun image-overlay-minimal-repro ()
  (interactive)
  (let ((ov (make-overlay (point) (+ (point) 10))))
    (overlay-put ov
                 'display
                 (list 'image :type 'png :file "~/Downloads/dog-png-dog-png-image-267.png"))))

; 1234567890 test test

The image overlay will occlude all the digits, and it only takes one motion of point to cross the entire overlay. I want it to take 10 movements of point.

Cardano
  • 163
  • 6
  • This doesn't sound right. Can you provide a minimal example showing that behavior? – wasamasa May 21 '19 at 18:16
  • @wasamasa please see the minimal repro – Cardano May 21 '19 at 19:03
  • @Cardano, I am curious, do you have code anywhere related to this endeavor? I was just thinking how nice it'd be to do image occlusion in org-mode directly since we can do screenshots from there already. Combined with org-drill we'd have an anki + image occlusion replacement. – Joe Jun 12 '19 at 23:29
  • @Joe No, I haven't published anything yet since it's still a work in progress. Here's a gist demonstrating the rough idea, though: https://gist.github.com/johnbcoughlin/de5586229ae843c3c523089eee226e59 – Cardano Jun 13 '19 at 14:59
  • @Cardano, thanks for sharing that – Joe Jun 13 '19 at 21:07

2 Answers2

3

I believe you are looking for the variable disable-point-adjustment. You will want to read its docstring to better understand how you want to use it (i.e. you'll have to reset it every time point "enters" one of those overlays).

Stefan
  • 26,154
  • 3
  • 46
  • 84
-2

No, this isn't possible. To quote the manual ("Replacing Specs"):

Some kinds of display specifications specify something to display instead of the text that has the property. These are called “replacing” display specifications. Emacs does not allow the user to interactively move point into the middle of buffer text that is replaced in this way.

You'd instead have to track attempts at the user moving point inside the overlay and at which point of the text they'd be at, then update the image accordingly. Overlays have a keymap attribute that can be used for that purpose.

wasamasa
  • 21,803
  • 1
  • 65
  • 97