emacs-devel
[Top][All Lists]
Advanced

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

Re: [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-l


From: Stefan Monnier
Subject: Re: [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-lock-fontify-now
Date: Sun, 07 Feb 2016 22:09:46 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

>>> -            (jit-lock-fontify-now (min beg end) (max beg end))))
>>> +            (font-lock-fontify-region (min beg end) (max beg end))))
>> Maybe even better would be to use font-lock-ensure (when available)?
> It's unclear to me what's the difference between font-lock-ensure and
> font-lock-fontify-region.

font-lock-fontify-region will use font-lock rules and apply them to the
specified region, regardless of what happened before, and without
keeping track of the fact that those rules were applied there.
It's mostly an internal function in font-lock.

font-lock-ensure simply asks Emacs to make sure that the specified
region has had font-lock rules applied.  It's a function specifically
designed to be used by external packages.

> It seems that font-lock-ensure is relatively new, introduced in 24.4,

Indeed, it's brand new.

> so maybe not quite yet depend on it on an ELPA package.

(fboundp 'font-lock-ensure) will take care of that.

> There are some "alias wrappers" like below in Emacs code so maybe I'll
> use similar with wcheck-mode.
>     (eval-when-compile
>       (defalias 'wcheck--fontify-region
>         (if (fboundp 'font-lock-ensure)
>             'font-lock-ensure
>           'font-lock-fontify-region)))

You can use that  [ Tho, note that eval-when-compile is wrong here:
this function will be needed at run-time, not at compile time.  ]
But if there's only a single cal to that function, you might as well
inline it at its only call site.


        Stefan



reply via email to

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