comparison lisp/font-lock.el @ 83542:2d56e13fd23d

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-413 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-414 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-415 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-416 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-417 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-418 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-419 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-420 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-421 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-422 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-423 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-424 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-425 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-426 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-427 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-428 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-429 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-430 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-431 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-432 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-433 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-434 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-435 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-436 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-437 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-438 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-439 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-440 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-441 lisp/url/url-methods.el: Fix format error when http_proxy is empty string * emacs@sv.gnu.org/emacs--devo--0--patch-442 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-443 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-444 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-445 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-446 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-447 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-448 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-449 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-450 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-451 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-452 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-453 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-454 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-455 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-456 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-457 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-458 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-459 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-460 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-461 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-462 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-463 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-464 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-465 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-466 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-467 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-468 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-469 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-470 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-471 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-472 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-473 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-128 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-129 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-130 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-131 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-132 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-133 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-134 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-135 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-136 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-137 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-138 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-139 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-140 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-141 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-142 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-143 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-144 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-145 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-146 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-147 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-148 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-149 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-582
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 14 Oct 2006 17:36:28 +0000
parents 694bbb62a75d 57c68ed8bb9c
children b8d9a391daf3
comparison
equal deleted inserted replaced
83541:694bbb62a75d 83542:2d56e13fd23d
716 (append old keywords) 716 (append old keywords)
717 (append keywords old))))) 717 (append keywords old)))))
718 ;; If the keywords were compiled before, compile them again. 718 ;; If the keywords were compiled before, compile them again.
719 (if was-compiled 719 (if was-compiled
720 (setq font-lock-keywords 720 (setq font-lock-keywords
721 (font-lock-compile-keywords font-lock-keywords t))))))) 721 (font-lock-compile-keywords font-lock-keywords)))))))
722 722
723 (defun font-lock-update-removed-keyword-alist (mode keywords how) 723 (defun font-lock-update-removed-keyword-alist (mode keywords how)
724 "Update `font-lock-removed-keywords-alist' when adding new KEYWORDS to MODE." 724 "Update `font-lock-removed-keywords-alist' when adding new KEYWORDS to MODE."
725 ;; When font-lock is enabled first all keywords in the list 725 ;; When font-lock is enabled first all keywords in the list
726 ;; `font-lock-keywords-alist' are added, then all keywords in the 726 ;; `font-lock-keywords-alist' are added, then all keywords in the
823 (delete keyword font-lock-keywords))) 823 (delete keyword font-lock-keywords)))
824 824
825 ;; If the keywords were compiled before, compile them again. 825 ;; If the keywords were compiled before, compile them again.
826 (if was-compiled 826 (if was-compiled
827 (setq font-lock-keywords 827 (setq font-lock-keywords
828 (font-lock-compile-keywords font-lock-keywords t))))))) 828 (font-lock-compile-keywords font-lock-keywords)))))))
829 829
830 ;;; Font Lock Support mode. 830 ;;; Font Lock Support mode.
831 831
832 ;; This is the code used to interface font-lock.el with any of its add-on 832 ;; This is the code used to interface font-lock.el with any of its add-on
833 ;; packages, and provide the user interface. Packages that have their own 833 ;; packages, and provide the user interface. Packages that have their own
1166 ;; Actually, this is not needed because 1166 ;; Actually, this is not needed because
1167 ;; font-lock-default-fontify-region already rounds up to a whole 1167 ;; font-lock-default-fontify-region already rounds up to a whole
1168 ;; number of lines. 1168 ;; number of lines.
1169 ;; (setq beg (progn (goto-char beg) (line-beginning-position)) 1169 ;; (setq beg (progn (goto-char beg) (line-beginning-position))
1170 ;; end (progn (goto-char end) (line-beginning-position 2))) 1170 ;; end (progn (goto-char end) (line-beginning-position 2)))
1171 ) 1171 (unless (eq end (point-max))
1172 ;; Rounding up to a whole number of lines should include the
1173 ;; line right after `end'. Typical case: the first char of
1174 ;; the line was deleted. Or a \n was inserted in the middle
1175 ;; of a line.
1176 (setq end (1+ end))))
1172 (font-lock-fontify-region beg end))))) 1177 (font-lock-fontify-region beg end)))))
1173 1178
1174 (defvar jit-lock-start) (defvar jit-lock-end) 1179 (defvar jit-lock-start) (defvar jit-lock-end)
1175 (defun font-lock-extend-jit-lock-region-after-change (beg end old-len) 1180 (defun font-lock-extend-jit-lock-region-after-change (beg end old-len)
1176 "Function meant for `jit-lock-after-change-extend-region-functions'. 1181 "Function meant for `jit-lock-after-change-extend-region-functions'.
1203 (when (and (> beg (point-min)) 1208 (when (and (> beg (point-min))
1204 (get-text-property (1- beg) 'font-lock-multiline)) 1209 (get-text-property (1- beg) 'font-lock-multiline))
1205 (setq beg (or (previous-single-property-change 1210 (setq beg (or (previous-single-property-change
1206 beg 'font-lock-multiline) 1211 beg 'font-lock-multiline)
1207 (point-min)))) 1212 (point-min))))
1208 (setq end (or (text-property-any end (point-max) 1213 (when (< end (point-max))
1209 'font-lock-multiline nil) 1214 (setq end
1210 (point-max))) 1215 (if (get-text-property end 'font-lock-multiline)
1216 (or (text-property-any end (point-max)
1217 'font-lock-multiline nil)
1218 (point-max))
1219 ;; Rounding up to a whole number of lines should include the
1220 ;; line right after `end'. Typical case: the first char of
1221 ;; the line was deleted. Or a \n was inserted in the middle
1222 ;; of a line.
1223 (1+ end))))
1211 ;; Finally, pre-enlarge the region to a whole number of lines, to try 1224 ;; Finally, pre-enlarge the region to a whole number of lines, to try
1212 ;; and anticipate what font-lock-default-fontify-region will do, so as to 1225 ;; and anticipate what font-lock-default-fontify-region will do, so as to
1213 ;; avoid double-redisplay. 1226 ;; avoid double-redisplay.
1214 ;; We could just run `font-lock-extend-region-functions', but since 1227 ;; We could just run `font-lock-extend-region-functions', but since
1215 ;; the only purpose is to avoid the double-redisplay, we prefer to 1228 ;; the only purpose is to avoid the double-redisplay, we prefer to
1216 ;; do here only the part that is cheap and most likely to be useful. 1229 ;; do here only the part that is cheap and most likely to be useful.
1217 (when (memq 'font-lock-extend-region-wholelines 1230 (when (memq 'font-lock-extend-region-wholelines
1218 font-lock-extend-region-functions) 1231 font-lock-extend-region-functions)
1219 (goto-char beg) 1232 (goto-char beg)
1220 (forward-line 0) 1233 (setq jit-lock-start (min jit-lock-start (line-beginning-position)))
1221 (setq jit-lock-start (min jit-lock-start (point)))
1222 (goto-char end) 1234 (goto-char end)
1223 (forward-line 1) 1235 (setq jit-lock-end
1224 (setq jit-lock-end (max jit-lock-end (point))))))) 1236 (max jit-lock-end
1237 (if (bolp) (point) (line-beginning-position 2))))))))
1225 1238
1226 (defun font-lock-fontify-block (&optional arg) 1239 (defun font-lock-fontify-block (&optional arg)
1227 "Fontify some lines the way `font-lock-fontify-buffer' would. 1240 "Fontify some lines the way `font-lock-fontify-buffer' would.
1228 The lines could be a function or paragraph, or a specified number of lines. 1241 The lines could be a function or paragraph, or a specified number of lines.
1229 If ARG is given, fontify that many lines before and after point, or 16 lines if 1242 If ARG is given, fontify that many lines before and after point, or 16 lines if
1412 (setq font-lock-syntactic-keywords (font-lock-eval-keywords 1425 (setq font-lock-syntactic-keywords (font-lock-eval-keywords
1413 font-lock-syntactic-keywords))) 1426 font-lock-syntactic-keywords)))
1414 ;; If `font-lock-syntactic-keywords' is not compiled, compile it. 1427 ;; If `font-lock-syntactic-keywords' is not compiled, compile it.
1415 (unless (eq (car font-lock-syntactic-keywords) t) 1428 (unless (eq (car font-lock-syntactic-keywords) t)
1416 (setq font-lock-syntactic-keywords (font-lock-compile-keywords 1429 (setq font-lock-syntactic-keywords (font-lock-compile-keywords
1417 font-lock-syntactic-keywords))) 1430 font-lock-syntactic-keywords
1431 t)))
1418 ;; Get down to business. 1432 ;; Get down to business.
1419 (let ((case-fold-search font-lock-keywords-case-fold-search) 1433 (let ((case-fold-search font-lock-keywords-case-fold-search)
1420 (keywords (cddr font-lock-syntactic-keywords)) 1434 (keywords (cddr font-lock-syntactic-keywords))
1421 keyword matcher highlights) 1435 keyword matcher highlights)
1422 (while keywords 1436 (while keywords
1568 "Fontify according to `font-lock-keywords' between START and END. 1582 "Fontify according to `font-lock-keywords' between START and END.
1569 START should be at the beginning of a line. 1583 START should be at the beginning of a line.
1570 LOUDLY, if non-nil, allows progress-meter bar." 1584 LOUDLY, if non-nil, allows progress-meter bar."
1571 (unless (eq (car font-lock-keywords) t) 1585 (unless (eq (car font-lock-keywords) t)
1572 (setq font-lock-keywords 1586 (setq font-lock-keywords
1573 (font-lock-compile-keywords font-lock-keywords t))) 1587 (font-lock-compile-keywords font-lock-keywords)))
1574 (let ((case-fold-search font-lock-keywords-case-fold-search) 1588 (let ((case-fold-search font-lock-keywords-case-fold-search)
1575 (keywords (cddr font-lock-keywords)) 1589 (keywords (cddr font-lock-keywords))
1576 (bufname (buffer-name)) (count 0) 1590 (bufname (buffer-name)) (count 0)
1577 (pos (make-marker)) 1591 (pos (make-marker))
1578 keyword matcher highlights) 1592 keyword matcher highlights)
1624 1638
1625 ;;; End of Keyword regexp fontification functions. 1639 ;;; End of Keyword regexp fontification functions.
1626 1640
1627 ;; Various functions. 1641 ;; Various functions.
1628 1642
1629 (defun font-lock-compile-keywords (keywords &optional regexp) 1643 (defun font-lock-compile-keywords (keywords &optional syntactic-keywords)
1630 "Compile KEYWORDS into the form (t KEYWORDS COMPILED...) 1644 "Compile KEYWORDS into the form (t KEYWORDS COMPILED...)
1631 Here each COMPILED is of the form (MATCHER HIGHLIGHT ...) as shown in the 1645 Here each COMPILED is of the form (MATCHER HIGHLIGHT ...) as shown in the
1632 `font-lock-keywords' doc string. 1646 `font-lock-keywords' doc string.
1633 If REGEXP is non-nil, it means these keywords are used for 1647 If SYNTACTIC-KEYWORDS is non-nil, it means these keywords are used for
1634 `font-lock-keywords' rather than for `font-lock-syntactic-keywords'." 1648 `font-lock-syntactic-keywords' rather than for `font-lock-keywords'."
1635 (if (not font-lock-set-defaults) 1649 (if (not font-lock-set-defaults)
1636 ;; This should never happen. But some external packages sometimes 1650 ;; This should never happen. But some external packages sometimes
1637 ;; call font-lock in unexpected and incorrect ways. It's important to 1651 ;; call font-lock in unexpected and incorrect ways. It's important to
1638 ;; stop processing at this point, otherwise we may end up changing the 1652 ;; stop processing at this point, otherwise we may end up changing the
1639 ;; global value of font-lock-keywords and break highlighting in many 1653 ;; global value of font-lock-keywords and break highlighting in many
1642 (if (eq (car-safe keywords) t) 1656 (if (eq (car-safe keywords) t)
1643 keywords 1657 keywords
1644 (setq keywords 1658 (setq keywords
1645 (cons t (cons keywords 1659 (cons t (cons keywords
1646 (mapcar 'font-lock-compile-keyword keywords)))) 1660 (mapcar 'font-lock-compile-keyword keywords))))
1647 (if (and regexp 1661 (if (and (not syntactic-keywords)
1648 (eq (or syntax-begin-function 1662 (let ((beg-function
1649 font-lock-beginning-of-syntax-function) 1663 (or font-lock-beginning-of-syntax-function
1650 'beginning-of-defun) 1664 syntax-begin-function)))
1665 (or (eq beg-function 'beginning-of-defun)
1666 (get beg-function 'font-lock-syntax-paren-check)))
1651 (not beginning-of-defun-function)) 1667 (not beginning-of-defun-function))
1652 ;; Try to detect when a string or comment contains something that 1668 ;; Try to detect when a string or comment contains something that
1653 ;; looks like a defun and would thus confuse font-lock. 1669 ;; looks like a defun and would thus confuse font-lock.
1654 (nconc keywords 1670 (nconc keywords
1655 `((,(if defun-prompt-regexp 1671 `((,(if defun-prompt-regexp
1772 (when removed-keywords 1788 (when removed-keywords
1773 (font-lock-remove-keywords nil removed-keywords)) 1789 (font-lock-remove-keywords nil removed-keywords))
1774 ;; Now compile the keywords. 1790 ;; Now compile the keywords.
1775 (unless (eq (car font-lock-keywords) t) 1791 (unless (eq (car font-lock-keywords) t)
1776 (setq font-lock-keywords 1792 (setq font-lock-keywords
1777 (font-lock-compile-keywords font-lock-keywords t)))))) 1793 (font-lock-compile-keywords font-lock-keywords))))))
1778 1794
1779 ;;; Colour etc. support. 1795 ;;; Colour etc. support.
1780 1796
1781 ;; Note that `defface' will not overwrite any faces declared above via 1797 ;; Note that `defface' will not overwrite any faces declared above via
1782 ;; `custom-declare-face'. 1798 ;; `custom-declare-face'.