aboutsummaryrefslogtreecommitdiff
path: root/.emacs.d
diff options
context:
space:
mode:
authorRaúl Benencia <id@rbenencia.name>2024-01-14 12:15:39 -0800
committerRaúl Benencia <id@rbenencia.name>2024-04-17 10:28:24 -0700
commita9aeb16b917547dff0b2edaa27be25223cb8437a (patch)
treee98dad530e7b249843b17ec974bc2e34651ea444 /.emacs.d
parentcb6bfe77678783ce264932081fd0abf6f9586a0c (diff)
emacs: eglot modeline
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/rul-lisp/packages/rul-modeline.el76
1 files changed, 12 insertions, 64 deletions
diff --git a/.emacs.d/rul-lisp/packages/rul-modeline.el b/.emacs.d/rul-lisp/packages/rul-modeline.el
index a05eeb9..ae250c4 100644
--- a/.emacs.d/rul-lisp/packages/rul-modeline.el
+++ b/.emacs.d/rul-lisp/packages/rul-modeline.el
@@ -66,68 +66,16 @@ Truncation is done up to `rul-modeline-string-truncate-length'."
(propertize "%]" 'face 'rul-modeline-indicator-red))
"Mode line construct for displaying major modes.")
-;(makunbound 'rul-modeline-major-mode)
-
-;;;; Align right
-(defun prot-modeline--right-align-rest ()
- "Return string if everything after `prot-modeline-align-right'."
- (format-mode-line
- `(""
- ,@(cdr (memq 'prot-modeline-align-right mode-line-format)))))
-
-(defun prot-modeline--right-align-width ()
- "Return pixel width of `prot-modeline--right-align-rest'."
- (string-pixel-width (prot-modeline--right-align-rest)))
-
-(defun prot-modeline--box-p ()
- "Return non-nil if the `mode-line' has a box attribute."
- (and (face-attribute 'mode-line :box)
- (null (eq (face-attribute 'mode-line :box) 'unspecified))))
-
-(defun prot-modeline--variable-pitch-p ()
- "Return non-nil if the `mode-line' inherits `variable-pitch'."
- (when-let* ((mode-line-inherit (face-attribute 'mode-line :inherit))
- ((string-match-p "variable-pitch" (symbol-name mode-line-inherit)))
- (family-face (face-attribute mode-line-inherit :inherit))
- (variable-pitch
- (if (listp family-face)
- (memq 'variable-pitch family-face)
- (eq 'variable-pitch family-face))))
- variable-pitch))
-
-(defun prot-modeline--magic-number ()
- "Return constant for use in `prot-modeline-align-right'."
- (let ((height (face-attribute 'mode-line :height nil 'default))
- (m-width (string-pixel-width (propertize "m" 'face 'mode-line))))
- (round height (* m-width (* height m-width 0.001)))))
-
-(defvar-local prot-modeline-align-right
- '(:eval
- (propertize
- " "
- 'display
- (let ((box-p (prot-modeline--box-p))
- (variable-pitch-p (prot-modeline--variable-pitch-p))
- (magic-number (prot-modeline--magic-number)))
- `(space
- :align-to
- (- right
- right-fringe
- right-margin
- ,(ceiling
- (prot-modeline--right-align-width)
- (string-pixel-width (propertize "m" 'face 'mode-line)))
- ,(cond
- ((and variable-pitch-p box-p)
- (* magic-number 0.5))
- ((and (not variable-pitch-p) box-p)
- (* magic-number 0.25))
- ((and variable-pitch-p (not box-p))
- (* magic-number -0.05))
- (t (* magic-number -0.1))))))))
- "Mode line construct to align following elements to the right.
-Read Info node `(elisp) Pixel Specification'.")
-
+(with-eval-after-load 'eglot
+ (setq mode-line-misc-info
+ (delete '(eglot--managed-mode (" [" eglot--mode-line-format "] ")) mode-line-misc-info)))
+
+(defvar-local prot-modeline-eglot
+ `(:eval
+ (when (and (featurep 'eglot) (mode-line-window-selected-p))
+ '(eglot--managed-mode eglot--mode-line-format)))
+ "Mode line construct displaying Eglot information.
+Specific to the current window's mode line.")
;;;; Miscellaneous
(defvar-local rul-modeline-misc-info
@@ -146,7 +94,6 @@ Specific to the current window's mode line.")
(dolist (construct '(
rul-modeline-major-mode
rul-modeline-misc-info
- prot-modeline-align-right
))
(put construct 'risky-local-variable t))
@@ -157,7 +104,8 @@ Specific to the current window's mode line.")
mode-line-buffer-identification
mode-line-front-space
rul-modeline-major-mode
- prot-modeline-align-right
+ prot-modeline-eglot
+ mode-line-format-right-align
rul-modeline-misc-info
))
nihil fit ex nihilo