kiennq / emacs-mini-modeline

Display emacs mode line in minibuffer
GNU General Public License v3.0
202 stars 14 forks source link

Different alignments in horizontally split vs non-split frames #29

Open johnmwu opened 4 years ago

johnmwu commented 4 years ago

As an example, an unsplit frame looks like

image

whereas a split frame looks like

image

Most notably, it appears that the global info, i.e mode-line-misc-info, only appears when the frame is horizontally split. Now obviously this isn't the reason (that's stupid), but I can't find any better pattern for reproducing this.

johnmwu commented 4 years ago

Digging a bit further, this definitely has to do with smart-mode-line. In sml/generate-minor-modes, there is:

(defun sml/generate-minor-modes ()
  "Extracts all rich strings necessary for the minor mode list."
  (if sml/simplified
      ""
    (let* (;; The minor-mode-alist
           (nameList (rm--mode-list-as-string-list))
           ;; The size available
           (size (max 0
                      (- (if (member sml/mode-width '(full right))
                             ;; Calculate how much width is available
                             (sml/fill-width-available)
                           ;; or use what the user requested.
                           sml/mode-width)
                         (string-width (format-mode-line
...

Here, size is the number of chars in the minor mode list. I believe there's a bug in the calculation of sml/fill-width-available, where it calculates a number that's far too high (so the global info is pushed off). Also, this computation uses window-total-width, which explains why alignment changes when splitting the window horizontally.

I was able to fix the issue of global info by

(setq sml/mode-width 40)
kiennq commented 4 years ago

Can you try with this (:eval (string-trim (format-mode-line mode-line-modes))) instead of mode-line-modes in mini-modeline-r-format? And also try to remove mode-line-end-spaces too