Simplify formatting logic
This commit is contained in:
parent
50b224b342
commit
d695e20e0e
67
mood-line.el
67
mood-line.el
@ -338,16 +338,17 @@ returned from `mood-line-glyphs-ascii'."
|
|||||||
mood-line-glyphs-ascii))))
|
mood-line-glyphs-ascii))))
|
||||||
|
|
||||||
(defun mood-line--format (left right)
|
(defun mood-line--format (left right)
|
||||||
"Format a mode line with a `LEFT' and `RIGHT' justified list of elements.
|
"Format a mode line string with LEFT and RIGHT justified lists of segments.
|
||||||
The mode line should fit the `window-width' with space between the lists."
|
Returned string will be padded in the center to fit `window-width'."
|
||||||
(let ((reserve (length right)))
|
(let* ((left-str (string-join left))
|
||||||
(concat left
|
(right-str (string-join right))
|
||||||
" "
|
(reserve (length right-str)))
|
||||||
|
(concat left-str
|
||||||
(propertize " "
|
(propertize " "
|
||||||
'display `((space :align-to (- right
|
'display `((space :align-to (- right
|
||||||
(- 0 right-margin)
|
(- 0 right-margin)
|
||||||
,reserve))))
|
,reserve))))
|
||||||
right)))
|
right-str)))
|
||||||
|
|
||||||
;; -------------------------------------------------------------------------- ;;
|
;; -------------------------------------------------------------------------- ;;
|
||||||
;;
|
;;
|
||||||
@ -695,8 +696,7 @@ Checkers checked, in order: `flycheck', `flymake'."
|
|||||||
|
|
||||||
(defun mood-line-segment-buffer-name ()
|
(defun mood-line-segment-buffer-name ()
|
||||||
"Display the name of the current buffer."
|
"Display the name of the current buffer."
|
||||||
(propertize "%b "
|
(format-mode-line "%b " 'mood-line-buffer-name))
|
||||||
'face 'mood-line-buffer-name))
|
|
||||||
|
|
||||||
;; ---------------------------------- ;;
|
;; ---------------------------------- ;;
|
||||||
;; Cursor position segment
|
;; Cursor position segment
|
||||||
@ -704,12 +704,11 @@ Checkers checked, in order: `flycheck', `flymake'."
|
|||||||
|
|
||||||
(defun mood-line-segment-cursor-position ()
|
(defun mood-line-segment-cursor-position ()
|
||||||
"Display the position of the cursor in the current buffer."
|
"Display the position of the cursor in the current buffer."
|
||||||
(concat "%l:%c"
|
(concat (format-mode-line "%l:%c")
|
||||||
(when mood-line-show-cursor-point
|
(when mood-line-show-cursor-point
|
||||||
(propertize (format ":%d" (point))
|
(propertize (format ":%d" (point))
|
||||||
'face 'mood-line-unimportant))
|
'face 'mood-line-unimportant))
|
||||||
(propertize " %o%% "
|
(format-mode-line " %o%% " 'mood-line-unimportant)))
|
||||||
'face 'mood-line-unimportant)))
|
|
||||||
|
|
||||||
;; ---------------------------------- ;;
|
;; ---------------------------------- ;;
|
||||||
;; EOL segment
|
;; EOL segment
|
||||||
@ -822,29 +821,25 @@ Checkers checked, in order: `flycheck', `flymake'."
|
|||||||
|
|
||||||
;; Set new value of `mode-line-format'
|
;; Set new value of `mode-line-format'
|
||||||
(setq-default mode-line-format
|
(setq-default mode-line-format
|
||||||
'((:eval
|
'(:eval (mood-line--format
|
||||||
(mood-line--format
|
;; Left
|
||||||
;; Left
|
(list " "
|
||||||
(format-mode-line
|
(mood-line-segment-modal)
|
||||||
'(" "
|
(mood-line-segment-buffer-status)
|
||||||
(:eval (mood-line-segment-modal))
|
(mood-line-segment-buffer-name)
|
||||||
(:eval (mood-line-segment-buffer-status))
|
(mood-line-segment-anzu)
|
||||||
(:eval (mood-line-segment-buffer-name))
|
(mood-line-segment-multiple-cursors)
|
||||||
(:eval (mood-line-segment-anzu))
|
(mood-line-segment-cursor-position))
|
||||||
(:eval (mood-line-segment-multiple-cursors))
|
;; Right
|
||||||
(:eval (mood-line-segment-cursor-position))))
|
(list (mood-line-segment-indentation)
|
||||||
|
(mood-line-segment-eol)
|
||||||
;; Right
|
(mood-line-segment-encoding)
|
||||||
(format-mode-line
|
(mood-line-segment-vc)
|
||||||
'((:eval (mood-line-segment-indentation))
|
(mood-line-segment-major-mode)
|
||||||
(:eval (mood-line-segment-eol))
|
(mood-line-segment-misc-info)
|
||||||
(:eval (mood-line-segment-encoding))
|
(mood-line-segment-checker)
|
||||||
(:eval (mood-line-segment-vc))
|
(mood-line-segment-process)
|
||||||
(:eval (mood-line-segment-major-mode))
|
" ")))))
|
||||||
(:eval (mood-line-segment-misc-info))
|
|
||||||
(:eval (mood-line-segment-checker))
|
|
||||||
(:eval (mood-line-segment-process))
|
|
||||||
" ")))))))
|
|
||||||
|
|
||||||
;; ---------------------------------- ;;
|
;; ---------------------------------- ;;
|
||||||
;; Deactivation function
|
;; Deactivation function
|
||||||
|
Loading…
Reference in New Issue
Block a user