diff options
| author | Richard M. Stallman | 1993-07-22 06:12:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-07-22 06:12:37 +0000 |
| commit | 313d590c15bda951da66306f3d705474e4295eef (patch) | |
| tree | bcea9a46c5d07f8b3f08c63f4ddbe24e2b13fff8 | |
| parent | 23b97eb96a339d72e654784749268281cfa094fd (diff) | |
| download | emacs-313d590c15bda951da66306f3d705474e4295eef.tar.gz emacs-313d590c15bda951da66306f3d705474e4295eef.zip | |
(perl-font-lock-keywords): Add a `(... . 1)' to the
first element of the list.
(font-lock-hack-keywords, font-lock-unfontify-region)
(font-lock-fontify-region): Bind buffer-read-only to nil,
and don't alter buffer-modified-p.
(font-lock-fontify-region): Use comment-start-skip, not comment-start.
(font-lock-function-name-face): defvar renamed.
(font-lock-hack-keywords): Evaluate face specs from keyword list.
| -rw-r--r-- | lisp/font-lock.el | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el index c3a8726b08d..e2c404ce6c1 100644 --- a/lisp/font-lock.el +++ b/lisp/font-lock.el | |||
| @@ -70,7 +70,7 @@ | |||
| 70 | 'underline | 70 | 'underline |
| 71 | "Face to use for string constants.") | 71 | "Face to use for string constants.") |
| 72 | 72 | ||
| 73 | (defvar font-lock-function-face | 73 | (defvar font-lock-function-name-face |
| 74 | 'bold-italic | 74 | 'bold-italic |
| 75 | "Face to use for function names.") | 75 | "Face to use for function names.") |
| 76 | 76 | ||
| @@ -127,7 +127,9 @@ slow things down!") | |||
| 127 | (goto-char start) | 127 | (goto-char start) |
| 128 | (beginning-of-line) | 128 | (beginning-of-line) |
| 129 | (setq end (min end (point-max))) | 129 | (setq end (min end (point-max))) |
| 130 | (let (state startline prev prevstate) | 130 | (let ((buffer-read-only nil) |
| 131 | state startline prev prevstate | ||
| 132 | (modified (buffer-modified-p))) | ||
| 131 | ;; Find the state at the line-beginning before START. | 133 | ;; Find the state at the line-beginning before START. |
| 132 | (setq startline (point)) | 134 | (setq startline (point)) |
| 133 | (if (eq (point) font-lock-cache-position) | 135 | (if (eq (point) font-lock-cache-position) |
| @@ -164,7 +166,7 @@ slow things down!") | |||
| 164 | ;; Find each interesting place between here and END. | 166 | ;; Find each interesting place between here and END. |
| 165 | (while (and (< (point) end) | 167 | (while (and (< (point) end) |
| 166 | (setq prev (point) prevstate state) | 168 | (setq prev (point) prevstate state) |
| 167 | (re-search-forward (concat "\\s\"\\|" (regexp-quote comment-start)) end t) | 169 | (re-search-forward (concat "\\s\"\\|" comment-start-skip) end t) |
| 168 | ;; Clear out the fonts of what we skip over. | 170 | ;; Clear out the fonts of what we skip over. |
| 169 | (progn (remove-text-properties prev (point) '(face nil)) t) | 171 | (progn (remove-text-properties prev (point) '(face nil)) t) |
| 170 | ;; Verify the state at that place | 172 | ;; Verify the state at that place |
| @@ -199,7 +201,8 @@ slow things down!") | |||
| 199 | ;; only if it was set on the very last iteration. | 201 | ;; only if it was set on the very last iteration. |
| 200 | (setq prev nil)) | 202 | (setq prev nil)) |
| 201 | (and prev | 203 | (and prev |
| 202 | (remove-text-properties prev end '(face nil)))))) | 204 | (remove-text-properties prev end '(face nil))) |
| 205 | (set-buffer-modified-p modified)))) | ||
| 203 | 206 | ||
| 204 | ;; This code used to be used to show a string on reaching the end of it. | 207 | ;; This code used to be used to show a string on reaching the end of it. |
| 205 | ;; It is probably not needed due to later changes to handle strings | 208 | ;; It is probably not needed due to later changes to handle strings |
| @@ -224,7 +227,10 @@ slow things down!") | |||
| 224 | ;; font-lock-string-face))))) | 227 | ;; font-lock-string-face))))) |
| 225 | 228 | ||
| 226 | (defun font-lock-unfontify-region (beg end) | 229 | (defun font-lock-unfontify-region (beg end) |
| 227 | (remove-text-properties beg end '(face nil))) | 230 | (let ((modified (buffer-modified-p)) |
| 231 | (buffer-read-only nil)) | ||
| 232 | (remove-text-properties beg end '(face nil)) | ||
| 233 | (set-buffer-modified-p modified))) | ||
| 228 | 234 | ||
| 229 | ;; Called when any modification is made to buffer text. | 235 | ;; Called when any modification is made to buffer text. |
| 230 | (defun font-lock-after-change-function (beg end old-len) | 236 | (defun font-lock-after-change-function (beg end old-len) |
| @@ -259,6 +265,8 @@ slow things down!") | |||
| 259 | (let ((case-fold-search font-lock-keywords-case-fold-search) | 265 | (let ((case-fold-search font-lock-keywords-case-fold-search) |
| 260 | (rest font-lock-keywords) | 266 | (rest font-lock-keywords) |
| 261 | (count 0) | 267 | (count 0) |
| 268 | (buffer-read-only nil) | ||
| 269 | (modified (buffer-modified-p)) | ||
| 262 | first str match face s e allow-overlap-p) | 270 | first str match face s e allow-overlap-p) |
| 263 | (while rest | 271 | (while rest |
| 264 | (setq first (car rest) rest (cdr rest)) | 272 | (setq first (car rest) rest (cdr rest)) |
| @@ -267,11 +275,11 @@ slow things down!") | |||
| 267 | (setq str (car first)) | 275 | (setq str (car first)) |
| 268 | (cond ((consp (cdr first)) | 276 | (cond ((consp (cdr first)) |
| 269 | (setq match (nth 1 first) | 277 | (setq match (nth 1 first) |
| 270 | face (nth 2 first) | 278 | face (eval (nth 2 first)) |
| 271 | allow-overlap-p (nth 3 first))) | 279 | allow-overlap-p (nth 3 first))) |
| 272 | ((symbolp (cdr first)) | 280 | ((symbolp (cdr first)) |
| 273 | (setq match 0 allow-overlap-p nil | 281 | (setq match 0 allow-overlap-p nil |
| 274 | face (cdr first))) | 282 | face (eval (cdr first)))) |
| 275 | (t | 283 | (t |
| 276 | (setq match (cdr first) | 284 | (setq match (cdr first) |
| 277 | allow-overlap-p nil | 285 | allow-overlap-p nil |
| @@ -290,8 +298,8 @@ slow things down!") | |||
| 290 | (put-text-property s e 'face face)))) | 298 | (put-text-property s e 'face face)))) |
| 291 | (if loudly (message "Fontifying %s... (regexps...%s)" | 299 | (if loudly (message "Fontifying %s... (regexps...%s)" |
| 292 | (buffer-name) | 300 | (buffer-name) |
| 293 | (make-string (setq count (1+ count)) ?.)))))) | 301 | (make-string (setq count (1+ count)) ?.)))) |
| 294 | 302 | (set-buffer-modified-p modified))) | |
| 295 | 303 | ||
| 296 | ;; The user level functions | 304 | ;; The user level functions |
| 297 | 305 | ||
| @@ -540,13 +548,13 @@ This does a lot more highlighting.") | |||
| 540 | 548 | ||
| 541 | (defvar perl-font-lock-keywords | 549 | (defvar perl-font-lock-keywords |
| 542 | (list | 550 | (list |
| 543 | (concat "[ \n\t{]*\\(" | 551 | (cons (concat "[ \n\t{]*\\(" |
| 544 | (mapconcat 'identity | 552 | (mapconcat 'identity |
| 545 | '("if" "until" "while" "elsif" "else" "unless" "for" | 553 | '("if" "until" "while" "elsif" "else" "unless" "for" |
| 546 | "foreach" "continue" "exit" "die" "last" "goto" "next" | 554 | "foreach" "continue" "exit" "die" "last" "goto" "next" |
| 547 | "redo" "return" "local" "exec") | 555 | "redo" "return" "local" "exec") |
| 548 | "\\|") | 556 | "\\|") |
| 549 | "\\)[ \n\t;(]") | 557 | "\\)[ \n\t;(]") 1) |
| 550 | (mapconcat 'identity | 558 | (mapconcat 'identity |
| 551 | '("#endif" "#else" "#ifdef" "#ifndef" "#if" "#include" | 559 | '("#endif" "#else" "#ifdef" "#ifndef" "#if" "#include" |
| 552 | "#define" "#undef") | 560 | "#define" "#undef") |