From 7342b4a809ddd269e9d1eb17e518200e593f8566 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Mon, 24 Aug 2020 14:58:38 -0400 Subject: [PATCH] Try to cleanup the modeline --- .gitmodules | 3 ++ global.org | 74 +++++++++++++++++++++++++++++++++------------ margin-current-line | 1 + 3 files changed, 59 insertions(+), 19 deletions(-) create mode 160000 margin-current-line diff --git a/.gitmodules b/.gitmodules index a0ae041..3b0beff 100644 --- a/.gitmodules +++ b/.gitmodules @@ -103,3 +103,6 @@ [submodule "emacs-application-framework"] path = emacs-application-framework url = gh:emacs-application-framework +[submodule "margin-current-line"] + path = margin-current-line + url = gh:margin-current-line diff --git a/global.org b/global.org index 392abd2..146b31e 100644 --- a/global.org +++ b/global.org @@ -171,12 +171,13 @@ (setq-default display-buffer-reuse-frames t) #+END_SRC -** Modeline +** Mode-line #+BEGIN_SRC emacs-lisp - (setq-default mode-line-modified '(:eval (if (buffer-modified-p) "●" "·")) ;Still needs some improvements, does not report Readonly state + (setq-default mode-line-modified '(:eval (if (buffer-modified-p) "●" "·")) + ;Still needs some improvements, does not report Readonly state mode-line-remote '(:eval (let ((s (format-mode-line "%@"))) (cond - ((equal s "-") "·") ((equal s "@") "@") (t s))))) + ((equal s "-") " ") ((equal s "@") "@") (t s))))) (defface mode-line-indicator '((t nil)) @@ -200,7 +201,6 @@ (add-hook 'buffer-list-update-hook (lambda () (walk-windows #'mode-line-update-face nil t))) - (defvar wilder-buffer-vc-mode-line '("%b" (vc-mode (:propertize ;; Strip the backend name from the VC status information @@ -212,7 +212,7 @@ face magit-branch-local)))) (defvar wilder-position - '("[%p·%I] " )) + '("%p · %I" )) (put 'wilder-buffer-vc-mode-line 'risky-local-variable t) (put 'wilder-position 'risky-local-variable t) @@ -231,21 +231,58 @@ (propertize "%]" 'help-echo recursive-edit-help-echo) " ")) "Mode line construct for displaying major and minor modes.") + (put 'wilder/mode-line-modes 'risky-local-variable t) - (setq-default mode-line-format - '("%e" - mode-line-front-space - mode-line-mule-info - mode-line-modified - mode-line-remote - mode-line-frame-identification - wilder-buffer-vc-mode-line " " - wilder-position - (:propertize " " face mode-line-indicator) - wilder/mode-line-modes - mode-line-misc-info - mode-line-end-spaces)) + (setq-default header-line-format nil);'("%e" ));wilder-buffer-vc-mode-line)) + + (defun simple-mode-line-render (left right) + "Return a string of `window-width' length containing LEFT, and RIGHT + aligned respectively." + (let* ((available-width (- (window-width) (length left) 2))) + (format (format " %%s %%%ds " available-width) left right))) + + (defun mode-line-left-right (left right) + (let* ((len-left (length (format-mode-line left))) + (len-right (length (format-mode-line right))) + (len-separator (- (window-width) (+ len-left len-right 3))) + (separator (format (format "%%%ds" len-separator) ""))) + (append left (list separator) right))) + + (defvar mode-line-separator + (let* ((len-left (length (format-mode-line mode-line-format-left))) + (len-right (length (format-mode-line mode-line-format-right))) + (len-separator (- (window-width) (+ len-left len-right)))) + (format (format "%%%ds" len-separator) ""))) + + + (defvar mode-line-format-left + '("%e" + mode-line-front-space + mode-line-front-space + mode-line-front-space + ; mode-line-mule-info + mode-line-modified + mode-line-remote + mode-line-frame-identification + wilder-buffer-vc-mode-line + "  " + wilder/mode-line-modes + mode-line-misc-info)) + + (defvar mode-line-format-right + '((:propertize " " face mode-line-indicator) + wilder-position + mode-line-end-spaces)) + + (put 'mode-line-format-left 'risky-local-variable t) + (put 'mode-line-format-right 'risky-local-variable t) + (put 'mode-line-separator 'risky-local-variable t) + + (setq-default mode-line-format + '("%e" mode-line-format-left + mode-line-separator + mode-line-format-right)) #+END_SRC The following has been found in [[https://www.masteringemacs.org/article/hiding-replacing-modeline-strings][here]] to clean up the modeline #+BEGIN_SRC emacs-lisp @@ -281,7 +318,6 @@ must pass the correct minor/major mode symbol and a string you want to use in the modeline *in lieu of* the original.") - (defun clean-mode-line () (interactive) (loop for cleaner in mode-line-cleaner-alist diff --git a/margin-current-line b/margin-current-line new file mode 160000 index 0000000..8ea1bb7 --- /dev/null +++ b/margin-current-line @@ -0,0 +1 @@ +Subproject commit 8ea1bb774ee1163bf49bc15831156056fd646f1e