Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect face remapping in separators #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 44 additions & 32 deletions powerline-separators.el
Original file line number Diff line number Diff line change
Expand Up @@ -101,43 +101,55 @@ destination color, and 2 is the interpolated color between 0 and 1."

(defun pl/background-color (face)
(face-attribute face
(if (face-attribute face :inverse-video nil 'default)
:foreground
:background)
nil
'default))
(if (face-attribute face :inverse-video nil 'default)
:foreground
:background)
nil
'default))

(defun pl/wrap-defun (name dir width let-vars body)
"Generate a powerline function of NAME in DIR with WIDTH using LET-VARS and BODY."
(let* ((src-face (if (eq dir 'left) 'face1 'face2))
(dst-face (if (eq dir 'left) 'face2 'face1)))
`(defun ,(intern (format "powerline-%s-%s" name (symbol-name dir)))
(face1 face2 &optional height)
(when window-system
(unless height (setq height (pl/separator-height)))
(let* ,(append `((color1 (when ,src-face
(pl/hex-color (pl/background-color ,src-face))))
(color2 (when ,dst-face
(pl/hex-color (pl/background-color ,dst-face))))
(colori (when (and color1 color2) (pl/interpolate color1 color2)))
(color1 (or color1 "None"))
(color2 (or color2 "None"))
(colori (or colori "None")))
let-vars)
(create-image ,(append `(concat (format "/* XPM */ static char * %s_%s[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\","
,(replace-regexp-in-string "-" "_" name)
(symbol-name ',dir)
,width
height
color1
color2
colori))
body
'("};"))
'xpm t
:ascent 'center
:face (when (and face1 face2)
,dst-face)))))))
`(progn
(defun ,(intern (format "powerline-%s-%s" name (symbol-name dir)))
(face1 face2 &optional height)
(let ((face1 face1)
(face2 face2)
(fa (assoc face1 face-remapping-alist)))
(when fa
(setq face1 (car (cdr fa))))
(setq fa (assoc face2 face-remapping-alist))
(when fa
(setq face2 (car (cdr fa))))
(,(intern (format "powerline-%s-%s--1" name (symbol-name dir))) face1 face2 height)))
(defun ,(intern (format "powerline-%s-%s--1" name (symbol-name dir)))
(face1 face2 &optional height)
(when window-system
(unless height (setq height (pl/separator-height)))
(let* ,(append `((color1 (when ,src-face
(pl/hex-color (pl/background-color ,src-face))))
(color2 (when ,dst-face
(pl/hex-color (pl/background-color ,dst-face))))
(colori (when (and color1 color2) (pl/interpolate color1 color2)))
(color1 (or color1 "None"))
(color2 (or color2 "None"))
(colori (or colori "None")))
let-vars)
(create-image ,(append `(concat (format "/* XPM */ static char * %s_%s[] = { \"%s %s 3 1\", \"0 c %s\", \"1 c %s\", \"2 c %s\","
,(replace-regexp-in-string "-" "_" name)
(symbol-name ',dir)
,width
height
color1
color2
colori))
body
'("};"))
'xpm t
:ascent 'center
:face (when (and face1 face2)
,dst-face))))))))


(defmacro pl/alternate (dir)
Expand Down