4

Is there any way to forbid insertion of text before and after specific overlay? (I mean on the same line that displays overlay.) Forbid means that either changes cancelled somehow or immediately reverted, or something like this. I'm ready to consider other options as well.

4
  • Perhaps there's a read-only property for the overlay?
    – Dan
    Sep 6, 2015 at 20:05
  • @Dan, I don't see it here. Sep 6, 2015 at 20:12
  • 1
    I believe this: emacs.stackexchange.com/questions/13592/… should help.
    – wvxvw
    Sep 6, 2015 at 20:40
  • @wvxvw, this is definitely useful link. I'll try to experiment and see if it does what I want. According to that answer I can set text properties of text from beginning of line till overlay and from end of overlay to end of line so that these regions are indeed "read-only". Sep 6, 2015 at 20:46

1 Answer 1

2

Indeed @Dan's advice helped me. My final solution is:

  1. Mark all text beginning one character before overlay (that is including newline before it) and ending where overlay ends as read-only:

    (set-text-properties (1- beg) end '(read-only t))
    
  2. Now create overlay.

  3. When it's time to remove overlay don't forget to remove read-only property as well:

    (let ((inhibit-read-only t))
      (remove-text-properties (1- beg) end '(read-only nil)))
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.