Skip to content

Instantly share code, notes, and snippets.

@BJTerry
Created April 18, 2015 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BJTerry/2f7594536dccc0ca4971 to your computer and use it in GitHub Desktop.
Save BJTerry/2f7594536dccc0ca4971 to your computer and use it in GitHub Desktop.
Using rainbow-identifiers-mode with php-mode
(setq rainbow-identifiers-faces-to-override (default font-lock-variable-name-face))
(defun rainbow-identifiers-face-overridable (begin end)
"Test if all the faces under the identifier are overridable."
(let ((current begin)
(contains-non-default nil))
(catch 'rainbow-identifiers--face-overridable
(while (progn
(let ((face (get-text-property current 'face)))
; In PHP function names have no style
(if (not (or (eq face 'default) (null face))) (setq contains-non-default t))
(cond
((null face)
t)
((listp face)
(dolist (face* face)
(unless (memq face* rainbow-identifiers-faces-to-override)
(throw 'rainbow-identifiers--face-overridable nil))))
(t
(unless (memq face rainbow-identifiers-faces-to-override)
(throw 'rainbow-identifiers--face-overridable nil)))))
(setq current (next-single-property-change current 'face nil end))
(not (eq current end))))
contains-non-default)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment