unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
@ 2011-11-16 12:29 Leo
  2011-11-16 14:49 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Leo @ 2011-11-16 12:29 UTC (permalink / raw)
  To: 10063; +Cc: Lars Magne Ingebrigtsen

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





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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-11-16 12:29 bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound! Leo
@ 2011-11-16 14:49 ` Stefan Monnier
  2011-11-21 19:37   ` Lars Magne Ingebrigtsen
  2011-12-26 20:02   ` Wolfgang Jenkner
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2011-11-16 14:49 UTC (permalink / raw)
  To: Leo; +Cc: Lars Magne Ingebrigtsen, 10063

> 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





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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-11-16 14:49 ` Stefan Monnier
@ 2011-11-21 19:37   ` Lars Magne Ingebrigtsen
  2011-12-26 20:02   ` Wolfgang Jenkner
  1 sibling, 0 replies; 9+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-11-21 19:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 10063, Leo

Stefan Monnier <monnier@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/





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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-11-16 14:49 ` Stefan Monnier
  2011-11-21 19:37   ` Lars Magne Ingebrigtsen
@ 2011-12-26 20:02   ` Wolfgang Jenkner
  2011-12-26 23:36     ` Katsumi Yamaoka
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfgang Jenkner @ 2011-12-26 20:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Lars Magne Ingebrigtsen, 10063, Katsumi Yamaoka, Leo

Tags: patch

Stefan Monnier <monnier@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@inode.at>

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

2011-12-26  Wolfgang Jenkner  <wjenkner@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






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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-12-26 20:02   ` Wolfgang Jenkner
@ 2011-12-26 23:36     ` Katsumi Yamaoka
  2011-12-27  1:29       ` Stefan Monnier
                         ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Katsumi Yamaoka @ 2011-12-26 23:36 UTC (permalink / raw)
  To: Wolfgang Jenkner; +Cc: Lars Magne Ingebrigtsen, 10063, Leo

Wolfgang Jenkner wrote:
[...]
> 2011-12-26  Wolfgang Jenkner  <wjenkner@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")





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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-12-26 23:36     ` Katsumi Yamaoka
@ 2011-12-27  1:29       ` Stefan Monnier
  2011-12-28  2:40         ` Katsumi Yamaoka
  2011-12-27 16:26       ` Wolfgang Jenkner
  2011-12-27 19:48       ` Wolfgang Jenkner
  2 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2011-12-27  1:29 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: Lars Magne Ingebrigtsen, Wolfgang Jenkner, 10063, Leo

> 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





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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-12-26 23:36     ` Katsumi Yamaoka
  2011-12-27  1:29       ` Stefan Monnier
@ 2011-12-27 16:26       ` Wolfgang Jenkner
  2011-12-27 19:48       ` Wolfgang Jenkner
  2 siblings, 0 replies; 9+ messages in thread
From: Wolfgang Jenkner @ 2011-12-27 16:26 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: Lars Magne Ingebrigtsen, 10063, Leo

Katsumi Yamaoka <yamaoka@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





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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-12-26 23:36     ` Katsumi Yamaoka
  2011-12-27  1:29       ` Stefan Monnier
  2011-12-27 16:26       ` Wolfgang Jenkner
@ 2011-12-27 19:48       ` Wolfgang Jenkner
  2 siblings, 0 replies; 9+ messages in thread
From: Wolfgang Jenkner @ 2011-12-27 19:48 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: Lars Magne Ingebrigtsen, 10063, Leo

Katsumi Yamaoka <yamaoka@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





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

* bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound!
  2011-12-27  1:29       ` Stefan Monnier
@ 2011-12-28  2:40         ` Katsumi Yamaoka
  0 siblings, 0 replies; 9+ messages in thread
From: Katsumi Yamaoka @ 2011-12-28  2:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Lars Magne Ingebrigtsen, Wolfgang Jenkner, 10063, Leo

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.





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

end of thread, other threads:[~2011-12-28  2:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16 12:29 bug#10063: 24.0.91; Making font-lock-mode-hook buffer-local while locally let-bound! Leo
2011-11-16 14:49 ` Stefan Monnier
2011-11-21 19:37   ` Lars Magne Ingebrigtsen
2011-12-26 20:02   ` Wolfgang Jenkner
2011-12-26 23:36     ` Katsumi Yamaoka
2011-12-27  1:29       ` Stefan Monnier
2011-12-28  2:40         ` Katsumi Yamaoka
2011-12-27 16:26       ` Wolfgang Jenkner
2011-12-27 19:48       ` Wolfgang Jenkner

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