emacs-devel
[Top][All Lists]
Advanced

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

Re: What to do when font-lock-flush + font-lock-ensure do less than font


From: Kaushal Modi
Subject: Re: What to do when font-lock-flush + font-lock-ensure do less than font-lock-fontify-buffer?
Date: Mon, 22 Feb 2016 11:35:58 -0500


On Mon, Feb 22, 2016 at 11:29 AM, Clément Pit--Claudel <address@hidden> wrote:
In any case where font-lock-fontified is nil font-lock-fontify-buffer will properly refontify the whole buffer, but font-lock-flush and font-lock ensure will not do anything. I don't know what causes that variable to be nil in the first place, though.

I am not sure if this is related. But in order for hi-lock-file-patterns to work in a text-mode buffer, I need to do the below because font-lock-fontified is nil for text-mode (as technically there are no comments or keywords to highlight in that major mode).

    ;; Enable `hi-lock-mode' in `text-mode' too
    ;; The hi-lock fontification will not be visible (the `font-lock-keywords'
    ;; variable will not be updated unless `font-lock-fontified' is already `t'.
    ;; This was derived by studying the definition of `hi-lock-font-lock-hook'
    ;; function.
    (defun modi/hi-lock-enable-in-text-mode ()
      (setq-local font-lock-fontified t))
    (add-hook 'text-mode-hook #'modi/hi-lock-enable-in-text-mode)

--
Kaushal Modi

reply via email to

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