Skip to content

Commit

Permalink
add: an user option for padding (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmaiKinono authored and kiennq committed Mar 5, 2020
1 parent 8762d2e commit e15ffd1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ You can customize those variable for better experiences.
8. `mini-modeline-truncate-p`
Truncates the `mini-modeline` to fit in one line.

9. `mini-modeline-right-padding`
Padding to use in the right side. Set this to the minimal value that doesn't cause truncation.

# Why?

Echo area or `minibuffer` which reside in it is a big waste most of the time.
Expand Down
15 changes: 13 additions & 2 deletions mini-modeline.el
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ Nil means current selected frame."
:type 'sexp
:group 'mini-modeline)

(defcustom mini-modeline-right-padding 3
"Padding to use in the right side.
Set this to the minimal value that doesn't cause truncation."
:type 'integer
:group 'mini-modeline)

(defvar mini-modeline--last-echoed nil)

(defvar mini-modeline--msg nil)
Expand Down Expand Up @@ -203,15 +209,20 @@ When ARG is:
"Render the LEFT and RIGHT part of mini-modeline."
(let* ((left (or left ""))
(right (or right ""))
(available-width (max (- (frame-width mini-modeline-frame) (string-width left) 3) 0))
(available-width (max (- (frame-width mini-modeline-frame)
(string-width left)
mini-modeline-right-padding)
0))
(required-width (string-width right)))
(if (< available-width required-width)
(if mini-modeline-truncate-p
(cons
(format (format "%%s %%%1$d.%1$ds" available-width) left right)
0)
(cons
(format (format "%%%1$d.%1$ds\n%%s" (- (frame-width mini-modeline-frame) 3)) right left)
(format (format "%%%1$d.%1$ds\n%%s" (- (frame-width mini-modeline-frame)
mini-modeline-right-padding))
right left)
1))
(cons (format (format "%%s %%%ds" available-width) left right) 0))))

Expand Down

0 comments on commit e15ffd1

Please sign in to comment.