unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-lock-fontify-now
       [not found] ` <E1aPaDu-0002jJ-Ei@vcs.savannah.gnu.org>
@ 2016-01-31  0:45   ` Stefan Monnier
  2016-02-07 10:10     ` Teemu Likonen
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2016-01-31  0:45 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: emacs-devel

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


        Stefan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-lock-fontify-now
  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
  0 siblings, 2 replies; 5+ messages in thread
From: Teemu Likonen @ 2016-02-07 10:10 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

Stefan Monnier [2016-01-30 19:45:23-05] wrote:

>> -            (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. It seems that font-lock-ensure is relatively
new, introduced in 24.4, so maybe not quite yet depend on it on an ELPA
package.

Are there established practices for writing a compatibility code in
situations like this? Perhaps calling a custom function
wcheck--fontify-region and having code like below?

    (eval-when-compile
      (if (fboundp 'font-lock-ensure)
          (defalias 'wcheck--fontify-region 'font-lock-ensure)
        (defun wcheck--fontify-region (beg end)
          (font-lock-fontify-region beg end))))

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-lock-fontify-now
  2016-02-07 10:10     ` Teemu Likonen
@ 2016-02-07 10:56       ` Teemu Likonen
  2016-02-08  3:09       ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Teemu Likonen @ 2016-02-07 10:56 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 503 bytes --]

Teemu Likonen [2016-02-07 12:10:55+02] wrote:

> Are there established practices for writing a compatibility code in
> situations like this? Perhaps calling a custom function
> wcheck--fontify-region and having code like below?

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-lock-fontify-now
  2016-02-07 10:10     ` Teemu Likonen
  2016-02-07 10:56       ` Teemu Likonen
@ 2016-02-08  3:09       ` Stefan Monnier
  2016-02-08 19:24         ` Teemu Likonen
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2016-02-08  3:09 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: emacs-devel

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [elpa] master 19862ff: Use font-lock-fontify-region instead of jit-lock-fontify-now
  2016-02-08  3:09       ` Stefan Monnier
@ 2016-02-08 19:24         ` Teemu Likonen
  0 siblings, 0 replies; 5+ messages in thread
From: Teemu Likonen @ 2016-02-08 19:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

Stefan Monnier [2016-02-07 22:09:46-05] wrote:

>>         (if (fboundp 'font-lock-ensure)
>>             'font-lock-ensure
>>           'font-lock-fontify-region)))

> But if there's only a single cal to that function, you might as well
> inline it at its only call site.

Ok, thanks. I'll push the simple version.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-02-08 19:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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
2016-02-08 19:24         ` Teemu Likonen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).