[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Font-lock is limited to text matching" is a myth

From: Lennart Borgman
Subject: Re: "Font-lock is limited to text matching" is a myth
Date: Tue, 11 Aug 2009 17:08:18 +0200

On Tue, Aug 11, 2009 at 4:53 PM, Daniel Colascione<address@hidden> wrote:

> Don't forget the undo entries too. Actually, the full list comes from
> font-lock.el:
> (defmacro save-buffer-state (varlist &rest body)
>    "Bind variables according to VARLIST and eval BODY restoring buffer
> state."
>    (declare (indent 1) (debug let))
>    (let ((modified (make-symbol "modified")))
>      `(let* ,(append varlist
>                      `((,modified (buffer-modified-p))
>                        (buffer-undo-list t)
>                        (inhibit-read-only t)
>                        (inhibit-point-motion-hooks t)
>                        (inhibit-modification-hooks t)
>                        deactivate-mark
>                        buffer-file-name
>                        buffer-file-truename))
>         (progn
>           ,@body)
>         (unless ,modified
>           (restore-buffer-modified-p nil)))))

And JIT lock takes care of errors too:

(defmacro jit-with-buffer-unmodified (&rest body)
  "Eval BODY, preserving the current buffer's modified state."
  (declare (debug t))
  (let ((modified (make-symbol "modified")))
    `(let ((,modified (buffer-modified-p)))
           (progn ,@body)
         (unless ,modified
           (restore-buffer-modified-p nil))))))

(defmacro with-buffer-prepared-for-jit-lock (&rest body)
  "Execute BODY in current buffer, overriding several variables.
Preserves the `buffer-modified-p' state of the current buffer."
  (declare (debug t))
    (let ((buffer-undo-list t)
          (inhibit-read-only t)
          (inhibit-point-motion-hooks t)
          (inhibit-modification-hooks t)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]