How to fix the value on the right side of the model?

Is there a way to place the value on the right end of the model?

In my understanding, at present the model “pushes” its values ​​further to the right if the values ​​increase in size. I would prefer that some values ​​start on the right side and expand in the middle.

I tried solutions like powerline, but they seem rather distracting and more complicated to set up to display the same information as the standard model.

+6
source share
2 answers

As far as I know, this cannot be done by simply setting up the normal mode line. You can change the mode-line-format variable to change its appearance and content to some extent, but with regard to the built-in constructions for text alignment, I’m pretty sure that you are limited to controlling the line width of the lines, either by filling or truncating. It might be advisable to use some smart hacker within the variable mode-line-format (using forms (:eval ...) and / or (list ...) ) to achieve the desired result. See the Emacs Lisp Reference Guide on the mode-line-format page for more information. In addition, you will have to use third-party packages.

+1
source

Here is one way to do it. The trick is to add spaces to the end of the line minus the space needed to display your text (extracted from the powerline code in 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" ) ) 
+4
source

Source: https://habr.com/ru/post/945946/


All Articles