Lots and lots of changes, oh jeez
This commit is contained in:
parent
cdb6c1cf89
commit
038e5de1ad
79
init.el
79
init.el
|
@ -24,13 +24,19 @@
|
||||||
(setq debug-on-error t)
|
(setq debug-on-error t)
|
||||||
|
|
||||||
(setup (:require +emacs)
|
(setup (:require +emacs)
|
||||||
|
(:also-load +lisp)
|
||||||
;; +emacs.el contains super-basic defaults that are basically
|
;; +emacs.el contains super-basic defaults that are basically
|
||||||
;; necessary for good functioning. In this block, I add extra
|
;; necessary for good functioning. In this block, I add extra
|
||||||
;; things or more "experimental" ones that might not belong in a
|
;; things or more "experimental" ones that might not belong in a
|
||||||
;; separate file.
|
;; separate file.
|
||||||
(:global "C-x C-k" 'kill-this-buffer
|
(:global "C-x C-k" #'kill-this-buffer
|
||||||
"C-x 4 n" 'clone-buffer
|
"C-x 4 n" #'clone-buffer
|
||||||
"C-c v" 'visible-mode)
|
"C-c v" #'visible-mode
|
||||||
|
"C-M-;" #'+lisp-comment-or-uncomment-sexp)
|
||||||
|
;; Unbind stuff, too.
|
||||||
|
(dolist (key '("C-M-j"
|
||||||
|
"M-j"))
|
||||||
|
(global-set-key (kbd key) nil))
|
||||||
;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults
|
;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults
|
||||||
(global-set-key (kbd "C-h") 'delete-backward-char)
|
(global-set-key (kbd "C-h") 'delete-backward-char)
|
||||||
(keyboard-translate ?\C-h ?\C-?)
|
(keyboard-translate ?\C-h ?\C-?)
|
||||||
|
@ -44,10 +50,7 @@
|
||||||
(advice-add 'yank-pop :after '+yank@indent))
|
(advice-add 'yank-pop :after '+yank@indent))
|
||||||
|
|
||||||
(setup (:require +init)
|
(setup (:require +init)
|
||||||
(:bind "C-c s" (lambda ()
|
(:bind "C-c s" #'+init-sort-then-save)
|
||||||
(interactive)
|
|
||||||
(+init-sort)
|
|
||||||
(save-buffer)))
|
|
||||||
(:hook #'+init-add-setup-to-imenu))
|
(:hook #'+init-add-setup-to-imenu))
|
||||||
|
|
||||||
(setup (:require +key)
|
(setup (:require +key)
|
||||||
|
@ -68,8 +71,7 @@
|
||||||
(:also-load +pulse)
|
(:also-load +pulse)
|
||||||
(:option pulse-flag nil
|
(:option pulse-flag nil
|
||||||
pulse-delay 0.5
|
pulse-delay 0.5
|
||||||
pulse-iterations 1
|
pulse-iterations 1)
|
||||||
(append +pulse-location-commands) 'lui-track-jump-to-indicator)
|
|
||||||
(+pulse-location-mode +1))
|
(+pulse-location-mode +1))
|
||||||
|
|
||||||
(setup (:require reading)
|
(setup (:require reading)
|
||||||
|
@ -93,8 +95,8 @@
|
||||||
(setup browse-url
|
(setup browse-url
|
||||||
(:require +browse-url)
|
(:require +browse-url)
|
||||||
(:option browse-url-secondary-browser-function (if (executable-find "firefox")
|
(:option browse-url-secondary-browser-function (if (executable-find "firefox")
|
||||||
'browse-url-firefox
|
#'browse-url-firefox
|
||||||
'browse-url-default-browser)
|
#'browse-url-default-browser)
|
||||||
browse-url-new-window-flag nil
|
browse-url-new-window-flag nil
|
||||||
browse-url-firefox-arguments '("--new-tab")
|
browse-url-firefox-arguments '("--new-tab")
|
||||||
browse-url-firefox-new-window-is-tab t)
|
browse-url-firefox-new-window-is-tab t)
|
||||||
|
@ -105,15 +107,15 @@
|
||||||
"." (or "jpeg" "jpg" "png") eos)
|
"." (or "jpeg" "jpg" "png") eos)
|
||||||
(lambda (&rest args)
|
(lambda (&rest args)
|
||||||
(apply
|
(apply
|
||||||
(cond ((executable-find "mpv") '+browse-image-with-mpv)
|
(cond ((executable-find "mpv") #'+browse-image-with-mpv)
|
||||||
(t 'eww-browse-url))
|
(t #'eww-browse-url))
|
||||||
args)))
|
args)))
|
||||||
(cons (rx ; videos
|
(cons (rx ; videos
|
||||||
(or "youtube.com" "youtu.be" "yewtu.be"
|
(or "youtube.com" "youtu.be" "yewtu.be"
|
||||||
(seq "." (or "mp4" "gif" "mov" "MOV") eos)))
|
(seq "." (or "mp4" "gif" "mov" "MOV") eos)))
|
||||||
(lambda (&rest args)
|
(lambda (&rest args)
|
||||||
(apply (if (executable-find "mpv")
|
(apply (if (executable-find "mpv")
|
||||||
'+browse-url-with-mpv
|
#'+browse-url-with-mpv
|
||||||
browse-url-secondary-browser-function)
|
browse-url-secondary-browser-function)
|
||||||
args)))
|
args)))
|
||||||
(cons (rx ; non-eww-friendly websites
|
(cons (rx ; non-eww-friendly websites
|
||||||
|
@ -130,7 +132,7 @@
|
||||||
))
|
))
|
||||||
browse-url-secondary-browser-function)
|
browse-url-secondary-browser-function)
|
||||||
(cons "." ; everything else
|
(cons "." ; everything else
|
||||||
'eww-browse-url)))
|
#'eww-browse-url)))
|
||||||
;; Transform URLs before passing to `browse-url'
|
;; Transform URLs before passing to `browse-url'
|
||||||
(:option +browse-url-transformations `((,(rx "//" (or "youtube.com"
|
(:option +browse-url-transformations `((,(rx "//" (or "youtube.com"
|
||||||
"youtu.be"))
|
"youtu.be"))
|
||||||
|
@ -163,7 +165,8 @@
|
||||||
custom-raised-buttons nil
|
custom-raised-buttons nil
|
||||||
custom-unlispify-tag-names nil
|
custom-unlispify-tag-names nil
|
||||||
custom-variable-default-form 'lisp
|
custom-variable-default-form 'lisp
|
||||||
+custom-variable-allowlist '(safe-local-variable-values))
|
+custom-variable-allowlist '(safe-local-variable-values
|
||||||
|
warning-suppress-types))
|
||||||
(when (file-exists-p custom-file)
|
(when (file-exists-p custom-file)
|
||||||
(+custom-load-ignoring-most-customizations t))
|
(+custom-load-ignoring-most-customizations t))
|
||||||
(advice-add #'custom-buffer-create-internal :after #'+cus-edit-expand-widgets)
|
(advice-add #'custom-buffer-create-internal :after #'+cus-edit-expand-widgets)
|
||||||
|
@ -183,10 +186,10 @@
|
||||||
dired-listing-switches "-Al"
|
dired-listing-switches "-Al"
|
||||||
ls-lisp-dirs-first t
|
ls-lisp-dirs-first t
|
||||||
dired-ls-F-marks-symlinks t
|
dired-ls-F-marks-symlinks t
|
||||||
dired-no-confirm '(byte-compile
|
dired-no-confirm '(byte-compile load
|
||||||
chgrp chmod chown copy
|
chgrp chmod chown
|
||||||
hardlink load move
|
copy move hardlink symlink
|
||||||
shell touch symlink)
|
shell touch)
|
||||||
dired-dwim-target t)
|
dired-dwim-target t)
|
||||||
(:bind "<backspace>" #'dired-up-directory
|
(:bind "<backspace>" #'dired-up-directory
|
||||||
"TAB" #'dired-subtree-cycle
|
"TAB" #'dired-subtree-cycle
|
||||||
|
@ -205,7 +208,7 @@
|
||||||
(:option dired-listing-switches
|
(:option dired-listing-switches
|
||||||
(concat dired-listing-switches " -F")))))
|
(concat dired-listing-switches " -F")))))
|
||||||
(with-eval-after-load 'frowny
|
(with-eval-after-load 'frowny
|
||||||
(add-to-list 'frowny-inhibit-modes 'dired-mode)))
|
(add-to-list 'frowny-inhibit-modes #'dired-mode)))
|
||||||
|
|
||||||
(setup eldoc
|
(setup eldoc
|
||||||
(:hook-into elisp-mode
|
(:hook-into elisp-mode
|
||||||
|
@ -333,7 +336,7 @@
|
||||||
|
|
||||||
(setup scratch
|
(setup scratch
|
||||||
(:require +scratch)
|
(:require +scratch)
|
||||||
(:option initial-major-mode 'lisp-interaction-mode
|
(:option initial-major-mode #'lisp-interaction-mode
|
||||||
initial-scratch-message
|
initial-scratch-message
|
||||||
";; ABANDON ALL HOPE YE WHO ENTER HERE\n\n")
|
";; ABANDON ALL HOPE YE WHO ENTER HERE\n\n")
|
||||||
(add-hook 'kill-buffer-query-functions #'+scratch-immortal))
|
(add-hook 'kill-buffer-query-functions #'+scratch-immortal))
|
||||||
|
@ -344,7 +347,7 @@
|
||||||
(setup (:straight 0x0)
|
(setup (:straight 0x0)
|
||||||
(:option 0x0-default-server 'ttm)
|
(:option 0x0-default-server 'ttm)
|
||||||
(with-eval-after-load 'embark
|
(with-eval-after-load 'embark
|
||||||
(define-key embark-region-map (kbd "U") '0x0-dwim)))
|
(define-key embark-region-map (kbd "U") #'0x0-dwim)))
|
||||||
|
|
||||||
(setup (:straight ace-window)
|
(setup (:straight ace-window)
|
||||||
(:require +ace-window)
|
(:require +ace-window)
|
||||||
|
@ -454,7 +457,8 @@
|
||||||
(,(+lui-make-formatting-list-rx "_")
|
(,(+lui-make-formatting-list-rx "_")
|
||||||
1 lui-emphasis-face)
|
1 lui-emphasis-face)
|
||||||
(,(+lui-make-formatting-list-rx "/")
|
(,(+lui-make-formatting-list-rx "/")
|
||||||
1 lui-emphasis-face)))
|
1 lui-emphasis-face))
|
||||||
|
(append +pulse-location-commands) 'lui-track-jump-to-indicator)
|
||||||
(:hook #'visual-line-mode
|
(:hook #'visual-line-mode
|
||||||
#'enable-lui-track
|
#'enable-lui-track
|
||||||
#'visual-fill-column-mode)
|
#'visual-fill-column-mode)
|
||||||
|
@ -881,11 +885,18 @@ See also `crux-reopen-as-root-mode'."
|
||||||
(setup (:straight org-sticky-header)
|
(setup (:straight org-sticky-header)
|
||||||
(:hook-into org-mode))
|
(:hook-into org-mode))
|
||||||
|
|
||||||
|
(setup (:straight package-lint))
|
||||||
|
|
||||||
(setup (:straight paredit)
|
(setup (:straight paredit)
|
||||||
(:bind "DEL" #'paredit-backward-delete
|
(:bind "DEL" #'paredit-backward-delete
|
||||||
"C-<backspace>" #'paredit-backward-kill-word)
|
"C-<backspace>" #'paredit-backward-kill-word)
|
||||||
(:hook-into emacs-lisp-mode lisp-interaction-mode
|
(dolist (hook '(emacs-lisp-mode-hook
|
||||||
lisp-mode scheme-mode)
|
eval-expression-minibuffer-setup-hook
|
||||||
|
ielm-mode-hook
|
||||||
|
lisp-interaction-mode-hook
|
||||||
|
lisp-mode-hook
|
||||||
|
scheme-mode-hook))
|
||||||
|
(add-hook hook #'enable-paredit-mode))
|
||||||
(:also-load eldoc)
|
(:also-load eldoc)
|
||||||
(eldoc-add-command #'paredit-backward-delete #'paredit-close-round))
|
(eldoc-add-command #'paredit-backward-delete #'paredit-close-round))
|
||||||
|
|
||||||
|
@ -911,13 +922,15 @@ See also `crux-reopen-as-root-mode'."
|
||||||
(setup (:straight sicp))
|
(setup (:straight sicp))
|
||||||
|
|
||||||
(setup (:straight (simple-modeline
|
(setup (:straight (simple-modeline
|
||||||
:fork (:repo "duckwork/simple-modeline")))
|
:fork (:host github :repo "duckwork/simple-modeline")))
|
||||||
(:also-load +modeline)
|
(:also-load +modeline)
|
||||||
(:option simple-modeline-segments '((;; left
|
(:option simple-modeline-segments `((;; left
|
||||||
+modeline-ace-window-display
|
+modeline-ace-window-display
|
||||||
+modeline-modified
|
+modeline-modified
|
||||||
+modeline-reading-mode
|
,(+modeline-concat
|
||||||
+modeline-narrowed
|
'(+modeline-reading-mode
|
||||||
|
+modeline-narrowed)
|
||||||
|
",")
|
||||||
+modeline-buffer-name
|
+modeline-buffer-name
|
||||||
+modeline-position
|
+modeline-position
|
||||||
+modeline-anzu
|
+modeline-anzu
|
||||||
|
@ -1023,7 +1036,6 @@ See also `crux-reopen-as-root-mode'."
|
||||||
|
|
||||||
(setup (:straight whitespace-cleanup-mode)
|
(setup (:straight whitespace-cleanup-mode)
|
||||||
(:option whitespace-cleanup-mode-preserve-point t)
|
(:option whitespace-cleanup-mode-preserve-point t)
|
||||||
;;(remove-hook 'before-save-hook 'whitespace-cleanup)
|
|
||||||
(global-whitespace-cleanup-mode +1))
|
(global-whitespace-cleanup-mode +1))
|
||||||
|
|
||||||
(setup (:straight zoom-frm))
|
(setup (:straight zoom-frm))
|
||||||
|
@ -1034,3 +1046,8 @@ See also `crux-reopen-as-root-mode'."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(call-interactively
|
(call-interactively
|
||||||
(if prefix #'zzz-up-to-char #'zzz-to-char)))))
|
(if prefix #'zzz-up-to-char #'zzz-to-char)))))
|
||||||
|
|
||||||
|
(setup (:straight (actually-selected-window
|
||||||
|
:host github
|
||||||
|
:repo "duckwork/actually-selected-window.el"))
|
||||||
|
(actually-selected-window-mode +1))
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
;; Emacs. But like, why would I want to?
|
;; Emacs. But like, why would I want to?
|
||||||
|
|
||||||
;; Other notable packages include
|
;; Other notable packages include
|
||||||
;; https://git.sr.ht/~technomancy/better-defaults/
|
;; - https://git.sr.ht/~technomancy/better-defaults/
|
||||||
|
;; - https://github.com/susam/emfy
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ Do this only if the buffer is not visiting a file."
|
||||||
completion-category-overrides '((file (styles . (partial-completion))))
|
completion-category-overrides '((file (styles . (partial-completion))))
|
||||||
completion-ignore-case t
|
completion-ignore-case t
|
||||||
completion-styles '(substring partial-completion)
|
completion-styles '(substring partial-completion)
|
||||||
|
create-lockfiles nil
|
||||||
cursor-in-non-selected-windows 'hollow
|
cursor-in-non-selected-windows 'hollow
|
||||||
cursor-type 'bar
|
cursor-type 'bar
|
||||||
custom-file (.etc "custom.el")
|
custom-file (.etc "custom.el")
|
||||||
|
@ -64,6 +66,8 @@ Do this only if the buffer is not visiting a file."
|
||||||
hscroll-step 1
|
hscroll-step 1
|
||||||
imenu-auto-rescan t
|
imenu-auto-rescan t
|
||||||
indent-tabs-mode nil
|
indent-tabs-mode nil
|
||||||
|
indicate-empty-lines t
|
||||||
|
indicate-buffer-boundaries 'left
|
||||||
inhibit-startup-screen t
|
inhibit-startup-screen t
|
||||||
initial-buffer-choice t
|
initial-buffer-choice t
|
||||||
kill-do-not-save-duplicates t
|
kill-do-not-save-duplicates t
|
||||||
|
@ -101,7 +105,9 @@ Do this only if the buffer is not visiting a file."
|
||||||
show-paren-style 'mixed
|
show-paren-style 'mixed
|
||||||
show-paren-when-point-in-periphery t
|
show-paren-when-point-in-periphery t
|
||||||
show-paren-when-point-inside-paren t
|
show-paren-when-point-inside-paren t
|
||||||
|
;;show-trailing-whitespace t
|
||||||
tab-bar-show 1
|
tab-bar-show 1
|
||||||
|
tab-width 4
|
||||||
tramp-backup-directory-alist backup-directory-alist
|
tramp-backup-directory-alist backup-directory-alist
|
||||||
use-dialog-box nil
|
use-dialog-box nil
|
||||||
use-file-dialog nil
|
use-file-dialog nil
|
||||||
|
@ -117,6 +123,13 @@ Do this only if the buffer is not visiting a file."
|
||||||
yank-pop-change-selection t
|
yank-pop-change-selection t
|
||||||
)
|
)
|
||||||
|
|
||||||
|
;; Programming language offsets.
|
||||||
|
;; Set these after the initial block so I can use `tab-width'
|
||||||
|
(setq-default
|
||||||
|
c-basic-offset tab-width)
|
||||||
|
|
||||||
|
;; Emacs 28 ships with an option, `use-short-answers', that makes this form
|
||||||
|
;; obsolete, but I still use 27 at work.
|
||||||
(when (version< emacs-version "28")
|
(when (version< emacs-version "28")
|
||||||
(fset 'yes-or-no-p 'y-or-n-p))
|
(fset 'yes-or-no-p 'y-or-n-p))
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,12 @@ are sorted lexigraphically."
|
||||||
;; otherwise, sort lexigraphically
|
;; otherwise, sort lexigraphically
|
||||||
(t (string< s1 s2))))))))))))
|
(t (string< s1 s2))))))))))))
|
||||||
|
|
||||||
|
(defun +init-sort-then-save ()
|
||||||
|
"Sort init.el, then save it."
|
||||||
|
(interactive)
|
||||||
|
(+init-sort)
|
||||||
|
(save-buffer))
|
||||||
|
|
||||||
;;; Add `setup' forms to `imenu-generic-expression'
|
;;; Add `setup' forms to `imenu-generic-expression'
|
||||||
|
|
||||||
(defun +init-add-setup-to-imenu ()
|
(defun +init-add-setup-to-imenu ()
|
||||||
|
|
|
@ -67,5 +67,94 @@ with `string<' starting with the key determined by KEY-FN."
|
||||||
(insert-before-markers real)
|
(insert-before-markers real)
|
||||||
(delete-region (point) (marker-position end))))))))
|
(delete-region (point) (marker-position end))))))))
|
||||||
|
|
||||||
|
;;; Comment-or-uncomment-sexp
|
||||||
|
;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html
|
||||||
|
|
||||||
|
(defun +lisp-uncomment-sexp (&optional n)
|
||||||
|
"Uncomment N sexps around point."
|
||||||
|
(interactive "P")
|
||||||
|
(let* ((initial-point (point-marker))
|
||||||
|
(inhibit-field-text-motion t)
|
||||||
|
(p)
|
||||||
|
(end (save-excursion
|
||||||
|
(when (elt (syntax-ppss) 4)
|
||||||
|
(re-search-backward comment-start-skip
|
||||||
|
(line-beginning-position)
|
||||||
|
t))
|
||||||
|
(setq p (point-marker))
|
||||||
|
(comment-forward (point-max))
|
||||||
|
(point-marker)))
|
||||||
|
(beg (save-excursion
|
||||||
|
(forward-line 0)
|
||||||
|
(while (and (not (bobp))
|
||||||
|
(= end (save-excursion
|
||||||
|
(comment-forward (point-max))
|
||||||
|
(point))))
|
||||||
|
(forward-line -1))
|
||||||
|
(goto-char (line-end-position))
|
||||||
|
(re-search-backward comment-start-skip
|
||||||
|
(line-beginning-position)
|
||||||
|
t)
|
||||||
|
(ignore-errors
|
||||||
|
(while (looking-at-p comment-start-skip)
|
||||||
|
(forward-char -1)))
|
||||||
|
(point-marker))))
|
||||||
|
(unless (= beg end)
|
||||||
|
(uncomment-region beg end)
|
||||||
|
(goto-char p)
|
||||||
|
;; Indentify the "top-level" sexp inside the comment.
|
||||||
|
(while (and (ignore-errors (backward-up-list) t)
|
||||||
|
(>= (point) beg))
|
||||||
|
(skip-chars-backward (rx (syntax expression-prefix)))
|
||||||
|
(setq p (point-marker)))
|
||||||
|
;; Re-comment everything before it.
|
||||||
|
(ignore-errors
|
||||||
|
(comment-region beg p))
|
||||||
|
;; And everything after it.
|
||||||
|
(goto-char p)
|
||||||
|
(forward-sexp (or n 1))
|
||||||
|
(skip-chars-forward "\r\n[:blank:]")
|
||||||
|
(if (< (point) end)
|
||||||
|
(ignore-errors
|
||||||
|
(comment-region (point) end))
|
||||||
|
;; If this is a closing delimiter, pull it up.
|
||||||
|
(goto-char end)
|
||||||
|
(skip-chars-forward "\r\n[:blank:]")
|
||||||
|
(when (eq 5 (car (syntax-after (point))))
|
||||||
|
(delete-indentation))))
|
||||||
|
;; Without a prefix, it's more useful to leave point where
|
||||||
|
;; it was.
|
||||||
|
(unless n
|
||||||
|
(goto-char initial-point))))
|
||||||
|
|
||||||
|
(defun +lisp-comment-sexp--raw ()
|
||||||
|
"Comment the sexp at point or ahead of point."
|
||||||
|
(pcase (or (bounds-of-thing-at-point 'sexp)
|
||||||
|
(save-excursion
|
||||||
|
(skip-chars-forward "\r\n[:blank:]")
|
||||||
|
(bounds-of-thing-at-point 'sexp)))
|
||||||
|
(`(,l . ,r)
|
||||||
|
(goto-char r)
|
||||||
|
(skip-chars-forward "\r\n[:blank:]")
|
||||||
|
(save-excursion
|
||||||
|
(comment-region l r))
|
||||||
|
(skip-chars-forward "\r\n[:blank:]"))))
|
||||||
|
|
||||||
|
(defun +lisp-comment-or-uncomment-sexp (&optional n)
|
||||||
|
"Comment the sexp at point and move past it.
|
||||||
|
If already inside (or before) a comment, uncomment instead.
|
||||||
|
With a prefix argument N, (un)comment that many sexps."
|
||||||
|
(interactive "P")
|
||||||
|
(if (or (elt (syntax-ppss) 4)
|
||||||
|
(< (save-excursion
|
||||||
|
(skip-chars-forward "\r\n[:blank:]")
|
||||||
|
(point))
|
||||||
|
(save-excursion
|
||||||
|
(comment-forward 1)
|
||||||
|
(point))))
|
||||||
|
(+lisp-uncomment-sexp n)
|
||||||
|
(dotimes (_ (or n 1))
|
||||||
|
(+lisp-comment-sexp--raw))))
|
||||||
|
|
||||||
(provide '+lisp)
|
(provide '+lisp)
|
||||||
;;; +lisp.el ends here
|
;;; +lisp.el ends here
|
||||||
|
|
|
@ -17,11 +17,51 @@
|
||||||
:prefix "+modeline-"
|
:prefix "+modeline-"
|
||||||
:group 'simple-modeline)
|
:group 'simple-modeline)
|
||||||
|
|
||||||
(defun +modeline-buffer-name () ; gonsie
|
(defcustom +modeline-default-spacer " "
|
||||||
|
"Default spacer to use for modeline elements.
|
||||||
|
All modeline elements take an optional argument, `spacer', which
|
||||||
|
will default to this string.")
|
||||||
|
|
||||||
|
;;; Combinators
|
||||||
|
|
||||||
|
(defun +modeline-concat (segments &optional separator)
|
||||||
|
"Concatenate multiple `simple-modeline'-style SEGMENTS.
|
||||||
|
SEGMENTS is a list of either modeline segment-functions (see
|
||||||
|
`simple-modeline' functions for an example of types of
|
||||||
|
functions), though it can also contain cons cells of the
|
||||||
|
form (SEGMENT . PREDICATE).
|
||||||
|
|
||||||
|
Segments are separated from each other using SEPARATOR, which
|
||||||
|
defaults to a \" \". space. Only segments that evaluate to a
|
||||||
|
non-trivial string (that is, a string not equal to \"\") will be
|
||||||
|
separated, for a cleaner look.
|
||||||
|
|
||||||
|
This function makes a lambda, so you can throw it straight into
|
||||||
|
`simple-modeline-segments'."
|
||||||
|
(setq separator (or separator +modeline-default-spacer))
|
||||||
|
(lambda ()
|
||||||
|
(apply #'concat
|
||||||
|
(let (this-sep result-list)
|
||||||
|
(dolist (segment segments)
|
||||||
|
(push (funcall (or (car-safe segment) segment)
|
||||||
|
this-sep)
|
||||||
|
result-list)
|
||||||
|
(if (or (cdr-safe segment)
|
||||||
|
(and (car result-list)
|
||||||
|
(not (equal (car result-list) ""))))
|
||||||
|
(setq this-sep separator)
|
||||||
|
(setq this-sep nil)))
|
||||||
|
(unless (seq-some #'null result-list)
|
||||||
|
(push +modeline-default-spacer result-list))
|
||||||
|
(nreverse result-list)))))
|
||||||
|
|
||||||
|
;;; Modeline segments
|
||||||
|
|
||||||
|
(defun +modeline-buffer-name (&optional spacer) ; gonsie
|
||||||
"Display the buffer name."
|
"Display the buffer name."
|
||||||
(concat " " (propertize
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(+string-align (buffer-name) 20 :before "" :ellipsis "~ ")
|
(propertize
|
||||||
'face 'bold
|
(+string-align (buffer-name) 20 :ellipsis nil)
|
||||||
'help-echo (or (buffer-file-name)
|
'help-echo (or (buffer-file-name)
|
||||||
(buffer-name))
|
(buffer-name))
|
||||||
'mouse-face 'mode-line-highlight)))
|
'mouse-face 'mode-line-highlight)))
|
||||||
|
@ -30,9 +70,9 @@
|
||||||
"The \"icon\" for `+modeline-minions' button."
|
"The \"icon\" for `+modeline-minions' button."
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
(defun +modeline-minions ()
|
(defun +modeline-minions (&optional spacer)
|
||||||
"Display a button for `minions-minor-modes-menu'."
|
"Display a button for `minions-minor-modes-menu'."
|
||||||
(concat " "
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(propertize
|
(propertize
|
||||||
+modeline-minions-icon
|
+modeline-minions-icon
|
||||||
'help-echo "Minor modes menu\nmouse-1: show menu."
|
'help-echo "Minor modes menu\nmouse-1: show menu."
|
||||||
|
@ -45,9 +85,9 @@
|
||||||
(minions-minor-modes-menu)))))
|
(minions-minor-modes-menu)))))
|
||||||
'mouse-face 'mode-line-highlight)))
|
'mouse-face 'mode-line-highlight)))
|
||||||
|
|
||||||
(defun +modeline-major-mode ()
|
(defun +modeline-major-mode (&optional spacer)
|
||||||
"Display the current `major-mode'."
|
"Display the current `major-mode'."
|
||||||
(concat " "
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(propertize (+string-truncate (format-mode-line mode-name)
|
(propertize (+string-truncate (format-mode-line mode-name)
|
||||||
12 "~")
|
12 "~")
|
||||||
'face 'bold
|
'face 'bold
|
||||||
|
@ -80,7 +120,7 @@ The order of elements matters: whichever one matches first is applied."
|
||||||
`+modeline-modified'."
|
`+modeline-modified'."
|
||||||
:type '(repeat function))
|
:type '(repeat function))
|
||||||
|
|
||||||
(defun +modeline-modified () ; 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)
|
||||||
|
@ -94,14 +134,20 @@ The order of elements matters: whichever one matches first is applied."
|
||||||
('t t)
|
('t t)
|
||||||
(_ nil))
|
(_ nil))
|
||||||
(throw :icon (cdr cell)))))))
|
(throw :icon (cdr cell)))))))
|
||||||
(concat " "
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(propertize (or icon "")
|
(propertize (or icon "")
|
||||||
'mouse-face 'mode-line-highlight))))
|
'mouse-face 'mode-line-highlight))))
|
||||||
|
|
||||||
(defun +modeline-narrowed ()
|
(defun +modeline-buffer-modes (&optional spacer)
|
||||||
|
"Display various buffer-specific stuff cleanly."
|
||||||
|
;; This is clunky and should probably be improved.
|
||||||
|
(concat (+modeline-reading-mode)
|
||||||
|
(+modeline-narrowed (when reading-mode ","))))
|
||||||
|
|
||||||
|
(defun +modeline-narrowed (&optional spacer)
|
||||||
"Display an indication that the buffer is narrowed."
|
"Display an indication that the buffer is narrowed."
|
||||||
(when (buffer-narrowed-p)
|
(when (buffer-narrowed-p)
|
||||||
(concat " "
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(propertize "N"
|
(propertize "N"
|
||||||
'help-echo (format "%s\n%s"
|
'help-echo (format "%s\n%s"
|
||||||
"Buffer is narrowed."
|
"Buffer is narrowed."
|
||||||
|
@ -111,10 +157,10 @@ The order of elements matters: whichever one matches first is applied."
|
||||||
'face 'font-lock-doc-face
|
'face 'font-lock-doc-face
|
||||||
'mouse-face 'mode-line-highlight))))
|
'mouse-face 'mode-line-highlight))))
|
||||||
|
|
||||||
(defun +modeline-reading-mode ()
|
(defun +modeline-reading-mode (&optional spacer)
|
||||||
"Display an indication that the buffer is in `reading-mode'."
|
"Display an indication that the buffer is in `reading-mode'."
|
||||||
(when reading-mode
|
(when reading-mode
|
||||||
(concat " "
|
(concat (or spacer +modeline-default-spacer)
|
||||||
(propertize
|
(propertize
|
||||||
(concat "R" (when (bound-and-true-p +eww-readable-p) "w"))
|
(concat "R" (when (bound-and-true-p +eww-readable-p) "w"))
|
||||||
'help-echo (format "%s\n%s"
|
'help-echo (format "%s\n%s"
|
||||||
|
@ -136,7 +182,7 @@ The order of elements matters: whichever one matches first is applied."
|
||||||
"Toggle the percentage display in the mode line (File Percentage Mode)."
|
"Toggle the percentage display in the mode line (File Percentage Mode)."
|
||||||
:init-value t :global t :group 'mode-line)
|
:init-value t :global t :group 'mode-line)
|
||||||
|
|
||||||
(defun +modeline-position () ; adapted from `simple-modeline'
|
(defun +modeline-position (&optional _) ; adapted from `simple-modeline'
|
||||||
"Display the current cursor position."
|
"Display the current cursor position."
|
||||||
(list '((line-number-mode
|
(list '((line-number-mode
|
||||||
((column-number-mode
|
((column-number-mode
|
||||||
|
@ -160,34 +206,38 @@ The order of elements matters: whichever one matches first is applied."
|
||||||
(region-bounds))))
|
(region-bounds))))
|
||||||
'font-lock-face 'font-lock-variable-name-face))))
|
'font-lock-face 'font-lock-variable-name-face))))
|
||||||
|
|
||||||
(defun +modeline-vc ()
|
(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."
|
||||||
;; from https://www.gonsie.com/blorg/modeline.html, from Doom
|
;; from https://www.gonsie.com/blorg/modeline.html, from Doom
|
||||||
(if-let ((backend (vc-backend buffer-file-name)))
|
(if-let ((backend (vc-backend buffer-file-name)))
|
||||||
(concat " " (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2)))))
|
(concat (or spacer +modeline-default-spacer)
|
||||||
|
(substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2)))))
|
||||||
|
|
||||||
(defun +modeline-track ()
|
(defun +modeline-track (&optional spacer)
|
||||||
"Display `tracking-mode' information."
|
"Display `tracking-mode' information."
|
||||||
'(tracking-mode
|
(when tracking-mode
|
||||||
tracking-mode-line-buffers))
|
tracking-mode-line-buffers))
|
||||||
|
|
||||||
(defun +modeline-anzu ()
|
(defun +modeline-anzu (&optional spacer)
|
||||||
"Display `anzu--update-mode-line'."
|
"Display `anzu--update-mode-line'."
|
||||||
(concat " " (anzu--update-mode-line)))
|
(concat (or spacer +modeline-default-spacer)
|
||||||
|
(anzu--update-mode-line)))
|
||||||
|
|
||||||
(defun +modeline-text-scale ()
|
(defun +modeline-text-scale (&optional spacer)
|
||||||
"Display text scaling level."
|
"Display text scaling level."
|
||||||
;; adapted from https://github.com/seagle0128/doom-modeline
|
;; adapted from https://github.com/seagle0128/doom-modeline
|
||||||
(when (and (boundp 'text-scale-mode-amount)
|
(when (and (boundp 'text-scale-mode-amount)
|
||||||
(/= text-scale-mode-amount 0))
|
(/= text-scale-mode-amount 0))
|
||||||
(format (if (> text-scale-mode-amount 0) " (%+d)" " (%-d)")
|
(format (if (> text-scale-mode-amount 0) "%s(%+d)" "%s(%-d)")
|
||||||
|
(or spacer +modeline-default-spacer)
|
||||||
text-scale-mode-amount)))
|
text-scale-mode-amount)))
|
||||||
|
|
||||||
(defun +modeline-ace-window-display ()
|
(defun +modeline-ace-window-display (&optional spacer)
|
||||||
"Display `ace-window-display-mode' information in the modeline."
|
"Display `ace-window-display-mode' information in the modeline."
|
||||||
'(+ace-window-display-mode
|
(when (and +ace-window-display-mode
|
||||||
(ace-window-mode
|
ace-window-mode)
|
||||||
(" " (:eval (window-parameter (selected-window) 'ace-window-path))))))
|
(concat (or spacer +modeline-default-spacer)
|
||||||
|
(window-parameter (selected-window) 'ace-window-path))))
|
||||||
|
|
||||||
(provide '+modeline)
|
(provide '+modeline)
|
||||||
;;; +modeline.el ends here
|
;;; +modeline.el ends here
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
|
|
||||||
(setup-define :straight
|
(setup-define :straight
|
||||||
(lambda (recipe)
|
(lambda (recipe)
|
||||||
`(unless (straight-use-package ',recipe)
|
`(unless (ignore-errors (straight-use-package ',recipe))
|
||||||
,(setup-quit)))
|
,(setup-quit)))
|
||||||
:documentation
|
:documentation
|
||||||
"Install RECIPE with `straight-use-package'.
|
"Install RECIPE with `straight-use-package'.
|
||||||
|
|
|
@ -58,7 +58,8 @@ either side of S.
|
||||||
|
|
||||||
FILL is the string to fill extra space with (default \" \").
|
FILL is the string to fill extra space with (default \" \").
|
||||||
|
|
||||||
ELLIPSIS is the string to show when S is too long to fit (default \"...\").
|
ELLIPSIS is the string to show when S is too long to fit (default
|
||||||
|
\"...\"). If nil, don't truncate the string.
|
||||||
|
|
||||||
ALIGNMENT can be one of these:
|
ALIGNMENT can be one of these:
|
||||||
- nil: align to `+string-default-alignment'
|
- nil: align to `+string-default-alignment'
|
||||||
|
@ -73,7 +74,7 @@ ALIGNMENT can be one of these:
|
||||||
(format "%s%s%s%s%s"
|
(format "%s%s%s%s%s"
|
||||||
before
|
before
|
||||||
(if (eq alignment 'left) "" filler)
|
(if (eq alignment 'left) "" filler)
|
||||||
(+string-truncate s max-length ellipsis alignment)
|
(if ellipsis (+string-truncate s max-length ellipsis alignment) s)
|
||||||
(if (eq alignment 'right) "" filler)
|
(if (eq alignment 'right) "" filler)
|
||||||
after)))
|
after)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue