X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/292203c9ef2ab5c1bb349b83132c9a51d3dfb274..ca970e12a5259f981341213ee76afaf80faebafb:/lisp/font-core.el diff --git a/lisp/font-core.el b/lisp/font-core.el index d2cb8dccd1..e3c34b012c 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el @@ -1,17 +1,17 @@ ;;; font-core.el --- Core interface to font-lock ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -;; 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +;; 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. ;; Maintainer: FSF ;; Keywords: languages, faces ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,9 +19,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. +;; along with GNU Emacs. If not, see . ;;; Code: @@ -81,35 +79,7 @@ Each item should be a list of the form: where MAJOR-MODE is a symbol and FONT-LOCK-DEFAULTS is a list of default settings. See the variable `font-lock-defaults', which takes precedence.") -(make-obsolete-variable 'font-lock-defaults-alist 'font-lock-defaults) - -(defvar font-lock-extend-region-function nil - "A function that determines the region to fontify after a change. - -This buffer-local variable is either nil, or is a function that determines the -region to fontify. It is usually set by the major mode. The currently active -font-lock after-change function calls this function after each buffer change. - -The function is given three parameters, the standard BEG, END, and OLD-LEN -from after-change-functions. It should return either a cons of the beginning -and end buffer positions \(in that order) of the region to fontify, or nil -\(which directs the caller to fontify a default region). This function need -not preserve point or the match-data, but must preserve the current -restriction. The region it returns may start or end in the middle of a -line.") -(make-variable-buffer-local 'font-lock-extend-region-function) - -(defun font-lock-extend-region (beg end old-len) - "Determine the region to fontify after a buffer change. - -BEG END and OLD-LEN are the standard parameters from after-change-functions. -The return value is either nil \(which directs the caller to chose the region -itself), or a cons of the beginning and end \(in that order) of the region. -The region returned may start or end in the middle of a line." - (if font-lock-extend-region-function - (save-match-data - (save-excursion - (funcall font-lock-extend-region-function beg end old-len))))) +(make-obsolete-variable 'font-lock-defaults-alist 'font-lock-defaults "21.1") (defvar font-lock-function 'font-lock-default-function "A function which is called when `font-lock-mode' is toggled. @@ -152,10 +122,6 @@ generally prefer. When you turn Font Lock mode on/off the buffer is fontified/defontified, though fontification occurs only if the buffer is less than `font-lock-maximum-size'. -For example, to use maximum levels of fontification, put in your ~/.emacs: - - (setq font-lock-maximum-decoration t) - To add your own highlighting for some major mode, and modify the highlighting selected automatically via the variable `font-lock-maximum-decoration', you can use `font-lock-add-keywords'. @@ -177,7 +143,7 @@ your own function which is called when `font-lock-mode' is toggled via nil nil nil ;; Don't turn on Font Lock mode if we don't have a display (we're running a ;; batch job) or if the buffer is invisible (the name starts with a space). - (when (or noninteractive (eq (aref (buffer-name) 0) ?\ )) + (when (or noninteractive (eq (aref (buffer-name) 0) ?\s)) (setq font-lock-mode nil)) (funcall font-lock-function font-lock-mode) ;; Arrange to unfontify this buffer if we change major mode later. @@ -266,7 +232,7 @@ this function onto `change-major-mode-hook'." ;; 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 +;; `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 @@ -286,7 +252,7 @@ this function onto `change-major-mode-hook'." ;; Although Global Font Lock mode is a pseudo-mode, I think that the user ;; interface should conform to the usual Emacs convention for modes, i.e., a ;; command to toggle the feature (`global-font-lock-mode') with a variable for -;; finer control of the mode's behaviour (`font-lock-global-modes'). +;; finer control of the mode's behavior (`font-lock-global-modes'). ;; ;; The feature should not be enabled by loading font-lock.el, since other ;; mechanisms for turning on Font Lock mode, such as M-x font-lock-mode RET or @@ -313,14 +279,17 @@ means that Font Lock mode is turned on for buffers in C and C++ modes only." (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))) +(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-global-minor-mode global-font-lock-mode - font-lock-mode turn-on-font-lock-if-enabled +(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))