Mercurial > hg > xemacs-beta
comparison lisp/font-lock.el @ 406:b8cc9ab3f761 r21-2-33
Import from CVS: tag r21-2-33
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:17:09 +0200 |
parents | 2f8bb876ab1d |
children | 501cfd01ee6d |
comparison
equal
deleted
inserted
replaced
405:0e08f63c74d2 | 406:b8cc9ab3f761 |
---|---|
1494 (defun font-lock-fontify-keywords-region (start end &optional loudvar) | 1494 (defun font-lock-fontify-keywords-region (start end &optional loudvar) |
1495 "Fontify according to `font-lock-keywords' between START and END. | 1495 "Fontify according to `font-lock-keywords' between START and END. |
1496 START should be at the beginning of a line." | 1496 START should be at the beginning of a line." |
1497 (let ((loudly (and font-lock-verbose | 1497 (let ((loudly (and font-lock-verbose |
1498 (>= (- end start) font-lock-message-threshold)))) | 1498 (>= (- end start) font-lock-message-threshold)))) |
1499 (let ((case-fold-search font-lock-keywords-case-fold-search) | 1499 (let* ((case-fold-search font-lock-keywords-case-fold-search) |
1500 (keywords (cdr (if (eq (car-safe font-lock-keywords) t) | 1500 (keywords (cdr (if (eq (car-safe font-lock-keywords) t) |
1501 font-lock-keywords | 1501 font-lock-keywords |
1502 (font-lock-compile-keywords)))) | 1502 (font-lock-compile-keywords)))) |
1503 (bufname (buffer-name)) (count 5) | 1503 (bufname (buffer-name)) |
1504 keyword matcher highlights) | 1504 (progress 5) (old-progress 5) |
1505 (iter 0) | |
1506 (nkeywords (length keywords)) | |
1507 keyword matcher highlights) | |
1505 ;; | 1508 ;; |
1506 ;; Fontify each item in `font-lock-keywords' from `start' to `end'. | 1509 ;; Fontify each item in `font-lock-keywords' from `start' to `end'. |
1510 ;; In order to measure progress accurately we need to know how | |
1511 ;; many keywords we have and how big the region is. Then progress | |
1512 ;; is ((pos - start)/ (end - start) * nkeywords | |
1513 ;; + iteration / nkeywords) * 100 | |
1507 (while keywords | 1514 (while keywords |
1508 (when loudly (lprogress-display 'font-lock "Fontifying %s... (regexps)" | |
1509 (setq count (+ count 5)) bufname)) | |
1510 ;; | 1515 ;; |
1511 ;; Find an occurrence of `matcher' from `start' to `end'. | 1516 ;; Find an occurrence of `matcher' from `start' to `end'. |
1512 (setq keyword (car keywords) matcher (car keyword)) | 1517 (setq keyword (car keywords) matcher (car keyword)) |
1513 (goto-char start) | 1518 (goto-char start) |
1514 (while (and (< (point) end) | 1519 (while (and (< (point) end) |
1515 (if (stringp matcher) | 1520 (if (stringp matcher) |
1516 (re-search-forward matcher end t) | 1521 (re-search-forward matcher end t) |
1517 (funcall matcher end))) | 1522 (funcall matcher end))) |
1523 ;; calculate progress | |
1524 (setq progress | |
1525 (+ (/ (* (- (point) start) 95) (* (- end start) nkeywords)) | |
1526 (/ (* iter 95) nkeywords) 5)) | |
1527 (when (and loudly (> progress old-progress)) | |
1528 (lprogress-display 'font-lock "Fontifying %s... (regexps)" | |
1529 progress bufname)) | |
1530 (setq old-progress progress) | |
1518 ;; Apply each highlight to this instance of `matcher', which may be | 1531 ;; Apply each highlight to this instance of `matcher', which may be |
1519 ;; specific highlights or more keywords anchored to `matcher'. | 1532 ;; specific highlights or more keywords anchored to `matcher'. |
1520 (setq highlights (cdr keyword)) | 1533 (setq highlights (cdr keyword)) |
1521 (while highlights | 1534 (while highlights |
1522 (if (numberp (car (car highlights))) | 1535 (if (numberp (car (car highlights))) |
1526 ;; keyword so keywords can share bracketing | 1539 ;; keyword so keywords can share bracketing |
1527 ;; expressions. | 1540 ;; expressions. |
1528 (and end (goto-char end))) | 1541 (and end (goto-char end))) |
1529 (font-lock-fontify-anchored-keywords (car highlights) end)) | 1542 (font-lock-fontify-anchored-keywords (car highlights) end)) |
1530 (setq highlights (cdr highlights)))) | 1543 (setq highlights (cdr highlights)))) |
1544 (setq iter (1+ iter)) | |
1531 (setq keywords (cdr keywords)))) | 1545 (setq keywords (cdr keywords)))) |
1532 (if loudly (lprogress-display 'font-lock "Fontifying %s... " 100 (buffer-name))))) | 1546 (if loudly (lprogress-display 'font-lock "Fontifying %s... " 100 (buffer-name))))) |
1533 | 1547 |
1534 | 1548 |
1535 ;; Various functions. | 1549 ;; Various functions. |