all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Teemu Likonen <tlikonen@iki.fi>
Cc: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <jwvy4avykd5.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <874mdkltjk.fsf@iki.fi> (Teemu Likonen's message of "Sun, 07 Feb 2016 12:10:55 +0200")

>>> -            (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



  parent reply	other threads:[~2016-02-08  3:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20160130182614.10459.39544@vcs.savannah.gnu.org>
     [not found] ` <E1aPaDu-0002jJ-Ei@vcs.savannah.gnu.org>
2016-01-31  0:45   ` [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-lock-fontify-now Stefan Monnier
2016-02-07 10:10     ` Teemu Likonen
2016-02-07 10:56       ` Teemu Likonen
2016-02-08  3:09       ` Stefan Monnier [this message]
2016-02-08 19:24         ` Teemu Likonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy4avykd5.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=tlikonen@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.