TheBB / spaceline

Powerline theme from Spacemacs
GNU General Public License v3.0
534 stars 60 forks source link

How to define new segments #195

Open ghost opened 6 years ago

ghost commented 6 years ago

I'm trying to define some new segments. I tried to follow the docs:

(spaceline-define-segment my-spaceline-segment-left "My segment." "Hello, World (left)!" )
(spaceline-define-segment my-spaceline-segment-right "My segment." "Hello, World (right)!" )
(spaceline-compile "my-modeline" '(my-spaceline-segment-left) '(my-spaceline-segment-right))
(setq mode-line-format '("%e" (:eval (my-modeline))))

Executing this empties my mode-line, but doesn't add "Hello, World (left)!" and "Hello, World (right)!" like I was expecting. I'm sure I'm doing something wrong -- could you point me in the right direction? Thanks.

TheBB commented 6 years ago

The resulting function isn't called my-modeline. It has a prefix. See the docstring for spaceline-compile. I'm on a phone now so it's difficult for me to check. It's something like spaceline-ml-my-modeline.

ghost commented 6 years ago

Ah, right you are, thanks.

I made a summary demo, posting in case you think it'd be helpful for the readme. Cheers!

;; Custom spaceline example
(spaceline-define-segment my-segment-left-1 "My first left segment." "Hello, World (LEFT 1)!")
(spaceline-define-segment my-segment-left-2 "My second left segment." "Hello, World (LEFT 2)!")
(spaceline-define-segment my-segment-right-1 "My first right segment." "Hello, World (RIGHT 1)!")
(spaceline-define-segment my-segment-right-2 "My second right segment." "Hello, World (RIGHT 2)!")
(spaceline-compile "my-modeline" '(my-segment-left-1 my-segment-left-2) '(my-segment-right-1 my-segment-right-2))
(setq mode-line-format '("%e" (:eval (spaceline-ml-my-modeline))))

image