diff options
author | David Edmondson <dme@dme.org> | 2010-04-26 10:25:28 +0100 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-04-26 07:30:33 -0700 |
commit | 7b31a11f209271748e3d6c3b8cd7d69d073fe674 (patch) | |
tree | b509833175e6a70a98813eb148f1bc0285eb75f7 /emacs/notmuch-hello.el | |
parent | 42bda003a0df6c4b798ee1063a01c2ce0b2962e5 (diff) |
emacs: Adapt the logo background colour to that of the frame
The notmuch logo uses transparency. That can display poorly when
inserting the image into an emacs buffer (black logo on a black
background), so force the background colour of the image. We use a
face (`notmuch-hello-logo-background') to represent the colour so that
`defface' can be used to declare the different possible colours, which
depend on whether the frame has a light or dark background.
Diffstat (limited to 'emacs/notmuch-hello.el')
-rw-r--r-- | emacs/notmuch-hello.el | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 482ef681..3a74ebd6 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -55,9 +55,14 @@ :type 'boolean :group 'notmuch) -(defcustom notmuch-hello-logo-background "#5f5f5f" +(defface notmuch-hello-logo-background + '((((class color) + (background dark)) + (:background "#5f5f5f")) + (((class color) + (background light)) + (:background "white"))) "Background colour for the notmuch logo." - :type 'color :group 'notmuch) (defcustom notmuch-hello-jump-to-search t @@ -209,12 +214,16 @@ diagonal." (when notmuch-hello-show-logo (let ((image notmuch-hello-logo)) - ;; dme: Sorry, I don't know any other way to achieve this :-( The - ;; notmuch logo uses transparency. That works out badly when - ;; inserting the image into an emacs buffer, so force the - ;; background colour of the image. - (setq image (cons 'image (append (cdr image) - `(:background ,notmuch-hello-logo-background)))) + ;; The notmuch logo uses transparency. That can display poorly + ;; when inserting the image into an emacs buffer (black logo on + ;; a black background), so force the background colour of the + ;; image. We use a face to represent the colour so that + ;; `defface' can be used to declare the different possible + ;; colours, which depend on whether the frame has a light or + ;; dark background. + (setq image (cons 'image + (append (cdr image) + (list :background (face-background 'notmuch-hello-logo-background))))) (insert-image image)) (widget-insert " ")) |