[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Wed, 01 Jul 2020 19:23:21 +0200
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Douglas Lewan wrote:
> Is there a "Hello, World!" kind of tutorial about
> setting (and unsetting) faces?
> The only thing I find in the emacs info suggests
> putting face attributes character by character.
> I can do that, but there has to be something more
> appropriately abstract.
Here are some face stuff:
;;; -*- lexical-binding: t -*-
;;; this file:
(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) )))
;; use this to test
(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) ) ; <- eval me
(defun test-all-faces ()
"Print a test string in every color, normal and bright."
(let ((str "this is what it looks like"))
(dolist (bold '(nil t))
(dolist (color '("black" "red" "green" "yellow" "blue"
"magenta" "cyan" "white") )
(format "%s in %s (that is %sbold)\n" str color
(if bold "" "not "))
color bold) ))))
;; test all colors:
;; (test-all-faces) ; <- eval me
And even more in this long file , in particular
the `font-lock-add-keywords' stuff (line 27) and
"what-face" (line 49).
I wonder tho... why is this, uhm, required?
The byte compiler doesn't issue any complaint if
I comment it out. But without it, Emacs reports an
invalid face error on boot (when the file is loaded).
What I can see ERC doesn't get any special treatment
in that file, either.
underground experts united
- Faces?, Douglas Lewan, 2020/07/01
- Re: Faces?, Eli Zaretskii, 2020/07/01
- Re: Faces?,
Emanuel Berg <=