uhhhhhhhh

This commit is contained in:
Case Duckworth 2021-12-04 23:09:33 -06:00
parent c2098fcdc9
commit b1d3071269
4 changed files with 286 additions and 1 deletions

62
init.el
View File

@ -16,10 +16,13 @@
;;; Code:
;; Delete when no longer ... remacs'd
;; Require early-init.el just in case it hasn't been yet.
(require 'early-init (locate-user-emacs-file "early-init.el") :noerror)
;; Requre my private stuff
(require 'private)
(setq debug-on-error t)
(setup (:require +defaults))
@ -72,6 +75,20 @@
(with-eval-after-load 'frowny
(add-to-list 'frowny-inhibit-modes 'dired-mode)))
(setup eldoc
(:hook-into elisp-mode
lisp-interaction-mode))
(setup elisp-mode
(:also-load +elisp)
(:option eval-expression-print-length nil
eval-expression-print-level nil)
(:with-map (emacs-lisp-mode-map lisp-interaction-mode-map)
(:bind "C-c C-c" 'eval-defun
"C-c C-k" '+elisp-eval-region-or-buffer
"C-c C-z" 'ielm))
(advice-add 'eval-region :around '+eval-region@pulse))
(setup eshell
(:also-load +eshell
em-smart
@ -108,6 +125,22 @@
'("tildegit.org" "tildegit.org/api/v1" "tildegit.org"
forge-gitea-repository)))))
(setup prog
(:local-set comment-auto-fill-only-comments t)
(:hook 'prettify-symbols-mode
'display-fill-column-indicator-mode
'turn-on-auto-fill))
(setup pulse
(:also-load +pulse)
(:option pulse-flag nil
pulse-delay 0.5
pulse-iterations 1)
(+pulse-location-mode +1))
(setup text
(:hook 'turn-on-auto-fill))
(setup (:straight 0x0)
(:option 0x0-default-server 'ttm)
(with-eval-after-load 'embark
@ -118,6 +151,7 @@
)
(setup (:straight anzu)
(:option anzu-cons-mode-line-p nil)
(:global [remap query-replace] 'anzu-query-replace-regexp
[remap query-replace-regexp] 'anzu-query-replace-regexp)
(global-anzu-mode +1)
@ -348,7 +382,7 @@
(:option prefix-help-command 'embark-prefix-help-command)
(:global "C-." 'embark-act
"M-." 'embark-dwim
"C-h B" 'embark-bindings))
"<help> B" 'embark-bindings))
(setup (:straight embark-consult)
(:load-after consult embark)
@ -565,6 +599,25 @@
"M-!" 'shell-command+)
(:global "M-!" 'shell-command+))
(setup (:straight (simple-modeline
:fork (:repo "duckwork/simple-modeline")))
(:also-load +modeline)
(:option simple-modeline-segments '((;; left
+modeline-modified
+modeline-buffer-name
+modeline-position
+modeline-anzu
)
(;; right
+modeline-track
+modeline-vc
simple-modeline-segment-misc-info
simple-modeline-segment-process
+modeline-narrowed
+modeline-minions
+modeline-major-mode)))
(simple-modeline-mode +1))
(setup (:straight (sophomore
:host github
:repo "duckwork/sophomore.el"))
@ -637,3 +690,10 @@
(:option whitespace-cleanup-mode-preserve-point t)
(remove-hook 'before-save-hook 'whitespace-cleanup)
(global-whitespace-cleanup-mode +1))
(setup (:straight zzz-to-char)
(:global "M-z" (lambda (prefix)
"Call `zzz-to-char' or `zzz-up-to-char' with PREFIX arg."
(interactive "P")
(call-interactively
(if prefix #'zzz-up-to-char #'zzz-to-char)))))

18
lisp/+elisp.el Normal file
View File

@ -0,0 +1,18 @@
;;; +elisp.el -*- lexical-binding: t; -*-
;;; Code:
(defun +elisp-eval-region-or-buffer ()
(interactive)
(if (region-active-p)
(eval-region (region-beginning) (region-end))
(eval-buffer)))
;; Should I move this to `+pulse' ?
(defun +eval-region@pulse (advised beg end &rest args)
"ADVICE to pulse an eval'd region."
(apply advised beg end args)
(pulse-momentary-highlight-region beg end))
(provide '+elisp)
;;; +elisp.el ends here

157
lisp/+modeline.el Normal file
View File

@ -0,0 +1,157 @@
;;; +modeline.el --- my modeline customizations -*- lexical-binding: t; -*-
;;; Commentary:
;; `+modeline.el' is kind of a dumping ground for various
;; modeline-related functions. I probably don't use everything in
;; here. Credit given where possible.
;;; Code:
(require '+util)
(require 'simple-modeline)
(require 'minions)
(defgroup +modeline nil
"Various customization options for my modeline things."
:prefix "+modeline-"
:group 'simple-modeline)
(defun +modeline-buffer-name () ; gonsie
"Display the buffer name."
(propertize
(+string-align (buffer-name) 20 :before " " :ellipsis "")
'face 'bold
'help-echo (or (buffer-file-name)
(buffer-name))
'mouse-face 'mode-line-highlight))
(defcustom +modeline-minions-icon "&"
"The \"icon\" for `+modeline-minions' button."
:type 'string)
(defun +modeline-minions ()
"Display a button for `minions-minor-modes-menu'."
(concat " "
(propertize
+modeline-minions-icon
'help-echo "Minor modes menu\nmouse-1: show menu."
'local-map (purecopy (simple-modeline-make-mouse-map
'mouse-1
(lambda (event)
(interactive "e")
(with-selected-window
(posn-window (event-start event))
(minions-minor-modes-menu)))))
'mouse-face 'mode-line-highlight)))
(defun +modeline-major-mode ()
"Display the current `major-mode'."
(concat " "
(propertize (+string-truncate (format-mode-line mode-name)
12 "")
'face 'bold
'keymap mode-line-major-mode-keymap
'mouse-face 'mode-line-highlight)))
(defcustom +modeline-modified-icon-alist '((ephemeral . "*")
(readonly . "=")
(modified . "+")
(special . "~")
(t . "-"))
"\"Icons\" to display depending on buffer status in modeline.
The CAR of each field is one of `readonly', `modified',
`special', `ephemeral', or t, and the CDR is a string to display
in that mode.
`readonly' is true if the buffer is read-only and visiting a file.
`modified' is true if the buffer is modified.
`special' is true if the buffer is a special-mode or derived buffer.
`ephemeral' is true if the buffer is not visiting a file.
t is the fall-back, shown when nothing else in the alist applies.
The order of elements matters: whichever one matches first is applied."
:type '(alist :key-type symbol
:value-type string)
:options '("readonly" "modified" "special" "t"))
(defcustom +modeline-modified-icon-special-modes '(special-mode)
"Modes to apply the `special-mode' icon to in the
`+modeline-modified'."
:type '(repeat function))
(defun +modeline-modified () ; modified from `simple-modeline-status-modified'
"Display a color-coded \"icon\" indicator for the buffer's status."
(let* ((icon (catch :icon
(dolist (cell +modeline-modified-icon-alist)
(when (pcase (car cell)
('ephemeral (not (buffer-file-name)))
('readonly buffer-read-only)
('modified (buffer-modified-p))
('special
(apply 'derived-mode-p
+modeline-modified-icon-special-modes))
('t t)
(_ nil))
(throw :icon (cdr cell)))))))
(concat " "
(propertize (or icon "")
'mouse-face 'mode-line-highlight))))
(defun +modeline-narrowed ()
"Display an indication that the buffer is narrowed."
(when (buffer-narrowed-p)
(concat " "
(propertize "N"
'help-echo (format "%s\n%s"
"Buffer is narrowed."
"mouse-2: widen buffer.")
'local-map (purecopy (simple-modeline-make-mouse-map
'mouse-2 'mode-line-widen))
'mouse-face 'mode-line-highlight))))
(define-minor-mode file-percentage-mode
"Toggle the percentage display in the mode line (File Percentage Mode)."
:init-value t :global t :group 'mode-line)
(defun +modeline-position () ; adapted from `simple-modeline'
"Display the current cursor position."
(list '((line-number-mode
((column-number-mode
(column-number-indicator-zero-based
(9 " %l:%c")
(9 " %l:%C"))
(6 " %l:")))
((column-number-mode
(column-number-indicator-zero-based
(5 " :%c")
(5 " :%C"))))))
'(file-percentage-mode
((-3 "%p") "%% "))
(if (region-active-p)
(propertize (format "%s%-5d"
(if (and (mark) (< (point) (mark))) "-" "+")
(apply '+ (mapcar
(lambda (pos)
(- (cdr pos)
(car pos)))
(region-bounds))))
'font-lock-face 'font-lock-variable-name-face))))
(defun +modeline-vc ()
"Display the version control branch of the current buffer in the modeline."
;; from https://www.gonsie.com/blorg/modeline.html, from Doom
(if-let ((backend (vc-backend buffer-file-name)))
(concat " " (substring vc-mode (+ (if (eq backend 'Hg) 2 3) 2)))))
(defun +modeline-track ()
"Display `tracking-mode' information."
'(tracking-mode
tracking-mode-line-buffers))
(defun +modeline-anzu ()
"Display `anzu--update-mode-line'."
(anzu--update-mode-line))
(provide '+modeline)
;;; +modeline.el ends here

50
lisp/+pulse.el Normal file
View File

@ -0,0 +1,50 @@
;;; +pulse.el -*- lexical-binding: t; -*-
;;; Code:
(defgroup +pulse nil
"Extra customizations for `pulse'."
:group 'pulse
:prefix "+pulse-")
(defcustom +pulse-location-commands '(scroll-up-command
scroll-down-command
recenter-top-bottom
other-window
switch-to-buffer
redraw-frame)
"Commands to pulse the current line after.
Good for finding location."
:type '(repeat function))
(defcustom +pulse-location-function '+pulse-line-current-window
"What function to call after `+pulse-location-commands'."
:type 'function)
;; XXX: this doesn't work yet. I only want to pulse the line in the
;; active window, so when I have the same buffer viewed in multiple
;; windows I can still see where my cursor is. To see the issue, C-x
;; 2 then C-x o a few times.
(defun +pulse-line-current-window (&rest _)
"Pulse the current line, but only if this window is active."
(pulse-momentary-highlight-one-line
(window-point (selected-window))))
(defun +pulse--advice-remove (symbol where function &optional props)
"Remove advice SYMBOL from FUNCTION.
This uses the same args as `advice-add' for easy toggling.
WHERE and PROPS are discarded."
(ignore where props)
(advice-remove symbol function))
(define-minor-mode +pulse-location-mode
"After moving locations, pulse where we are."
:global t
:keymap nil
(dolist (command +pulse-location-commands)
(funcall
(if +pulse-location-mode 'advice-add '+pulse--advice-remove)
command :after +pulse-location-function)))
(provide '+pulse)
;;; +pulse.el ends here