emacs-php / emacs-php/php-mode

Define individual faces for individual keywords

Open
#601 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
602
Forks
117
Avg merge
12h 54m
Merged PRs (30d)
3

Description

At the moment, changing the `php-keyword` face, will affect elements like `new`, `public`, `function`, `extends` and more.

I believe this is because most `*-kwds` constants will get assigned `font-lock-keyword-face` by font-lock. In particular:

```
(c-lang-defconst c-typeless-decl-kwds
php (append (c-lang-const c-class-decl-kwds) '("function")))

(c-lang-defconst c-modifier-kwds
php '("abstract" "const" "final" "static"))

(c-lang-defconst c-protection-kwds
"Access protection label keywords in classes."
php '("private" "protected" "public"))

(c-lang-defconst c-postfix-decl-spec-kwds
php '("implements" "extends"))

(c-lang-defconst c-type-list-kwds
php '("@new" ;; @new is *NOT* language construct, it's workaround for coloring.
"new" "use" "implements" "extends" "namespace" "instanceof" "insteadof"))

(c-lang-defconst c-ref-list-kwds
php nil)

(c-lang-defconst c-block-stmt-2-kwds
php '("catch" "declare" "elseif" "for" "foreach" "if" "switch" "while"))

(c-lang-defconst c-simple-stmt-kwds
php '("break" "continue" "die" "echo" "exit" "goto" "return" "throw"
"include" "include_once" "print" "require" "require_once"))

(c-lang-defconst c-constant-kwds
php '("true" "false" "null"))

(c-lang-defconst c-lambda-kwds
php '("function" "use"))

(c-lang-defconst c-other-block-decl-kwds
php '("namespace"))

(c-lang-defconst c-other-kwds
"Keywords not accounted for by any other `*-kwds' language constant."
php
'(
"__halt_compiler"
"and"
"array"
"as"
"break"
"catch"
"clone"
"default"
"empty"
"enddeclare"
"endfor"
"endforeach"
"endif"
"endswitch"
"endwhile"
"eval"
"fn" ;; NOT c-lambda-kwds
"global"
"isset"
"list"
"or"
"parent"
"static"
"unset"
"var"
"xor"
"yield"
"yield from"

;; Below keywords are technically not reserved keywords, but
;; threated no differently by php-mode from actual reserved
;; keywords
;;
;;; declare directives:
"encoding"
"ticks"
"strict_types"

;;; self for static references:
"self"
))
```

these. In my opinon the user should have more freedom in choosing which statement should be fontified by what face (E.g. maybe I want `if` to be colored different from `class ... extends ...`).

I could write a PR for that, but first I wanted to make sure a change like that would be welcomed by the maintainer.

Waiting on feedback for this.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.