2

I know it's possible to make a "portion" of a buffer read-only. As an effect, the whole line becomes uneditable. What I would like it to make a specific region uneditable, for exemple a rectangle region :

- item n°1 (uneditable) : "editable part 1"
- item n°2 (uneditable) : "editable part 2"
- and so on.

I'm pretty sure it's something customizable but I'm not well acquainted with elisp yet. Thanks for your insights.

3

1 Answer 1

2

It sounds like you very specifically want this for rectangles, rather than for "specific regions".

You can combine https://emacs.stackexchange.com/a/10093/454 (which works on a region) with these rectangle commands:

(defun set-rectangle-read-only (begin end)
  "`set-region-read-only' on a rectangle."
  (interactive "r")
  (save-excursion
    (apply-on-rectangle
     (lambda (startcol endcol)
       (set-region-read-only
        (progn (move-to-column startcol) (point))
        (progn (move-to-column endcol) (point))))
     begin end)))

(defun set-rectangle-writeable (begin end)
  "`set-region-writeable' on a rectangle."
  (interactive "r")
  (save-excursion
    (apply-on-rectangle
     (lambda (startcol endcol)
       (set-region-writeable
        (progn (move-to-column startcol) (point))
        (progn (move-to-column endcol) (point))))
     begin end)))

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.