unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* font-lock-global-modes = nil doesn't work
@ 2007-10-05 15:27 Juanma Barranquero
  2007-10-08 18:03 ` Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Juanma Barranquero @ 2007-10-05 15:27 UTC (permalink / raw)
  To: Emacs development discussions

According to `font-lock-global-modes' docstring:

"*Modes for which Font Lock mode is automagically turned on.
Global Font Lock mode is controlled by the command `global-font-lock-mode'.
If nil, means no modes have Font Lock mode automatically turned on.
[...]"

But that's not true:

 (setq font-lock-global-modes nil)
 (global-font-lock-modes 1)

still activates font-locking for all buffers.

The reason is this change (the relevant part of the patch is after the
signature):

2002-06-12  Colin Walters  <walters@debian.org>

        * font-core.el [...]
        (turn-on-font-lock-if-enabled): Always turn on font-lock unless it
        is specifically excluded by the user.

It is intended for font-lock-global-modes = nil to be ignored (and
then I'll fix the docstring) or it is a bug? (A bug, I think.)

It does not cause trouble, I suppose, because users who do *not* want
global font-locking just set (global-font-lock-mode -1) in their
.emacs, instead of setting font-lock-global-modes to nil. However, the
bug precludes setting it buffer-locally to nil.

             Juanma


@@ -354,10 +343,6 @@

 (defun turn-on-font-lock-if-enabled ()
-  (when (and (or font-lock-defaults
-		 (assq major-mode font-lock-defaults-alist))
-	     (or (eq font-lock-global-modes t)
-		 (if (eq (car-safe font-lock-global-modes) 'not)
-		     (not (memq major-mode (cdr font-lock-global-modes)))
-		   (memq major-mode font-lock-global-modes))))
+  (unless (and (eq (car-safe font-lock-global-modes) 'not)
+	       (memq major-mode (cdr font-lock-global-modes)))
     (let (inhibit-quit)
       (turn-on-font-lock))))

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

* Re: font-lock-global-modes = nil doesn't work
  2007-10-05 15:27 font-lock-global-modes = nil doesn't work Juanma Barranquero
@ 2007-10-08 18:03 ` Richard Stallman
  2007-10-09  8:27   ` Juanma Barranquero
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2007-10-08 18:03 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel

Does this fix the bug?  (It might be equivalent to reverting the previous
change, but it's cleaner.)

*** font-core.el	26 Jul 2007 12:57:21 -0400	1.46
--- font-core.el	07 Oct 2007 19:21:42 -0400	
***************
*** 234,240 ****
  ;; hook is run, the major mode is in the process of being changed and we do not
  ;; know what the final major mode will be.  So, `font-lock-change-major-mode'
  ;; only (a) notes the name of the current buffer, and (b) adds our function
! ;; `turn-on-font-lock-if-enabled' to the hook variables
  ;; `after-change-major-mode-hook' and `post-command-hook' (for modes
  ;; that do not yet run `after-change-major-mode-hook').  By the time
  ;; the functions on the first of these hooks to be run are run, the new major
--- 234,240 ----
  ;; hook is run, the major mode is in the process of being changed and we do not
  ;; know what the final major mode will be.  So, `font-lock-change-major-mode'
  ;; only (a) notes the name of the current buffer, and (b) adds our function
! ;; `turn-on-font-lock-if-desired' to the hook variables
  ;; `after-change-major-mode-hook' and `post-command-hook' (for modes
  ;; that do not yet run `after-change-major-mode-hook').  By the time
  ;; the functions on the first of these hooks to be run are run, the new major
***************
*** 281,294 ****
  		      (repeat :inline t (symbol :tag "mode"))))
    :group 'font-lock)
  
! (defun turn-on-font-lock-if-enabled ()
!   (unless (and (eq (car-safe font-lock-global-modes) 'not)
! 	       (memq major-mode (cdr font-lock-global-modes)))
      (let (inhibit-quit)
        (turn-on-font-lock))))
  
  (define-globalized-minor-mode global-font-lock-mode
!   font-lock-mode turn-on-font-lock-if-enabled
    :extra-args (dummy)
    :initialize 'custom-initialize-safe-default
    :init-value (not (or noninteractive emacs-basic-display))
--- 281,297 ----
  		      (repeat :inline t (symbol :tag "mode"))))
    :group 'font-lock)
  
! (defun turn-on-font-lock-if-desired ()
!   (when (cond ((eq font-lock-global-modes t)
! 	       t)
! 	      ((eq (car-safe font-lock-global-modes) 'not)
! 	       (not (memq major-mode (cdr font-lock-global-modes))))
! 	      (t (memq major-mode (cdr font-lock-global-modes))))
      (let (inhibit-quit)
        (turn-on-font-lock))))
  
  (define-globalized-minor-mode global-font-lock-mode
!   font-lock-mode turn-on-font-lock-if-desired
    :extra-args (dummy)
    :initialize 'custom-initialize-safe-default
    :init-value (not (or noninteractive emacs-basic-display))

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

* Re: font-lock-global-modes = nil doesn't work
  2007-10-08 18:03 ` Richard Stallman
@ 2007-10-09  8:27   ` Juanma Barranquero
  2007-10-10 13:01     ` Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Juanma Barranquero @ 2007-10-09  8:27 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

On 10/8/07, Richard Stallman <rms@gnu.org> wrote:

> Does this fix the bug?  (It might be equivalent to reverting the previous
> change, but it's cleaner.)

Yes.

             Juanma

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

* Re: font-lock-global-modes = nil doesn't work
  2007-10-09  8:27   ` Juanma Barranquero
@ 2007-10-10 13:01     ` Richard Stallman
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2007-10-10 13:01 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: emacs-devel

Thanks.  I will install the patch.  I will also ask Colin Walters
if he remembers the reason for his change.

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

end of thread, other threads:[~2007-10-10 13:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-05 15:27 font-lock-global-modes = nil doesn't work Juanma Barranquero
2007-10-08 18:03 ` Richard Stallman
2007-10-09  8:27   ` Juanma Barranquero
2007-10-10 13:01     ` Richard Stallman

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