1

In Emacs I am using cm-mode with markdown buffers. cm-mode inserts a few read-only characters to indicate document changes. When I issue fill-paragraph the fill is aborted with the message read-only Text.

Is there a way to fill a paragraph containing a few read-only characters? (I.e. after the fill the read-only characters should be read-only again.)

Drew
  • 29,895
  • 7
  • 74
  • 104
halloleo
  • 9,216
  • 13
  • 64
  • 122

1 Answers1

2

Bind or temporarily set inhibit-read-only to non-nil. C-h v tells us:

inhibit-read-only is a variable defined in C source code.

Its value is nil

Documentation:

Non-nil means disregard read-only status of buffers or characters.

If the value is t, disregard buffer-read-only and all read-only text properties. If the value is a list, disregard buffer-read-only and disregard a read-only text property if the property value is a member of the list.

Drew
  • 29,895
  • 7
  • 74
  • 104
  • It works! Thanks. - I just defined `(defun disregard-read-only () (interactive) (setq inhibit-read-only t)), but is there a predefined function/package for this? – halloleo Sep 11 '19 at 07:05
  • No command by default, that I know of. Just `M-: (setq inhibit-read-only t)`. But typically you want instead to *bind* it only in the context of some function, rather that setting it. – Drew Sep 11 '19 at 13:53
  • 1
    Great idea: I can have my own `my-fill-paragraph` that binds `inhibit-read-only` first! - Still very annoying that cm-mode forces me to do this... – halloleo Sep 11 '19 at 14:05