* Changing comment typefaces
@ 2022-02-20 6:40 fatiparty--- via Users list for the GNU Emacs text editor
0 siblings, 0 replies; only message in thread
From: fatiparty--- via Users list for the GNU Emacs text editor @ 2022-02-20 6:40 UTC (permalink / raw)
To: Help Gnu Emacs
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))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-20 6:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-20 6:40 Changing comment typefaces fatiparty--- via Users list for the GNU Emacs text editor
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.