aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/font-lock.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/font-lock.el')
-rw-r--r--lisp/font-lock.el247
1 files changed, 122 insertions, 125 deletions
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index aae73bd1e0..5065553121 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1311,12 +1311,19 @@ START should be at the beginning of a line."
;;; Syntactic fontification functions.
+(defvar font-lock-comment-start-skip nil
+ "If non-nil, Font Lock mode uses this instead of `comment-start-skip'.")
+
+(defvar font-lock-comment-end-skip nil
+ "If non-nil, Font Lock mode uses this instead of `comment-end'.")
+
(defun font-lock-fontify-syntactically-region (start end &optional loudly ppss)
"Put proper face on each string and comment between START and END.
START should be at the beginning of a line."
(let ((comment-end-regexp
- (regexp-quote
- (replace-regexp-in-string "^ *" "" comment-end)))
+ (or font-lock-comment-end-skip
+ (regexp-quote
+ (replace-regexp-in-string "^ *" "" comment-end))))
state face beg)
(if loudly (message "Fontifying %s... (syntactically...)" (buffer-name)))
(goto-char start)
@@ -1334,12 +1341,14 @@ START should be at the beginning of a line."
'syntax-table))
(when face (put-text-property beg (point) 'face face))
(when (and (eq face 'font-lock-comment-face)
- comment-start-skip)
+ (or font-lock-comment-start-skip
+ comment-start-skip))
;; Find the comment delimiters
;; and use font-lock-comment-delimiter-face for them.
(save-excursion
(goto-char beg)
- (if (looking-at comment-start-skip)
+ (if (looking-at (or font-lock-comment-start-skip
+ comment-start-skip))
(put-text-property beg (match-end 0) 'face
font-lock-comment-delimiter-face)))
(if (looking-back comment-end-regexp (point-at-bol))
@@ -1655,27 +1664,6 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
;; But now we do it the custom way. Note that `defface' will not overwrite any
;; faces declared above via `custom-declare-face'.
-(defface font-lock-comment-delimiter-face
- '((((class grayscale) (background light))
- (:foreground "DimGray" :weight bold :slant italic))
- (((class grayscale) (background dark))
- (:foreground "LightGray" :weight bold :slant italic))
- (((class color) (min-colors 88) (background light))
- (:foreground "Firebrick"))
- (((class color) (min-colors 88) (background dark))
- (:foreground "chocolate1"))
- (((class color) (min-colors 16) (background light))
- (:foreground "red"))
- (((class color) (min-colors 16) (background dark))
- (:foreground "red1"))
- (((class color) (min-colors 8) (background light))
- (:foreground "red"))
- (((class color) (min-colors 8) (background dark))
- (:foreground "red1"))
- (t (:weight bold :slant italic)))
- "Font Lock mode face used to highlight comment delimiters."
- :group 'font-lock-highlighting-faces)
-
(defface font-lock-comment-face
'((((class grayscale) (background light))
(:foreground "DimGray" :weight bold :slant italic))
@@ -1697,6 +1685,17 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
"Font Lock mode face used to highlight comments."
:group 'font-lock-highlighting-faces)
+(defface font-lock-comment-delimiter-face
+ '((default :inherit font-lock-comment-face)
+ (((class grayscale)))
+ (((class color) (min-colors 16)))
+ (((class color) (min-colors 8) (background light))
+ :foreground "red")
+ (((class color) (min-colors 8) (background dark))
+ :foreground "red1"))
+ "Font Lock mode face used to highlight comment delimiters."
+ :group 'font-lock-highlighting-faces)
+
(defface font-lock-string-face
'((((class grayscale) (background light)) (:foreground "DimGray" :slant italic))
(((class grayscale) (background dark)) (:foreground "LightGray" :slant italic))
@@ -1798,13 +1797,8 @@ Sets various variables using `font-lock-defaults' (or, if nil, using
"Font Lock mode face used to highlight warnings."
:group 'font-lock-highlighting-faces)
-;; Matches font-lock-builtin-face, because that is used for #ifndef and
-;; font-lock-keyword-face, which alas make-mode uses for ifndef
(defface font-lock-negation-char-face
- '((((class color) (min-colors 88) (background light)) (:foreground "VioletRed" :weight bold))
- (((class color) (min-colors 88) (background dark)) (:foreground "MediumOrchid1" :weight bold))
- (((class color) (min-colors 8)) (:foreground "red" :weight bold))
- (t (:inverse-video t :weight bold)))
+ '((t nil))
"Font Lock mode face used to highlight easy to overlook negation."
:group 'font-lock-highlighting-faces)
@@ -1974,109 +1968,112 @@ This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
(defconst lisp-font-lock-keywords-1
(eval-when-compile
- (list
- ;;
- ;; Definitions.
- (list (concat "(\\(def\\("
- ;; Function declarations.
- "\\(advice\\|varalias\\|alias\\|generic\\|macro\\*?\\|method\\|"
- "setf\\|subst\\*?\\|un\\*?\\|"
- "ine-\\(condition\\|\\(?:derived\\|minor\\|generic\\)-mode\\|"
- "method-combination\\|setf-expander\\|skeleton\\|widget\\|"
- "function\\|\\(compiler\\|modify\\|symbol\\)-macro\\)\\)\\|"
- ;; Variable declarations.
- "\\(const\\(ant\\)?\\|custom\\|face\\|parameter\\|var\\)\\|"
- ;; Structure declarations.
- "\\(class\\|group\\|theme\\|package\\|struct\\|type\\)"
- "\\)\\)\\>"
- ;; Any whitespace and defined object.
- "[ \t'\(]*"
- "\\(setf[ \t]+\\sw+)\\|\\sw+\\)?")
- '(1 font-lock-keyword-face)
- '(9 (cond ((match-beginning 3) font-lock-function-name-face)
- ((match-beginning 6) font-lock-variable-name-face)
- (t font-lock-type-face))
- nil t))
- ;;
- ;; Emacs Lisp autoload cookies.
- '("^;;;###\\(autoload\\)" 1 font-lock-warning-face prepend)
- ))
+ `(;; Definitions.
+ (,(concat "(\\(def\\("
+ ;; Function declarations.
+ "\\(advice\\|varalias\\|alias\\|generic\\|macro\\*?\\|method\\|"
+ "setf\\|subst\\*?\\|un\\*?\\|"
+ "ine-\\(condition\\|\\(?:derived\\|minor\\|generic\\)-mode\\|"
+ "method-combination\\|setf-expander\\|skeleton\\|widget\\|"
+ "function\\|\\(compiler\\|modify\\|symbol\\)-macro\\)\\)\\|"
+ ;; Variable declarations.
+ "\\(const\\(ant\\)?\\|custom\\|face\\|parameter\\|var\\)\\|"
+ ;; Structure declarations.
+ "\\(class\\|group\\|theme\\|package\\|struct\\|type\\)"
+ "\\)\\)\\>"
+ ;; Any whitespace and defined object.
+ "[ \t'\(]*"
+ "\\(setf[ \t]+\\sw+)\\|\\sw+\\)?")
+ (1 font-lock-keyword-face)
+ (9 (cond ((match-beginning 3) font-lock-function-name-face)
+ ((match-beginning 6) font-lock-variable-name-face)
+ (t font-lock-type-face))
+ nil t))
+ ;; Emacs Lisp autoload cookies.
+ ("^;;;###\\(autoload\\)" 1 font-lock-warning-face prepend)
+ ;; Regexp negated char group.
+ ("\\[\\(\\^\\)" 1 font-lock-negation-char-face prepend)))
"Subdued level highlighting for Lisp modes.")
(defconst lisp-font-lock-keywords-2
(append lisp-font-lock-keywords-1
(eval-when-compile
- (list
- ;;
- ;; Control structures. Emacs Lisp forms.
- (cons (concat
- "(" (regexp-opt
- '("cond" "if" "while" "let" "let*"
- "prog" "progn" "progv" "prog1" "prog2" "prog*"
- "inline" "lambda" "save-restriction" "save-excursion"
- "save-window-excursion" "save-selected-window"
- "save-match-data" "save-current-buffer" "unwind-protect"
- "condition-case" "track-mouse"
- "eval-after-load" "eval-and-compile" "eval-when-compile"
- "eval-when"
- "with-category-table"
- "with-current-buffer" "with-electric-help"
- "with-local-quit" "with-no-warnings"
- "with-output-to-string" "with-output-to-temp-buffer"
- "with-selected-window" "with-syntax-table"
- "with-temp-buffer" "with-temp-file" "with-temp-message"
- "with-timeout" "with-timeout-handler") t)
- "\\>")
- 1)
- ;;
- ;; Control structures. Common Lisp forms.
- (cons (concat
- "(" (regexp-opt
- '("when" "unless" "case" "ecase" "typecase" "etypecase"
- "ccase" "ctypecase" "handler-case" "handler-bind"
- "restart-bind" "restart-case" "in-package"
- "break" "ignore-errors"
- "loop" "do" "do*" "dotimes" "dolist" "the" "locally"
- "proclaim" "declaim" "declare" "symbol-macrolet"
- "lexical-let" "lexical-let*" "flet" "labels" "compiler-let"
- "destructuring-bind" "macrolet" "tagbody" "block" "go"
- "multiple-value-bind" "multiple-value-prog1"
- "return" "return-from"
- "with-accessors" "with-compilation-unit"
- "with-condition-restarts" "with-hash-table-iterator"
- "with-input-from-string" "with-open-file"
- "with-open-stream" "with-output-to-string"
- "with-package-iterator" "with-simple-restart"
- "with-slots" "with-standard-io-syntax") t)
- "\\>")
- 1)
- ;;
- ;; Exit/Feature symbols as constants.
- (list (concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\>"
- "[ \t']*\\(\\sw+\\)?")
- '(1 font-lock-keyword-face)
- '(2 font-lock-constant-face nil t))
- ;;
- ;; Erroneous structures.
- '("(\\(abort\\|assert\\|warn\\|check-type\\|cerror\\|error\\|signal\\)\\>" 1 font-lock-warning-face)
- ;;
- ;; Words inside \\[] tend to be for `substitute-command-keys'.
- '("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-constant-face prepend)
- ;;
- ;; Words inside `' tend to be symbol names.
- '("`\\(\\sw\\sw+\\)'" 1 font-lock-constant-face prepend)
- ;;
- ;; Constant values.
- '("\\<:\\sw+\\>" 0 font-lock-builtin-face)
- ;;
- ;; ELisp and CLisp `&' keywords as types.
- '("\\&\\sw+\\>" . font-lock-type-face)
- ;;
+ `(;; Control structures. Emacs Lisp forms.
+ (,(concat
+ "(" (regexp-opt
+ '("cond" "if" "while" "let" "let*"
+ "prog" "progn" "progv" "prog1" "prog2" "prog*"
+ "inline" "lambda" "save-restriction" "save-excursion"
+ "save-window-excursion" "save-selected-window"
+ "save-match-data" "save-current-buffer" "unwind-protect"
+ "condition-case" "track-mouse"
+ "eval-after-load" "eval-and-compile" "eval-when-compile"
+ "eval-when"
+ "with-category-table"
+ "with-current-buffer" "with-electric-help"
+ "with-local-quit" "with-no-warnings"
+ "with-output-to-string" "with-output-to-temp-buffer"
+ "with-selected-window" "with-syntax-table"
+ "with-temp-buffer" "with-temp-file" "with-temp-message"
+ "with-timeout" "with-timeout-handler") t)
+ "\\>")
+ . 1)
+ ;; Control structures. Common Lisp forms.
+ (,(concat
+ "(" (regexp-opt
+ '("when" "unless" "case" "ecase" "typecase" "etypecase"
+ "ccase" "ctypecase" "handler-case" "handler-bind"
+ "restart-bind" "restart-case" "in-package"
+ "break" "ignore-errors"
+ "loop" "do" "do*" "dotimes" "dolist" "the" "locally"
+ "proclaim" "declaim" "declare" "symbol-macrolet"
+ "lexical-let" "lexical-let*" "flet" "labels" "compiler-let"
+ "destructuring-bind" "macrolet" "tagbody" "block" "go"
+ "multiple-value-bind" "multiple-value-prog1"
+ "return" "return-from"
+ "with-accessors" "with-compilation-unit"
+ "with-condition-restarts" "with-hash-table-iterator"
+ "with-input-from-string" "with-open-file"
+ "with-open-stream" "with-output-to-string"
+ "with-package-iterator" "with-simple-restart"
+ "with-slots" "with-standard-io-syntax") t)
+ "\\>")
+ . 1)
+ ;; Exit/Feature symbols as constants.
+ (,(concat "(\\(catch\\|throw\\|featurep\\|provide\\|require\\)\\>"
+ "[ \t']*\\(\\sw+\\)?")
+ (1 font-lock-keyword-face)
+ (2 font-lock-constant-face nil t))
+ ;; Erroneous structures.
+ ("(\\(abort\\|assert\\|warn\\|check-type\\|cerror\\|error\\|signal\\)\\>" 1 font-lock-warning-face)
+ ;; Words inside \\[] tend to be for `substitute-command-keys'.
+ ("\\\\\\\\\\[\\(\\sw+\\)]" 1 font-lock-constant-face prepend)
+ ;; Words inside `' tend to be symbol names.
+ ("`\\(\\sw\\sw+\\)'" 1 font-lock-constant-face prepend)
+ ;; Constant values.
+ ("\\<:\\sw+\\>" 0 font-lock-builtin-face)
+ ;; ELisp and CLisp `&' keywords as types.
+ ("\\&\\sw+\\>" . font-lock-type-face)
+ ;; Make regexp grouping constructs bold, so they stand out, but only in strings.
+ ((lambda (bound)
+ (if (re-search-forward "\\([\\][\\]\\)\\([(|)]\\)\\(\\?:\\)?" bound)
+ (let ((face (get-text-property (1- (point)) 'face)))
+ (if (listp face)
+ (memq 'font-lock-string-face face)
+ (eq 'font-lock-string-face face)))))
+ (1 font-lock-comment-face prepend) ; Should we introduce a lowlight face for this?
+ ; Ideally that would retain the color, dimmed 50%.
+ (2 'bold prepend)
+ (3 font-lock-type-face prepend t))
+ ;; Underline innermost grouping, so that you can more easily see what belongs together.
+ ;; 2005-05-12: Font-lock can go into an unbreakable endless loop on this -- something's broken.
+ ;;("[\\][\\][(]\\(?:\\?:\\)?\\(\\(?:[^\\\"]+\\|[\\]\\(?:[^\\]\\|[\\][^(]\\)\\)+?\\)[\\][\\][)]"
+ ;;1 'underline prepend)
;;; This is too general -- rms.
;;; A user complained that he has functions whose names start with `do'
;;; and that they get the wrong color.
;;; ;; CL `with-' and `do-' constructs
-;;; '("(\\(\\(do-\\|with-\\)\\(\\s_\\|\\w\\)*\\)" 1 font-lock-keyword-face)
+;;; ("(\\(\\(do-\\|with-\\)\\(\\s_\\|\\w\\)*\\)" 1 font-lock-keyword-face)
)))
"Gaudy level highlighting for Lisp modes.")