Question

Is there a way to position a value on the the right end of the modeline?

From my understanding currently the modeline "pushes" its values farther right if the values increase in size. I would prefer it if some values would start on the right side and expand into the middle.

I have tried solutions like powerline, but they seem rather distracting and more complicated in setup to display the same amount of informatioon as the standard modeline.

Was it helpful?

Solution 2

As far as I'm aware, that isn't possible to do through straightforward customization of the ordinary mode line. You can modify the mode-line-format variable to alter its appearance and contents to some degree, but as far as built-in constructs for text alignment are concerned, I'm fairly certain that you're limited to controlling the width of mode line components via either padding or truncation. It might be feasible to employ some clever hackery within the mode-line-format variable (using the (:eval ...) and/or (list ...) forms) to achieve the desired result, however. You could consult the Emacs Lisp Reference Manual page on the mode-line-format variable for details. Beyond that, you'd have to use some third-party packages.

OTHER TIPS

Here is one way to do it. The trick is to add spaces until the end of the line minus the place needed to display your text (extracted from powerline code on the emacs wiki):

(defun mode-line-fill (face reserve)
  "Return empty space using FACE and leaving RESERVE space on the right."
  (unless reserve
    (setq reserve 20))
  (when (and window-system (eq 'right (get-scroll-bar-mode)))
    (setq reserve (- reserve 3)))
  (propertize " "
              'display `((space :align-to (- (+ right right-fringe right-margin) ,reserve)))
              'face face))


;; Set the modeline to tell me the filename, hostname, etc..
(setq-default mode-line-format (list
   " "
   mode-line-mule-info
   'mode-line-modified
   "-  "
   'mode-line-buffer-identification
   "  (%l, %c)  "
   'mode-line-modes
   " -- "
   `(vc-mode vc-mode)

   ;; Fill until the end of line but 10 characters
   (mode-line-fill 'mode-line 10)
   "Some text"
   )
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top