Change modeline
This commit is contained in:
parent
517b999407
commit
f0febf6814
14
init.el
14
init.el
|
@ -429,6 +429,8 @@
|
||||||
(add-to-list 'Info-additional-directory-list dir))
|
(add-to-list 'Info-additional-directory-list dir))
|
||||||
(:with-mode Info-mode ; -_-
|
(:with-mode Info-mode ; -_-
|
||||||
(:hook #'reading-mode)
|
(:hook #'reading-mode)
|
||||||
|
(:local-set +modeline-buffer-position #'+Info-modeline-breadcrumbs
|
||||||
|
+modeline-position-function #'ignore)
|
||||||
(:bind "c" #'+Info-copy-current-node-name
|
(:bind "c" #'+Info-copy-current-node-name
|
||||||
"w" #'+Info-copy-current-node-name)))
|
"w" #'+Info-copy-current-node-name)))
|
||||||
|
|
||||||
|
@ -1712,6 +1714,8 @@
|
||||||
(setup (:straight info+)
|
(setup (:straight info+)
|
||||||
(:load-after info)
|
(:load-after info)
|
||||||
(:option Info-fontify-isolated-quote-flag nil
|
(:option Info-fontify-isolated-quote-flag nil
|
||||||
|
Info-breadcrumbs-in-mode-line-mode nil
|
||||||
|
Info-fontify-emphasis-flag nil
|
||||||
Info-fontify-quotations nil
|
Info-fontify-quotations nil
|
||||||
Info-saved-history-file (.etc "info-history"))
|
Info-saved-history-file (.etc "info-history"))
|
||||||
(add-hook 'Info-mode-hook #'Info-variable-pitch-text-mode))
|
(add-hook 'Info-mode-hook #'Info-variable-pitch-text-mode))
|
||||||
|
@ -1802,6 +1806,7 @@
|
||||||
(cond
|
(cond
|
||||||
((string-match-p "hmm@" (buffer-name))
|
((string-match-p "hmm@" (buffer-name))
|
||||||
"🤔 ")))
|
"🤔 ")))
|
||||||
|
file-percentage-mode nil
|
||||||
wrap-prefix (make-string +jabber-ws-prefix ?\ )))
|
wrap-prefix (make-string +jabber-ws-prefix ?\ )))
|
||||||
(:+leader "C-j" jabber-global-keymap)
|
(:+leader "C-j" jabber-global-keymap)
|
||||||
(advice-add 'jabber-activity-add :after #'+jabber-tracking-add)
|
(advice-add 'jabber-activity-add :after #'+jabber-tracking-add)
|
||||||
|
@ -2173,7 +2178,7 @@
|
||||||
(readonly . "=")
|
(readonly . "=")
|
||||||
(modified . "+")
|
(modified . "+")
|
||||||
(t . "-"))
|
(t . "-"))
|
||||||
+modeline-minions-icon ";"
|
+modeline-minions-icon "&"
|
||||||
+modeline-buffer-name-max-length 0.35)
|
+modeline-buffer-name-max-length 0.35)
|
||||||
;; Segments
|
;; Segments
|
||||||
(:option simple-modeline-segments
|
(:option simple-modeline-segments
|
||||||
|
@ -2182,9 +2187,6 @@
|
||||||
+modeline-modified
|
+modeline-modified
|
||||||
+modeline-buffer-name
|
+modeline-buffer-name
|
||||||
(lambda () (+modeline-vc " : "))
|
(lambda () (+modeline-vc " : "))
|
||||||
,(+modeline-concat
|
|
||||||
'(+modeline-minions
|
|
||||||
+modeline-major-mode))
|
|
||||||
+modeline-anzu
|
+modeline-anzu
|
||||||
)
|
)
|
||||||
( ; right
|
( ; right
|
||||||
|
@ -2203,6 +2205,10 @@
|
||||||
",")
|
",")
|
||||||
+modeline-input-method
|
+modeline-input-method
|
||||||
+modeline-position
|
+modeline-position
|
||||||
|
,(+modeline-concat
|
||||||
|
'(+modeline-minions
|
||||||
|
+modeline-major-mode))
|
||||||
|
+modeline-file-percentage
|
||||||
)))
|
)))
|
||||||
(simple-modeline-mode +1))
|
(simple-modeline-mode +1))
|
||||||
|
|
||||||
|
|
|
@ -13,5 +13,72 @@ arg reversed."
|
||||||
(interactive "P" Info-mode)
|
(interactive "P" Info-mode)
|
||||||
(Info-copy-current-node-name (unless arg 0)))
|
(Info-copy-current-node-name (unless arg 0)))
|
||||||
|
|
||||||
|
(defun +Info-modeline-breadcrumbs ()
|
||||||
|
(let ((nodes (Info-toc-nodes Info-current-file))
|
||||||
|
(node Info-current-node)
|
||||||
|
(crumbs ())
|
||||||
|
(depth Info-breadcrumbs-depth-internal)
|
||||||
|
(text ""))
|
||||||
|
;; Get ancestors from the cached parent-children node info
|
||||||
|
(while (and (not (equal "Top" node)) (> depth 0))
|
||||||
|
(setq node (nth 1 (assoc node nodes)))
|
||||||
|
(when node (push node crumbs))
|
||||||
|
(setq depth (1- depth)))
|
||||||
|
;; Add bottom node.
|
||||||
|
(setq crumbs (nconc crumbs (list Info-current-node)))
|
||||||
|
(when crumbs
|
||||||
|
;; Add top node (and continuation if needed).
|
||||||
|
(setq crumbs (cons "Top" (if (member (pop crumbs) '(nil "Top"))
|
||||||
|
crumbs
|
||||||
|
(cons nil crumbs))))
|
||||||
|
(dolist (node crumbs)
|
||||||
|
(let ((crumbs-map (make-sparse-keymap))
|
||||||
|
(menu-map (make-sparse-keymap "Breadcrumbs in Mode Line")))
|
||||||
|
(define-key crumbs-map [mode-line mouse-3] menu-map)
|
||||||
|
(when node
|
||||||
|
(define-key menu-map [Info-prev]
|
||||||
|
`(menu-item "Previous Node" Info-prev
|
||||||
|
:visible ,(Info-check-pointer "prev[ious]*") :help "Go to the previous node"))
|
||||||
|
(define-key menu-map [Info-next]
|
||||||
|
`(menu-item "Next Node" Info-next
|
||||||
|
:visible ,(Info-check-pointer "next") :help "Go to the next node"))
|
||||||
|
(define-key menu-map [separator] '("--"))
|
||||||
|
(define-key menu-map [Info-breadcrumbs-in-mode-line-mode]
|
||||||
|
`(menu-item "Toggle Breadcrumbs" Info-breadcrumbs-in-mode-line-mode
|
||||||
|
:help "Toggle displaying breadcrumbs in the Info mode-line"
|
||||||
|
:button (:toggle . Info-breadcrumbs-in-mode-line-mode)))
|
||||||
|
(define-key menu-map [Info-set-breadcrumbs-depth]
|
||||||
|
`(menu-item "Set Breadcrumbs Depth" Info-set-breadcrumbs-depth
|
||||||
|
:help "Set depth of breadcrumbs to show in the mode-line"))
|
||||||
|
(setq node (if (equal node Info-current-node)
|
||||||
|
(propertize
|
||||||
|
(replace-regexp-in-string "%" "%%" Info-current-node)
|
||||||
|
'face 'mode-line-buffer-id
|
||||||
|
'help-echo "mouse-1: Scroll back, mouse-2: Scroll forward, mouse-3: Menu"
|
||||||
|
'mouse-face 'mode-line-highlight
|
||||||
|
'local-map
|
||||||
|
(progn
|
||||||
|
(define-key crumbs-map [mode-line mouse-1] 'Info-mouse-scroll-down)
|
||||||
|
(define-key crumbs-map [mode-line mouse-2] 'Info-mouse-scroll-up)
|
||||||
|
crumbs-map))
|
||||||
|
(propertize
|
||||||
|
node
|
||||||
|
'local-map (progn (define-key crumbs-map [mode-line mouse-1]
|
||||||
|
`(lambda () (interactive) (Info-goto-node ,node)))
|
||||||
|
(define-key crumbs-map [mode-line mouse-2]
|
||||||
|
`(lambda () (interactive) (Info-goto-node ,node)))
|
||||||
|
crumbs-map)
|
||||||
|
'mouse-face 'mode-line-highlight
|
||||||
|
'help-echo "mouse-1, mouse-2: Go to this node; mouse-3: Menu")))))
|
||||||
|
(let ((nodetext (if (not (equal node "Top"))
|
||||||
|
node
|
||||||
|
(concat (format "(%s)" (if (stringp Info-current-file)
|
||||||
|
(file-name-nondirectory Info-current-file)
|
||||||
|
;; Some legacy code can still use a symbol.
|
||||||
|
Info-current-file))
|
||||||
|
node))))
|
||||||
|
(setq text (concat text (if (equal node "Top") "" " > ") (if node nodetext "...")))))
|
||||||
|
text)))
|
||||||
|
|
||||||
(provide '+Info)
|
(provide '+Info)
|
||||||
;;; +Info.el ends here
|
;;; +Info.el ends here
|
||||||
|
|
|
@ -72,26 +72,34 @@ and appended with `truncate-string-ellipsis'."
|
||||||
(natnum :tag "Number of characters")
|
(natnum :tag "Number of characters")
|
||||||
(float :tag "Fraction of window's width")))
|
(float :tag "Fraction of window's width")))
|
||||||
|
|
||||||
|
(defcustom +modeline-buffer-position nil
|
||||||
|
"What to put in the `+modeline-buffer-name' position."
|
||||||
|
:type 'function
|
||||||
|
:local t)
|
||||||
|
|
||||||
(defun +modeline-buffer-name (&optional spacer) ; gonsie
|
(defun +modeline-buffer-name (&optional spacer) ; gonsie
|
||||||
"Display the buffer name."
|
"Display the buffer name."
|
||||||
(let ((bufname (string-trim (string-replace "%" "" (buffer-name)))))
|
(let ((bufname (string-trim (string-replace "%" "" (buffer-name)))))
|
||||||
(concat (or spacer +modeline-default-spacer)
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(propertize (cond
|
(if (and +modeline-buffer-position (fboundp +modeline-buffer-position))
|
||||||
((ignore-errors
|
(funcall +modeline-buffer-position)
|
||||||
(and (> +modeline-buffer-name-max-length 0)
|
(propertize (cond
|
||||||
(< +modeline-buffer-name-max-length 1)))
|
((ignore-errors
|
||||||
(truncate-string-to-width bufname
|
(and (> +modeline-buffer-name-max-length 0)
|
||||||
(* (window-total-width) +modeline-buffer-name-max-length)
|
(< +modeline-buffer-name-max-length 1)))
|
||||||
nil nil t))
|
(truncate-string-to-width bufname
|
||||||
((ignore-errors
|
(* (window-total-width)
|
||||||
(> +modeline-buffer-name-max-length 1))
|
+modeline-buffer-name-max-length)
|
||||||
(truncate-string-to-width bufname
|
nil nil t))
|
||||||
+modeline-buffer-name-max-length
|
((ignore-errors
|
||||||
nil nil t))
|
(> +modeline-buffer-name-max-length 1))
|
||||||
(t bufname))
|
(truncate-string-to-width bufname
|
||||||
'help-echo (or (buffer-file-name)
|
+modeline-buffer-name-max-length
|
||||||
(buffer-name))
|
nil nil t))
|
||||||
'mouse-face 'mode-line-highlight))))
|
(t bufname))
|
||||||
|
'help-echo (or (buffer-file-name)
|
||||||
|
(buffer-name))
|
||||||
|
'mouse-face 'mode-line-highlight)))))
|
||||||
|
|
||||||
(defcustom +modeline-minions-icon "&"
|
(defcustom +modeline-minions-icon "&"
|
||||||
"The \"icon\" for `+modeline-minions' button."
|
"The \"icon\" for `+modeline-minions' button."
|
||||||
|
@ -152,17 +160,17 @@ The order of elements matters: whichever one matches first is applied."
|
||||||
(defun +modeline-modified (&optional spacer) ; modified from `simple-modeline-status-modified'
|
(defun +modeline-modified (&optional spacer) ; modified from `simple-modeline-status-modified'
|
||||||
"Display a color-coded \"icon\" indicator for the buffer's status."
|
"Display a color-coded \"icon\" indicator for the buffer's status."
|
||||||
(let* ((icon (catch :icon
|
(let* ((icon (catch :icon
|
||||||
(dolist (cell +modeline-modified-icon-alist)
|
(dolist (cell +modeline-modified-icon-alist)
|
||||||
(when (pcase (car cell)
|
(when (pcase (car cell)
|
||||||
('ephemeral (not (buffer-file-name)))
|
('ephemeral (not (buffer-file-name)))
|
||||||
('readonly buffer-read-only)
|
('readonly buffer-read-only)
|
||||||
('modified (buffer-modified-p))
|
('modified (buffer-modified-p))
|
||||||
('special
|
('special
|
||||||
(apply 'derived-mode-p
|
(apply 'derived-mode-p
|
||||||
+modeline-modified-icon-special-modes))
|
+modeline-modified-icon-special-modes))
|
||||||
('t t)
|
('t t)
|
||||||
(_ nil))
|
(_ nil))
|
||||||
(throw :icon cell))))))
|
(throw :icon cell))))))
|
||||||
(concat (or spacer +modeline-default-spacer)
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(propertize (or (cdr-safe icon) "")
|
(propertize (or (cdr-safe icon) "")
|
||||||
'help-echo (format "Buffer \"%s\" is %s."
|
'help-echo (format "Buffer \"%s\" is %s."
|
||||||
|
@ -244,7 +252,8 @@ The order of elements matters: whichever one matches first is applied."
|
||||||
perc
|
perc
|
||||||
(unless (seq-some (lambda (s) (string= perc s))
|
(unless (seq-some (lambda (s) (string= perc s))
|
||||||
'("Top" "Bot" "All"))
|
'("Top" "Bot" "All"))
|
||||||
"%%%%")))))
|
"%%%%")
|
||||||
|
" "))))
|
||||||
|
|
||||||
(defun +modeline-file-percentage-icon (&optional spacer)
|
(defun +modeline-file-percentage-icon (&optional spacer)
|
||||||
"Display the position in the current file as an icon."
|
"Display the position in the current file as an icon."
|
||||||
|
@ -312,7 +321,8 @@ to a function in the current buffer, call that function instead."
|
||||||
+modeline-position-function
|
+modeline-position-function
|
||||||
(+modeline-concat '(+modeline-region
|
(+modeline-concat '(+modeline-region
|
||||||
+modeline-line-column
|
+modeline-line-column
|
||||||
+modeline-file-percentage)))))
|
;; +modeline-file-percentage
|
||||||
|
)))))
|
||||||
|
|
||||||
(defun +modeline-vc (&optional spacer)
|
(defun +modeline-vc (&optional spacer)
|
||||||
"Display the version control branch of the current buffer in the modeline."
|
"Display the version control branch of the current buffer in the modeline."
|
||||||
|
|
Loading…
Reference in New Issue