unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Wolfgang Jenkner <wjenkner@inode.at>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Lars Magne Ingebrigtsen <larsi@gnus.org>,
	10063@debbugs.gnu.org, Katsumi Yamaoka <yamaoka@jpl.org>,
	Leo <sdl.web@gmail.com>
Subject: 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	[thread overview]
Message-ID: <8539c714mr.fsf@iznogoud.viz> (raw)
In-Reply-To: <87y5vg5jzb.fsf@gmail.com>

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






  parent reply	other threads:[~2011-12-26 20:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=8539c714mr.fsf@iznogoud.viz \
    --to=wjenkner@inode.at \
    --cc=10063@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=sdl.web@gmail.com \
    --cc=yamaoka@jpl.org \
    /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 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).