[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: font-lock for comments
From: |
goncholden |
Subject: |
Re: font-lock for comments |
Date: |
Tue, 15 Feb 2022 11:32:08 +0000 |
------- Original Message -------
On Tuesday, February 15th, 2022 at 10:59 AM, Emanuel Berg via Users list for
the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> goncholden via Users list for the GNU Emacs text editor wrote:
> > I want to change font for comments to bold. Should I change
> > both font-lock-comment-delimiter-face and
> > font-lock-comment-delimiter-face ?
>
> Test this:
>
> ;;; -- lexical-binding: t --
> ;;; this file:
> ;;; http://user.it.uu.se/~embe8573/emacs-init/test-face.el
> ;;; https://dataswamp.org/~incal/emacs-init/test-face.el
>
> (defun insert-colored-text (str color bright)
> "Insert STR at point, in COLOR, and sometimes BRIGHT."
> (interactive (list (read-string "string: ")
> (read-string "color: ")
> (y-or-n-p "bright? ") ))
> (insert (propertize str 'font-lock-face
> `(:weight ,(if bright 'bold 'normal) :foreground ,color) )))
>
> (defun test-all-faces ()
> "Print a test string in every color, normal and bright."
> (interactive)
> (forward-line)
> (let ((str "this is what it looks like"))
> (dolist (bold '(nil t))
> (dolist (color '("black" "red" "green" "yellow" "blue"
> "magenta" "cyan" "white") )
> (insert-colored-text
> (format "%s in %s (that is %sbold)\n" str color
> (if bold "" "not "))
> color bold) ))))
> ;; (test-all-faces)
>
> (when nil
> (progn
> (goto-char (point-max))
> (insert "The French flag is ")
> (insert-colored-text "blue, " "blue" t)
> (insert-colored-text "white, " "white" t)
> (insert "and" )
> (insert-colored-text " red." "red" nil) ))
I failed to understand how the code helps me.