TheBB / spaceline

Powerline theme from Spacemacs
GNU General Public License v3.0
536 stars 59 forks source link

toggle-mode-line-battery-on causes error at startup #56

Open bastibl opened 8 years ago

bastibl commented 8 years ago

Hi,

when including

(spacemacs/toggle-mode-line-battery-on)

in my user_config, I get

Error during redisplay: (eval (spaceline--prepare spaceline-left spaceline-right)) signaled (wrong-type-argument stringp nil)

Everything seems to work, though. It's just a bit annoying.

I'm pretty new, so maybe I'm missing something obvious like a require. Switching the battery segment on and off with keybindings causes no error.

TheBB commented 8 years ago

I can't reproduce this. It works fine here. SPC hds? Can I see your dotfile?

TheBB commented 8 years ago

If the key binding doesn't cause errors, does it also work if you do (call-interactively 'spacemacs/toggle-mode-line-battery-on)?

bastibl commented 8 years ago

Thanks for your reply. Good to know that it's not normal. I looked a bit further. It only happens with the X version of emacs, the terminal version works fine.

I also tried removing everything from my user config, except for the battery mode toggle and still experienced the error, also with call-interactively.

Using call-interactively in the scratch buffer works fine.

System Info

(spacemacs-helm auto-completion better-defaults emacs-lisp
                (c-c++ :variables c-c++-enable-clang-support t)
                git markdown themes-megapack python html php javascript org osx vinegar
                (colors :variables colors-enable-nyan-cat-progress-bar t)
                (latex :variables latex-build-command "LatexMk" latex-enable-auto-fill nil)
                (shell :variables shell-default-shell 'eshell shell-default-term-shell "/bin/zsh" shell-default-height 30 shell-default-position 'bottom)
                spell-checking syntax-checking
                (version-control :variables version-control-diff-tool 'diff-hl version-control-global-margin t))
TheBB commented 8 years ago

Can you do SPC t D and evaluate (spaceline--prepare spaceline-left spaceline-right) manually (in scratch, say) so that you get a backtrace?

bastibl commented 8 years ago

that's the output, but I guess it's not useful. I also tried to start with --debug-init, I'm not sure how get a backtrace :-/

#(" org|➊   %* %I *scratch*   Text     80%% (6:01)   utf-8 | %l:%2c   %p " 0 1 (face (spacemacs-normal-face)) 1 4 (face (bold spacemacs-normal-face)) 4 5 (face (spacemacs-normal-face)) 5 6 (face (spacemacs-normal-face)) 6 7 (face (spacemacs-normal-face)) 7 8 (face spacemacs-normal-face display (image :type xpm :data "/* XPM */ static char * wave_right[] = { \"11 20 3 1\", \"0 c #202020\", \"1 c #eead0e\", \"2 c #876617\",\"11111111112\",\"11111111100\",\"11111111000\",\"11111112000\",\"11111110000\",\"11111120000\",\"11111100000\",\"11111100000\",\"11111200000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11112000000\",\"11110000000\",\"11110000000\",\"11120000000\",\"11100000000\",\"11200000000\",\"20000000000\",};" :ascent center :face spacemacs-normal-face)) 8 9 (face (mode-line)) 9 11 (face (mode-line)) 11 12 (face (mode-line)) 12 14 (face (mode-line) mouse-face mode-line-highlight local-map (keymap (mode-line keymap (mouse-1 lambda nil (interactive) (setq powerline-buffer-size-suffix (not powerline-buffer-size-suffix)) (force-mode-line-update))))) 14 15 (face (mode-line)) 15 24 (face (mode-line-buffer-id mode-line) help-echo "Buffer name
mouse-1: Previous buffer
mouse-3: Next buffer" mouse-face mode-line-highlight local-map (keymap (header-line keymap (mouse-3 . mode-line-next-buffer) (down-mouse-3 . ignore) (mouse-1 . mode-line-previous-buffer) (down-mouse-1 . ignore)) (mode-line keymap (mouse-3 . mode-line-next-buffer) (mouse-1 . mode-line-previous-buffer)))) 24 25 (face (mode-line)) 25 26 (face powerline-active1 display (image :type xpm :data "/* XPM */ static char * wave_left[] = { \"11 20 3 1\", \"0 c #202020\", \"1 c #2d2d2d\", \"2 c #262626\",\"21111111111\",\"00111111111\",\"00011111111\",\"00021111111\",\"00001111111\",\"00002111111\",\"00000111111\",\"00000111111\",\"00000211111\",\"00000011111\",\"00000011111\",\"00000011111\",\"00000011111\",\"00000021111\",\"00000001111\",\"00000001111\",\"00000002111\",\"00000000111\",\"00000000211\",\"00000000002\",};" :ascent center :face powerline-active1)) 26 27 (face (powerline-active1)) 27 31 (face (powerline-active1) mouse-face mode-line-highlight help-echo "Major mode
mouse-1: Display major mode menu
mouse-2: Show help for major mode
mouse-3: Toggle minor modes" local-map (keymap (mode-line keymap (down-mouse-3 keymap (abbrev-mode menu-item "Abbrev (Abbrev)" abbrev-mode :help "Automatically expand abbreviations" :button (:toggle . abbrev-mode)) (auto-fill-mode menu-item "Auto fill (Fill)" auto-fill-mode :help "Automatically insert new lines" :button (:toggle . auto-fill-function)) (auto-revert-mode menu-item "Auto revert (ARev)" auto-revert-mode :help "Revert the buffer when the file on disk changes" :button (:toggle bound-and-true-p auto-revert-mode)) (auto-revert-tail-mode menu-item "Auto revert tail (Tail)" auto-revert-tail-mode :help "Revert the tail of the buffer when buffer grows" :enable (buffer-file-name) :button (:toggle bound-and-true-p auto-revert-tail-mode)) (flyspell-mode menu-item "Flyspell (Fly)" flyspell-mode :help "Spell checking on the fly" :button (:toggle bound-and-true-p flyspell-mode)) (font-lock-mode menu-item "Font Lock" font-lock-mode :help "Syntax coloring" :button (:toggle . font-lock-mode)) (glasses-mode menu-item "Glasses (o^o)" glasses-mode :help "Insert virtual separators to make long identifiers easy to read" :button (:toggle bound-and-true-p glasses-mode)) (hide-ifdef-mode menu-item "Hide ifdef (Ifdef)" hide-ifdef-mode :help "Show/Hide code within #ifdef constructs" :button (:toggle bound-and-true-p hide-ifdef-mode)) (highlight-changes-mode menu-item "Highlight changes (Chg)" highlight-changes-mode :help "Show changes in the buffer in a distinctive color" :button (:toggle bound-and-true-p highlight-changes-mode)) (outline-minor-mode menu-item "Outline (Outl)" outline-minor-mode :help "" :button (:toggle bound-and-true-p outline-minor-mode)) (overwrite-mode menu-item "Overwrite (Ovwrt)" overwrite-mode :help "Overwrite mode: typed characters replace existing text" :button (:toggle . overwrite-mode)) "Minor Modes") (mouse-2 . describe-mode) (down-mouse-1 menu-item "Menu Bar" ignore :filter (lambda (_) (mouse-menu-major-mode-map)))))) 31 32 (face (powerline-active1)) 32 33 (face powerline-active1 display (image :type xpm :data "/* XPM */ static char * wave_right[] = { \"11 20 3 1\", \"0 c #4e4e4e\", \"1 c #2d2d2d\", \"2 c #3d3d3d\",\"11111111112\",\"11111111100\",\"11111111000\",\"11111112000\",\"11111110000\",\"11111120000\",\"11111100000\",\"11111100000\",\"11111200000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11112000000\",\"11110000000\",\"11110000000\",\"11120000000\",\"11100000000\",\"11200000000\",\"20000000000\",};" :ascent center :face powerline-active1)) 33 34 (display ((space :align-to (- (+ right right-fringe right-margin) 35.125))) face powerline-active2) 34 35 (face powerline-active2 display (image :type xpm :data "/* XPM */ static char * wave_right[] = { \"11 20 3 1\", \"0 c #2d2d2d\", \"1 c #4e4e4e\", \"2 c #3d3d3d\",\"11111111112\",\"11111111100\",\"11111111000\",\"11111112000\",\"11111110000\",\"11111120000\",\"11111100000\",\"11111100000\",\"11111200000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11112000000\",\"11110000000\",\"11110000000\",\"11120000000\",\"11100000000\",\"11200000000\",\"20000000000\",};" :ascent center :face powerline-active2)) 35 36 (face (powerline-active1)) 36 47 (face (fancy-battery-discharging powerline-active1)) 47 48 (face (powerline-active1)) 48 49 (face mode-line display (image :type xpm :data "/* XPM */ static char * wave_left[] = { \"11 20 3 1\", \"0 c #2d2d2d\", \"1 c #202020\", \"2 c #262626\",\"21111111111\",\"00111111111\",\"00011111111\",\"00021111111\",\"00001111111\",\"00002111111\",\"00000111111\",\"00000111111\",\"00000211111\",\"00000011111\",\"00000011111\",\"00000011111\",\"00000011111\",\"00000021111\",\"00000001111\",\"00000001111\",\"00000002111\",\"00000000111\",\"00000000211\",\"00000000002\",};" :ascent center :face mode-line)) 49 50 (face (mode-line)) 50 55 (face (mode-line)) 55 58 (face (mode-line)) 58 64 (face (mode-line)) 64 65 (face (mode-line)) 65 66 (face mode-line display (image :type xpm :data "/* XPM */ static char * wave_right[] = { \"11 20 3 1\", \"0 c #2d2d2d\", \"1 c #202020\", \"2 c #262626\",\"11111111112\",\"11111111100\",\"11111111000\",\"11111112000\",\"11111110000\",\"11111120000\",\"11111100000\",\"11111100000\",\"11111200000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11111000000\",\"11112000000\",\"11110000000\",\"11110000000\",\"11120000000\",\"11100000000\",\"11200000000\",\"20000000000\",};" :ascent center :face mode-line)) 66 67 (face (powerline-active1)) 67 69 (face (powerline-active1)) 69 70 (face (powerline-active1)))

Maybe the battery segment doesn't return a string when called for the first time?

I also found this, which, at least, seems to show similar problems. https://github.com/milkypostman/powerline/issues/58#issuecomment-90779067

TheBB commented 8 years ago

You can't get a backtrace from the modeline code (otherwise it would be impossible to do anything if it errored out). That's why I asked you to actually run it manually. But what you showed me is the return value, not the backtrace. Did you do SPC t D so that it would produce a backtrace on error?

bastibl commented 8 years ago

OK, makes sense :-) Yes, I did enable debug. I guess the problem is that it really happens only at startup. Running the command manually does not cause an error.

I already deleted the .cache directory and elpa to assert that there are no left-overs from upgrade or something.

Maybe it's really that the battery widget returns nil when called during startup. I tried requiring spaceline and fancy-batter before toggling the segment, but also no success.

bastibl commented 8 years ago

hmm, I added

  (require 'fancy-battery)
  (fancy-battery-update)

before toggling the segment and the error is gone. So I guess it's a problem of fancy-battery...?