info-gnus-english
[Top][All Lists]
Advanced

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

Re: font-locked Gnus browse server


From: Tassilo Horn
Subject: Re: font-locked Gnus browse server
Date: Sat, 16 May 2015 09:33:11 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

>> I think the reason why you need to trigger
>> font-locking explicitly using
>> `font-lock-fontify-buffer' (or `font-lock-ensure')
>> is that `gnus-browse-mode' doesn't set
>> `font-lock-defaults' which would be used to
>> initialize `font-lock-keywords'.
>
> You mean like this?
>
>     (defvar gnus-browse-font-lock-keywords
>       '(("^K"                       . font-lock-builtin-face)
>         ("\\([[:digit:]].*\\):"    (1 font-lock-function-name-face))
>         ("\\(gmane\\.\\)\\(.*\\)"  (1 font-lock-comment-face)
>                                    (2 font-lock-variable-name-face) )
>         ("\\(gwene\\.\\)\\(.*\\)"  (1 font-lock-constant-face)
>                                    (2 font-lock-type-face)) ))
>
>     (defun gnus-browse-mode-hook-f ()
>       (set (make-local-variable 'font-lock-defaults)
>            '(gnus-browse-font-lock-keywords t)) )
>     (add-hook 'gnus-browse-mode-hook 'gnus-browse-mode-hook-f)

Yes, this could also work.  BTW, `font-lock-defaults' is automatically
buffer-local, no need to make it so.

>> So calling `font-lock-add-keywords' with MODE = nil
>> will also trigger font-lock, and indeed ...
>>
>> th/gnus-browse-mode-init () (font-lock-add-keywords
>> nil ... )
>>
>> (add-hook 'gnus-browse-mode-hook
>> #'th/gnus-browse-mode-init)
>>
>> does work for me.
>
> With MODE as nil the font lock is done one the basis
> of the current buffer. It is not related to the mode
> itself apart from the invocation being placed in the
> mode entry hook. This means the keywords have to be
> added every time the mode is entered.

Yes, but that doesn't make a difference, no?

Bye,
Tassilo




reply via email to

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