comparison lisp/packages/font-lock.el @ 26:441bb1e64a06 r19-15b96

Import from CVS: tag r19-15b96
author cvs
date Mon, 13 Aug 2007 08:51:32 +0200
parents 859a2309aef8
children ec9a17fef872
comparison
equal deleted inserted replaced
25:383a494979f8 26:441bb1e64a06
272 272
273 MATCH-HIGHLIGHT should be of the form: 273 MATCH-HIGHLIGHT should be of the form:
274 274
275 (MATCH FACENAME OVERRIDE LAXMATCH) 275 (MATCH FACENAME OVERRIDE LAXMATCH)
276 276
277 Where MATCHER can be either the regexp to search for, or the function name to 277 Where MATCHER can be either the regexp to search for, a variable
278 call to make the search (called with one argument, the limit of the search). 278 containing the regexp to search for, or the function to call to make
279 MATCH is the subexpression of MATCHER to be highlighted. FACENAME is either 279 the search (called with one argument, the limit of the search). MATCH
280 a symbol naming a face, or an expression whose value is the face name to use. 280 is the subexpression of MATCHER to be highlighted. FACENAME is either
281 If you want FACENAME to be a symbol that evaluates to a face, use a form 281 a symbol naming a face, or an expression whose value is the face name
282 like \"(progn sym)\". 282 to use. If you want FACENAME to be a symbol that evaluates to a face,
283 use a form like \"(progn sym)\".
283 284
284 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may 285 OVERRIDE and LAXMATCH are flags. If OVERRIDE is t, existing fontification may
285 be overwritten. If `keep', only parts not already fontified are highlighted. 286 be overwritten. If `keep', only parts not already fontified are highlighted.
286 If `prepend' or `append', existing fontification is merged with the new, in 287 If `prepend' or `append', existing fontification is merged with the new, in
287 which the new or existing fontification, respectively, takes precedence. 288 which the new or existing fontification, respectively, takes precedence.
1125 (save-excursion (end-of-line) (setq limit (min limit (point)))) 1126 (save-excursion (end-of-line) (setq limit (min limit (point))))
1126 ;; Evaluate PRE-MATCH-FORM. 1127 ;; Evaluate PRE-MATCH-FORM.
1127 (eval (nth 1 keywords)) 1128 (eval (nth 1 keywords))
1128 (save-match-data 1129 (save-match-data
1129 ;; Find an occurrence of `matcher' before `limit'. 1130 ;; Find an occurrence of `matcher' before `limit'.
1131 (if (and (not (stringp matcher))
1132 (not (functionp matcher))
1133 (boundp matcher))
1134 (setq matcher (symbol-value matcher)))
1130 (while (if (stringp matcher) 1135 (while (if (stringp matcher)
1131 (re-search-forward matcher limit t) 1136 (re-search-forward matcher limit t)
1132 (funcall matcher limit)) 1137 (funcall matcher limit))
1133 ;; Apply each highlight to this instance of `matcher'. 1138 ;; Apply each highlight to this instance of `matcher'.
1134 (setq highlights lowdarks) 1139 (setq highlights lowdarks)
1155 (if loudly (message "Fontifying %s... (regexps..%s)" bufname 1160 (if loudly (message "Fontifying %s... (regexps..%s)" bufname
1156 (make-string (setq count (1+ count)) ?.))) 1161 (make-string (setq count (1+ count)) ?.)))
1157 ;; 1162 ;;
1158 ;; Find an occurrence of `matcher' from `start' to `end'. 1163 ;; Find an occurrence of `matcher' from `start' to `end'.
1159 (setq keyword (car keywords) matcher (car keyword)) 1164 (setq keyword (car keywords) matcher (car keyword))
1165 (if (and (not (stringp matcher))
1166 (not (functionp matcher))
1167 (boundp matcher))
1168 (setq matcher (symbol-value matcher)))
1160 (goto-char start) 1169 (goto-char start)
1161 (while (and (< (point) end) 1170 (while (and (< (point) end)
1162 (if (stringp matcher) 1171 (if (stringp matcher)
1163 (re-search-forward matcher end t) 1172 (re-search-forward matcher end t)
1164 (funcall matcher end))) 1173 (funcall matcher end)))
2517 '("\\[.*\\]" . font-lock-type-face) 2526 '("\\[.*\\]" . font-lock-type-face)
2518 '("`.*`" . font-lock-type-face) 2527 '("`.*`" . font-lock-type-face)
2519 )) 2528 ))
2520 "Additional expressions to highlight in sh-mode.") 2529 "Additional expressions to highlight in sh-mode.")
2521 2530
2522 (defconst python-font-lock-keywords
2523 (purecopy
2524 (list
2525 (cons (concat "\\b\\("
2526 (mapconcat 'identity
2527 '("access" "del" "from"
2528 "lambda" "return" "and"
2529 "elif" "global" "not"
2530 "try:" "break " "else:"
2531 "if" "or" "while"
2532 "except" "except:" "import"
2533 "pass" "continue" "finally:"
2534 "in" "print" "for"
2535 "is" "raise")
2536 "\\|")
2537 "\\)[ \n\t(]")
2538 1)
2539 '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
2540 1 font-lock-type-face)
2541 '("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)"
2542 1 font-lock-function-name-face)
2543 ))
2544 "Additional expressions to highlight in Python mode.")
2545
2546
2547 2531
2548 ;; Install ourselves: 2532 ;; Install ourselves:
2549 2533
2550 (add-hook 'find-file-hooks 'font-lock-set-defaults t) 2534 (add-hook 'find-file-hooks 'font-lock-set-defaults t)
2551 2535