I have the following function
(defun fphp/find-unimported-classes ()
(interactive)
(mapcar (lambda (classentry)
(ov-clear (classentry-overlay classentry))
)
classentries)
(setq classentries '())
(save-excursion
(goto-char (point-min))
(while (re-search-forward "$[A-Z]+" nil t)
(backward-word)
(backward-word)
(setq word (current-word))
(setq wordpoint (point))
(forward-word)
(setq endwordpoint (point))
(forward-word)
(if (string= (capitalize word) word)
(add-to-list 'classentries (make-classentry :word word))))
(mapcar (lambda (classentry)
(goto-char (point-max))
(setq word (classentry-word classentry))
(message word)
(setq classregexp (concat "\\(" (substring word 0 1) "\\)"
(substring word 1) "\s"))
(if (buffer-contains-string (concat "use [A-Z+\\]+" word ";"))
(ov-set classregexp 'face 'class-defined-face '(classentry-overlay classentry) t)
(ov-set classregexp 'face 'class-undefined-face '(classentry-overlay classentry) t)
)
)
classentries)
))
It's purpose is to match all unimported classes in the php code and it works quite well, however it matches also variable names, like:
$className
I want to modify it to match only capitalized words. The regexp is built here:
(setq classregexp (concat "\\(" (substring word 0 1) "\\)"
(substring word 1) "\s"))
How can I achieve it? Now it matches all cases of the first character.