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.

  • Perhaps there's a read-only property for the overlay? – Dan Sep 6 '15 at 20:05
  • @Dan, I don't see it here. – Mark Karpov Sep 6 '15 at 20:12
  • 1
    I believe this: emacs.stackexchange.com/questions/13592/… should help. – wvxvw Sep 6 '15 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". – Mark Karpov Sep 6 '15 at 20:46
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)))
    
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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