I am writing Latex Style Files and want to improve the appearance of Camel Case Variables and Functions. What kind of elisp function can I write to enhance readability.
Have been directed to glasses.el
. Rather than install another minor-mode to my configuration, I would like to take out the part that sets capital letters to a different colour.
Looking at the code I have identified glasses-face
and glasses-make-overlay
. But I need help to construct a function or two to enable and disable the colour functionality.
Have been working with the following function
(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)))
M-x glasses-mode
glasses-mode
, you'll need to be more specific about what help you need. In particular, please post functions that you have created but need help finishing. Otherwise, this question risks turning into a "please code this thing for me"-style post, which does not generally go down well here.