Web lists-archives.com

Re: text editors




On 2019-03-25 12:29, Teemu Likonen wrote:
mick crane [2019-03-25 04:38:31Z] wrote:

Is there any text editor, preferably in a terminal that has the facility
to protect lines in the document, not the document itself ?
I've got 2 blocks of "code" that look similar and I keep editing the
wrong one and then it doesn't work.

GNU Emacs has text properties which can be added to any piece of text.
One of the properties is named "read-only". I made two functions to
handle the situation you described.

Put these function to you Emacs's init file (~/.emacs or
~/.emacs.d/init.el):


    (defun read-only-region (beg end)
      "Makes a region in the current buffer read only, from buffer
    position BEG to END. If this function is called interactively use
    the current hightlighted region."
      (interactive "r")
      (add-text-properties beg end '(read-only t)))

    (defun remove-read-only ()
      "Remove all read only text properties from the current buffer."
      (interactive)
      (let ((inhibit-read-only t))
        (remove-text-properties (point-min) (point-max)
                                '(read-only t))))


Select some text in a buffer and execute command "Alt+x
read-only-region". That area becomes read only. To remove all read only
text areas from the current buffer execute command "Alt+x
remove-read-only".

there it is then, although I've so far managed to avoid Emacs since heard it is more of an operating system than an editor.

mick
--
Key ID    4BFEBB31