Show
Ignore:
Timestamp:
2005年11月01日 07時08分22秒 (3 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • vendor/emacs-CVS_HEAD/lisp/font-lock.el

    r3892 r3939  
    341341;; Fontification variables: 
    342342 
    343 ;;;###autoload 
    344343(defvar font-lock-keywords nil 
    345344  "A list of the keywords to highlight. 
     
    355354 
    356355 MATCHER 
    357  (MATCHER . MATCH
     356 (MATCHER . SUBEXP
    358357 (MATCHER . FACENAME) 
    359358 (MATCHER . HIGHLIGHT) 
     
    381380MATCH-HIGHLIGHT should be of the form: 
    382381 
    383  (MATCH FACENAME [OVERRIDE [LAXMATCH]]) 
    384  
    385 MATCH is the subexpression of MATCHER to be highlighted.  FACENAME is an 
    386 expression whose value is the face name to use.  Face default attributes 
    387 can be modified via \\[customize].  Instead of a face, FACENAME can 
    388 evaluate to a property list of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...) 
     382 (SUBEXP FACENAME [OVERRIDE [LAXMATCH]]) 
     383 
     384SUBEXP is the number of the subexpression of MATCHER to be highlighted. 
     385 
     386FACENAME is an expression whose value is the face name to use. 
     387Instead of a face, FACENAME can evaluate to a property list 
     388of the form (face FACE PROP1 VAL1 PROP2 VAL2 ...) 
    389389in which case all the listed text-properties will be set rather than 
    390390just FACE.  In such a case, you will most likely want to put those 
     
    396396If `prepend' or `append', existing fontification is merged with the new, in 
    397397which the new or existing fontification, respectively, takes precedence. 
    398 If LAXMATCH is non-nil, no error is signaled if there is no MATCH in MATCHER. 
     398If LAXMATCH is non-nil, that means don't signal an error if there is 
     399no match for SUBEXP in MATCHER. 
    399400 
    400401For example, an element of the form highlights (if not already highlighted): 
     
    509510 
    510511(defvar font-lock-syntactic-keywords nil 
    511   "A list of the syntactic keywords to highlight. 
    512 Can be the list or the name of a function or variable whose value is the list. 
     512  "A list of the syntactic keywords to put syntax properties on. 
     513The value can be the list itself, or the name of a function or variable 
     514whose value is the list. 
     515 
    513516See `font-lock-keywords' for a description of the form of this list; 
    514 the differences are listed below.  MATCH-HIGHLIGHT should be of the form: 
    515  
    516  (MATCH SYNTAX OVERRIDE LAXMATCH) 
     517only the differences are stated here.  MATCH-HIGHLIGHT should be of the form: 
     518 
     519 (SUBEXP SYNTAX OVERRIDE LAXMATCH) 
    517520 
    518521where SYNTAX can be a string (as taken by `modify-syntax-entry'), a syntax 
     
    520523value is such a form.  OVERRIDE cannot be `prepend' or `append'. 
    521524 
    522 For example, an element of the form highlights syntactically: 
     525Here are two examples of elements of `font-lock-syntactic-keywords' 
     526and what they do: 
    523527 
    524528 (\"\\\\$\\\\(#\\\\)\" 1 \".\") 
    525529 
    526  a hash character when following a dollar character, with a SYNTAX of 
    527  \".\" (meaning punctuation syntax).  Assuming that the buffer syntax table does 
    528  specify hash characters to have comment start syntax, the element will only 
    529  highlight hash characters that do not follow dollar characters as comments 
    530  syntactically. 
     530 gives a hash character punctuation syntax (\".\") when following a 
     531 dollar-sign character.  Hash characters in other contexts will still 
     532 follow whatever the syntax table says about the hash character. 
    531533 
    532534 (\"\\\\('\\\\).\\\\('\\\\)\" 
     
    534536  (2 \"\\\"\")) 
    535537 
    536  both single quotes which surround a single character, with a SYNTAX of 
    537  \"\\\"\" (meaning string quote syntax).  Assuming that the buffer syntax table 
    538  does not specify single quotes to have quote syntax, the element will only 
    539  highlight single quotes of the form 'c' as strings syntactically. 
    540  Other forms, such as foo'bar or 'fubar', will not be highlighted as strings. 
     538 gives a pair single-quotes, which surround a single character, a SYNTAX of 
     539 \"\\\"\" (meaning string quote syntax).  Single-quote characters in other 
     540 contexts will not be affected. 
    541541 
    542542This is normally set via `font-lock-defaults'.") 
     
    630630  (defvar font-lock-face-attributes))   ; Obsolete but respected if set. 
    631631 
    632 ;;;###autoload 
    633632(defun font-lock-mode-internal (arg) 
    634633  ;; Turn on Font Lock mode. 
     
    652651    (font-lock-turn-off-thing-lock))) 
    653652 
    654 ;;;###autoload 
    655653(defun font-lock-add-keywords (mode keywords &optional append) 
    656654  "Add highlighting KEYWORDS for MODE. 
     
    771769;; 
    772770;; (II) The keywords are removed from the current buffer. 
    773 ;;;###autoload 
    774771(defun font-lock-remove-keywords (mode keywords) 
    775772  "Remove highlighting KEYWORDS for MODE. 
     
    981978;; multi-line strings and comments; regexps are not appropriate for the job.) 
    982979 
    983 ;;;###autoload 
    984980(defun font-lock-fontify-buffer () 
    985981  "Fontify the current buffer the way the function `font-lock-mode' would." 
     
    10481044          ;; check to see if we should expand the beg/end area for 
    10491045          ;; proper multiline matches 
    1050           (when (and font-lock-multiline 
    1051                      (> beg (point-min)) 
     1046          (when (and (> beg (point-min)) 
    10521047                     (get-text-property (1- beg) 'font-lock-multiline)) 
    10531048            ;; We are just after or in a multiline match. 
     
    10571052            (goto-char beg) 
    10581053            (setq beg (line-beginning-position))) 
    1059           (when font-lock-multiline 
    1060             (setq end (or (text-property-any end (point-max) 
    1061                                              'font-lock-multiline nil) 
    1062                           (point-max)))) 
     1054          (setq end (or (text-property-any end (point-max) 
     1055                                           'font-lock-multiline nil) 
     1056                        (point-max))) 
    10631057          (goto-char end) 
    10641058          ;; Round up to a whole line. 
     
    11841178;; For completeness: this is to `remove-text-properties' as `put-text-property' 
    11851179;; is to `add-text-properties', etc. 
    1186 ;(defun remove-text-property (start end property &optional object) 
    1187 ;  "Remove a property from text from START to END. 
    1188 ;Argument PROPERTY is the property to remove. 
    1189 ;Optional argument OBJECT is the string or buffer containing the text. 
    1190 ;Return t if the property was actually removed, nil otherwise." 
    1191 ;  (remove-text-properties start end (list property) object)) 
     1180;;(defun remove-text-property (start end property &optional object) 
     1181;;  "Remove a property from text from START to END. 
     1182;;Argument PROPERTY is the property to remove. 
     1183;;Optional argument OBJECT is the string or buffer containing the text. 
     1184;;Return t if the property was actually removed, nil otherwise." 
     1185;;  (remove-text-properties start end (list property) object)) 
    11921186 
    11931187;; For consistency: maybe this should be called `remove-single-property' like 
    11941188;; `next-single-property-change' (not `next-single-text-property-change'), etc. 
    1195 ;(defun remove-single-text-property (start end prop value &optional object) 
    1196 ;  "Remove a specific property value from text from START to END. 
    1197 ;Arguments PROP and VALUE specify the property and value to remove.  The 
    1198 ;resulting property values are not equal to VALUE nor lists containing VALUE. 
    1199 ;Optional argument OBJECT is the string or buffer containing the text." 
    1200 ;  (let ((start (text-property-not-all start end prop nil object)) next prev) 
    1201 ;    (while start 
    1202 ;      (setq next (next-single-property-change start prop object end) 
    1203 ;         prev (get-text-property start prop object)) 
    1204 ;      (cond ((and (symbolp prev) (eq value prev)) 
    1205 ;          (remove-text-property start next prop object)) 
    1206 ;         ((and (listp prev) (memq value prev)) 
    1207 ;          (let ((new (delq value prev))) 
    1208 ;            (cond ((null new) 
    1209 ;                   (remove-text-property start next prop object)) 
    1210 ;                  ((= (length new) 1) 
    1211 ;                   (put-text-property start next prop (car new) object)) 
    1212 ;                  (t 
    1213 ;                   (put-text-property start next prop new object)))))) 
    1214 ;      (setq start (text-property-not-all next end prop nil object))))) 
     1189;;(defun remove-single-text-property (start end prop value &optional object) 
     1190;;  "Remove a specific property value from text from START to END. 
     1191;;Arguments PROP and VALUE specify the property and value to remove.  The 
     1192;;resulting property values are not equal to VALUE nor lists containing VALUE. 
     1193;;Optional argument OBJECT is the string or buffer containing the text." 
     1194;;  (let ((start (text-property-not-all start end prop nil object)) next prev) 
     1195;;    (while start 
     1196;;      (setq next (next-single-property-change start prop object end) 
     1197;;        prev (get-text-property start prop object)) 
     1198;;      (cond ((and (symbolp prev) (eq value prev)) 
     1199;;         (remove-text-property start next prop object)) 
     1200;;        ((and (listp prev) (memq value prev)) 
     1201;;         (let ((new (delq value prev))) 
     1202;;           (cond ((null new) 
     1203;;                  (remove-text-property start next prop object)) 
     1204;;                 ((= (length new) 1) 
     1205;;                  (put-text-property start next prop (car new) object)) 
     1206;;                 (t 
     1207;;                  (put-text-property start next prop new object)))))) 
     1208;;      (setq start (text-property-not-all next end prop nil object))))) 
    12151209 
    12161210;;; End of Additional text property functions. 
     
    15341528                             '(font-lock-string-face font-lock-doc-face 
    15351529                               font-lock-comment-face)) 
    1536                        font-lock-warning-face) 
     1530                       (list 'face font-lock-warning-face 
     1531                             'help-echo "Looks like a toplevel defun: escape the parenthesis")) 
    15371532                   prepend))))) 
    15381533    keywords)) 
     
    16021597                         (cdr (assq major-mode 
    16031598                                    (with-no-warnings 
    1604                                     font-lock-defaults-alist))))) 
     1599                                      font-lock-defaults-alist))))) 
    16051600           (keywords 
    16061601            (font-lock-choose-keywords (nth 0 defaults) 
     
    18541849;; mechanism is via `menu-toggle' and `menu-selected' symbol properties.  sm. 
    18551850 
    1856 ;;;;###autoload 
    1857 ;(progn 
    1858 ;  ;; Make the Font Lock menu. 
    1859 ;  (defvar font-lock-menu (make-sparse-keymap "Syntax Highlighting")) 
    1860 ;  ;; Add the menu items in reverse order. 
    1861 ;  (define-key font-lock-menu [fontify-less] 
    1862 ;    '("Less In Current Buffer" . font-lock-fontify-less)) 
    1863 ;  (define-key font-lock-menu [fontify-more] 
    1864 ;    '("More In Current Buffer" . font-lock-fontify-more)) 
    1865 ;  (define-key font-lock-menu [font-lock-sep] 
    1866 ;    '("--")) 
    1867 ;  (define-key font-lock-menu [font-lock-mode] 
    1868 ;    '("In Current Buffer" . font-lock-mode)) 
    1869 ;  (define-key font-lock-menu [global-font-lock-mode] 
    1870 ;    '("In All Buffers" . global-font-lock-mode))) 
    1871 ; 
    1872 ;;;;###autoload 
    1873 ;(progn 
    1874 ;  ;; We put the appropriate `menu-enable' etc. symbol property values on when 
    1875 ;  ;; font-lock.el is loaded, so we don't need to autoload the three variables. 
    1876 ;  (put 'global-font-lock-mode 'menu-toggle t) 
    1877 ;  (put 'font-lock-mode 'menu-toggle t) 
    1878 ;  (put 'font-lock-fontify-more 'menu-enable '(identity)) 
    1879 ;  (put 'font-lock-fontify-less 'menu-enable '(identity))) 
    1880 ; 
    1881 ; ;; Put the appropriate symbol property values on now.  See above. 
    1882 ;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode) 
    1883 ;(put 'font-lock-mode 'menu-selected 'font-lock-mode) 
    1884 ;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level)) 
    1885 ;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level)) 
    1886 ; 
    1887 ;(defvar font-lock-fontify-level nil) ; For less/more fontification. 
    1888 ; 
    1889 ;(defun font-lock-fontify-level (level) 
    1890 ;  (let ((font-lock-maximum-decoration level)) 
    1891 ;    (when font-lock-mode 
    1892 ;      (font-lock-mode)) 
    1893 ;    (font-lock-mode) 
    1894 ;    (when font-lock-verbose 
    1895 ;      (message "Fontifying %s... level %d" (buffer-name) level)))) 
    1896 ; 
    1897 ;(defun font-lock-fontify-less () 
    1898 ;  "Fontify the current buffer with less decoration. 
    1899 ;See `font-lock-maximum-decoration'." 
    1900 ;  (interactive) 
    1901 ;  ;; Check in case we get called interactively. 
    1902 ;  (if (nth 1 font-lock-fontify-level) 
    1903 ;      (font-lock-fontify-level (1- (car font-lock-fontify-level))) 
    1904 ;    (error "No less decoration"))) 
    1905 ; 
    1906 ;(defun font-lock-fontify-more () 
    1907 ;  "Fontify the current buffer with more decoration. 
    1908 ;See `font-lock-maximum-decoration'." 
    1909 ;  (interactive) 
    1910 ;  ;; Check in case we get called interactively. 
    1911 ;  (if (nth 2 font-lock-fontify-level) 
    1912 ;      (font-lock-fontify-level (1+ (car font-lock-fontify-level))) 
    1913 ;    (error "No more decoration"))) 
    1914 ; 
    1915 ; ;; This should be called by `font-lock-set-defaults'. 
    1916 ;(defun font-lock-set-menu () 
    1917 ;  ;; Activate less/more fontification entries if there are multiple levels for 
    1918 ;  ;; the current buffer.  Sets `font-lock-fontify-level' to be of the form 
    1919 ;  ;; (CURRENT-LEVEL IS-LOWER-LEVEL-P IS-HIGHER-LEVEL-P) for menu activation. 
    1920 ;  (let ((keywords (or (nth 0 font-lock-defaults) 
    1921 ;                   (nth 1 (assq major-mode font-lock-defaults-alist)))) 
    1922 ;     (level (font-lock-value-in-major-mode font-lock-maximum-decoration))) 
    1923 ;    (make-local-variable 'font-lock-fontify-level) 
    1924 ;    (if (or (symbolp keywords) (= (length keywords) 1)) 
    1925 ;     (font-lock-unset-menu) 
    1926 ;      (cond ((eq level t) 
    1927 ;          (setq level (1- (length keywords)))) 
    1928 ;         ((or (null level) (zerop level)) 
    1929 ;          ;; The default level is usually, but not necessarily, level 1. 
    1930 ;          (setq level (- (length keywords) 
    1931 ;                         (length (member (eval (car keywords)) 
    1932 ;                                         (mapcar 'eval (cdr keywords)))))))) 
    1933 ;      (setq font-lock-fontify-level (list level (> level 1) 
    1934 ;                                       (< level (1- (length keywords)))))))) 
    1935 ; 
    1936 ; ;; This should be called by `font-lock-unset-defaults'. 
    1937 ;(defun font-lock-unset-menu () 
    1938 ;  ;; Deactivate less/more fontification entries. 
    1939 ;  (setq font-lock-fontify-level nil)) 
     1851;;;;;###autoload 
     1852;;(progn 
     1853;;  ;; Make the Font Lock menu. 
     1854;;  (defvar font-lock-menu (make-sparse-keymap "Syntax Highlighting")) 
     1855;;  ;; Add the menu items in reverse order. 
     1856;;  (define-key font-lock-menu [fontify-less] 
     1857;;    '("Less In Current Buffer" . font-lock-fontify-less)) 
     1858;;  (define-key font-lock-menu [fontify-more] 
     1859;;    '("More In Current Buffer" . font-lock-fontify-more)) 
     1860;;  (define-key font-lock-menu [font-lock-sep] 
     1861;;    '("--")) 
     1862;;  (define-key font-lock-menu [font-lock-mode] 
     1863;;    '("In Current Buffer" . font-lock-mode)) 
     1864;;  (define-key font-lock-menu [global-font-lock-mode] 
     1865;;    '("In All Buffers" . global-font-lock-mode))) 
     1866;; 
     1867;;;;;###autoload 
     1868;;(progn 
     1869;;  ;; We put the appropriate `menu-enable' etc. symbol property values on when 
     1870;;  ;; font-lock.el is loaded, so we don't need to autoload the three variables. 
     1871;;  (put 'global-font-lock-mode 'menu-toggle t) 
     1872;;  (put 'font-lock-mode 'menu-toggle t) 
     1873;;  (put 'font-lock-fontify-more 'menu-enable '(identity)) 
     1874;;  (put 'font-lock-fontify-less 'menu-enable '(identity))) 
     1875;; 
     1876;; ;; Put the appropriate symbol property values on now.  See above. 
     1877;;(put 'global-font-lock-mode 'menu-selected 'global-font-lock-mode) 
     1878;;(put 'font-lock-mode 'menu-selected 'font-lock-mode) 
     1879;;(put 'font-lock-fontify-more 'menu-enable '(nth 2 font-lock-fontify-level)) 
     1880;;(put 'font-lock-fontify-less 'menu-enable '(nth 1 font-lock-fontify-level)) 
     1881;; 
     1882;;(defvar font-lock-fontify-level nil)        ; For less/more fontification. 
     1883;; 
     1884;;(defun font-lock-fontify-level (level) 
     1885;;  (let ((font-lock-maximum-decoration level)) 
     1886;;    (when font-lock-mode 
     1887;;      (font-lock-mode)) 
     1888;;    (font-lock-mode) 
     1889;;    (when font-lock-verbose 
     1890;;      (message "Fontifying %s... level %d" (buffer-name) level)))) 
     1891;; 
     1892;;(defun font-lock-fontify-less () 
     1893;;  "Fontify the current buffer with less decoration. 
     1894;;See `font-lock-maximum-decoration'." 
     1895;;  (interactive) 
     1896;;  ;; Check in case we get called interactively. 
     1897;;  (if (nth 1 font-lock-fontify-level) 
     1898;;      (font-lock-fontify-level (1- (car font-lock-fontify-level))) 
     1899;;    (error "No less decoration"))) 
     1900;; 
     1901;;(defun font-lock-fontify-more () 
     1902;;  "Fontify the current buffer with more decoration. 
     1903;;See `font-lock-maximum-decoration'." 
     1904;;  (interactive) 
     1905;;  ;; Check in case we get called interactively. 
     1906;;  (if (nth 2 font-lock-fontify-level) 
     1907;;      (font-lock-fontify-level (1+ (car font-lock-fontify-level))) 
     1908;;    (error "No more decoration"))) 
     1909;; 
     1910;; ;; This should be called by `font-lock-set-defaults'. 
     1911;;(defun font-lock-set-menu () 
     1912;;  ;; Activate less/more fontification entries if there are multiple levels for 
     1913;;  ;; the current buffer.  Sets `font-lock-fontify-level' to be of the form 
     1914;;  ;; (CURRENT-LEVEL IS-LOWER-LEVEL-P IS-HIGHER-LEVEL-P) for menu activation. 
     1915;;  (let ((keywords (or (nth 0 font-lock-defaults) 
     1916;;                  (nth 1 (assq major-mode font-lock-defaults-alist)))) 
     1917;;    (level (font-lock-value-in-major-mode font-lock-maximum-decoration))) 
     1918;;    (make-local-variable 'font-lock-fontify-level) 
     1919;;    (if (or (symbolp keywords) (= (length keywords) 1)) 
     1920;;    (font-lock-unset-menu) 
     1921;;      (cond ((eq level t) 
     1922;;         (setq level (1- (length keywords)))) 
     1923;;        ((or (null level) (zerop level)) 
     1924;;         ;; The default level is usually, but not necessarily, level 1. 
     1925;;         (setq level (- (length keywords) 
     1926;;                        (length (member (eval (car keywords)) 
     1927;;                                        (mapcar 'eval (cdr keywords)))))))) 
     1928;;      (setq font-lock-fontify-level (list level (> level 1) 
     1929;;                                      (< level (1- (length keywords)))))))) 
     1930;; 
     1931;; ;; This should be called by `font-lock-unset-defaults'. 
     1932;;(defun font-lock-unset-menu () 
     1933;;  ;; Deactivate less/more fontification entries. 
     1934;;  (setq font-lock-fontify-level nil)) 
    19401935 
    19411936;;; End of Menu support. 
    19421937  
    19431938;;; Various regexp information shared by several modes. 
    1944 ; ;; Information specific to a single mode should go in its load library. 
     1939;; ;; Information specific to a single mode should go in its load library. 
    19451940 
    19461941;; Font Lock support for C, C++, Objective-C and Java modes is now in 
     
    20362031                 "condition-case" "track-mouse" 
    20372032                 "eval-after-load" "eval-and-compile" "eval-when-compile" 
    2038                  "eval-when" 
     2033                 "eval-when" "eval-at-startup" "eval-next-after-load" 
    20392034                 "with-category-table" 
    20402035                 "with-current-buffer" "with-electric-help"