changeset 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 134f7085c56b
children fa57d5ed7df8
files lisp/font-lock.el
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/font-lock.el	Tue Oct 18 21:53:19 1994 +0000
+++ b/lisp/font-lock.el	Tue Oct 18 22:34:04 1994 +0000
@@ -337,7 +337,15 @@
 			(concat "\\s\"\\|" comment-start-skip)
 		      "\\s\""))
 	    (cend (if comment-end
-		      (concat "\\s>\\|" (regexp-quote comment-end))
+		      (concat "\\s>\\|"
+			      (regexp-quote
+			       ;; Discard leading spaces from comment-end.
+			       ;; In C mode, it is " */"
+			       ;; and we don't want to fail to notice a */
+			       ;; just because there's no space there.
+			       (if (string-match "^ +" comment-end)
+				   (substring comment-end (match-end 0))
+				 comment-end)))
 		    "\\s>"))
 	    (startline (point))
 	    state prev prevstate)
@@ -462,8 +470,12 @@
       (if font-lock-no-comments
 	  (remove-text-properties beg end '(face nil))
 	(font-lock-fontify-region beg end))
-      ;; Now scan for keywords.
-      (font-lock-hack-keywords beg end))))
+      ;; Now scan for keywords, but not if we are inside a comment now.
+      (or (and (not font-lock-no-comments)
+	       (let ((state (parse-partial-sexp beg end nil nil 
+						font-lock-cache-state)))
+		 (or (nth 4 state) (nth 7 state))))
+	  (font-lock-hack-keywords beg end)))))
 
 ;;; Fontifying arbitrary patterns