all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: fatiparty--- via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Changing comment typefaces
Date: Sun, 20 Feb 2022 07:40:49 +0100 (CET)	[thread overview]
Message-ID: <MwKr7cj--3-2@tutanota.com> (raw)


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))





                 reply	other threads:[~2022-02-20  6:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MwKr7cj--3-2@tutanota.com \
    --to=help-gnu-emacs@gnu.org \
    --cc=fatiparty@tutanota.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.