I'm trying to build a function but having trouble with the regex. Specifically, I want to match capital letters only.
This function is supposed to capitalize words that are in lowercase (the
→ The
) but not touch words that are already in uppercase (like #+STARTUP:
or * TODO
).
(defun capitalize-unless-org-heading ()
(interactive)
(unless
(or
(looking-at "\*")
(looking-at "[\n\t ]*\\*") ; don't capitalize an org heading
(looking-at "* TODO") ; don't capitalize an org todo heading
(looking-at "[\n\t\ ]*#+") ; don't capitalize org options like #+STARTUP:
(looking-at "[\n\t\ *[A-Z]") ; don't capitalize any word that might be all uppercase
)
(capitalize-word 1))
)
If it matters, case-fold-search
is set to t
so I can search for text in my buffers without worrying about case. How do I build a regex to search for uppercase letters only?