Skip to content

Instantly share code, notes, and snippets.

@endofunky
Last active January 4, 2026 11:13
Show Gist options
  • Select an option

  • Save endofunky/d8a9ab978e93ce527e093f36413fc687 to your computer and use it in GitHub Desktop.

Select an option

Save endofunky/d8a9ab978e93ce527e093f36413fc687 to your computer and use it in GitHub Desktop.
(use-package bindings
:custom
(mode-line-right-align-edge 'right-margin)
(mode-line-collapse-minor-modes '(not ef-maximize-window-mode
erpg-minor-mode
flymake-mode
macrostep-mode
magit-blame-mode
overwrite-mode
smerge-mode))
(mode-line-modes-delimiters nil)
(mode-line-format
`(;; Dedicated window indicator
(:eval
(cond
((eq (window-dedicated-p) t)
(propertize
" D "
'help-echo "Window strongly dedicated to its buffer\n\
mouse-1: Toggle"
'local-map
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(toggle-window-dedicated))))
map)
'face '(:inherit font-lock-keyword-face :inverse-video t)
'mouse-face '(:inherit mode-line-highlight :inverse-video t)))
((window-dedicated-p)
(propertize
" d "
'help-echo "Window dedicated to its buffer\n\
mouse-1: Toggle"
'local-map
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(toggle-window-dedicated))))
map)
'face '(:inherit font-lock-keyword-face :inverse-video t)
'mouse-face '(:inherit mode-line-highlight :inverse-video t)))))
;; kmacro recording
(defining-kbd-macro
(:propertize
" Macro "
face (:inherit font-lock-function-name-face :inverse-video t)
mouse-face (:inherit mode-line-highlight :inverse-video t)
help-echo "Macro recording\n\
mouse-1: End recording"
local-map ,(make-mode-line-mouse-map
'mouse-1 #'kmacro-end-macro)))
;; Out-of-memory indicator
"%e"
;; Frame identification
(:eval (if (or (null window-system)
(eq window-system 'pc))
" %F "
" "))
;; Buffer name / line number / etc.
(:eval (propertized-buffer-identification "%b"))
(:eval
(when (and buffer-file-name (buffer-modified-p))
(propertize "*"
'face 'error
'mouse-face 'mode-line-highlight
'help-echo 'mode-line-modified-help-echo
'local-map (make-mode-line-mouse-map
'mouse-1 #'mode-line-toggle-modified))))
" "
(line-number-mode
(:propertize "%l "
mouse-face mode-line-highlight
local-map ,mode-line-column-line-number-mode-map
help-echo "Window Scroll Position
mouse-1: Display Line and Column Mode Menu"))
(column-number-mode
(:propertize "%c "
face font-lock-comment-face
mouse-face mode-line-highlight
local-map ,mode-line-column-line-number-mode-map
help-echo "Window Column Scroll Position
mouse-1: Display Line and Column Mode Menu"))
(size-indication-mode
(:propertize "%I "
mouse-face mode-line-highlight
local-map ,mode-line-column-line-number-mode-map
help-echo "Size indication mode\n\
mouse-1: Display Line and Column Mode Menu"))
;; The default mode-line-format includes this, but it's *extremely*
;; sluggish. Keep it here for reference, as this is where I would put it,
;; but shall it never be enabled.
;; (project-mode-line project-mode-line-format)
;; VC status
(vc-mode (,vc-mode " "))
;; Modes / Misc info
mode-line-modes
mode-line-misc-info
mode-line-format-right-align
;; Remote file / TRAMP
(default-directory
(:eval
(when-let (method (file-remote-p default-directory 'method))
(propertize (concat " " (upcase method))
'face 'warning
'mouse-face 'mode-line-highlight
'help-echo
(lambda (window _object _point)
(with-selected-window window
(format "Current directory is remote: %s"
default-directory)))))))
;; Input method
(current-input-method
(:propertize (" " current-input-method-title)
help-echo (concat
"Current input method: "
current-input-method
"\n\
mouse-2: Disable input method\n\
mouse-3: Describe current input method")
local-map ,mode-line-input-method-map
mouse-face mode-line-highlight))
;; Coding system
(:eval
(let ((name (plist-get (coding-system-plist buffer-file-coding-system)
:name)))
(unless (eq name 'undecided)
(propertize (concat " " (upcase (symbol-name name)))
'mouse-face 'mode-line-highlight
'help-echo 'mode-line-mule-info-help-echo
'local-map mode-line-coding-system-map))))
;; Line ending type
(:eval
(let ((eol (coding-system-eol-type buffer-file-coding-system)))
(propertize
(pcase-exhaustive eol
(0 " UNIX")
(1 " DOS")
(2 " MAC")
(_ ""))
'mouse-face 'mode-line-highlight
'help-echo (format "End-of-line style: %s\n\
mouse-1: Cycle"
(pcase-exhaustive eol
(0 "Unix-style LF")
(1 "DOS-style CRLF")
(2 "Mac-style CR")
(_ "Undecided")))
'local-map (make-mode-line-mouse-map
'mouse-1 #'mode-line-change-eol))))
;; Indentation mode
(:eval
(propertize
(if (bound-and-true-p indent-tabs-mode)
" TAB"
" SPC")
'mouse-face 'mode-line-highlight
'help-echo "Indentation Mode\n\
mouse-1: Toggle Indent Tabs Mode"
'local-map
(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1]
(lambda (e)
(interactive "e")
(with-selected-window (posn-window (event-start e))
(setq-local indent-tabs-mode
(not indent-tabs-mode)))))
map)))
;; Read-only flag
(buffer-read-only
(:propertize
" RO"
face error
mouse-face mode-line-highlight
help-echo mode-line-read-only-help-echo
local-map ,(make-mode-line-mouse-map
'mouse-1 #'mode-line-toggle-read-only)))
" ")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment