From 80abceb212b2acb420317232cb2c3d0ab69af13b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 27 May 2022 13:26:19 -0500 Subject: [PATCH] asdpofiuasdpfoiasjdpfoiajsdf --- init.el | 130 +++++++++++++++------------------------------- lisp/+elfeed.el | 14 +++-- lisp/+emacs.el | 2 +- lisp/+modeline.el | 9 ++++ lisp/+setup.el | 21 ++++---- lisp/+tab-bar.el | 13 ++--- lisp/acdw.el | 7 +++ machines/bob.el | 2 +- 8 files changed, 83 insertions(+), 115 deletions(-) diff --git a/init.el b/init.el index 9bd342b..2932768 100644 --- a/init.el +++ b/init.el @@ -38,7 +38,8 @@ ;; good functioning. In this block, I add extra things or more "experimental" ;; ones that might not belong in a separate file. (:also-load +lisp) - (:option truncate-string-ellipsis "…") + (:option truncate-string-ellipsis "…" + ring-bell-function 'ignore) ;; Bindings (:global "C-x C-k" #'kill-current-buffer "C-x 4 n" #'clone-buffer @@ -52,7 +53,7 @@ "C-x C-m" #'execute-extended-command ; original: coding systems "C-" #'+backward-kill-word "C-x TAB" #'+indent-rigidly - "C-x C-c" nil) + "C-x C-c" #'+save-buffers-quit) ;; C-h deletes backward - see https://idiomdrottning.org/bad-emacs-defaults (global-set-key (kbd "C-h") 'delete-backward-char) (keyboard-translate ?\C-h ?\C-?) @@ -105,8 +106,8 @@ (dolist (var '(safe-local-variable-values warning-suppress-types)) (add-to-list '+custom-variable-allowlist var)) - (+ensure-after-init - (+custom-load-ignoring-most-customizations)) + (+with-ensure-after-init + (+custom-load-ignoring-most-customizations)) (advice-add #'custom-buffer-create-internal :after #'+cus-edit-expand-widgets) (:with-mode Custom-mode (:local-set imenu-generic-expression +cus-edit-imenu-generic-expression))) @@ -147,7 +148,7 @@ (+ensure-after-init #'+key-global-mode)) (setup _work - (+with-ensure-after-init + (with-eval-after-load 'bbdb (require '_work))) (setup abbrev @@ -672,12 +673,13 @@ (:global [f8] #'org-clock-in [f9] #'org-clock-out "C-c l" #'org-store-link) - (:hook #'variable-pitch-mode + (+with-ensure-after-init + (:hook #'variable-pitch-mode #'visual-fill-column-mode #'turn-off-auto-fill #'org-indent-mode #'prettify-symbols-mode - #'+org-wrap-on-hyphens) + #'+org-wrap-on-hyphens)) (:local-set prettify-symbols-alist '(("DEADLINE:" . ?→) ("SCHEDULED:" . ?↷) ("CLOSED:" . ?✓)) @@ -974,12 +976,10 @@ (setq affe-regexp-compiler (defun affe-orderless-regexp-compiler (input &rest _) (setq input (orderless-pattern-compiler input)) (cons input (lambda (str) (orderless--highlight input str))))) - (+with-eval-after-loads (affe vertico-multiform) + (+with-eval-after-loads (affe) (setq affe-regexp-compiler (defun affe-orderless-regexp-compiler (input &rest _) (setq input (orderless-pattern-compiler input)) (cons input (lambda (str) (orderless--highlight input str))))) - (setf (alist-get 'affe-grep vertico-multiform-commands) nil - (alist-get 'affe-find vertico-multiform-commands) nil) (:+key "M-s g" #'affe-grep "M-s f" #'affe-find))) @@ -1262,10 +1262,7 @@ column-number-mode nil file-percentage-mode nil visual-fill-column-extra-text-width - (cons +circe-left-margin 0)) - (with-eval-after-load 'vertico-multiform - (setf (alist-get 'lui-next-button-or-complete vertico-multiform-commands) - '(flat)))) + (cons +circe-left-margin 0))) (tracking-mode +1) (:with-mode tracking-mode @@ -1383,41 +1380,10 @@ (comint-mode-map . comint-mode-hook) (sly-mrepl-mode-map . sly-mrepl-hook))) (with-eval-after-load 'orderless - (:option consult--regexp-compiler #'consult--orderless-regexp-compiler)) - (with-eval-after-load 'vertico-multiform - (setf (alist-get 'consult-buffer vertico-multiform-commands) '(flat)) - (dolist (buf-cmd '(consult-find - consult-flymake - consult-focus-lines - consult-git-grep - consult-grep - consult-imenu - consult-imenu-multi - consult-keep-lines - consult-line - consult-line-multi - consult-locate - consult-multi-occur - consult-outline - consult-ripgrep - consult-yank-pop)) - (setf (alist-get buf-cmd vertico-multiform-commands) nil))))) - -(setup (:straight consult-dir) - (:load-after consult) - (:+key "C-x C-d" #'consult-dir) - (:with-map vertico-map - (:bind "C-x C-d" #'consult-dir - "C-x C-j" #'consult-dir-jump-file))) - -(setup (:straight consult-notmuch) - (:load-after consult notmuch) - (with-eval-after-load 'vertico-multiform - (setf (alist-get 'consult-notmuch vertico-multiform-commands) nil - (alist-get 'consult-notmuch-tree vertico-multiform-commands) nil))) + (:option consult--regexp-compiler #'consult--orderless-regexp-compiler)))) (setup (:straight corfu) - (corfu-global-mode +1)) + (global-corfu-mode +1)) (setup (:straight crossword) ;; This isn't the perfect Emacs crossword puzzle, but it's the only one I @@ -1587,11 +1553,7 @@ (:bind "C-." #'embark-act "M-." #'embark-dwim)) (:with-map embark-file-map - (:bind "l" #'vlf)) - ;; Integrations - (with-eval-after-load 'vertico-multiform - (setf (alist-get 'embark-prefix-help-command vertico-multiform-commands) - nil))) + (:bind "l" #'vlf))) (setup (:straight embark-consult) (:load-after consult embark) @@ -1687,9 +1649,7 @@ (:option flyspell-correct--cr-key ";") (:bind-into flyspell "C-;" #'flyspell-correct-wrapper - "" #'+flyspell-correct-buffer) - (with-eval-after-load 'vertico-multiform - (setf (alist-get 'flyspell vertico-multiform-categories) nil))) + "" #'+flyspell-correct-buffer)) (setup (:straight focus) (:require) @@ -1765,12 +1725,6 @@ " v" #'helpful-variable " k" #'helpful-key " ." #'helpful-at-point) - (with-eval-after-load 'vertico-multiform - (dolist (cmd '(describe-symbol ; describe-* included here for completeness - describe-function describe-variable - helpful-function helpful-macro helpful-callable - helpful-variable)) - (setf (alist-get cmd vertico-multiform-commands) nil))) ;; Load faster on first invocation by pre-loading a slow function ;; (see https://github.com/Wilfred/helpful/issues/236) (run-with-idle-timer 1 nil (lambda () @@ -1778,8 +1732,8 @@ (info-lookup-setup-mode 'symbol 'emacs-lisp-mode)))) (setup (:straight (hippie-completing-read - :host github - :repo "duckwork/hippie-completing-read")) + :host nil + :repo "https://codeberg.org/acdw/hippie-completing-read.el")) (:+key "M-/" #'hippie-completing-read)) (setup (:straight hungry-delete) @@ -1918,10 +1872,7 @@ (keychain-refresh-environment)) (setup (:straight lacarte) - (:+key "" #'lacarte-execute-menu-command) - (with-eval-after-load 'vertico-multiform - (setf (alist-get 'lacarte-execute-menu-command vertico-multiform-commands) - '(buffer grid (vertico-sort-function . vertico-sort-length-alpha))))) + (:+key "" #'lacarte-execute-menu-command)) (setup (:straight (lin :host nil :repo "https://git.sr.ht/~protesilaos/lin")) @@ -1967,7 +1918,11 @@ lisp-interaction-mode-map)) (define-key (symbol-value m) (kbd "C-c e") #'macrostep-expand))) -(setup (:straight (magit :host github :repo "magit/magit"))) +(setup (:straight (magit :host github :repo "magit/magit" + :build (:not compile)) + (:straight (transient :host github :repo "magit/transient" + :build (:not compile)))) + (autoload 'transient--with-suspended-override "transient")) (setup (:straight marginalia) (marginalia-mode +1)) @@ -2098,12 +2053,13 @@ ((,class :inherit font-lock-comment-face :foreground ,fg-header :background ,yellow-intense-bg))) - `(mode-line - ((,class :height 100))) - `(mode-line-inactive - ((,class :height 100))) - `(tab-bar - ((,class :height 100))))))) + ;; `(mode-line + ;; ((,class :height 100))) + ;; `(mode-line-inactive + ;; ((,class :height 100))) + ;; `(tab-bar + ;; ((,class :height 100))) + )))) (require 'dawn) (dawn-schedule #'modus-themes-load-operandi @@ -2140,6 +2096,13 @@ (:hook #'visual-fill-column-mode) (:file-match (rx ".epub" eos))) +(setup (:straight nyan-mode) + (:require) + ;; For some reason, in some modes the mode-line isn't updated after these + ;; commands. I think it might have to do with `+modeline-position-function'. + (advice-add 'end-of-buffer :after #'force-mode-line-update) + (advice-add 'beginning-of-buffer :after #'force-mode-line-update)) + (setup (:straight ol-notmuch)) (setup (:straight orderless) @@ -2342,6 +2305,7 @@ +modeline-major-mode (lambda () (+modeline-vc " : ")) +modeline-anzu + +modeline-nyan-on-focused ) ( ; right simple-modeline-segment-process @@ -2350,7 +2314,6 @@ (+modeline-concat '(+modeline-track simple-modeline-segment-misc-info)))) - simple-modeline-segment-process ,(+modeline-concat '(+modeline-god-mode +modeline-kmacro-indicator @@ -2360,7 +2323,7 @@ +modeline-input-method) " ") +modeline-position - ;; +modeline-spacer + +modeline-spacer ))) (simple-modeline-mode +1)) @@ -2483,7 +2446,8 @@ (setup (:straight (twtxt :fork (:repo "duckwork/twtxt-el"))) (:option twtxt-file "/sshx:hetzner:/var/www/acdw.casa/tw.txt" - twtxt-following '(("acdw" "https://acdw.casa/tw.txt")))) + twtxt-following '(("acdw" "https://acdw.casa/tw.txt"))) + (+with-ensure-after-init (:require))) (setup (:straight undo-fu) (:option undo-fu-allow-undo-in-region t) @@ -2533,20 +2497,8 @@ ;; Extensions (:also-load vertico-directory vertico-mouse - vertico-unobtrusive - vertico-multiform vertico-quick) (vertico-mouse-mode +1) - (vertico-multiform-mode +1) - ;; I `setf' these so they don't override the other setfs elsewhere in init.el. - (setf (alist-get 'execute-extended-command vertico-multiform-commands) '(flat)) - (setf (alist-get 'completion-at-point vertico-multiform-commands) '(flat)) - (setf (alist-get 'indent-for-tab-command vertico-multiform-commands) '(flat)) - (setf (alist-get 'insert-char vertico-multiform-commands) nil) - (setf (alist-get 'file vertico-multiform-categories) nil) - (setf (alist-get 'bookmark vertico-multiform-categories) nil) - ;; Default. Needs to be `add-to-list' so that it appears at the end. - (add-to-list 'vertico-multiform-categories '(t flat) :append) (:with-map vertico-map (:bind "RET" #'vertico-directory-enter "DEL" #'vertico-directory-delete-char diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index 9257c8d..c3e5301 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el @@ -46,20 +46,24 @@ If multiple items are selected, don't advance." (message "[Elfeed] Update in progress") 'ignore) -(defvar +elfeed--update-running nil "Whether an update is currently running.") +(defvar +elfeed--update-running-p nil "Whether an update is currently running.") (defvar +elfeed--update-count 0 "How many times `+elfeed-update-command' has run.") (defcustom +elfeed-update-niceness 15 "How \"nice\" `+elfeed-update-command' should be." :type 'integer :group 'elfeed) +(defcustom +elfeed-update-lockfile + (expand-file-name "+elfeed-update-lock" (temporary-file-directory)) + "The file to ") + (defun +elfeed-update-command () (interactive) - (unless (or +elfeed--update-running + (unless (or +elfeed--update-running-p (derived-mode-p 'elfeed-show-mode 'elfeed-search-mode)) (let ((script (expand-file-name "/tmp/elfeed-update.el")) (update-message-format "[Elfeed] Background update: %s")) - (setq +elfeed--update-running t) + (setq +elfeed--update-running-p t) (elfeed-db-save) (advice-add 'elfeed :override #'+elfeed--update-message) (ignore-errors (kill-buffer "*elfeed-search*")) @@ -128,7 +132,7 @@ If multiple items are selected, don't advance." script)) (lambda (proc stat) (advice-remove 'elfeed #'+elfeed--update-message) - (setq +elfeed--update-running nil) + (setq +elfeed--update-running-p nil) (unless (string= stat "killed") (setq +elfeed--update-count (1+ +elfeed--update-count))) (message update-message-format (string-trim stat))))))) @@ -152,7 +156,7 @@ non-nil, proceed." (defun +elfeed--cancel-update-timer () "Cancel `+elfeed--update-timer'." - (unless +elfeed--update-running + (unless +elfeed--update-running-p (ignore-errors (cancel-timer +elfeed--update-timer)) (setq +elfeed--update-timer nil))) diff --git a/lisp/+emacs.el b/lisp/+emacs.el index dedde98..7c8a1a6 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el @@ -121,7 +121,7 @@ Do this only if the buffer is not visiting a file." show-paren-when-point-inside-paren t ;;show-trailing-whitespace t tab-bar-show 1 - tab-width 4 + tab-width 8 ; so alignment expecting the default looks right tramp-backup-directory-alist backup-directory-alist undo-limit 100000000 ; 10 MB use-dialog-box nil diff --git a/lisp/+modeline.el b/lisp/+modeline.el index 33d34c3..026302b 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el @@ -9,6 +9,7 @@ ;;; Code: (require '+util) +(require 'actually-selected-window) (require 'simple-modeline) (require 'minions) @@ -472,5 +473,13 @@ to a function in the current buffer, call that function instead." (kmacro-end-macro nil))))) 'mouse-face 'mode-line-highlight)))) +(defun +modeline-nyan-on-focused (&optional spacer) + "Display the cat from `nyan-mode', but only on the focused window." + (require 'nyan-mode) + (when (actually-selected-window-p) + (concat (or spacer "") (nyan-create) + (propertize "." + 'face 'font-lock-comment-face)))) + (provide '+modeline) ;;; +modeline.el ends here diff --git a/lisp/+setup.el b/lisp/+setup.el index 919e312..1f110d6 100644 --- a/lisp/+setup.el +++ b/lisp/+setup.el @@ -80,21 +80,22 @@ If PATH does not exist, abort the evaluation." ;;; Straight.el -(with-eval-after-load 'straight - (defun setup--straight-handle-arg (arg var) - (cond - ((and (boundp var) (symbol-value var)) t) - ((keywordp arg) (set var t)) - ((functionp arg) (set var nil) (funcall arg)) - ((listp arg) (set var nil) (eval arg :lexical)))) +(defun setup--straight-handle-arg (arg var) + (cond + ((and (boundp var) (symbol-value var)) t) + ((keywordp arg) (set var t)) + ((functionp arg) (set var nil) (funcall arg)) + ((listp arg) (set var nil) arg))) +(with-eval-after-load 'straight (setup-define :straight (lambda (recipe &rest predicates) (let* ((skp (make-symbol "straight-keyword-p")) (straight-use-p - (cl-every (lambda (f) (setup--straight-handle-arg f skp)) - predicates)) - (form `(unless (and ,straight-use-p + (cl-mapcar + (lambda (f) (setup--straight-handle-arg f skp)) + predicates)) + (form `(unless (and ,@straight-use-p (condition-case e (straight-use-package ',recipe) (error diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index e9daaf4..3e6968e 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el @@ -7,6 +7,7 @@ ;;; Code: +(require 'acdw) (require 'tab-bar) (defface +tab-bar-extra @@ -35,7 +36,7 @@ "Display `tracking-mode-line-buffers' in the tab-bar." ;; TODO: write something to convert a mode-line construct to a tab-bar ;; construct. - (when (and tracking-mode + (when (and (bound-and-true-p tracking-mode) (not (and +tracking-hide-when-org-clocking (bound-and-true-p org-clock-current-task)))) (cons (when (> (length tracking-mode-line-buffers) 0) @@ -261,14 +262,8 @@ name to the left." (require 'shr) ; `shr-string-pixel-width' (let* ((rest (cdr (memq '+tab-bar-format-align-right tab-bar-format))) (rest (tab-bar-format-list rest)) - (rest (mapconcat (lambda (item) x(nth 2 item)) rest "")) - (hpos - ;; I have to rewrite `shr-string-pixel-width' to take the tab-bar face - ;; into account. - (let ((pt (point))) - (prog1 (with-temp-buffer (insert (propertize rest 'face 'tab-bar)) - (shr-pixel-column)) - (goto-char pt)))) + (rest (mapconcat (lambda (item) (nth 2 item)) rest "")) + (hpos (shr-string-pixel-width rest)) (str (propertize " " 'display `(space :align-to (- right (,hpos)))))) `((align-right menu-item ,str ignore)))) diff --git a/lisp/acdw.el b/lisp/acdw.el index 191cdfb..fdcca84 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -288,6 +288,13 @@ always nil; this function is mostly intended for use in init." :type '(repeat function) :group 'applications) +(defun +string-repeat (n str) + "Repeat STR N times." + (let ((r "")) + (dotimes (_ n) + (setq r (concat r str))) + r)) + (defun chat-disconnect () "Disconnect from all chats." (interactive) diff --git a/machines/bob.el b/machines/bob.el index e043719..06e605a 100644 --- a/machines/bob.el +++ b/machines/bob.el @@ -13,7 +13,7 @@ (italic-face nil) ;; (bold-face nil) (mono-face nil) - (var-face "IBM Plex Serif") + (var-face "IBM Plex Sans") (var-size 1.0)) (+set-faces `((default