domtronn / spaceline-all-the-icons.el

A Spaceline Mode Line theme using All The Icons for Emacs
MIT License
235 stars 25 forks source link

Add custom segments with callback #32

Closed frapples closed 7 years ago

frapples commented 7 years ago

I want to add a segments displaying file encoding:

  (spaceline-all-the-icons-theme 'file-encoding
                                 (lambda () (format "%s" buffer-file-coding-system))
                                 'etc)

But the code can not work.

But I try:

 (spaceline-all-the-icons-theme 'file-encoding
                                 (lambda () "hello")
                                 'etc)

Work well.

domtronn commented 7 years ago

Segments need to be defined as a mode line evaluation string, so Spaceline comes with some segments predefined, which can be called, for example

(spaceline-all-the-icons-theme 'buffer-encoding 'remote-host)

Otherwise, you want an eval expression, like

(spaceline-all-the-icons-theme '("%e" (:eval (format "hello %s"))))

Hope this helps 🙂

frapples commented 7 years ago

Thank you! :smile: