Make font-lock face variables obsolete

Using these variables as "another mechanism for changing face
appearance" never really worked, since mode authors were free to use the
face instead of the variable (i.e. quoting the symbol).  This means that
when users customized the variables, it would change its appearance only
in some cases, which is a rather surprising interface.

Indeed, it turns out that some modes have not always been consistent,
and mixed using the variable and the face, increasing the confusion even
further.  Thus, the only thing users could rely on to always work was to
leave the variables at their default value, and to customize the face.

We now recommend customizing the face, and are obsoleting these
variables.  This will lead to some minor code-churn, but it is believed
that it will be ultimately worth it.  To fix existing Lisp code, you
should typically only need to quote the symbol, as this commit shows.

It might be the case that we will have to keep the obsolete variables,
that have been with us since Emacs 19, around for a longer time-period
than normal, to allow package authors to adapt.

* lisp/font-lock.el (font-lock-comment-face)
(font-lock-comment-delimiter-face, font-lock-string-face)
(font-lock-doc-face, font-lock-doc-markup-face, font-lock-keyword-face)
(font-lock-builtin-face, font-lock-function-name-face)
(font-lock-variable-name-face, font-lock-type-face)
(font-lock-constant-face, font-lock-warning-face)
(font-lock-negation-char-face, font-lock-preprocessor-face): Make face
variables obsolete in favor of customizing the faces directly
instead.  (Bug#71469)

* doc/lispref/modes.texi (Faces for Font Lock): Don't document above
obsolete variables.

* lisp/cedet/data-debug.el (data-debug-insert-hash-table)
(data-debug-insert-widget-properties, data-debug-insert-string)
(data-debug-insert-number):
* lisp/emacs-lisp/lisp-mode.el (elisp--font-lock-backslash)
(lisp-font-lock-syntactic-face-function):
* lisp/emacs-lisp/package.el (describe-package-1):
* lisp/generic-x.el (rc-generic-mode, rul-generic-mode):
* lisp/org/org-table.el (org-table-edit-formulas):
* lisp/progmodes/cc-fonts.el (c-font-lock-invalid-single-quotes)
(c-maybe-font-lock-wrong-style-comments, c-font-lock-declarators)
(c-font-lock-c++-lambda-captures, c-font-lock-c++-modules):
* lisp/progmodes/cperl-mode.el (cperl-find-sub-attrs)
(cperl-look-at-leading-count, cperl-process-here-doc)
(cperl-find-pods-heres):
* lisp/progmodes/gdb-mi.el (gdb-init-1, gdb-update, gdb-running)
(gdb-starting, gdb-stopped, gdb-internals)
(gdb-breakpoints--add-breakpoint-row, gdb-locals-handler-custom)
(gdb-registers-handler-custom, gdb-get-source-file):
* lisp/progmodes/js.el (js--font-lock-keywords-1)
(js--font-lock-keywords-2, js-font-lock-syntactic-face-function):
* lisp/progmodes/lua-ts-mode.el (lua-ts--comment-font-lock):
* lisp/progmodes/meta-mode.el (meta-indent-in-string-p):
* lisp/progmodes/prolog.el (prolog-font-lock-keywords):
* lisp/progmodes/python.el (python-font-lock-syntactic-face-function):
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--comment-font-lock):
* lisp/progmodes/sh-script.el (sh-font-lock-syntactic-face-function):
* lisp/textmodes/tex-mode.el (doctex-font-lock-syntactic-face-function):
* test/lisp/faces-tests.el (faces--test-color-at-point):
* test/lisp/progmodes/cperl-mode-tests.el (cperl-test-extra-delimiters)
(cperl-test-bug-47112, cperl-test-bug-65834, cperl-test-bug-66145)
(cperl-test-bug-66161, cperl-test-bug-69604):
* test/lisp/progmodes/python-tests.el
(python-ts-mode-compound-keywords-face)
(python-ts-mode-named-assignment-face-1)
(python-ts-mode-assignment-face-2, python-ts-mode-nested-types-face-1)
(python-ts-mode-union-types-face-1, python-ts-mode-union-types-face-2)
(python-ts-mode-types-face-1, python-ts-mode-types-face-2)
(python-ts-mode-types-face-3, python-ts-mode-isinstance-type-face-1)
(python-ts-mode-isinstance-type-face-2)
(python-ts-mode-isinstance-type-face-3)
(python-ts-mode-superclass-type-face, python-ts-mode-class-patterns-face)
(python-ts-mode-dotted-decorator-face-1)
(python-ts-mode-dotted-decorator-face-2)
(python-ts-mode-builtin-call-face)
(python-ts-mode-interpolation-nested-string)
(python-ts-mode-level-fontification-wo-interpolation)
(python-ts-mode-disabled-string-interpolation)
(python-ts-mode-interpolation-doc-string):
* test/lisp/progmodes/ruby-mode-tests.el
(ruby-heredoc-font-lock, ruby-heredoc-highlights-interpolations)
(ruby-exit!-font-lock, ruby-regexp-interpolation-is-highlighted)
(ruby-recognize-symbols-starting-with-at-character)
(ruby-hash-character-not-interpolation)
(ruby-interpolation-suppresses-quotes-inside)
(ruby-interpolation-suppresses-one-double-quote)
(ruby-interpolation-inside-percent-literal)
(ruby-interpolation-inside-percent-literal-with-paren)
(ruby-interpolation-inside-another-interpolation)
(ruby-interpolation-inside-double-quoted-percent-literals)
(ruby-no-interpolation-in-single-quoted-literals):
Don't use above obsolete variables.
* lisp/progmodes/cc-fonts.el (font-lock-constant-face): Don't
declare now-unused variable.
This commit is contained in:
Stefan Kangas 2024-12-18 03:46:04 +01:00
parent 03249f7815
commit 3d3c109460
23 changed files with 256 additions and 198 deletions

View file

@ -3905,10 +3905,6 @@ faces specifically for Font Lock to use to highlight text. These
modes for syntactic highlighting outside of Font Lock mode (@pxref{Major
Mode Conventions}).
Each of these symbols is both a face name, and a variable whose
default value is the symbol itself. Thus, the default value of
@code{font-lock-comment-face} is @code{font-lock-comment-face}.
The faces are listed with descriptions of their typical usage, and in
order of greater to lesser prominence. If a mode's syntactic
categories do not fit well with the usage descriptions, the faces can be

View file

@ -50,6 +50,30 @@ enabled, you can disable mouse tracking by putting '(xterm-mouse-mode
* Changes in Emacs 31.1
+++
** Several font-lock face variables are now obsolete.
The following variables are now obsolete: font-lock-comment-face,
font-lock-comment-delimiter-face, font-lock-string-face,
font-lock-doc-face, font-lock-doc-markup-face, font-lock-keyword-face,
font-lock-builtin-face, font-lock-function-name-face,
font-lock-variable-name-face, font-lock-type-face,
font-lock-constant-face, font-lock-warning-face,
font-lock-negation-char-face, and font-lock-preprocessor-face.
These variables contributed both to confusion about the relation between
faces and variables, and to inconsistency when major mode authors used
one or the other (sometimes interchangeably). We always recommended
using faces directly, and not creating variables going by the same name.
If you have customized these variables, you should now customize the
corresponding faces instead, using something like:
M-x customize-face RET font-lock-string-face RET
If you have been using these variables in Lisp code (for example, in
font-lock rules), simply quote the symbol, to use the face directly
instead of its now-obsolete variable.
** Etags
+++

View file

@ -392,10 +392,10 @@ PREBUTTONTEXT is some text between prefix and the stuff list button."
(lambda (key value)
(data-debug-insert-thing
key prefix
(propertize "key " 'face font-lock-comment-face))
(propertize "key " 'face 'font-lock-comment-face))
(data-debug-insert-thing
value prefix
(propertize "val " 'face font-lock-comment-face)))
(propertize "val " 'face 'font-lock-comment-face)))
hash-table))
(defun data-debug-insert-hash-table-from-point (point)
@ -446,7 +446,7 @@ in front of the button text."
prefix
(concat
(propertize (format "%s" (car rest))
'face font-lock-comment-face)
'face 'font-lock-comment-face)
" : "))
(setq rest (cdr (cdr rest))))
))
@ -682,7 +682,7 @@ PREBUTTONTEXT is some text between prefix and the thing."
(setq newstr (replace-match "\\t" t t newstr)))
(insert prefix prebuttontext
(propertize (format "\"%s\"" newstr)
'face font-lock-string-face)
'face 'font-lock-string-face)
"\n" )))
;;; Number
@ -693,7 +693,7 @@ PREFIX is the text that precedes the button.
PREBUTTONTEXT is some text between prefix and the thing."
(insert prefix prebuttontext
(propertize (format "%S" thing)
'face font-lock-string-face)
'face 'font-lock-string-face)
"\n"))
;;; Lambda Expression

View file

@ -308,7 +308,7 @@ This will generate compile-time constants from BINDINGS."
(buffer-substring-no-properties
beg0 end0)))))
(buffer-substring-no-properties (1+ beg0) end0))
`(face ,font-lock-warning-face
'(face font-lock-warning-face
help-echo "This \\ has no effect"))))
(defun lisp--match-confusable-symbol-character (limit)
@ -660,9 +660,9 @@ Lisp font lock syntactic face function."
(let ((listbeg (nth 1 state)))
(if (or (lisp-string-in-doc-position-p listbeg startpos)
(lisp-string-after-doc-keyword-p listbeg startpos))
font-lock-doc-face
font-lock-string-face))))
font-lock-comment-face))
'font-lock-doc-face
'font-lock-string-face))))
'font-lock-comment-face))
(defun lisp-adaptive-fill ()
"Return fill prefix found at point.

View file

@ -2864,7 +2864,7 @@ Helper function for `describe-package'."
'action #'package-delete-button-action
'package-desc desc)))
(incompatible-reason
(insert (propertize "Incompatible" 'font-lock-face font-lock-warning-face)
(insert (propertize "Incompatible" 'font-lock-face 'font-lock-warning-face)
" because it depends on ")
(if (stringp incompatible-reason)
(insert "Emacs " incompatible-reason ".")

View file

@ -303,62 +303,96 @@ If a number, only buffers greater than this size have fontification messages."
(other :tag "always" t))
:group 'font-lock
:version "24.1")
;; Obsolete face variables.
;; Originally these variable values were face names such as `bold' etc.
;; Now we create our own faces, but we keep these variables for compatibility
;; and they give users another mechanism for changing face appearance.
;; We now allow a FACENAME in `font-lock-keywords' to be any expression that
;; returns a face. So the easiest thing is to continue using these variables,
;; rather than sometimes evalling FACENAME and sometimes not. sm.
;; Note that in new code, in the vast majority of cases there is no
;; need to create variables that specify face names. Simply using
;; faces directly is enough. Font-lock is not a template to be
;; followed in this area.
(make-obsolete-variable
'font-lock-comment-face
"use the quoted symbol instead: \\='font-lock-comment-face" "31.1")
(defvar font-lock-comment-face 'font-lock-comment-face
"Face name to use for comments.")
(make-obsolete-variable
'font-lock-comment-delimiter-face
"use the quoted symbol instead: \\='font-lock-comment-delimiter-face" "31.1")
(defvar font-lock-comment-delimiter-face 'font-lock-comment-delimiter-face
"Face name to use for comment delimiters.")
(make-obsolete-variable
'font-lock-string-face
"use the quoted symbol instead: \\='font-lock-string-face" "31.1")
(defvar font-lock-string-face 'font-lock-string-face
"Face name to use for strings.")
(make-obsolete-variable
'font-lock-doc-face
"use the quoted symbol instead: \\='font-lock-doc-face" "31.1")
(defvar font-lock-doc-face 'font-lock-doc-face
"Face name to use for documentation.")
(make-obsolete-variable
'font-lock-doc-markup-face
"use the quoted symbol instead: \\='font-lock-doc-markup-face" "31.1")
(defvar font-lock-doc-markup-face 'font-lock-doc-markup-face
"Face name to use for documentation mark-up.")
(make-obsolete-variable
'font-lock-keyword-face
"use the quoted symbol instead: \\='font-lock-keyword-face" "31.1")
(defvar font-lock-keyword-face 'font-lock-keyword-face
"Face name to use for keywords.")
(make-obsolete-variable
'font-lock-builtin-face
"use the quoted symbol instead: \\='font-lock-builtin-face" "31.1")
(defvar font-lock-builtin-face 'font-lock-builtin-face
"Face name to use for builtins.")
(make-obsolete-variable
'font-lock-function-name-face
"use the quoted symbol instead: \\='font-lock-function-name-face" "31.1")
(defvar font-lock-function-name-face 'font-lock-function-name-face
"Face name to use for function names.")
(make-obsolete-variable
'font-lock-variable-name-face
"use the quoted symbol instead: \\='font-lock-variable-name-face" "31.1")
(defvar font-lock-variable-name-face 'font-lock-variable-name-face
"Face name to use for variable names.")
(make-obsolete-variable
'font-lock-type-face
"use the quoted symbol instead: \\='font-lock-type-face" "31.1")
(defvar font-lock-type-face 'font-lock-type-face
"Face name to use for type and class names.")
(make-obsolete-variable
'font-lock-constant-face
"use the quoted symbol instead: \\='font-lock-constant-face" "31.1")
(defvar font-lock-constant-face 'font-lock-constant-face
"Face name to use for constant and label names.")
(make-obsolete-variable
'font-lock-warning-face
"use the quoted symbol instead: \\='font-lock-warning-face" "31.1")
(defvar font-lock-warning-face 'font-lock-warning-face
"Face name to use for things that should stand out.")
(make-obsolete-variable
'font-lock-negation-char-face
"use the quoted symbol instead: \\='font-lock-negation-char-face" "31.1")
(defvar font-lock-negation-char-face 'font-lock-negation-char-face
"Face name to use for easy to overlook negation.
This can be an \"!\" or the \"n\" in \"ifndef\".")
(make-obsolete-variable
'font-lock-preprocessor-face
"use the quoted symbol instead: \\='font-lock-preprocessor-face" "31.1")
(defvar font-lock-preprocessor-face 'font-lock-preprocessor-face
"Face name to use for preprocessor directives.")
;; Fontification variables:
(defvar font-lock-keywords nil

View file

@ -702,9 +702,9 @@ like an INI file. You can add this hook to `find-file-hook'."
"FILETYPE"
"FILEVERSION"
"PRODUCTVERSION") 'symbols)
1 font-lock-type-face)
1 'font-lock-type-face)
(list (regexp-opt '("BEGIN" "BLOCK" "END" "VALUE") 'symbols)
1 font-lock-function-name-face)
1 'font-lock-function-name-face)
'("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face)
'("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face)
'("^#[ \t]*\\(elif\\|if\\)\\>"
@ -1323,22 +1323,22 @@ like an INI file. You can add this hook to `find-file-hook'."
(list (concat "[^_]"
(regexp-opt installshield-system-variables-list 'symbols)
"[^_]")
1 font-lock-variable-name-face)
1 'font-lock-variable-name-face)
;; system functions
(list (concat "[^_]"
(regexp-opt installshield-system-functions-list 'symbols)
"[^_]")
1 font-lock-function-name-face)
1 'font-lock-function-name-face)
;; type keywords
(list (concat "[^_]"
(regexp-opt installshield-types-list 'symbols)
"[^_]")
1 font-lock-type-face)
1 'font-lock-type-face)
;; function argument constants
(list (concat "[^_]"
(regexp-opt installshield-funarg-constants-list 'symbols)
"[^_]")
1 font-lock-variable-name-face))) ; is this face the best choice?
1 'font-lock-variable-name-face))) ; is this face the best choice?
'("\\.[rR][uU][lL]\\'")
'(generic-rul-mode-setup-function)
"Generic mode for InstallShield RUL files.")

View file

@ -3412,7 +3412,7 @@ Parameters get priority."
(when title
(unless (bobp) (insert "\n"))
(insert
(org-add-props (cdr title) nil 'face font-lock-comment-face))
(org-add-props (cdr title) nil 'face 'font-lock-comment-face))
(setq titles (remove title titles)))
(when (equal key (car entry)) (setq startline (org-current-line)))
(let ((s (concat

View file

@ -122,8 +122,6 @@
'font-lock-reference-face)
(t 'font-lock-constant-face)))
(cc-bytecomp-defvar font-lock-constant-face)
(defconst c-label-face-name
(cond ((c-face-name-p 'font-lock-label-face)
;; If it happens to occur in the future. (Well, the more
@ -712,7 +710,7 @@ stuff. Used on level 1 and higher."
(< (point) end))
(if (and (equal (c-get-char-property (point) 'syntax-table) '(1))
(not (c-get-char-property (point) 'c-digit-separator)))
(c-put-font-lock-face (point) (1+ (point)) font-lock-warning-face))
(c-put-font-lock-face (point) (1+ (point)) 'font-lock-warning-face))
(forward-char))
(parse-partial-sexp end limit nil nil state 'syntax-table)))
nil)
@ -743,7 +741,7 @@ stuff. Used on level 1 and higher."
;; Font lock the block comment ender with warning face.
(when (not (nth 4 s))
(c-put-font-lock-face (- (point) (length c-block-comment-ender))
(point) font-lock-warning-face)))
(point) 'font-lock-warning-face)))
(t ; In a line comment, or a "valid" block comment
(setq s (parse-partial-sexp (point) limit nil nil s 'syntax-table))))
@ -760,14 +758,14 @@ stuff. Used on level 1 and higher."
(setq s (parse-partial-sexp (point) limit nil nil s 'syntax-table)))
((nth 4 s) ; In an invalid comment
;; Fontify the invalid comment opener.
(c-put-font-lock-face (nth 8 s) (point) font-lock-warning-face)
(c-put-font-lock-face (nth 8 s) (point) 'font-lock-warning-face)
;; Move to end of comment or LIMIT.
(setq s (parse-partial-sexp (point) limit nil nil s 'syntax-table))
;; Fontify an invalid block comment ender, if that's what we have.
(when (and (not c-block-comment-flag)
(not (nth 4 s))) ; We're outside the comment
(c-put-font-lock-face (- (point) (length c-block-comment-ender))
(point) font-lock-warning-face)))))))
(point) 'font-lock-warning-face)))))))
nil)
(c-lang-defconst c-basic-matchers-before
@ -1173,7 +1171,7 @@ casts and declarations are fontified. Used on level 2 and higher."
(c-put-font-lock-face
(point)
(progn (c-forward-over-token) (point))
font-lock-function-name-face)))))
'font-lock-function-name-face)))))
(and template-class
(eq init-char ?=) ; C++ "<class X = Y>"?
(progn
@ -2066,7 +2064,7 @@ casts and declarations are fontified. Used on level 2 and higher."
((and capture-default
(eq mode capture-default))
'font-lock-warning-face)
((eq mode ?=) font-lock-constant-face)
((eq mode ?=) 'font-lock-constant-face)
(t 'font-lock-variable-name-face))))
(c-syntactic-re-search-forward "," limit 'bound t))
@ -2194,7 +2192,7 @@ casts and declarations are fontified. Used on level 2 and higher."
(c-put-font-lock-face
(1+ beg) (if end (1- end) (point)) font-lock-string-face)
(c-put-font-lock-face
beg (or end (point)) font-lock-string-face))
beg (or end (point)) 'font-lock-string-face))
(c-forward-syntactic-ws limit)
t)
(t nil)))
@ -2234,9 +2232,9 @@ casts and declarations are fontified. Used on level 2 and higher."
c-reference-face-name)))
;; No semicolon, so put warning faces on any delimiters.
(when beg
(c-put-font-lock-face beg (1+ beg) font-lock-warning-face))
(c-put-font-lock-face beg (1+ beg) 'font-lock-warning-face))
(when end
(c-put-font-lock-face (1- end) end font-lock-warning-face))))))))
(c-put-font-lock-face (1- end) end 'font-lock-warning-face))))))))
(c-lang-defconst c-simple-decl-matchers
"Simple font lock matchers for types and declarations. These are used

View file

@ -4030,10 +4030,10 @@ an attribute. ST-L and POS are a cached from a previous call."
(and (match-beginning 1)
(cperl-postpone-fontification
(match-beginning 0) (cperl-1+ (match-beginning 0))
'face font-lock-constant-face))
'face 'font-lock-constant-face))
(setq start1 (match-beginning 3) end1 (match-end 3))
(cperl-postpone-fontification start1 end1
'face font-lock-constant-face)
'face 'font-lock-constant-face)
(goto-char end1) ; end or before `('
(if (match-end 4) ; Have attribute arguments...
(progn
@ -4102,7 +4102,7 @@ If IS-X-REX is non-nil, then process a regular expression which has an
(if (eq ?\{ (preceding-char)) nil
(cperl-postpone-fontification
(1- (point)) (point)
'face font-lock-warning-face))))
'face 'font-lock-warning-face))))
;; Do some smarter-highlighting
;; XXXX Currently ignores alphanum/dash delims,
@ -4219,7 +4219,7 @@ END-OF-HERE-DOC is the end of a previous here-doc in the same
line, or nil if this is the first. DELIM-BEGIN and DELIM-END are
the positions where the here-document's delimiter has been found.
This is part of `cperl-find-pods-heres' (below)."
(let* ((my-cperl-delimiters-face font-lock-constant-face)
(let* ((my-cperl-delimiters-face 'font-lock-constant-face)
(delimiter (buffer-substring-no-properties delim-begin delim-end))
(qtag (regexp-quote delimiter))
(use-syntax-state (and cperl-syntax-state
@ -4358,23 +4358,18 @@ recursive calls in starting lines of here-documents."
(cdr cperl-syntax-state)))
;; (st-l '(nil)) (err-l '(nil)) ; Would overwrite - propagates from a function call to a function call!
(st-l (list nil)) (err-l (list nil))
;; Somehow font-lock may be not loaded yet...
;; (e.g., when building TAGS via command-line call)
(font-lock-string-face (if (boundp 'font-lock-string-face)
font-lock-string-face
'font-lock-string-face))
(my-cperl-delimiters-face
font-lock-constant-face)
(my-cperl-delimiters-face
'font-lock-constant-face)
(my-cperl-REx-spec-char-face ; [] ^.$ and wrapper-of ({})
font-lock-function-name-face)
'font-lock-function-name-face)
(my-cperl-REx-0length-face ; 0-length, (?:)etc, non-literal \
font-lock-builtin-face)
'font-lock-builtin-face)
(my-cperl-REx-ctl-face ; (|)
font-lock-keyword-face)
'font-lock-keyword-face)
(my-cperl-REx-modifiers-face ; //gims
'cperl-nonoverridable-face)
(my-cperl-REx-length1-face ; length=1 escaped chars, POSIX classes
font-lock-type-face)
'font-lock-type-face)
(stop-point (if ignore-max
(point-max)
max))
@ -4639,7 +4634,7 @@ recursive calls in starting lines of here-documents."
(end-of-line)
;; Highlight the format line
(cperl-postpone-fontification b1 (point)
'face font-lock-string-face)
'face 'font-lock-string-face)
(cperl-commentify b1 (point) nil)
(cperl-put-do-not-fontify b1 (point) t))))
;; We do not search to max, since we may be called from
@ -4650,7 +4645,7 @@ recursive calls in starting lines of here-documents."
(progn
;; Highlight the ending delimiter
(cperl-postpone-fontification (point) (+ (point) 1)
'face font-lock-string-face)
'face 'font-lock-string-face)
(cperl-commentify (point) (+ (point) 1) nil)
(cperl-put-do-not-fontify (point) (+ (point) 1) t))
(setq warning-message
@ -4921,7 +4916,7 @@ recursive calls in starting lines of here-documents."
(not (looking-at "split\\>")))
(error t))))
(cperl-postpone-fontification
b e 'face font-lock-warning-face)
b e 'face 'font-lock-warning-face)
(if (or i2 ; Has 2 args
(and cperl-fontify-m-as-s
(or
@ -5037,8 +5032,8 @@ recursive calls in starting lines of here-documents."
(eq (char-after (1+ (point))) ?\?))
my-cperl-REx-0length-face
my-cperl-REx-ctl-face)
font-lock-warning-face))
(error font-lock-warning-face)))
'font-lock-warning-face))
(error 'font-lock-warning-face)))
((eq was-subgr ?\| )
my-cperl-REx-ctl-face)
((eq was-subgr ?\$ )
@ -5052,7 +5047,7 @@ recursive calls in starting lines of here-documents."
(1+ b))
(eq (point)
(1- e))) 1 t)))
font-lock-variable-name-face)
'font-lock-variable-name-face)
my-cperl-REx-spec-char-face))
((memq was-subgr (append "^." nil) )
my-cperl-REx-spec-char-face)
@ -5080,7 +5075,7 @@ recursive calls in starting lines of here-documents."
(- (point) 2) (- (point) 1) 'face
(if (memq qtag
(append "ghijkmoqvFHIJKMORTVY" nil))
font-lock-warning-face
'font-lock-warning-face
my-cperl-REx-0length-face))
(if (and (eq (char-after b) qtag)
(memq qtag (append ".])^$|*?+" nil)))
@ -5221,7 +5216,7 @@ recursive calls in starting lines of here-documents."
(while tag
(cperl-postpone-fontification
(car (car tag)) (cdr (car tag))
'face font-lock-variable-name-face) ;my-cperl-REx-length1-face
'face 'font-lock-variable-name-face) ;my-cperl-REx-length1-face
(setq tag (cdr tag)))
(setq was-subgr nil)) ; did facing already
;; Now rare stuff:
@ -5239,7 +5234,7 @@ recursive calls in starting lines of here-documents."
'syntax-table cperl-st-punct))
(cperl-postpone-fontification
(1- (point)) (point)
'face font-lock-warning-face))
'face 'font-lock-warning-face))
((match-beginning 5) ; before (?{}) (??{})
(setq tag (match-end 0))
(if (or (setq qtag
@ -5255,7 +5250,7 @@ recursive calls in starting lines of here-documents."
(format "%s" qtag)))
(cperl-postpone-fontification
(1- tag) (1- (point))
'face font-lock-variable-name-face)
'face 'font-lock-variable-name-face)
(cperl-postpone-fontification
REx-subgr-start (1- tag)
'face my-cperl-REx-spec-char-face)
@ -5293,7 +5288,7 @@ recursive calls in starting lines of here-documents."
REx-subgr-start REx-subgr-end nil)
(cperl-postpone-fontification
REx-subgr-start REx-subgr-end
'face font-lock-comment-face))))))
'face 'font-lock-comment-face))))))
(if (and is-REx is-x-REx)
(put-text-property (1+ b) (1- e)
'syntax-subtype 'x-REx)))

View file

@ -1102,7 +1102,7 @@ detailed description of this mode.
(setq gdb-buffer-type 'gdbmi)
;;
(gdb-force-mode-line-update
(propertize "initializing..." 'face font-lock-variable-name-face))
(propertize "initializing..." 'face 'font-lock-variable-name-face))
;; This needs to be done before we ask GDB for anything that might
;; trigger questions about debuginfod queries.
@ -2122,7 +2122,7 @@ If `gdb-thread-number' is nil, just wrap NAME in asterisks."
If NO-PROC is non-nil, do not try to contact the GDB process."
(when gdb-first-prompt
(gdb-force-mode-line-update
(propertize "initializing..." 'face font-lock-variable-name-face))
(propertize "initializing..." 'face 'font-lock-variable-name-face))
(gdb-init-1)
(setq gdb-first-prompt nil))
@ -2678,7 +2678,7 @@ Sets `gdb-thread-number' to new id."
(setq gdb-frame-number nil)))
(setq gdb-inferior-status "running")
(gdb-force-mode-line-update
(propertize gdb-inferior-status 'face font-lock-type-face))
(propertize gdb-inferior-status 'face 'font-lock-type-face))
(when (not gdb-non-stop)
(setq gud-running t))
(setq gdb-active-process t))
@ -2697,7 +2697,7 @@ Sets `gdb-thread-number' to new id."
(setq gud-async-running nil))
(gdb-force-mode-line-update
(propertize gdb-inferior-status 'face font-lock-type-face))
(propertize gdb-inferior-status 'face 'font-lock-type-face))
(setq gdb-active-process t)
(setq gud-running t)
(gud-hide-current-line-indicator nil))
@ -2734,7 +2734,7 @@ current thread and update GDB buffers."
(setq gdb-inferior-status (or reason "unknown"))
(gdb-force-mode-line-update
(propertize gdb-inferior-status 'face font-lock-warning-face))
(propertize gdb-inferior-status 'face 'font-lock-warning-face))
(if (string-equal reason "exited-normally")
(setq gdb-active-process nil))
@ -2795,7 +2795,7 @@ current thread and update GDB buffers."
(gdb-mi--c-string-from-string output-field)))
(put-text-property
0 (length error-message)
'face font-lock-warning-face
'face 'font-lock-warning-face
error-message)
error-message)))))
@ -3205,10 +3205,10 @@ See `def-gdb-auto-update-handler'."
(if (string-equal flag "y")
(eval-when-compile
(propertize "y" 'font-lock-face
font-lock-warning-face))
'font-lock-warning-face))
(eval-when-compile
(propertize "n" 'font-lock-face
font-lock-comment-face))))
'font-lock-comment-face))))
addr
(or (gdb-mi--field bkpt 'times) "")
(if (and type (string-match ".*watchpoint" type))
@ -3218,7 +3218,7 @@ See `def-gdb-auto-update-handler'."
(concat "in "
(propertize (or func "unknown")
'font-lock-face
font-lock-function-name-face)
'font-lock-function-name-face)
(gdb-frame-location bkpt)))))
;; Add clickable properties only for
;; breakpoints with file:line information
@ -4565,8 +4565,8 @@ left-to-right display order of the properties."
local-map ,gdb-edit-locals-map-1)
value))
(setf (gdb-table-right-align table) t)
(setq name (propertize name 'font-lock-face font-lock-variable-name-face))
(setq type (propertize type 'font-lock-face font-lock-type-face))
(setq name (propertize name 'font-lock-face 'font-lock-variable-name-face))
(setq type (propertize type 'font-lock-face 'font-lock-type-face))
(gdb-table-add-row
table
(gdb-locals-table-columns-list `((name . ,name)
@ -4685,9 +4685,9 @@ executes FUNCTION."
table
(list
(propertize register-name
'font-lock-face font-lock-variable-name-face)
'font-lock-face 'font-lock-variable-name-face)
(if (member register-number gdb-changed-registers)
(propertize value 'font-lock-face font-lock-warning-face)
(propertize value 'font-lock-face 'font-lock-warning-face)
value))
`(mouse-face highlight
help-echo "mouse-2: edit value"
@ -5320,7 +5320,7 @@ buffers, if required."
gdb-main-file
(display-buffer (gud-find-file gdb-main-file))))
(gdb-force-mode-line-update
(propertize "ready" 'face font-lock-variable-name-face)))
(propertize "ready" 'face 'font-lock-variable-name-face)))
;;from put-image
(defun gdb-put-string (putstring pos &optional dprop &rest sprops)

View file

@ -299,15 +299,15 @@ Match group 1 is the name of the macro.")
(defconst js--font-lock-keywords-1
(list
"\\_<import\\_>"
(list js--function-heading-1-re 1 font-lock-function-name-face)
(list js--function-heading-2-re 1 font-lock-function-name-face))
(list js--function-heading-1-re 1 'font-lock-function-name-face)
(list js--function-heading-2-re 1 'font-lock-function-name-face))
"Level one font lock keywords for `js-mode'.")
(defconst js--font-lock-keywords-2
(append js--font-lock-keywords-1
(list (list js--keyword-re 1 font-lock-keyword-face)
(cons js--basic-type-re font-lock-type-face)
(cons js--constant-re font-lock-constant-face)))
(list (list js--keyword-re 1 'font-lock-keyword-face)
(cons js--basic-type-re 'font-lock-type-face)
(cons js--constant-re 'font-lock-constant-face)))
"Level two font lock keywords for `js-mode'.")
;; js--pitem is the basic building block of the lexical
@ -1854,12 +1854,12 @@ This performs fontification according to `js--class-styles'."
(defun js-font-lock-syntactic-face-function (state)
"Return syntactic face given STATE."
(if (nth 3 state)
font-lock-string-face
'font-lock-string-face
(if (save-excursion
(goto-char (nth 8 state))
(looking-at "/\\*\\*"))
font-lock-doc-face
font-lock-comment-face)))
'font-lock-doc-face
'font-lock-comment-face)))
(defconst js--syntax-propertize-regexp-regexp
(rx

View file

@ -153,11 +153,11 @@ values of OVERRIDE."
(string-match "\\`--" node-text))
(treesit-fontify-with-override node-start
delimiter-end
font-lock-comment-delimiter-face
'font-lock-comment-delimiter-face
override))
(treesit-fontify-with-override (max delimiter-end start)
(min node-end end)
font-lock-comment-face
'font-lock-comment-face
override)))
(defvar lua-ts--font-lock-settings

View file

@ -535,7 +535,7 @@ If the list was changed, sort the list and remove duplicates first."
(defun meta-indent-in-string-p ()
"Tell if the point is in a string."
(or (nth 3 (syntax-ppss))
(eq (get-text-property (point) 'face) font-lock-string-face)))
(eq (get-text-property (point) 'face) 'font-lock-string-face)))
(defun meta-indent-looking-at-code (regexp)
"Same as `looking-at' but checks that the point is not in a string."

View file

@ -1922,12 +1922,12 @@ Argument BOUND is a buffer position limiting searching."
;; "Native" Prolog patterns
(head-predicates
(list (format "^\\(%s\\)\\((\\|[ \t]*:-\\)" prolog-atom-regexp)
1 font-lock-function-name-face))
1 'font-lock-function-name-face))
;(list (format "^%s" prolog-atom-regexp)
; 0 font-lock-function-name-face))
(head-predicates-1
(list (format "\\.[ \t]*\\(%s\\)" prolog-atom-regexp)
1 font-lock-function-name-face) )
1 'font-lock-function-name-face))
(variables
'("\\<\\([_A-Z][a-zA-Z0-9_]*\\)"
1 font-lock-variable-name-face))
@ -1941,7 +1941,7 @@ Argument BOUND is a buffer position limiting searching."
(predspecs ; module:predicate/cardinality
(list (format "\\<\\(%s:\\|\\)%s/[0-9]+"
prolog-atom-regexp prolog-atom-regexp)
0 font-lock-function-name-face 'prepend))
0 'font-lock-function-name-face 'prepend))
(keywords ; directives (queries)
(list
(if (eq prolog-system 'mercury)

View file

@ -569,9 +569,9 @@ The type returned can be `comment', `string' or `paren'."
"Return syntactic face given STATE."
(if (nth 3 state)
(if (python-info-docstring-p state)
font-lock-doc-face
font-lock-string-face)
font-lock-comment-face))
'font-lock-doc-face
'font-lock-string-face)
'font-lock-comment-face))
(defconst python--f-string-start-regexp
(rx bow

View file

@ -223,9 +223,9 @@ values of OVERRIDE."
(<= plus-1 end)
(string-match-p "\\`#" text))
(treesit-fontify-with-override node-start plus-1
font-lock-comment-delimiter-face override))
'font-lock-comment-delimiter-face override))
(treesit-fontify-with-override (max plus-1 start) (min node-end end)
font-lock-comment-face override)))
'font-lock-comment-face override)))
(defun ruby-ts--font-lock-settings (language)
"Tree-sitter font-lock settings for Ruby."

View file

@ -1128,9 +1128,9 @@ subshells can nest."
(let ((q (nth 3 state)))
(if q
(if (characterp q)
(if (eq q ?\`) 'sh-quoted-exec font-lock-string-face)
(if (eq q ?\`) 'sh-quoted-exec 'font-lock-string-face)
'sh-heredoc)
font-lock-comment-face)))
'font-lock-comment-face)))
(defgroup sh-indentation nil
"Variables controlling indentation in shell scripts.

View file

@ -3070,7 +3070,7 @@ There might be text before point."
'(?\n nil))))
;; Anything else is just as for LaTeX.
(tex-font-lock-syntactic-face-function state)
font-lock-doc-face))
'font-lock-doc-face))
(eval-when-compile
(defconst doctex-syntax-propertize-rules

View file

@ -58,6 +58,17 @@
""
:group 'faces--test)
(defmacro faces---with-tmp-face (face bg fg &rest body)
(declare (indent 3))
`(let ((old-fg (face-foreground ,face))
(old-bg (face-background ,face)))
(unwind-protect
(progn (set-face-foreground ,face ,fg)
(set-face-background ,face ,bg)
,@body)
(set-face-foreground ,face old-fg)
(set-face-background ,face old-bg))))
(ert-deftest faces--test-color-at-point ()
(with-temp-buffer
(insert (propertize "STRING" 'face '(faces--test2 faces--test1)))
@ -71,16 +82,16 @@
(should (equal (foreground-color-at-point) "black")))
(with-temp-buffer
(emacs-lisp-mode)
(setq-local font-lock-comment-face 'faces--test1)
(setq-local font-lock-constant-face 'faces--test2)
(insert ";; `symbol'")
(font-lock-fontify-region (point-min) (point-max))
(goto-char (point-min))
(should (equal (background-color-at-point) "black"))
(should (equal (foreground-color-at-point) "black"))
(goto-char 6)
(should (equal (background-color-at-point) "black"))
(should (equal (foreground-color-at-point) "black"))))
(faces---with-tmp-face 'font-lock-comment-face "black" "black"
(faces---with-tmp-face 'font-lock-constant-face "black" "black"
(insert ";; `symbol'")
(font-lock-fontify-region (point-min) (point-max))
(goto-char (point-min))
(should (equal (background-color-at-point) "black"))
(should (equal (foreground-color-at-point) "black"))
(goto-char 6)
(should (equal (background-color-at-point) "black"))
(should (equal (foreground-color-at-point) "black"))))))
(ert-deftest faces--test-face-id ()
;; Face ID of 0 is the 'default' face; no face should have the same ID.

View file

@ -925,26 +925,26 @@ have extra paired delimiters."
(goto-char (point-min))
(search-forward-regexp "\\(label:\\)")
(should (equal (get-text-property (match-beginning 1) 'face)
font-lock-constant-face))
'font-lock-constant-face))
(search-forward-regexp "\\(comment\\)")
(should (equal (get-text-property (match-beginning 1) 'face)
font-lock-comment-face))
'font-lock-comment-face))
(search-forward-regexp "\\(sanity\\)")
(should (equal (get-text-property (match-beginning 1) 'face)
font-lock-variable-name-face))
'font-lock-variable-name-face))
;; Now switch off the minor mode and redo
(cperl-extra-paired-delimiters-mode -1)
(font-lock-ensure)
(goto-char (point-min))
(search-forward-regexp "\\(label:\\)")
(should (equal (get-text-property (match-beginning 1) 'face)
font-lock-string-face))
'font-lock-string-face))
(search-forward-regexp "\\(comment\\)")
(should (equal (get-text-property (match-beginning 1) 'face)
font-lock-string-face))
'font-lock-string-face))
(search-forward-regexp "\\(sanity\\)")
(should (equal (get-text-property (match-beginning 1) 'face)
font-lock-variable-name-face))))
'font-lock-variable-name-face))))
;;; Function test: Building an index for imenu
@ -1364,13 +1364,13 @@ as that quote like operator."
(search-forward "bar")
(should (equal (get-text-property (match-beginning 0) 'face)
'font-lock-string-face))
; perl-mode doesn't highlight
;; perl-mode doesn't highlight
(when (eq cperl-test-mode #'cperl-mode)
(search-forward "_")
(should (equal (get-text-property (match-beginning 0) 'face)
(if (eq cperl-test-mode #'cperl-mode)
'font-lock-constant-face
font-lock-string-face))))))
'font-lock-string-face))))))
(ert-deftest cperl-test-hyperactive-electric-else ()
"Demonstrate cperl-electric-else behavior.
@ -1511,10 +1511,10 @@ detected as left-shift operator."
(font-lock-ensure)
(search-forward "retur") ; leaves point before the "n"
(should (equal (get-text-property (point) 'face)
font-lock-keyword-face))
'font-lock-keyword-face))
(search-forward "# comm") ; leaves point before "ent"
(should (equal (get-text-property (point) 'face)
font-lock-comment-face))))
'font-lock-comment-face))))
(ert-deftest cperl-test-bug-66145 ()
"Verify that hashes and arrays are only fontified in code.
@ -1528,7 +1528,7 @@ beginning with `cperl-test-unicode`."
("comment" . font-lock-comment-face)
("here" . ,(if (equal cperl-test-mode 'perl-mode)
'perl-heredoc
font-lock-string-face)))))
'font-lock-string-face)))))
(with-temp-buffer
(insert-file-contents (ert-resource-file "cperl-bug-66145.pl"))
(funcall cperl-test-mode)
@ -1552,7 +1552,7 @@ cperl-mode fontifies text after the delimiter as Perl code."
(font-lock-ensure)
(search-forward "TODO") ; leaves point before the colon
(should (equal (get-text-property (point) 'face)
font-lock-comment-face))))
'font-lock-comment-face))))
(ert-deftest cperl-test-bug-69604 ()
"Verify that $\" in a double-quoted string does not end the string.
@ -1571,7 +1571,7 @@ not appropriate."
(goto-char (point-min))
(search-forward "in string")
(should (equal (get-text-property (point) 'face)
font-lock-string-face))))))
'font-lock-string-face))))))
(ert-deftest cperl-test-bug-72296 ()
"Verify that the perl modes correctly handle the flip-flop operator.

View file

@ -7673,14 +7673,14 @@ always located at the beginning of buffer."
(python-ts-tests-with-temp-buffer
(concat "t " test " t")
(forward-to-word 1)
(should (eq (face-at-point) font-lock-keyword-face))
(should (eq (face-at-point) 'font-lock-keyword-face))
(forward-to-word 1)
(should (eq (face-at-point) font-lock-keyword-face)))))
(should (eq (face-at-point) 'font-lock-keyword-face)))))
(ert-deftest python-ts-mode-named-assignment-face-1 ()
(python-ts-tests-with-temp-buffer
"var := 3"
(should (eq (face-at-point) font-lock-variable-name-face))))
(should (eq (face-at-point) 'font-lock-variable-name-face))))
(ert-deftest python-ts-mode-assignment-face-2 ()
(python-ts-tests-with-temp-buffer
@ -7688,14 +7688,14 @@ always located at the beginning of buffer."
(dolist (test '("var" "rest"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-variable-name-face))))
(should (eq (face-at-point) 'font-lock-variable-name-face))))
(python-ts-tests-with-temp-buffer
"def func(*args):"
(dolist (test '("args"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-variable-name-face))))))
(should (not (eq (face-at-point) 'font-lock-variable-name-face))))))
(ert-deftest python-ts-mode-nested-types-face-1 ()
(python-ts-tests-with-temp-buffer
@ -7703,7 +7703,7 @@ always located at the beginning of buffer."
(dolist (test '("dict" "list" "tuple" "str" "int" "None" "None"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-union-types-face-1 ()
(python-ts-tests-with-temp-buffer
@ -7711,7 +7711,7 @@ always located at the beginning of buffer."
(dolist (test '("tuple" "tuple" "list" "Lvl1" "Lvl2" "Lvl3" "Lvl4" "Lvl5" "None" "Lvl2"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-union-types-face-2 ()
(python-ts-tests-with-temp-buffer
@ -7719,24 +7719,24 @@ always located at the beginning of buffer."
(dolist (test '("Type0" "Type1" "Type2" "Type3" "Type4" "None"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))
(should (eq (face-at-point) 'font-lock-type-face)))
(goto-char (point-min))
(dolist (test '("pack0" "pack1" "pack2"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-type-face))))))
(should (not (eq (face-at-point) 'font-lock-type-face))))))
(ert-deftest python-ts-mode-types-face-1 ()
(python-ts-tests-with-temp-buffer
"def f(val: Callable[[Type0], (Type1, Type2)]):"
(search-forward "val")
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-variable-name-face))
(should (eq (face-at-point) 'font-lock-variable-name-face))
(dolist (test '("Callable" "Type0" "Type1" "Type2"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-types-face-2 ()
(python-ts-tests-with-temp-buffer
@ -7744,12 +7744,12 @@ always located at the beginning of buffer."
(dolist (test '("Type0" "Type1"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))
(should (eq (face-at-point) 'font-lock-type-face)))
(goto-char (point-min))
(dolist (test '("pack0" "pack1" "pack2" "pack3"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-type-face))))))
(should (not (eq (face-at-point) 'font-lock-type-face))))))
(ert-deftest python-ts-mode-types-face-3 ()
(python-ts-tests-with-temp-buffer
@ -7757,12 +7757,12 @@ always located at the beginning of buffer."
(dolist (test '("Iterator" "Type0"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))
(should (eq (face-at-point) 'font-lock-type-face)))
(goto-char (point-min))
(dolist (test '("collections" "abc"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-type-face))))))
(should (not (eq (face-at-point) 'font-lock-type-face))))))
(ert-deftest python-ts-mode-isinstance-type-face-1 ()
(python-ts-tests-with-temp-buffer
@ -7774,13 +7774,13 @@ always located at the beginning of buffer."
(let ((case-fold-search nil))
(search-forward test))
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-type-face))))
(should (not (eq (face-at-point) 'font-lock-type-face))))
(goto-char (point-min))
(dolist (test '("Type0" "str" "dict" "Type1"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-isinstance-type-face-2 ()
(python-ts-tests-with-temp-buffer
@ -7788,7 +7788,7 @@ always located at the beginning of buffer."
(dolist (test '("int" "list" "Iterable"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-isinstance-type-face-3 ()
(python-ts-tests-with-temp-buffer
@ -7799,13 +7799,13 @@ always located at the beginning of buffer."
(dolist (test '("typevar1" "typevar2" "pkg0" "self" "typevar3" "typevar4"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-type-face))))
(should (not (eq (face-at-point) 'font-lock-type-face))))
(goto-char (point-min))
(dolist (test '("Type1" "tuple" "Coll" "Type2"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-superclass-type-face ()
(python-ts-tests-with-temp-buffer
@ -7814,13 +7814,13 @@ always located at the beginning of buffer."
(dolist (test '("Base1" "Base2" "Sequence" "T1" "T2"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))
(should (eq (face-at-point) 'font-lock-type-face)))
(goto-char (point-min))
(dolist (test '("pack0"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-type-face))))))
(should (not (eq (face-at-point) 'font-lock-type-face))))))
(ert-deftest python-ts-mode-class-patterns-face ()
(python-ts-tests-with-temp-buffer
@ -7835,13 +7835,13 @@ always located at the beginning of buffer."
(dolist (test '("str" "Type0" "bytes" "Type1" "int" "float"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))
(should (eq (face-at-point) 'font-lock-type-face)))
(goto-char (point-min))
(dolist (test '("pack0" "pack1"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-type-face))))))
(should (not (eq (face-at-point) 'font-lock-type-face))))))
(ert-deftest python-ts-mode-dotted-decorator-face-1 ()
(python-ts-tests-with-temp-buffer
@ -7852,7 +7852,7 @@ always located at the beginning of buffer."
(dolist (test '("pytest" "mark" "skip" "pytest" "mark" "skip"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-dotted-decorator-face-2 ()
(python-ts-tests-with-temp-buffer
@ -7863,14 +7863,14 @@ always located at the beginning of buffer."
(dolist (test '("pytest" "mark" "skip"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-type-face)))))
(should (eq (face-at-point) 'font-lock-type-face)))))
(ert-deftest python-ts-mode-builtin-call-face ()
(python-ts-tests-with-temp-buffer
"all()"
;; enable 'function' feature from 4th level
(setopt treesit-font-lock-level 4)
(should (eq (face-at-point) font-lock-builtin-face))))
(should (eq (face-at-point) 'font-lock-builtin-face))))
(ert-deftest python-ts-mode-interpolation-nested-string ()
(python-ts-tests-with-temp-buffer
@ -7878,20 +7878,20 @@ always located at the beginning of buffer."
(search-forward "True")
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-constant-face))
(should (eq (face-at-point) 'font-lock-constant-face))
(goto-char (point-min))
(dolist (test '("f" "{" "+" "}"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-string-face))))
(should (not (eq (face-at-point) 'font-lock-string-face))))
(goto-char (point-min))
(dolist (test '("beg" "'string'" "\""))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-string-face)))))
(should (eq (face-at-point) 'font-lock-string-face)))))
(ert-deftest python-ts-mode-level-fontification-wo-interpolation ()
(python-ts-tests-with-temp-buffer
@ -7900,12 +7900,12 @@ always located at the beginning of buffer."
(setopt treesit-font-lock-level 2)
(search-forward "f")
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-string-face)))
(should (not (eq (face-at-point) 'font-lock-string-face)))
(dolist (test '("\"" "beg" "{" "True" "var" "}" "\""))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-string-face)))))
(should (eq (face-at-point) 'font-lock-string-face)))))
(ert-deftest python-ts-mode-disabled-string-interpolation ()
(python-ts-tests-with-temp-buffer
@ -7919,12 +7919,12 @@ always located at the beginning of buffer."
(search-forward "f")
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-string-face)))
(should (not (eq (face-at-point) 'font-lock-string-face)))
(dolist (test '("\"" "beg" "{" "True" "var" "}" "\""))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-string-face))))
(should (eq (face-at-point) 'font-lock-string-face))))
(setf (nth 2 treesit-font-lock-feature-list)
(append (nth 2 treesit-font-lock-feature-list) '(string-interpolation))))))
@ -7935,25 +7935,25 @@ always located at the beginning of buffer."
(search-forward "True")
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-constant-face))
(should (eq (face-at-point) 'font-lock-constant-face))
(goto-char (point-min))
(dolist (test '("f" "{" "+" "}"))
(search-forward test)
(goto-char (match-beginning 0))
(should (not (eq (face-at-point) font-lock-string-face))))
(should (not (eq (face-at-point) 'font-lock-string-face))))
(goto-char (point-min))
(dolist (test '("\"\"\"" "beg" "end" "\"\"\""))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-doc-face)))
(should (eq (face-at-point) 'font-lock-doc-face)))
(goto-char (point-min))
(dolist (test '("'s1'" "'s2'"))
(search-forward test)
(goto-char (match-beginning 0))
(should (eq (face-at-point) font-lock-string-face)))))
(should (eq (face-at-point) 'font-lock-string-face)))))
(provide 'python-tests)

View file

@ -87,14 +87,14 @@ VALUES-PLIST is a list with alternating index and value elements."
(ert-deftest ruby-heredoc-font-lock ()
(let ((s "foo <<eos.gsub('^ *', '')"))
(ruby-assert-face s 9 font-lock-string-face)
(ruby-assert-face s 9 'font-lock-string-face)
(ruby-assert-face s 10 nil)))
(ert-deftest ruby-singleton-class-no-heredoc-font-lock ()
(ruby-assert-face "class<<a" 8 nil))
(ert-deftest ruby-heredoc-highlights-interpolations ()
(ruby-assert-face "s = <<EOS\n #{foo}\nEOS" 15 font-lock-variable-name-face))
(ruby-assert-face "s = <<EOS\n #{foo}\nEOS" 15 'font-lock-variable-name-face))
(ert-deftest ruby-no-heredoc-inside-quotes ()
(ruby-assert-state "\"<<\", \"\",\nfoo" 3 nil))
@ -109,7 +109,7 @@ VALUES-PLIST is a list with alternating index and value elements."
(ruby-assert-state "class <<self\nend" 3 nil))
(ert-deftest ruby-exit!-font-lock ()
(ruby-assert-face "exit!" 5 font-lock-builtin-face))
(ruby-assert-face "exit!" 5 'font-lock-builtin-face))
(ert-deftest ruby-deep-indent ()
(let ((ruby-deep-arglist nil)
@ -137,7 +137,7 @@ VALUES-PLIST is a list with alternating index and value elements."
(ruby-assert-state "'(/', /\d+/" 3 ?/ 8))
(ert-deftest ruby-regexp-interpolation-is-highlighted ()
(ruby-assert-face "/#{foobs}/" 4 font-lock-variable-name-face))
(ruby-assert-face "/#{foobs}/" 4 'font-lock-variable-name-face))
(ert-deftest ruby-regexp-skips-over-interpolation ()
(ruby-assert-state "/#{foobs.join('/')}/" 3 nil))
@ -427,32 +427,32 @@ VALUES-PLIST is a list with alternating index and value elements."
(should (string= "foo {|b| b + 2 }" (buffer-string)))))
(ert-deftest ruby-recognize-symbols-starting-with-at-character ()
(ruby-assert-face ":@abc" 3 font-lock-constant-face))
(ruby-assert-face ":@abc" 3 'font-lock-constant-face))
(ert-deftest ruby-hash-character-not-interpolation ()
(ruby-assert-face "\"This is #{interpolation}\"" 15
font-lock-variable-name-face)
'font-lock-variable-name-face)
(ruby-assert-face "\"This is \\#{no interpolation} despite the #\""
15 font-lock-string-face)
(ruby-assert-face "\n#@comment, not ruby code" 5 font-lock-comment-face)
15 'font-lock-string-face)
(ruby-assert-face "\n#@comment, not ruby code" 5 'font-lock-comment-face)
(ruby-assert-state "\n#@comment, not ruby code" 4 t)
(ruby-assert-face "# A comment cannot have #{an interpolation} in it"
30 font-lock-comment-face)
30 'font-lock-comment-face)
(ruby-assert-face "# #{comment}\n \"#{interpolation}\"" 16
font-lock-variable-name-face))
'font-lock-variable-name-face))
(ert-deftest ruby-interpolation-suppresses-quotes-inside ()
(let ((s "\"<ul><li>#{@files.join(\"</li><li>\")}</li></ul>\""))
(ruby-assert-state s 8 nil)
(ruby-assert-face s 9 font-lock-string-face)
(ruby-assert-face s 10 font-lock-variable-name-face)
(ruby-assert-face s 41 font-lock-string-face)))
(ruby-assert-face s 9 'font-lock-string-face)
(ruby-assert-face s 10 'font-lock-variable-name-face)
(ruby-assert-face s 41 'font-lock-string-face)))
(ert-deftest ruby-interpolation-suppresses-one-double-quote ()
(let ((s "\"foo#{'\"'}\""))
(ruby-assert-state s 8 nil)
(ruby-assert-face s 8 font-lock-variable-name-face)
(ruby-assert-face s 11 font-lock-string-face)))
(ruby-assert-face s 8 'font-lock-variable-name-face)
(ruby-assert-face s 11 'font-lock-string-face)))
(ert-deftest ruby-interpolation-suppresses-one-backtick ()
(let ((s "`as#{'`'}das`"))
@ -469,39 +469,39 @@ VALUES-PLIST is a list with alternating index and value elements."
(ert-deftest ruby-interpolation-inside-percent-literal ()
(let ((s "%( #{boo} )"))
(ruby-assert-face s 1 font-lock-string-face)
(ruby-assert-face s 4 font-lock-variable-name-face)
(ruby-assert-face s 10 font-lock-string-face)
(ruby-assert-face s 1 'font-lock-string-face)
(ruby-assert-face s 4 'font-lock-variable-name-face)
(ruby-assert-face s 10 'font-lock-string-face)
(ruby-assert-state s 8 nil)))
(ert-deftest ruby-interpolation-inside-percent-literal-with-paren ()
:expected-result :failed
(let ((s "%(^#{\")\"}^)"))
(ruby-assert-face s 3 font-lock-string-face)
(ruby-assert-face s 4 font-lock-variable-name-face)
(ruby-assert-face s 10 font-lock-string-face)
(ruby-assert-face s 3 'font-lock-string-face)
(ruby-assert-face s 4 'font-lock-variable-name-face)
(ruby-assert-face s 10 'font-lock-string-face)
;; It's confused by the closing paren in the middle.
(ruby-assert-state s 8 nil)))
(ert-deftest ruby-interpolation-inside-another-interpolation ()
:expected-result :failed
(let ((s "\"#{[a, b, c].map { |v| \"#{v}\" }.join}\""))
(ruby-assert-face s 1 font-lock-string-face)
(ruby-assert-face s 2 font-lock-variable-name-face)
(ruby-assert-face s 38 font-lock-string-face)
(ruby-assert-face s 1 'font-lock-string-face)
(ruby-assert-face s 2 'font-lock-variable-name-face)
(ruby-assert-face s 38 'font-lock-string-face)
(ruby-assert-state s 8 nil)))
(ert-deftest ruby-interpolation-inside-double-quoted-percent-literals ()
(ruby-assert-face "%Q{foo #@bar}" 8 font-lock-variable-name-face)
(ruby-assert-face "%W{foo #@bar}" 8 font-lock-variable-name-face)
(ruby-assert-face "%r{foo #@bar}" 8 font-lock-variable-name-face)
(ruby-assert-face "%x{foo #@bar}" 8 font-lock-variable-name-face))
(ruby-assert-face "%Q{foo #@bar}" 8 'font-lock-variable-name-face)
(ruby-assert-face "%W{foo #@bar}" 8 'font-lock-variable-name-face)
(ruby-assert-face "%r{foo #@bar}" 8 'font-lock-variable-name-face)
(ruby-assert-face "%x{foo #@bar}" 8 'font-lock-variable-name-face))
(ert-deftest ruby-no-interpolation-in-single-quoted-literals ()
(ruby-assert-face "'foo #@bar'" 7 font-lock-string-face)
(ruby-assert-face "%q{foo #@bar}" 8 font-lock-string-face)
(ruby-assert-face "%w{foo #@bar}" 8 font-lock-string-face)
(ruby-assert-face "%s{foo #@bar}" 8 font-lock-string-face))
(ruby-assert-face "'foo #@bar'" 7 'font-lock-string-face)
(ruby-assert-face "%q{foo #@bar}" 8 'font-lock-string-face)
(ruby-assert-face "%w{foo #@bar}" 8 'font-lock-string-face)
(ruby-assert-face "%s{foo #@bar}" 8 'font-lock-string-face))
(ert-deftest ruby-interpolation-after-dollar-sign ()
(ruby-assert-face "\"$#{balance}\"" 2 'font-lock-string-face)