[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changing comment typefaces
From: |
fatiparty |
Subject: |
Changing comment typefaces |
Date: |
Sun, 20 Feb 2022 07:40:49 +0100 (CET) |
I have the function "richkov-annotation-typeface" chat changes the colour
of comments, which I can then cycle through using a keybinding. I also want
to assign comments with normal weight (as I customarily use bold typefaces).
There seems to be some incompatibilities between "richkov-comment-delimiter"
and "richkov-annotation-typeface". I could really do with some advice on
structuring
my code.
(defvar richkov-annotation-contrast 2
"Sets the colour contrast (against background) for comments.")
(defvar richkov-annotation-chroma
'( (dark . ((low . "#8600E6") (mid . "#AA33FF") (high . "#C370FF")))
(light . ((low . "#C16BFF") (mid . "#AA33FF") (high . "#8000DB"))) )
"Colour contrast for comments, indigo on dark and light background.")
(defun richkov-comment-delimiter ()
"Use normal weight typeface for comments."
(set-face-attribute 'font-lock-comment-face nil
:weight 'normal :slant 'italic)
;; copy typeface to font-lock-comment-delimiter-face
(copy-face 'font-lock-comment-face 'font-lock-comment-delimiter-face)
;; delimiter-face inherits from font-lock-comment-face
(if (eq 'dark (frame-parameter nil 'background-mode))
(set-face-attribute 'font-lock-comment-delimiter-face nil
:foreground "#00FF00") ; for dark theme
(set-face-attribute 'font-lock-comment-delimiter-face nil
:foreground "#00FFFF") )) ; for light theme
(defun richkov-annotation-typeface (chroma)
"Set the foreground colour for comments.
CHROMA Intensity Key used for setting colour of comments ."
(message "richkov-annotation-typeface ")
(let* ( (colors richkov-annotation-chroma)
(levels
(alist-get (frame-parameter nil 'background-mode) colors)) )
(face-remap-add-relative 'font-lock-comment-face
`(:foreground ,(alist-get chroma levels)))
(message "richkov-annotation: %s contrast" chroma)) )
(defun richkov-annotation-sweep ()
"Cycles through the colour chroma for comments.
Colours are determined by `richkov-annotation'."
(interactive)
(pcase richkov-annotation-contrast
(1
(richkov-annotation-typeface 'low)
(setq richkov-annotation-contrast 2))
(2
(richkov-annotation-typeface 'mid)
(setq richkov-annotation-contrast 3))
(_
(richkov-annotation-typeface 'high)
(setq richerenkov-annotation-contrast 1)) ))
(defun richkov-annotation-low-contrast ()
(when richkov-minor-mode
(richkov-annotation-typeface 'low)))
(defun richkov-annotation-keytrigger ()
"Key trigger for rapid execution of richkov commands"
(interactive)
(global-set-key (kbd "H-;") #'richkov-annotation-sweep))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Changing comment typefaces,
fatiparty <=