GNU bug report logs - #10063
24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!

Previous Next

Packages: emacs, gnus;

Reported by: Leo <sdl.web <at> gmail.com>

Date: Wed, 16 Nov 2011 12:31:05 UTC

Severity: normal

Found in version 24.0.91

Fixed in version 24.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10063 in the body.
You can then email your comments to 10063 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to larsi <at> gnus.org, bug-gnu-emacs <at> gnu.org:
bug#10063; Package emacs. (Wed, 16 Nov 2011 12:31:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Leo <sdl.web <at> gmail.com>:
New bug report received and forwarded. Copy sent to larsi <at> gnus.org, bug-gnu-emacs <at> gnu.org. (Wed, 16 Nov 2011 12:31:05 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Leo <sdl.web <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Wed, 16 Nov 2011 20:29:12 +0800
I am seeing this warning in Gnus.
,----
| Making font-lock-mode-hook buffer-local while locally let-bound!
`----

which seems to relate to line 602 in mm-view.el

601:	    ;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
602:	    (font-lock-mode-hook nil)
603:	    (font-lock-support-mode nil)

Leo




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10063; Package emacs. (Wed, 16 Nov 2011 14:51:01 GMT) Full text and rfc822 format available.

Message #8 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Leo <sdl.web <at> gmail.com>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, 10063 <at> debbugs.gnu.org
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Wed, 16 Nov 2011 09:49:37 -0500
> I am seeing this warning in Gnus.
> ,----
> | Making font-lock-mode-hook buffer-local while locally let-bound!
> `----

> which seems to relate to line 602 in mm-view.el

> 601:	    ;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
> 602:	    (font-lock-mode-hook nil)
> 603:	    (font-lock-support-mode nil)

BTW, these should not be let-bindings but buffer-local bindings.

Also the mode-setting and font-locking should be wrapped in
with-demoted-errors so that errors in them don't prevent showing the
attachment's content.

Finally, font-lock-maximum-size should not be set to nil: there is
nothing special about font-locking attachments that makes it more
desirable to font-lock them entirely than normal files.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#10063; Package emacs,gnus. (Mon, 21 Nov 2011 19:40:01 GMT) Full text and rfc822 format available.

Message #11 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 10063 <at> debbugs.gnu.org, Leo <sdl.web <at> gmail.com>
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Mon, 21 Nov 2011 20:37:36 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> BTW, these should not be let-bindings but buffer-local bindings.
>
> Also the mode-setting and font-locking should be wrapped in
> with-demoted-errors so that errors in them don't prevent showing the
> attachment's content.
>
> Finally, font-lock-maximum-size should not be set to nil: there is
> nothing special about font-locking attachments that makes it more
> desirable to font-lock them entirely than normal files.

Ok; done.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Added tag(s) fixed. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 21 Nov 2011 19:40:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.1, send any further explanations to 10063 <at> debbugs.gnu.org and Leo <sdl.web <at> gmail.com> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 21 Nov 2011 19:40:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Dec 2011 12:24:03 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Wolfgang Jenkner <wjenkner <at> inode.at> to control <at> debbugs.gnu.org. (Mon, 26 Dec 2011 20:05:01 GMT) Full text and rfc822 format available.

Removed tag(s) fixed. Request was from Wolfgang Jenkner <wjenkner <at> inode.at> to control <at> debbugs.gnu.org. (Mon, 26 Dec 2011 20:05:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#10063; Package emacs,gnus. (Mon, 26 Dec 2011 20:08:01 GMT) Full text and rfc822 format available.

Message #24 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Wolfgang Jenkner <wjenkner <at> inode.at>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, Katsumi Yamaoka <yamaoka <at> jpl.org>,
	10063 <at> debbugs.gnu.org, Leo <sdl.web <at> gmail.com>
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Mon, 26 Dec 2011 21:02:52 +0100
Tags: patch

Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> 601:	    ;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
>> 602:	    (font-lock-mode-hook nil)
>> 603:	    (font-lock-support-mode nil)
>
> BTW, these should not be let-bindings but buffer-local bindings.

There's usually a major mode being called a few lines later, so
kill-all-local-variables has already undone those settings before
font-locking happens.

Here's more context from mm-view.el (mm-display-inline-fontify):

#+begin_src emacs-lisp
      (let ((font-lock-verbose nil))
	;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
	(set (make-local-variable 'font-lock-mode-hook) nil)
	(set (make-local-variable 'font-lock-support-mode) nil)
        ...
	(with-demoted-errors
	  (if mode
	      (funcall mode)
            ...)
          ...))
#+end_src

By the way, if you were viewing this in a Gnus article buffer after
having set org-src-fontify-natively to t such a snippet used to be
font-locked like in emacs-lisp mode but now it isn't, for the reason
just given.

The first patch below is relative to emacs bzr trunk and the second
patch relative to gnus git master (No Gnus).

2011-12-26  Wolfgang Jenkner  <wjenkner <at> inode.at>

        * font-lock.el (font-lock-support-mode): Mark it permanent-local.
        (Bug#10063)

2011-12-26  Wolfgang Jenkner  <wjenkner <at> inode.at>

        * mm-view.el (mm-display-inline-fontify): Scrap `font-lock-mode-hook'.
        The 2005-09-06 entry gives disabling support modes as the only reason
        for caring about that variable, but already in NEWS.19 the advice is to
        use `font-lock-support-mode' instead as hook for support functions.


=== modified file 'lisp/font-lock.el'
--- lisp/font-lock.el	2011-11-20 07:30:16 +0000
+++ lisp/font-lock.el	2011-12-26 05:03:58 +0000
@@ -887,6 +887,8 @@
   :version "21.1"
   :group 'font-lock)
 
+(put 'font-lock-support-mode 'permanent-local t)
+
 (defvar fast-lock-mode)
 (defvar lazy-lock-mode)
 (defvar jit-lock-mode)

-- >8 --
Subject: [PATCH] Scrap font-lock-mode-hook.

---
 lisp/mm-view.el |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/lisp/mm-view.el b/lisp/mm-view.el
index 854ca34..0b3db15 100644
--- a/lisp/mm-view.el
+++ b/lisp/mm-view.el
@@ -566,8 +566,6 @@
 		     (face-property 'default prop) (current-buffer))))
 	      (delete-region ,(point-min-marker) ,(point-max-marker)))))))))
 
-;; Shut up byte-compiler.
-(defvar font-lock-mode-hook)
 (defun mm-display-inline-fontify (handle &optional mode)
   "Insert HANDLE inline fontifying with MODE.
 If MODE is not set, try to find mode automatically."
@@ -602,7 +600,6 @@ If MODE is not set, try to find mode automatically."
       ;; I find font-lock a bit too verbose.
       (let ((font-lock-verbose nil))
 	;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
-	(set (make-local-variable 'font-lock-mode-hook) nil)
 	(set (make-local-variable 'font-lock-support-mode) nil)
         (setq buffer-file-name (mm-handle-filename handle))
         (set (make-local-variable 'enable-local-variables) nil)
-- 
1.7.8





Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#10063; Package emacs,gnus. (Mon, 26 Dec 2011 23:40:01 GMT) Full text and rfc822 format available.

Message #27 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Wolfgang Jenkner <wjenkner <at> inode.at>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, 10063 <at> debbugs.gnu.org,
	Stefan Monnier <monnier <at> iro.umontreal.ca>, Leo <sdl.web <at> gmail.com>
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Tue, 27 Dec 2011 08:36:53 +0900
Wolfgang Jenkner wrote:
[...]
> 2011-12-26  Wolfgang Jenkner  <wjenkner <at> inode.at>

>         * mm-view.el (mm-display-inline-fontify): Scrap `font-lock-mode-hook'.
[...]
> --- a/lisp/mm-view.el
> +++ b/lisp/mm-view.el
[...]
> -;; Shut up byte-compiler.
> -(defvar font-lock-mode-hook)

Why it is defvar'd here is that it no longer exists in Emacs but
still exists in XEmacs.  XEmacs people use it to run some support
modes `fast-lock', `lazy-lock', etc. as Emacs people use
`font-lock-support-mode'.

>  	;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
> -	(set (make-local-variable 'font-lock-mode-hook) nil)

Gnus should run with not only old Emacsen but also XEmacsen[1],
so please don't scrap it.  (when (featurep 'xemacs) ...?

[1] (info "(gnus)Emacsen")




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#10063; Package emacs,gnus. (Tue, 27 Dec 2011 16:30:01 GMT) Full text and rfc822 format available.

Message #30 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Wolfgang Jenkner <wjenkner <at> inode.at>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, 10063 <at> debbugs.gnu.org,
	Leo <sdl.web <at> gmail.com>
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Tue, 27 Dec 2011 17:26:42 +0100
Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> Wolfgang Jenkner wrote:
>> -(defvar font-lock-mode-hook)
>
> Why it is defvar'd here is that it no longer exists in Emacs but
> still exists in XEmacs.

Well, it doesn't exist anymore but it still works (and is used, e.g., in
c-mode) in Emacs as well (as a consequence of font-lock-mode being
defined via define-minor-mode).

> Gnus should run with not only old Emacsen but also XEmacsen[1],
> so please don't scrap it.  (when (featurep 'xemacs) ...?

There's also the problem that setting (or binding) font-lock-mode-hook
to nil prevents other (perhaps essential) functions on this hook from
running as well.  So, here "to scrap" really means "to honour" ;-)

Thank you for the explanation!

Wolfgang




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#10063; Package emacs,gnus. (Tue, 27 Dec 2011 19:52:01 GMT) Full text and rfc822 format available.

Message #33 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Wolfgang Jenkner <wjenkner <at> inode.at>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, 10063 <at> debbugs.gnu.org,
	Stefan Monnier <monnier <at> iro.umontreal.ca>, Leo <sdl.web <at> gmail.com>
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Tue, 27 Dec 2011 20:48:45 +0100
Katsumi Yamaoka <yamaoka <at> jpl.org> writes:

> Gnus should run with not only old Emacsen but also XEmacsen[1],
> so please don't scrap it.

Obviously, my patch for Gnus would work only with a current or future
version of Emacs containing my other patch.  So, now, I scrap my
proposal ;-)

Wolfgang




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#10063; Package emacs,gnus. (Tue, 27 Dec 2011 22:16:02 GMT) Full text and rfc822 format available.

Message #36 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Katsumi Yamaoka <yamaoka <at> jpl.org>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>,
	Wolfgang Jenkner <wjenkner <at> inode.at>, 10063 <at> debbugs.gnu.org,
	Leo <sdl.web <at> gmail.com>
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Mon, 26 Dec 2011 20:29:40 -0500
> Why it is defvar'd here is that it no longer exists in Emacs but
> still exists in XEmacs.  XEmacs people use it to run some support
> modes `fast-lock', `lazy-lock', etc. as Emacs people use
> `font-lock-support-mode'.

A note about it (not near the defvar but near the place where you force
this var to nil) would be welcome.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org, bugs <at> gnus.org:
bug#10063; Package emacs,gnus. (Wed, 28 Dec 2011 02:44:01 GMT) Full text and rfc822 format available.

Message #39 received at 10063 <at> debbugs.gnu.org (full text, mbox):

From: Katsumi Yamaoka <yamaoka <at> jpl.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>,
	Wolfgang Jenkner <wjenkner <at> inode.at>, 10063 <at> debbugs.gnu.org,
	Leo <sdl.web <at> gmail.com>
Subject: Re: bug#10063: 24.0.91;
	Making font-lock-mode-hook buffer-local while locally let-bound!
Date: Wed, 28 Dec 2011 11:40:35 +0900
Stefan Monnier wrote:
>> Why it is defvar'd here is that it no longer exists in Emacs but
>> still exists in XEmacs.  XEmacs people use it to run some support
>> modes `fast-lock', `lazy-lock', etc. as Emacs people use
>> `font-lock-support-mode'.

> A note about it (not near the defvar but near the place where you force
> this var to nil) would be welcome.

Ok.  Done.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 25 Jan 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 207 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.