Mercurial > hg > xemacs-beta
comparison lisp/packages/font-lock.el @ 102:a145efe76779 r20-1b3
Import from CVS: tag r20-1b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:15:49 +0200 |
parents | dbb370e3c29e |
children | 360340f9fd5f |
comparison
equal
deleted
inserted
replaced
101:a0ec055d74dd | 102:a145efe76779 |
---|---|
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))) |
2524 '("\\[.*\\]" . font-lock-type-face) | 2533 '("\\[.*\\]" . font-lock-type-face) |
2525 '("`.*`" . font-lock-type-face) | 2534 '("`.*`" . font-lock-type-face) |
2526 )) | 2535 )) |
2527 "Additional expressions to highlight in sh-mode.") | 2536 "Additional expressions to highlight in sh-mode.") |
2528 | 2537 |
2529 (defconst python-font-lock-keywords | |
2530 (purecopy | |
2531 (list | |
2532 (cons (concat "\\b\\(" | |
2533 (mapconcat 'identity | |
2534 '("access" "del" "from" | |
2535 "lambda" "return" "and" | |
2536 "elif" "global" "not" | |
2537 "try:" "break " "else:" | |
2538 "if" "or" "while" | |
2539 "except" "except:" "import" | |
2540 "pass" "continue" "finally:" | |
2541 "in" "print" "for" | |
2542 "is" "raise") | |
2543 "\\|") | |
2544 "\\)[ \n\t(]") | |
2545 1) | |
2546 '("\\bclass[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" | |
2547 1 font-lock-type-face) | |
2548 '("\\bdef[ \t]+\\([a-zA-Z_]+[a-zA-Z0-9_]*\\)" | |
2549 1 font-lock-function-name-face) | |
2550 )) | |
2551 "Additional expressions to highlight in Python mode.") | |
2552 | |
2553 | |
2554 | 2538 |
2555 ;; Install ourselves: | 2539 ;; Install ourselves: |
2556 | 2540 |
2557 (add-hook 'find-file-hooks 'font-lock-set-defaults t) | 2541 (add-hook 'find-file-hooks 'font-lock-set-defaults t) |
2558 | 2542 |