aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1997-04-23 07:10:09 +0000
committerSimon Marshall1997-04-23 07:10:09 +0000
commit2273c36b4ed5c18c65d7912d5b4453c33ec6b854 (patch)
tree3860e4f23307bddc7c64972de1a0a5c22e85f40c
parent45d642dffa9f8bfc243c453907ef1c140362f39e (diff)
downloademacs-2273c36b4ed5c18c65d7912d5b4453c33ec6b854.tar.gz
emacs-2273c36b4ed5c18c65d7912d5b4453c33ec6b854.zip
Respect font-lock-face-attributes and custom fixes.
-rw-r--r--lisp/font-lock.el115
1 files changed, 88 insertions, 27 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index b532edb1eff..43a3029625e 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -183,15 +183,32 @@
183 183
184;;; Code: 184;;; Code:
185 185
186;; Define core `font-lock' group.
186(defgroup font-lock nil 187(defgroup font-lock nil
187 "Font Lock mode text highlighting package." 188 "Font Lock mode text highlighting package."
188 :link '(custom-manual "(emacs)Font Lock") 189 :link '(custom-manual "(emacs)Font Lock")
189 :group 'faces) 190 :group 'faces)
190 191
191(defgroup font-lock-faces nil 192(defgroup font-lock-highlighting-faces nil
192 "Font Lock mode faces." 193 "Faces for highlighting text."
193 :prefix "font-lock-" 194 :prefix "font-lock-"
194 :link '(custom-manual "(emacs)Font Lock") 195 :group 'font-lock)
196
197(defgroup font-lock-extra-types nil
198 "Extra mode-specific type names for highlighting declarations."
199 :group 'font-lock)
200
201;; Define support mode groups here for nicer `font-lock' group order.
202(defgroup fast-lock nil
203 "Font Lock support mode to cache fontification."
204 :link '(custom-manual "(emacs)Support Modes")
205 :load 'fast-lock
206 :group 'font-lock)
207
208(defgroup lazy-lock nil
209 "Font Lock support mode to fontify lazily."
210 :link '(custom-manual "(emacs)Support Modes")
211 :load 'lazy-lock
195 :group 'font-lock) 212 :group 'font-lock)
196 213
197;; User variables. 214;; User variables.
@@ -283,7 +300,7 @@ call to make the search (called with one argument, the limit of the search).
283MATCH is the subexpression of MATCHER to be highlighted. MATCH can be 300MATCH is the subexpression of MATCHER to be highlighted. MATCH can be
284calculated via the function `font-lock-keyword-depth'. FACENAME is an 301calculated via the function `font-lock-keyword-depth'. FACENAME is an
285expression whose value is the face name to use. FACENAME's default attributes 302expression whose value is the face name to use. FACENAME's default attributes
286can be defined via the variable `font-lock-face-attributes'. 303can be modified via \\[customize].
287 304
288OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification can 305OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification can
289be overwritten. If `keep', only parts not already fontified are highlighted. 306be overwritten. If `keep', only parts not already fontified are highlighted.
@@ -608,11 +625,9 @@ To fontify a block (the function or paragraph containing point, or a number of
608lines around point), perhaps because modification on the current line caused 625lines around point), perhaps because modification on the current line caused
609syntactic change on other lines, you can use \\[font-lock-fontify-block]. 626syntactic change on other lines, you can use \\[font-lock-fontify-block].
610 627
611The default Font Lock mode faces and their attributes are defined in the 628See the variable `font-lock-defaults-alist' for the Font Lock mode default
612variable `font-lock-face-attributes', and Font Lock mode default settings in 629settings. You can set your own default settings for some mode, by setting a
613the variable `font-lock-defaults-alist'. You can set your own default settings 630buffer local value for `font-lock-defaults', via its mode hook."
614for some mode, by setting a buffer local value for `font-lock-defaults', via
615its mode hook."
616 (interactive "P") 631 (interactive "P")
617 ;; Don't turn on Font Lock mode if we don't have a display (we're running a 632 ;; Don't turn on Font Lock mode if we don't have a display (we're running a
618 ;; batch job) or if the buffer is invisible (the name starts with a space). 633 ;; batch job) or if the buffer is invisible (the name starts with a space).
@@ -1432,6 +1447,37 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1432(defvar font-lock-warning-face 'font-lock-warning-face 1447(defvar font-lock-warning-face 'font-lock-warning-face
1433 "Face name to use for things that should stand out.") 1448 "Face name to use for things that should stand out.")
1434 1449
1450;; Originally face attributes were specified via `font-lock-face-attributes'.
1451;; Users then changed the default face attributes by setting this variable.
1452;; However, we try and be back-compatible and respect its value if set except
1453;; for faces where M-x customize has been used to save changes for the face.
1454(when (boundp 'font-lock-face-attributes)
1455 (let ((face-attributes font-lock-face-attributes))
1456 (while face-attributes
1457 (let* ((face-attribute (pop face-attributes))
1458 (face (car face-attribute)))
1459 ;; Rustle up a `defface' SPEC from a `font-lock-face-attributes' entry.
1460 (unless (get face 'saved-face)
1461 (let ((foreground (nth 1 face-attribute))
1462 (background (nth 2 face-attribute))
1463 (bold-p (nth 3 face-attribute))
1464 (italic-p (nth 4 face-attribute))
1465 (underline-p (nth 5 face-attribute))
1466 face-spec)
1467 (when foreground
1468 (setq face-spec (cons ':foreground (cons foreground face-spec))))
1469 (when background
1470 (setq face-spec (cons ':background (cons background face-spec))))
1471 (when bold-p
1472 (setq face-spec (append '(:bold t) face-spec)))
1473 (when italic-p
1474 (setq face-spec (append '(:italic t) face-spec)))
1475 (when underline-p
1476 (setq face-spec (append '(:underline t) face-spec)))
1477 (custom-declare-face face (list (list t face-spec)) nil)))))))
1478
1479;; But now we do it the custom way. Note that `defface' will not overwrite any
1480;; faces declared above via `custom-declare-face'.
1435(defface font-lock-comment-face 1481(defface font-lock-comment-face
1436 '((((class grayscale) (background light)) 1482 '((((class grayscale) (background light))
1437 (:foreground "DimGray" :bold t :italic t)) 1483 (:foreground "DimGray" :bold t :italic t))
@@ -1441,7 +1487,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1441 (((class color) (background dark)) (:foreground "OrangeRed")) 1487 (((class color) (background dark)) (:foreground "OrangeRed"))
1442 (t (:bold t :italic t))) 1488 (t (:bold t :italic t)))
1443 "Font Lock mode face used to highlight comments." 1489 "Font Lock mode face used to highlight comments."
1444 :group 'font-lock-faces) 1490 :group 'font-lock-highlighting-faces)
1445 1491
1446(defface font-lock-string-face 1492(defface font-lock-string-face
1447 '((((class grayscale) (background light)) (:foreground "DimGray" :italic t)) 1493 '((((class grayscale) (background light)) (:foreground "DimGray" :italic t))
@@ -1450,7 +1496,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1450 (((class color) (background dark)) (:foreground "LightSalmon")) 1496 (((class color) (background dark)) (:foreground "LightSalmon"))
1451 (t (:italic t))) 1497 (t (:italic t)))
1452 "Font Lock mode face used to highlight strings." 1498 "Font Lock mode face used to highlight strings."
1453 :group 'font-lock-faces) 1499 :group 'font-lock-highlighting-faces)
1454 1500
1455(defface font-lock-keyword-face 1501(defface font-lock-keyword-face
1456 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t)) 1502 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
@@ -1459,7 +1505,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1459 (((class color) (background dark)) (:foreground "Cyan")) 1505 (((class color) (background dark)) (:foreground "Cyan"))
1460 (t (:bold t))) 1506 (t (:bold t)))
1461 "Font Lock mode face used to highlight keywords." 1507 "Font Lock mode face used to highlight keywords."
1462 :group 'font-lock-faces) 1508 :group 'font-lock-highlighting-faces)
1463 1509
1464(defface font-lock-builtin-face 1510(defface font-lock-builtin-face
1465 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t)) 1511 '((((class grayscale) (background light)) (:foreground "LightGray" :bold t))
@@ -1468,7 +1514,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1468 (((class color) (background dark)) (:foreground "LightSteelBlue")) 1514 (((class color) (background dark)) (:foreground "LightSteelBlue"))
1469 (t (:bold t))) 1515 (t (:bold t)))
1470 "Font Lock mode face used to highlight builtins." 1516 "Font Lock mode face used to highlight builtins."
1471 :group 'font-lock-faces) 1517 :group 'font-lock-highlighting-faces)
1472 1518
1473(defface font-lock-function-name-face 1519(defface font-lock-function-name-face
1474 ;; Currently, Emacs/Custom does not support a :reverse or :invert spec. 1520 ;; Currently, Emacs/Custom does not support a :reverse or :invert spec.
@@ -1477,7 +1523,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1477 (t ;(:reverse t :bold t) 1523 (t ;(:reverse t :bold t)
1478 (:italic t :bold t))) 1524 (:italic t :bold t)))
1479 "Font Lock mode face used to highlight function names." 1525 "Font Lock mode face used to highlight function names."
1480 :group 'font-lock-faces) 1526 :group 'font-lock-highlighting-faces)
1481 1527
1482(defface font-lock-variable-name-face 1528(defface font-lock-variable-name-face
1483 '((((class grayscale) (background light)) 1529 '((((class grayscale) (background light))
@@ -1488,7 +1534,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1488 (((class color) (background dark)) (:foreground "LightGoldenrod")) 1534 (((class color) (background dark)) (:foreground "LightGoldenrod"))
1489 (t (:bold t :italic t))) 1535 (t (:bold t :italic t)))
1490 "Font Lock mode face used to highlight variable names." 1536 "Font Lock mode face used to highlight variable names."
1491 :group 'font-lock-faces) 1537 :group 'font-lock-highlighting-faces)
1492 1538
1493(defface font-lock-type-face 1539(defface font-lock-type-face
1494 '((((class grayscale) (background light)) (:foreground "Gray90" :bold t)) 1540 '((((class grayscale) (background light)) (:foreground "Gray90" :bold t))
@@ -1497,7 +1543,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1497 (((class color) (background dark)) (:foreground "PaleGreen")) 1543 (((class color) (background dark)) (:foreground "PaleGreen"))
1498 (t (:bold t :underline t))) 1544 (t (:bold t :underline t)))
1499 "Font Lock mode face used to highlight types." 1545 "Font Lock mode face used to highlight types."
1500 :group 'font-lock-faces) 1546 :group 'font-lock-highlighting-faces)
1501 1547
1502(defface font-lock-reference-face 1548(defface font-lock-reference-face
1503 '((((class grayscale) (background light)) 1549 '((((class grayscale) (background light))
@@ -1508,7 +1554,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1508 (((class color) (background dark)) (:foreground "Aquamarine")) 1554 (((class color) (background dark)) (:foreground "Aquamarine"))
1509 (t (:bold t :underline t))) 1555 (t (:bold t :underline t)))
1510 "Font Lock mode face used to highlight references." 1556 "Font Lock mode face used to highlight references."
1511 :group 'font-lock-faces) 1557 :group 'font-lock-highlighting-faces)
1512 1558
1513(defface font-lock-warning-face 1559(defface font-lock-warning-face
1514 ;; Currently, Emacs/Custom does not support a :reverse or :invert spec. 1560 ;; Currently, Emacs/Custom does not support a :reverse or :invert spec.
@@ -1517,7 +1563,7 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
1517 (t ;(:reverse t :bold t) 1563 (t ;(:reverse t :bold t)
1518 (:italic t :bold t))) 1564 (:italic t :bold t)))
1519 "Font Lock mode face used to highlight warnings." 1565 "Font Lock mode face used to highlight warnings."
1520 :group 'font-lock-faces) 1566 :group 'font-lock-highlighting-faces)
1521 1567
1522;;; End of Colour etc. support. 1568;;; End of Colour etc. support.
1523 1569
@@ -1679,7 +1725,7 @@ This means the number of parenthesized expressions."
1679 (list (concat "(\\(def\\(" 1725 (list (concat "(\\(def\\("
1680 ;; Function declarations. 1726 ;; Function declarations.
1681 "\\(advice\\|alias\\|" 1727 "\\(advice\\|alias\\|"
1682 "ine-\\(derived-mode\\|function\\|skeleton\\)\\|" 1728 "ine-\\(derived-mode\\|function\\|skeleton\\|widget\\)\\|"
1683 "macro\\|subst\\|un\\)\\|" 1729 "macro\\|subst\\|un\\)\\|"
1684 ;; Variable declarations. 1730 ;; Variable declarations.
1685 "\\(const\\|custom\\|face\\|var\\)\\|" 1731 "\\(const\\|custom\\|face\\|var\\)\\|"
@@ -1855,37 +1901,52 @@ This means the number of parenthesized expressions."
1855;; types might be the user's own or they might be generally accepted and used. 1901;; types might be the user's own or they might be generally accepted and used.
1856;; Generally accepted types are used to provide default variable values. 1902;; Generally accepted types are used to provide default variable values.
1857 1903
1858(defvar c-font-lock-extra-types '("FILE" "\\sw+_t") 1904(define-widget 'font-lock-extra-types-widget 'radio
1905 "Widget `:type' for members of the custom group `font-lock-extra-types'.
1906Members should `:load' the package `font-lock' to use this widget."
1907 :args '((const :tag "none" nil)
1908 (repeat :tag "types"
1909 (string :tag "regexp"))))
1910
1911(defcustom c-font-lock-extra-types '("FILE" "\\sw+_t")
1859 "*List of extra types to fontify in C mode. 1912 "*List of extra types to fontify in C mode.
1860Each list item should be a regexp not containing word-delimiters. 1913Each list item should be a regexp not containing word-delimiters.
1861For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word FILE and words 1914For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word FILE and words
1862ending in _t are treated as type names. 1915ending in _t are treated as type names.
1863 1916
1864The value of this variable is used when Font Lock mode is turned on.") 1917The value of this variable is used when Font Lock mode is turned on."
1918 :type 'font-lock-extra-types-widget
1919 :group 'font-lock-extra-types)
1865 1920
1866(defvar c++-font-lock-extra-types '("string") 1921(defcustom c++-font-lock-extra-types '("string")
1867 "*List of extra types to fontify in C++ mode. 1922 "*List of extra types to fontify in C++ mode.
1868Each list item should be a regexp not containing word-delimiters. 1923Each list item should be a regexp not containing word-delimiters.
1869For example, a value of (\"string\") means the word string is treated as a type 1924For example, a value of (\"string\") means the word string is treated as a type
1870name. 1925name.
1871 1926
1872The value of this variable is used when Font Lock mode is turned on.") 1927The value of this variable is used when Font Lock mode is turned on."
1928 :type 'font-lock-extra-types-widget
1929 :group 'font-lock-extra-types)
1873 1930
1874(defvar objc-font-lock-extra-types '("Class" "BOOL" "IMP" "SEL") 1931(defcustom objc-font-lock-extra-types '("Class" "BOOL" "IMP" "SEL")
1875 "*List of extra types to fontify in Objective-C mode. 1932 "*List of extra types to fontify in Objective-C mode.
1876Each list item should be a regexp not containing word-delimiters. 1933Each list item should be a regexp not containing word-delimiters.
1877For example, a value of (\"Class\" \"BOOL\" \"IMP\" \"SEL\") means the words 1934For example, a value of (\"Class\" \"BOOL\" \"IMP\" \"SEL\") means the words
1878Class, BOOL, IMP and SEL are treated as type names. 1935Class, BOOL, IMP and SEL are treated as type names.
1879 1936
1880The value of this variable is used when Font Lock mode is turned on.") 1937The value of this variable is used when Font Lock mode is turned on."
1938 :type 'font-lock-extra-types-widget
1939 :group 'font-lock-extra-types)
1881 1940
1882(defvar java-font-lock-extra-types '("[A-Z\300-\326\330-\337]\\sw+") 1941(defcustom java-font-lock-extra-types '("[A-Z\300-\326\330-\337]\\sw+")
1883 "*List of extra types to fontify in Java mode. 1942 "*List of extra types to fontify in Java mode.
1884Each list item should be a regexp not containing word-delimiters. 1943Each list item should be a regexp not containing word-delimiters.
1885For example, a value of (\"[A-Z\300-\326\330-\337]\\\\sw+\") means capitalised 1944For example, a value of (\"[A-Z\300-\326\330-\337]\\\\sw+\") means capitalised
1886words (and words conforming to the Java id spec) are treated as type names. 1945words (and words conforming to the Java id spec) are treated as type names.
1887 1946
1888The value of this variable is used when Font Lock mode is turned on.") 1947The value of this variable is used when Font Lock mode is turned on."
1948 :type 'font-lock-extra-types-widget
1949 :group 'font-lock-extra-types)
1889 1950
1890;;; C. 1951;;; C.
1891 1952