* Starting emacs with coloured annotations
@ 2022-03-15 21:20 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-03-15 21:20 UTC (permalink / raw)
To: Help Gnu Emacs
I want to colour comments using normal weight, bet have everything else in bold.
Have not been able to have the following code get comments with normal weight
and display the scratch buffer comments using the low contrast colour #8600E6
when using a dark theme.
(defun bold-frames ()
"Set bold weight attribute for all frames."
(set-face-attribute 'default nil :weight 'bold))
(defun annotation-style ()
"Set colour for the comment delimiter.
Use normal weight typeface for comments."
(set-face-attribute 'font-lock-comment-face nil
:weight 'normal :slant 'italic))
(defun annotation-delimiter-colour ()
"Set foreground colour for the comment delimiter."
(if (eq 'dark (frame-parameter nil 'background-mode))
(set-face-attribute 'font-lock-comment-delimiter-face nil
:foreground "#00FF00")
(set-face-attribute 'font-lock-comment-delimiter-face nil
:foreground "#00FFFF") ))
(defvar 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 annotation-body-colour (chroma)
"Set the foreground colour for comments following delimiter.
CHROMA Intensity Key used for setting colour of comments ."
(let* ( (colors annotation-chroma)
(frame-bg (frame-parameter nil 'background-mode))
(levels (alist-get frame-bg colors)) )
(face-remap-add-relative 'font-lock-comment-face
`(:foreground ,(alist-get chroma levels)))) )
(defun annotation-low-contrast ()
(annotation-body-colour 'low))
(defun annotation-tools ()
"Aggregate annotation tools for comments."
(bold-frames)
(annotation-style)
(annotation-delimiter-colour)
(annotation-low-contrast)
(annotation-keytrigger))
;;;###autoload
(define-minor-mode annotation-minor-mode "Focused editing."
:lighter " annotation" ; indicator in mode-line
(let ( (w (face-attribute 'default :weight)) )
(set-face-attribute 'font-lock-comment-face nil :weight w))
(when annotation-minor-mode (annotation-tools)) )
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-15 21:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15 21:20 Starting emacs with coloured annotations fatiparty--- via Users list for the GNU Emacs text editor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).