dbordak / telephone-line

A new implementation of Powerline for Emacs
GNU General Public License v3.0
550 stars 51 forks source link

Boon mode segment #60

Open thorstengrothe opened 6 years ago

thorstengrothe commented 6 years ago

I'm in the process of finding the right modal mode for me, now I'm testing Boon Mode. So tried to make telephone-line compatible with Boon on my own. I added this to telephone-line-segments.el

(eval-after-load 'boon
  '(telephone-line-defsegment* telephone-line-boon-mode-segment ()
     (let ((tag (if boon-mode
                    "BOON" "INS")))
       (if telephone-line-evil-use-short-tag
           (seq-take tag 1)
         tag))))

and this to telephone-line.el

(defcustom telephone-line-faces
  '((evil . telephone-line-modal-face)
    ...
    (boon . telephone-line-boon-mode-face)
   ...
    (nil . (mode-line . mode-line-inactive)))

and this

(defun telephone-line-boon-mode-face (active)
  "Return an appropriate face depending whether boon-mode is activated, given whether frame is ACTIVE."
  (cond ((not active) 'mode-line-inactive)
        ((not (boundp 'boon-mode)) 'mode-line)
        ((not boon-mode) 'telephone-line-evil-insert)
        (t 'telephone-line-evil-normal)))

This is my config

(use-package telephone-line
  :ensure t
  :config
  ;; https://github.com/dbordak/telephone-line
  (setq telephone-line-lhs
        '((boon   . (telephone-line-boon-mode-segment))
          (accent . (telephone-line-vc-segment
                     telephone-line-erc-modified-channels-segment
                     telephone-line-process-segment))
          (nil    . (telephone-line-minor-mode-segment
                     telephone-line-buffer-segment))))
  (setq telephone-line-rhs
        '((nil    . (telephone-line-misc-info-segment))
          (accent . (telephone-line-major-mode-segment))
          (boon   . (telephone-line-airline-position-segment))))
  ;; Cubebed
  (setq telephone-line-primary-left-separator 'telephone-line-cubed-left
        telephone-line-secondary-left-separator 'telephone-line-cubed-hollow-left
        telephone-line-primary-right-separator 'telephone-line-cubed-right
        telephone-line-secondary-right-separator 'telephone-line-cubed-hollow-right)
  (setq telephone-line-height 24
        telephone-line-evil-use-short-tag t)
  (telephone-line-mode 1)
  )

But this does not work:
telephone-line/:config: Wrong type argument: sequencep, telephone-line-boon-mode-segment

What I'm doing wrong? Thorsten

thorstengrothe commented 6 years ago

I forgot to say that boon has three different states, you can see this in his Powerline config

Thorsten

dbordak commented 6 years ago

Hey, I'll look at this more closely over the coming week, but my first thought is that this looks like what happens when you try to use an eval-when-load'd segment before the package it depends upon is actually loaded. I'm not sure exactly how the load order works with use-package, though.

thorstengrothe commented 6 years ago

Hi,

most of it is running now.

telephone-line.el

(defcustom telephone-line-faces
  '((evil . telephone-line-modal-face)
    (modal . telephone-line-modal-face)
    (ryo . telephone-line-ryo-modal-face)
    (boon . telephone-line-boon-mode-face) ;; BOON
    (accent . (telephone-line-accent-active . telephone-line-accent-inactive))
    (nil . (mode-line . mode-line-inactive)))

(defun telephone-line-boon-mode-face (active)
  "Return an appropriate face depending whether boon-mode
   is activated, given whether frame is ACTIVE."
  (cond ((not active) 'mode-line-inactive) 
        ((not (boundp 'boon-mode)) 'mode-line) ;; This does not work
        (boon-insert-state 'telephone-line-evil-insert)
        (boon-special-state 'telephone-line-evil-emacs)
        (t 'telephone-line-evil-normal)))

telephone-line-segments.el

(eval-after-load 'boon
  '(telephone-line-defsegment* telephone-line-boon-mode-segment ()
     (let ((tag (cond
                 (boon-command-state "BOON")
                 (boon-insert-state "INS")
                 (boon-special-state "SPC")
                 )))
       (if telephone-line-evil-use-short-tag
           (seq-take tag 1)
         tag))))

The three states command/insert/special are working but if I disable Boon the evil tag does not vanish. Can you look at it, if you have time?

Regards Thorsten

thorstengrothe commented 6 years ago

Sorry, unfortunately I closed the issue, my mistake. I reopen it again.

Thorsten

dbordak commented 6 years ago

If you want the segment to return nil when you're not using boon, you'd need to write that yourself; there's no code here that says what to do when boon is loaded but not enabled.

thorstengrothe commented 6 years ago

Ok, I see. No problem I can live with that. For me it's working fine. Should the above code merged to to the official telephone-line package?

dbordak commented 6 years ago

Sure, I don't see why not.