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

seems to be window-number error #30

Closed trivialfis closed 7 years ago

trivialfis commented 7 years ago

When I place my cursor on the mode line and hold it still, the entire mode line disappear just as described in the README section. It will come back if I switch to mini buffer by M-x, so I have to bind the spaceline-all-the-icons--debug-segments to a key binding to avoid activating the mini buffer (Little trick can be added to README). Here's the error message: Error during redisplay: (eval (spaceline-ml-all-the-icons)) signaled (wrong-type-argument number-or-marker-p nil) [5 times] Here is what I got from --debug-segments: spaceline-all-the-icons--debug-segments: Errors found in Spaceline Segments: [window-number]Error during redisplay: (eval (spaceline-ml-all-the-icons)) signaled (wrong-type-argument number-or-marker-p nil) By the way, I am currently running Emacs 25.2.

domtronn commented 7 years ago

Hey @fisgithub, are you using window-numbering or winum-mode?

trivialfis commented 7 years ago

It's the new winum-mode. I have the old Windows-numbering removed.

domtronn commented 7 years ago

Hmmm, so does this works normally? It's only when you hover over the mode line that this is happening?

Do you know what Emacs is doing when you hover over the mode line as I can't seem to reproduce this... 🙁

trivialfis commented 7 years ago

It works fine if I don't place my cursor on it and hold it still (about for a second or two). Well, could be anything, viewing message, coding, eshell or just scratch, I can reproduce it any time. I am new to elisp but have some experience with edebug. It's there any tip so that I can help? Since I can't really put a (debug) in (:eval ....).

domtronn commented 7 years ago

I'm afraid I can't reproduce it...

I'm assuming it's okay if you toggle the window number segment off with spaceline-toggle-all-the-icons-window-number-off?

And no, it's going to be hard to debug as its dependent on you mousing over the mode line. Do you have any code specifically to do highlighting the mode line?

Otherwise, try redefining the segment with this snippet

(spaceline-define-segment all-the-icons-window-number
  "An `all-the-icons' segment depicting the current window number"
  (let* ((face `(:height ,(spaceline-all-the-icons--height 1.4) :inherit))
         (window-num
          (cond
           ((bound-and-true-p winum-mode) (winum-get-number))
           ((bound-and-true-p window-numbering-mode) (window-numbering-get-number))))

         ;; Debug message statement
         (window-num (and (message "Window Num: %s" window-num) window-num))

         (icon-set (if (> window-num 9) 'string spaceline-all-the-icons-icon-set-window-numbering))
         (icon (cl-case icon-set
                 (solid   (format "%c" (+ window-num 10121)))
                 (circle  (format "%c" (+ window-num 9311)))
                 (string  (progn
                            (setq face (append `(:height ,(spaceline-all-the-icons--height 1.2)) face))
                            (number-to-string window-num)))
                 (square  (progn
                            (setq face (append `(:height ,(spaceline-all-the-icons--height 0.8)) face))
                            (setq face (append `(:family ,(all-the-icons-material-family)) face))
                            (all-the-icons-material (format "filter_%s" window-num) :v-adjust -0.2))))))
    (propertize icon 'face face))

  :when (and
         (or (bound-and-true-p winum-mode)
             (bound-and-true-p window-numbering-mode))
         (or spaceline-all-the-icons-window-number-always-visible
             (> (length (window-list)) 1))))

After evaluating this, just run spaceline-all-the-icons-theme to recompile the mode line 👍

I've added a message statement that should print out the value of window-num before doing anything with it. I'm kind of clutching at straws but the only thing I can think it would be is that the winum-get-number is returning nil when you hover over the mode line.

Then, recreate the error and check the *Messages* buffer and see if you've got any non-integer values for the window number.

Does that make sense? Let me know the results or if I can help in any way 🙂

If this is the case, I'll have to think what it means for the window to be nil and what the segment should do in this case... Most likely just not show anything!

trivialfis commented 7 years ago

I think you got it right, it does show nil. Here is the message:

Error during redisplay: (eval (spaceline-ml-all-the-icons)) signaled (wrong-type-argument number-or-marker-p nil)
Window Num: nil

I don't have any other code highlighting the mode line. As you mention it, I thought the theme might have something to do with it. So I changed back to the default theme, but it doesn't seem to fix the bug. Thanks for the hard work. 🙂

domtronn commented 7 years ago

No worries, I've updated the predicated to return nil when the window number isn't a number! This means that the window number segment won't appear in this case, but the rest of the mode line should work.

So hopefully this should fix your issue 🙂 Let me know how you get on and then I can close this

trivialfis commented 7 years ago

It works fine now. Thanks.🙂