Mercurial > emacs
comparison lisp/font-lock.el @ 9597:d352bebc9103
(font-lock-after-change-function): If inside a comment,
don't scan for keywords.
(font-lock-fontify-region): Discard leading spaces from comment-end.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 18 Oct 1994 22:34:04 +0000 |
parents | 76ce1230257f |
children | 5ae33de679f6 |
comparison
equal
deleted
inserted
replaced
9596:134f7085c56b | 9597:d352bebc9103 |
---|---|
335 (modified (buffer-modified-p)) | 335 (modified (buffer-modified-p)) |
336 (cstart (if comment-start-skip | 336 (cstart (if comment-start-skip |
337 (concat "\\s\"\\|" comment-start-skip) | 337 (concat "\\s\"\\|" comment-start-skip) |
338 "\\s\"")) | 338 "\\s\"")) |
339 (cend (if comment-end | 339 (cend (if comment-end |
340 (concat "\\s>\\|" (regexp-quote comment-end)) | 340 (concat "\\s>\\|" |
341 (regexp-quote | |
342 ;; Discard leading spaces from comment-end. | |
343 ;; In C mode, it is " */" | |
344 ;; and we don't want to fail to notice a */ | |
345 ;; just because there's no space there. | |
346 (if (string-match "^ +" comment-end) | |
347 (substring comment-end (match-end 0)) | |
348 comment-end))) | |
341 "\\s>")) | 349 "\\s>")) |
342 (startline (point)) | 350 (startline (point)) |
343 state prev prevstate) | 351 state prev prevstate) |
344 ;; Find the state at the line-beginning before START. | 352 ;; Find the state at the line-beginning before START. |
345 (if (eq startline font-lock-cache-position) | 353 (if (eq startline font-lock-cache-position) |
460 ;; Must scan from line start in case of | 468 ;; Must scan from line start in case of |
461 ;; inserting space into `intfoo () {}', and after widened. | 469 ;; inserting space into `intfoo () {}', and after widened. |
462 (if font-lock-no-comments | 470 (if font-lock-no-comments |
463 (remove-text-properties beg end '(face nil)) | 471 (remove-text-properties beg end '(face nil)) |
464 (font-lock-fontify-region beg end)) | 472 (font-lock-fontify-region beg end)) |
465 ;; Now scan for keywords. | 473 ;; Now scan for keywords, but not if we are inside a comment now. |
466 (font-lock-hack-keywords beg end)))) | 474 (or (and (not font-lock-no-comments) |
475 (let ((state (parse-partial-sexp beg end nil nil | |
476 font-lock-cache-state))) | |
477 (or (nth 4 state) (nth 7 state)))) | |
478 (font-lock-hack-keywords beg end))))) | |
467 | 479 |
468 ;;; Fontifying arbitrary patterns | 480 ;;; Fontifying arbitrary patterns |
469 | 481 |
470 (defun font-lock-hack-keywords (start end &optional loudly) | 482 (defun font-lock-hack-keywords (start end &optional loudly) |
471 "Fontify according to `font-lock-keywords' between START and END." | 483 "Fontify according to `font-lock-keywords' between START and END." |