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" ) )
source share