powerline icon indicating copy to clipboard operation
powerline copied to clipboard

Trying to get a colored background for "powerline-vc" stuff

Open fniessen opened this issue 10 years ago • 7 comments

Hello,

I'm trying to customize your EXCELLENT modeline package so that it better meets what I have in mind. Among others, I'd like to get the "SVN" or "Git" tag colored in red or green, depending on whether or not the file is up-to-date regarding the VCS or not.

I defined new fonts, I have conditional code, but it does not work (if you uncomment the 4 lines somewhere in the code).

I guess it could be related to the function vc-workfile-unchanged-p not being defined. But, by protecting it in the "when" (with a test on vc-mode being non-nil), it should be OK.

I don't understand why it's not working. Would you have an idea?

(PS- I'm sure it's a bug on my side, not in Powerline itself, though).

Best regards, Fabrice

Code:

(defface powerline-evil-modified-face '((((class color)) (:background "red" :foreground "black" :weight bold)) (t (:weight bold))) "Face to fontify modified files." :group 'powerline)

(defface powerline-evil-normal-face '((((class color)) (:background "green" :foreground "black" :weight bold)) (t (:weight bold))) "Face to fontify unchanged files." :group 'powerline)

(defun powerline-leuven-theme () "Setup the leuven mode-line." (interactive) (setq-default mode-line-format '("%e" (:eval (let* ((active (powerline-selected-window-active)) (mode-line (if active 'mode-line 'mode-line-inactive)) (face1 (if active 'powerline-active1 'powerline-inactive1)) (face2 (if active 'powerline-active2 'powerline-inactive2)) (separator-left (intern (format "powerline-%s-%s" powerline-default-separator (car powerline-default-separator-dir)))) (separator-right (intern (format "powerline-%s-%s" powerline-default-separator (cdr powerline-default-separator-dir)))) (lhs (list (powerline-vc face1 'r)

                                 ;; (when (and (buffer-file-name (current-buffer)) vc-mode)
                                 ;;   (if (vc-workfile-unchanged-p (buffer-file-name (current-buffer)))
                                 ;;       (powerline-vc powerline-evil-insert-face 'r)
                                 ;;     (powerline-vc powerline-evil-normal-face 'r)))

                                 (funcall separator-left face1 mode-line)
                                 (powerline-raw "%*" nil 'l)
                                 (powerline-raw mode-line-mule-info nil 'l)
                                 (powerline-buffer-id nil 'l)
                                 (when (and (boundp 'which-func-mode) which-func-mode)
                                   (powerline-raw which-func-format nil 'l))
                                 (powerline-raw " ")
                                 (funcall separator-left mode-line face1)
                                 (when (boundp 'erc-modified-channels-object)
                                   (powerline-raw erc-modified-channels-object face1 'l))
                                 (powerline-major-mode face1 'l)
                                 (powerline-process face1)
                                 (powerline-raw " " face1)
                                 (funcall separator-left face1 face2)
                                 (powerline-minor-modes face2 'l)
                                 (powerline-narrow face2 'l)))
                      (rhs (list (powerline-raw global-mode-string face2 'r)
                                 (funcall separator-right face2 face1)
                                 (powerline-raw "%l" face1 'l)
                                 (powerline-raw ", " face1 'l)
                                 (powerline-raw "%c" face1 'r)
                                 (funcall separator-right face1 mode-line)
                                 (powerline-raw " ")
                                 (powerline-raw "%4p of" nil 'r)
                                 (powerline-buffer-size nil 'l)
                                 (powerline-hud face2 face1))))
                 (concat (powerline-render lhs)
                         (powerline-fill face2 (powerline-width rhs))
                         (powerline-render rhs)))))))

fniessen avatar Sep 04 '14 20:09 fniessen

fabrice, sorry I haven’t replied yet I have been busy and don’t run powerline anymore (sorry it’s unmaintained).

You need to escape the faces when you use them,

(when (and (buffer-file-name (current-buffer)) vc-mode) (if (vc-workfile-unchanged-p (buffer-file-name (current-buffer))) (powerline-vc 'powerline-evil-insert-face 'r) (powerline-vc 'powerline-evil-normal-face 'r)))

In my test the vc-workfile-unchanged-p didn’t update always on time. But hopefully this will get you started with it.

I debugged by pulling the statement apart and looking at the Messages buffer. By inserting the powerline-vc lines by themselves I could see ti was treating powerline-evil-normal-face as a variable. ​

On Thu, Sep 4, 2014 at 1:28 PM, Fabrice Niessen [email protected] wrote:

Hello,

I'm trying to customize your EXCELLENT modeline package so that it better meets what I have in mind. Among others, I'd like to get the "SVN" or "Git" tag colored in red or green, depending on whether or not the file is up-to-date regarding the VCS or not.

I defined new fonts, I have conditional code, but it does not work (if you uncomment the 4 lines somewhere in the code).

I guess it could be related to the function vc-workfile-unchanged-p not being defined. But, by protecting it in the "when" (with a test on vc-mode being non-nil), it should be OK.

I don't understand why it's not working. Would you have an idea?

(PS- I'm sure it's a bug on my side, not in Powerline itself, though).

Best regards, Fabrice

Code:

(defface powerline-evil-modified-face '((((class color)) (:background "red" :foreground "black" :weight bold)) (t (:weight bold))) "Face to fontify modified files." :group 'powerline)

(defface powerline-evil-normal-face '((((class color)) (:background "green" :foreground "black" :weight bold)) (t (:weight bold))) "Face to fontify unchanged files." :group 'powerline)

(defun powerline-leuven-theme () "Setup the leuven mode-line." (interactive) (setq-default mode-line-format '("%e" (:eval (let* ((active (powerline-selected-window-active)) (mode-line (if active 'mode-line 'mode-line-inactive)) (face1 (if active 'powerline-active1 'powerline-inactive1)) (face2 (if active 'powerline-active2 'powerline-inactive2)) (separator-left (intern (format "powerline-%s-%s" powerline-default-separator (car powerline-default-separator-dir)))) (separator-right (intern (format "powerline-%s-%s" powerline-default-separator (cdr powerline-default-separator-dir)))) (lhs (list (powerline-vc face1 'r)

                             ;; (when (and (buffer-file-name (current-buffer)) vc-mode)
                             ;;   (if (vc-workfile-unchanged-p (buffer-file-name (current-buffer)))
                             ;;       (powerline-vc powerline-evil-insert-face 'r)
                             ;;     (powerline-vc powerline-evil-normal-face 'r)))

                             (funcall separator-left face1 mode-line)
                             (powerline-raw "%*" nil 'l)
                             (powerline-raw mode-line-mule-info nil 'l)
                             (powerline-buffer-id nil 'l)
                             (when (and (boundp 'which-func-mode) which-func-mode)
                               (powerline-raw which-func-format nil 'l))
                             (powerline-raw " ")
                             (funcall separator-left mode-line face1)
                             (when (boundp 'erc-modified-channels-object)
                               (powerline-raw erc-modified-channels-object face1 'l))
                             (powerline-major-mode face1 'l)
                             (powerline-process face1)
                             (powerline-raw " " face1)
                             (funcall separator-left face1 face2)
                             (powerline-minor-modes face2 'l)
                             (powerline-narrow face2 'l)))
                  (rhs (list (powerline-raw global-mode-string face2 'r)
                             (funcall separator-right face2 face1)
                             (powerline-raw "%l" face1 'l)
                             (powerline-raw ", " face1 'l)
                             (powerline-raw "%c" face1 'r)
                             (funcall separator-right face1 mode-line)
                             (powerline-raw " ")
                             (powerline-raw "%4p of" nil 'r)
                             (powerline-buffer-size nil 'l)
                             (powerline-hud face2 face1))))
             (concat (powerline-render lhs)
                     (powerline-fill face2 (powerline-width rhs))
                     (powerline-render rhs)))))))

— Reply to this email directly or view it on GitHub https://github.com/milkypostman/powerline/issues/68.

milkypostman avatar Sep 08 '14 17:09 milkypostman

Thanks for your answer. I'm progressing...

That makes me sad that you say it's not maintained anymore. Is there a living fork out of it?

fniessen avatar Sep 09 '14 12:09 fniessen

there are lots of other people who took the original powerline for emacs and have been working on it. mine had major rewrites in many parts to make the width exact. no forks of my version but there are people with forks that are more active.

On Tue, Sep 9, 2014 at 5:34 AM, Fabrice Niessen [email protected] wrote:

Thanks for your answer. I'm progressing...

That makes me sad that you say it's not maintained anymore. Is there a living fork out of it?

— Reply to this email directly or view it on GitHub https://github.com/milkypostman/powerline/issues/68#issuecomment-54961943 .

milkypostman avatar Sep 09 '14 12:09 milkypostman

Actually, from what I see on github you have 33 forks...

rougier avatar Sep 09 '14 15:09 rougier

yeah but which one do I pick as the new main one????

On Tue, Sep 9, 2014 at 8:28 AM, Nicolas P. Rougier <[email protected]

wrote:

Actually, from what I see on github you have 33 forks...

— Reply to this email directly or view it on GitHub https://github.com/milkypostman/powerline/issues/68#issuecomment-54986673 .

milkypostman avatar Sep 12 '14 22:09 milkypostman

That's the real question!!!!

And, for me, anyway, the main one is the one on MELPA, i.e. yours...

If someone takes your work over, then the MELPA package should be made from his repo.

fniessen avatar Sep 13 '14 08:09 fniessen

Someone else actually had commit access but I don't think they are maintaining. You could maintain it! On Sep 13, 2014 1:42 AM, "Fabrice Niessen" [email protected] wrote:

That's the real question!!!!

And, for me, anyway, the main one is the one on MELPA, i.e. yours...

If someone takes your work over, then the MELPA package should be made from his repo.

— Reply to this email directly or view it on GitHub https://github.com/milkypostman/powerline/issues/68#issuecomment-55485779 .

milkypostman avatar Sep 14 '14 02:09 milkypostman