diff options
author | jao <jao@gnu.org> | 2022-08-13 17:38:35 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-08-13 17:38:35 +0100 |
commit | 72ba87a9df87f8a16af96c21c3dcf6c387875294 (patch) | |
tree | ce6bd364f94468c308f8409c46843d6b80153efd /etc | |
parent | 09f9cb86a017d588db3f7524b3f12f6bee22f71c (diff) | |
download | xmobar-72ba87a9df87f8a16af96c21c3dcf6c387875294.tar.gz xmobar-72ba87a9df87f8a16af96c21c3dcf6c387875294.tar.bz2 |
xmobar.el nits
Diffstat (limited to 'etc')
-rw-r--r-- | etc/xmobar.el | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/etc/xmobar.el b/etc/xmobar.el index 905af3d..86f7190 100644 --- a/etc/xmobar.el +++ b/etc/xmobar.el @@ -54,7 +54,7 @@ :type 'string) (defcustom xmobar-tab-bar-format - '(xmobar-left-string tab-bar-format-align-right xmobar-right-string) + '(xmobar-left-string xmobar-elastic-space xmobar-right-string) "Format for the tab bar when `xmobar-tab-bar' is t." :type 'list) @@ -72,10 +72,12 @@ (if (featurep 'xterm-color) #'xterm-color-filter #'ansi-color-apply)) (defvar xmobar--old-tab-format tab-bar-format) +(defvar xmobar--len 0) (defun xmobar-string () xmobar-string) (defun xmobar-right-string () xmobar-string) (defun xmobar-left-string () xmobar--left-string) +(defun xmobar-elastic-space () (make-string (- (frame-width) xmobar--len 3) ? )) ;;;###autoload (define-minor-mode xmobar-mode @@ -90,8 +92,7 @@ (tab-bar-mode 1)) (or global-mode-string (setq global-mode-string '(""))) (unless (memq 'xmobar-string global-mode-string) - (setq global-mode-string - (append global-mode-string '(xmobar-string))))) + (add-to-list 'global-mode-string 'xmobar-string t))) (xmobar--start)) (when xmobar-tab-bar (setq tab-bar-format xmobar--old-tab-format)))) @@ -101,7 +102,9 @@ (let* ((str (funcall xmobar--colorize-fn update)) (strs (and xmobar-tab-split (split-string str xmobar-tab-split)))) (setq xmobar-string (if strs (cadr strs) str) - xmobar--left-string (or (car strs) ""))) + xmobar--left-string (or (car strs) "") + xmobar--len (+ (string-width xmobar--left-string) + (string-width xmobar-string)))) (force-mode-line-update t))) (defun xmobar--process-filter (proc string) @@ -115,7 +118,7 @@ (insert string) (set-marker (process-mark proc) (point))) (when (string-match-p "\n$" string) - (xmobar--update (buffer-string)) + (xmobar--update (buffer-substring (point-min) (- (point-max) 1))) (delete-region (point-min) (point-max))))))) (defun xmobar--process-sentinel (proc status) |