Understanding (some) Lisp (was: Re: text editors)
- Date: Thu, 28 Mar 2019 12:00:44 -0400
- From: rhkramer@xxxxxxxxx
- Subject: Understanding (some) Lisp (was: Re: text editors)
<Intentionally top posting -- I think it works better for this case...>
As an exercise for myself (having once had to "learn" Lisp in school, and more
than once having tried to learn to use EMACS (before the days of the mouse and
menu, iirc)), I decided to see if I could understand any of the code.
I think I got the gist of most of it, but I don't understand why the double
parenthesis around "((inhibit-read-only t))"?
On Monday, March 25, 2019 08:29:17 AM Teemu Likonen wrote:
> 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
> (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."
> (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