diff options
| author | Richard M. Stallman | 1994-10-18 22:34:04 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-10-18 22:34:04 +0000 |
| commit | c9ed66f41f21730103554ee2a9f29856bdc0e7fb (patch) | |
| tree | d4aefa9efed6f0d190430190856f66b346240e76 | |
| parent | abe9ff327fdcb86d6b1c051a6b6c77a31202edc6 (diff) | |
| download | emacs-c9ed66f41f21730103554ee2a9f29856bdc0e7fb.tar.gz emacs-c9ed66f41f21730103554ee2a9f29856bdc0e7fb.zip | |
(font-lock-after-change-function): If inside a comment,
don't scan for keywords.
(font-lock-fontify-region): Discard leading spaces from comment-end.
| -rw-r--r-- | lisp/font-lock.el | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index 88d605c74d3..a1b6df6537c 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -337,7 +337,15 @@ the face is also set; its value is the face name." | |||
| 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) |
| @@ -462,8 +470,12 @@ the face is also set; its value is the face name." | |||
| 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 | ||