aboutsummaryrefslogtreecommitdiff
path: root/Emacs
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-07-02 14:16:24 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-07-02 14:16:24 +0100
commitea232f3110748fe7a929e9863387ead422bc3379 (patch)
treed13bffeae36de2010ab8ef3278589224a9e3b9ae /Emacs
parent38b69af52b9a6f770b0cf4413fcfd53a9688c4cc (diff)
downloaddotfiles-ea232f3110748fe7a929e9863387ead422bc3379.tar.gz
dotfiles-ea232f3110748fe7a929e9863387ead422bc3379.tar.bz2
dotfiles-ea232f3110748fe7a929e9863387ead422bc3379.zip
(Emacs/elisp)~Use a symbol-shorthand to lower the size of symbols in better mode line
Diffstat (limited to 'Emacs')
-rw-r--r--Emacs/.config/emacs/elisp/better-mode-line.el41
1 files changed, 23 insertions, 18 deletions
diff --git a/Emacs/.config/emacs/elisp/better-mode-line.el b/Emacs/.config/emacs/elisp/better-mode-line.el
index 1314d1f..39c8d5e 100644
--- a/Emacs/.config/emacs/elisp/better-mode-line.el
+++ b/Emacs/.config/emacs/elisp/better-mode-line.el
@@ -27,22 +27,22 @@
;;; Code:
-(defvar better-mode-line/left-segment nil
+(defvar bml/left-segment nil
"List of elements that are placed on the left of the mode-line")
-(defvar better-mode-line/centre-segment nil
+(defvar bml/centre-segment nil
"List of elements that should be on the centre of the mode-line")
-(defvar better-mode-line/right-segment nil
+(defvar bml/right-segment nil
"List of elements that should be on the right of the mode-line")
-(defconst better-mode-line/--minimum-padding 4
+(defconst bml/--minimum-padding 4
"Minimum size of padding string.")
-(defun better-mode-line/--get-padding-size (other-size)
+(defun bml/--get-padding-size (other-size)
"Compute length of padding to ensure string of size OTHER is on an
extreme end to CENTRE-SEGMENT."
- (let* ((centre-size (length (format-mode-line better-mode-line/centre-segment)))
+ (let* ((centre-size (length (format-mode-line bml/centre-segment)))
(win-width (window-width))
(margins (window-margins))
(width (if (null (car margins))
@@ -50,27 +50,32 @@ extreme end to CENTRE-SEGMENT."
(+ (car margins) win-width (cdr margins)))))
(- (floor (/ width 2)) (floor (/ centre-size 2)) other-size)))
-(defun better-mode-line/--generate-padding (segment)
+(defun bml/--generate-padding (segment)
"Make padding string to separate center segment from SEGMENT."
(let* ((segment-size (length (format-mode-line segment)))
- (padding-size (better-mode-line/--get-padding-size segment-size)))
- (make-string (if (< padding-size better-mode-line/--minimum-padding)
- better-mode-line/--minimum-padding
+ (padding-size (bml/--get-padding-size segment-size)))
+ (make-string (if (< padding-size bml/--minimum-padding)
+ bml/--minimum-padding
padding-size)
?\s)))
-(defun better-mode-line/setup-mode-line ()
+(defun bml/setup-mode-line ()
"Call this to setup the mode-line when:
- first loading the package.
- segments are updated."
(setq-default mode-line-format
- `(,better-mode-line/left-segment
- (:eval (better-mode-line/--generate-padding
- better-mode-line/left-segment))
- ,better-mode-line/centre-segment
- (:eval (better-mode-line/--generate-padding
- better-mode-line/right-segment))
- ,better-mode-line/right-segment)))
+ `(,bml/left-segment
+ (:eval (bml/--generate-padding
+ bml/left-segment))
+ ,bml/centre-segment
+ (:eval (bml/--generate-padding
+ bml/right-segment))
+ ,bml/right-segment)))
(provide 'better-mode-line)
+
;;; better-mode-line.el ends here
+
+;; Local Variables:
+;; read-symbol-shorthands: (("bml" . "better-mode-line"))
+;; End: