* Colouring capital letters
@ 2023-09-20 12:08 uzibalqa
0 siblings, 0 replies; only message in thread
From: uzibalqa @ 2023-09-20 12:08 UTC (permalink / raw)
To: uzibalqa via Users list for the GNU Emacs text editor
I would to extract (from glasses.el) and complete the necessary code so that variable and
function names written in CamelCase appearing in capitals are coloured differently.
After having identified glasses-face and glasses-make-overlay, I need additional assistance
to implement the functionality.
(defun change-face-for-camel-case (face)
"Change the face of capital letters in CamelCase words throughout the buffer.
FACE is the face to apply to the capital letters."
(interactive "MFace for CamelCase letters: ")
(let ((case-fold-search nil))
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\b\\([A-Z][a-z0-9]*\\)\\([A-Z][a-z0-9]*\\)\\b" nil t)
(add-text-properties (match-beginning 1) (match-end 1) `(face ,face))
(add-text-properties (match-beginning 2) (match-end 2) `(face ,face)))
(font-lock-fontify-buffer))))
;; Bind the function to a key for easy use, e.g., F5
(global-set-key (kbd "<f5>")
(lambda ()
(interactive)
(change-face-for-camel-case 'font-lock-variable-name-face)))
Sent with Proton Mail secure email.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-20 12:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-20 12:08 Colouring capital letters uzibalqa
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.