Created
April 18, 2015 20:53
-
-
Save BJTerry/2f7594536dccc0ca4971 to your computer and use it in GitHub Desktop.
Using rainbow-identifiers-mode with php-mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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