From 1042c6f60156f67463bfd2cf764bc4cc33a79207 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 20:24:54 -0500 Subject: Change font I really should setup something based on what's /installed/, rather than system... or not... hm. --- early-init.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/early-init.el b/early-init.el index 90a2b0c..b964a5a 100644 --- a/early-init.el +++ b/early-init.el @@ -87,7 +87,7 @@ (:work 12) (_ 10)) acdw-fonts/variable (acdw/system - (:home "DejaVu Sans") + (:home "Inter") (:work "Calibri") (_ "sans-serif")) acdw-fonts/variable-size (acdw/system -- cgit 1.4.1-21-gabe81 From ed938fc096e2fd675f3e52842fea331630f67491 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 20:25:40 -0500 Subject: Enable `crux-reopen-as-root-mode' --- init.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 92a74b0..bfc736d 100644 --- a/init.el +++ b/init.el @@ -980,7 +980,9 @@ if ripgrep is installed, otherwise `consult-grep'." "C-o" crux-smart-open-line "M-o" crux-smart-open-line-above "C-M-\\" crux-cleanup-buffer-or-region - "C-x 4 t" crux-transpose-windows)) + "C-x 4 t" crux-transpose-windows) + + (crux-reopen-as-root-mode +1)) ;; requires extension: ;; https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/ -- cgit 1.4.1-21-gabe81 From d187b2b8cbf19ec387c800df37d2669a9d520448 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:03:54 -0500 Subject: Add acdw-compat.el --- init.el | 3 +++ lisp/acdw-compat.el | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 lisp/acdw-compat.el diff --git a/init.el b/init.el index bfc736d..733de04 100644 --- a/init.el +++ b/init.el @@ -48,6 +48,9 @@ ;;;; Private stuff (acdw/require-private) +;;;; Compatibility with older versions +(require 'acdw-compat) + ;;;; Utility functions and variables ;; see also: `acdw' and friends. Functions here aren't big enough, or they're diff --git a/lisp/acdw-compat.el b/lisp/acdw-compat.el new file mode 100644 index 0000000..b77527c --- /dev/null +++ b/lisp/acdw-compat.el @@ -0,0 +1,71 @@ +;;; acdw-compat.el -*- lexical-binding: t; coding: utf-8-unix -*- + +;; Author: Case Duckworth +;; Created: 2021-08-11 +;; Keywords: configuration +;; URL: https://tildegit.org/acdw/emacs + +;; This file is NOT part of GNU Emacs. + +;;; License: +;; Everyone is permitted to do whatever with this software, without +;; limitation. This software comes without any warranty whatsoever, +;; but with two pieces of advice: +;; - Don't hurt yourself. +;; - Make good choices. + +;;; Commentary: + +;; This file contains functions, variables, and other code that might not be in +;; every version of Emacs I use. + +;;; Code: + +;; Convenience macro +(defmacro safe-defun (name arglist &optional docstring &rest body) + "Like `defun', but only if the function doesn't already exist. + +Is it necessary? Who knows! + +\(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)" + (declare (doc-string 3) + (indent 2)) + `(unless (fboundp (function ,name)) + (defun ,name ,@body))) + + +;;; Functions for changing capitalization that Do What I Mean +;; Defined in /usr/share/emacs/28.0.50/lisp/simple.el + +(safe-defun upcase-dwim (arg) + "Upcase words in the region, if active; if not, upcase word at point. +If the region is active, this function calls `upcase-region'. +Otherwise, it calls `upcase-word', with prefix argument passed to it +to upcase ARG words." + (interactive "*p") + (if (use-region-p) + (upcase-region (region-beginning) (region-end) (region-noncontiguous-p)) + (upcase-word arg))) + +(safe-defun downcase-dwim (arg) + "Downcase words in the region, if active; if not, downcase word at point. +If the region is active, this function calls `downcase-region'. +Otherwise, it calls `downcase-word', with prefix argument passed to it +to downcase ARG words." + (interactive "*p") + (if (use-region-p) + (downcase-region (region-beginning) (region-end) (region-noncontiguous-p)) + (downcase-word arg))) + +(safe-defun capitalize-dwim (arg) + "Capitalize words in the region, if active; if not, capitalize word at point. +If the region is active, this function calls `capitalize-region'. +Otherwise, it calls `capitalize-word', with prefix argument passed to it +to capitalize ARG words." + (interactive "*p") + (if (use-region-p) + (capitalize-region (region-beginning) (region-end) (region-noncontiguous-p)) + (capitalize-word arg))) + +(provide 'acdw-compat) +;;; acdw-compat.el ends here -- cgit 1.4.1-21-gabe81 From 1fa1054de6ef3306c00d185109edb4c82e4f5fec Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:04:22 -0500 Subject: Set up eshell prompt for outline --- init.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/init.el b/init.el index 733de04..c6370a0 100644 --- a/init.el +++ b/init.el @@ -370,8 +370,8 @@ (apply f r)))) (:hook erc-autoaway-mode - erc-track-mode - erc-truncate-mode) + erc-track-mode + erc-truncate-mode) (:bind "C-c C-b" acdw-erc/erc-switch-to-buffer "C-c C-c" nil ; def: `erc-toggle-interpret-controls' @@ -417,9 +417,11 @@ like a dumbass." ;; Define keys (dolist (spec '(("C-d" . eshell-quit-or-delete-char))) (define-key eshell-mode-map (kbd (car spec)) (function (cdr spec)))) - ;; Etc. + ;; Fix modeline (when (boundp 'simple-modeline--mode-line) - (setq mode-line-format '(:eval simple-modeline--mode-line)))) + (setq mode-line-format '(:eval simple-modeline--mode-line))) + ;; Set outline-regexp for consult-outline + (setq outline-regexp eshell-prompt-regexp)) (defun eshell-buffer-name () (rename-buffer (concat "*eshell*<" (eshell/pwd) ">") t)) -- cgit 1.4.1-21-gabe81 From 6ad0efeee6cce4fdaa0fd42f79a8273fd7b8ce75 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:04:41 -0500 Subject: Recenter cursor on page after navigating pages --- init.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/init.el b/init.el index c6370a0..6938282 100644 --- a/init.el +++ b/init.el @@ -605,6 +605,13 @@ like a dumbass." (minibuffer-electric-default-mode +1) (fset 'yes-or-no-p #'y-or-n-p)) +(setup page + (defun recenter-to-top (&rest _args) + "Recenter the cursor to the top of the window." + (recenter 0)) + (:advise forward-page :after #'recenter-to-top + backward-page :after #'recenter-to-top)) + (setup prog (:option smie-indent-basic tab-width) -- cgit 1.4.1-21-gabe81 From eabc0680d81c1f30a61acf15da4bdeb07eb5f1f7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:05:02 -0500 Subject: Change {capitalize,upcase,downcase}-word to {}-dwim --- init.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 6938282..bb74a1d 100644 --- a/init.el +++ b/init.el @@ -833,7 +833,9 @@ like a dumbass." (:global "M-=" count-words "C-w" kill-region-or-backward-word " h" nil ; HELLO takes a long time to load on Windows - ) + "M-c" capitalize-dwim + "M-u" upcase-dwim + "M-l" downcase-dwim) ;; (when (display-graphic-p) ;; (:global "" keyboard-escape-quit)) -- cgit 1.4.1-21-gabe81 From c5bf46887872cf884a8ed1975c9d6de3983b5f5f Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:05:26 -0500 Subject: Use consult-rg BEFORE consult-git-grep --- init.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index bb74a1d..8feab77 100644 --- a/init.el +++ b/init.el @@ -899,10 +899,10 @@ like a dumbass." "Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep' if ripgrep is installed, otherwise `consult-grep'." (interactive "P") - (cond ((string-equal (vc-backend buffer-file-name) "Git") - (call-interactively #'consult-git-grep)) - ((executable-find "rg") + (cond ((executable-find "rg") (call-interactively #'consult-ripgrep)) + ((string-equal (vc-backend buffer-file-name) "Git") + (call-interactively #'consult-git-grep)) (t (call-interactively #'consult-grep)))) (defun consult-sensible-find (&optional arg) -- cgit 1.4.1-21-gabe81 From 7936875a2f21a3b0952c732016ab3e0e8a632205 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:05:43 -0500 Subject: Use Orderless Regexp Compiler for consult --- init.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/init.el b/init.el index 8feab77..9aa18a4 100644 --- a/init.el +++ b/init.el @@ -911,6 +911,15 @@ if ripgrep is installed, otherwise `consult-grep'." (cond ((executable-find "locate") (call-interactively #'consult-locate)) (t (call-interactively #'consult-find)))) + ;; Orderless Regexp Compiler! -- from Consult Wiki + (defun consult--orderless-regexp-compiler (input type) + (setq input (orderless-pattern-compiler input)) + (cons + (mapcar (lambda (r) (consult--convert-regexp r type)) input) + (lambda (str) (orderless--highlight input str)))) + + (setq consult--regexp-compiler #'consult--orderless-regexp-compiler) + ;; Bindings (:global ;; C-c bindings (`mode-specific-map') -- cgit 1.4.1-21-gabe81 From b5e070b137fd61cc66278635a3da0b31e6c4ebea Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:06:11 -0500 Subject: Add vertico crm integration I still don't know what crm is.... --- init.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 9aa18a4..79fb0ff 100644 --- a/init.el +++ b/init.el @@ -995,7 +995,16 @@ if ripgrep is installed, otherwise `consult-grep'." (defun crm-indicator (args) (cons (concat "[CRM] " (car args)) (cdr args))) (:advise completing-read-multiple - :filter-args #'crm-indicator))) + :filter-args #'crm-indicator)) + + (with-eval-after-load 'vertico + (with-eval-after-load 'consult + (define-key consult-crm-map "\r" #'+vertico-crm-exit) + (define-key consult-crm-map "\t" #'vertico-exit) + (defun +vertico-crm-exit () + (interactive) + (run-at-time 0 nil #'vertico-exit) + (funcall #'vertico-exit))))) (setup (:straight crux) -- cgit 1.4.1-21-gabe81 From a6793e3e539a624e88189b19cc16421d29f74ad5 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:06:26 -0500 Subject: Remove bind for embark-dwim --- init.el | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/init.el b/init.el index 79fb0ff..c4bf72a 100644 --- a/init.el +++ b/init.el @@ -1060,8 +1060,7 @@ if ripgrep is installed, otherwise `consult-grep'." (require 'gemini-write)))) (setup (:straight embark) - (:global "C-." embark-act - "C-;" embark-dwim) + (:global "C-." embark-act) (:option prefix-help-command #'embark-prefix-help-command (append display-buffer-alist) '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" -- cgit 1.4.1-21-gabe81 From eb46c6a27726d19ff73b536d985db367871a0af9 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:06:46 -0500 Subject: Add lots of orderless stuff --- init.el | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index c4bf72a..b848593 100644 --- a/init.el +++ b/init.el @@ -1236,7 +1236,57 @@ if ripgrep is installed, otherwise `consult-grep'." :host github :repo "oantolin/orderless")) (require 'orderless) - (:option (append completion-styles) 'orderless)) + + (:option (append completion-styles) 'orderless + orderless-component-separator #'orderless-escapable-split-on-space + orderless-style-dispatchers '(acdw/orderless-dispatch)) + + (defun fix-dollar (args) + (if (string-suffix-p "$" (car args)) + (list (concat (substring (car args) 0 -1) "[\x100000-\x10FFFD]*$")) + args)) + (advice-add #'orderless-regexp :filter-args #'fix-dollar) + + (defun acdw/orderless-dispatch (pattern _index _total) + "My custom dispatcher for `orderless'." + (cond + ;; Ensure that $ works with Consult commands, which add disambiguation + ;; suffixes -- see `fix-dollar' + ((string-suffix-p "$" pattern) + `(orderless-regexp . ,(concat (substring pattern 0 -1) + "[\x100000-\x10FFFD]*$"))) + ;; File extensions + ((string-match-p "\\`\\.." pattern) + `(orderless-regexp . ,(concat "\\." (substring pattern 1) + "[\x100000-\x10FFFD]*$"))) + ;; Ignore single ! + ((string= "!" pattern) + `(orderless-literal . "")) + ;; Character folding + ((string-prefix-p "%" pattern) + `(char-fold-to-regexp . ,(substring pattern 1))) + ((string-suffix-p "%" pattern) + `(char-fold-to-regexp . ,(substring pattern 0 -1))) + ;; Without literal + ((string-prefix-p "!" pattern) + `(orderless-without-literal . ,(substring pattern 1))) + ((string-suffix-p "!" pattern) + `(orderless-without-literal . ,(substring pattern 0 -1))) + ;; Initialism matching + ((string-prefix-p "`" pattern) + `(orderless-initialism . ,(substring pattern 1))) + ((string-suffix-p "`" pattern) + `(orderless-initialism . ,(substring pattern 0 -1))) + ;; Literal matching + ((string-prefix-p "=" pattern) + `(orderless-literal . ,(substring pattern 1))) + ((string-suffix-p "=" pattern) + `(orderless-literal . ,(substring pattern 0 -1))) + ;; Flex matching + ((string-prefix-p "~" pattern) + `(orderless-flex . ,(substring pattern 1))) + ((string-suffix-p "~" pattern) + `(orderless-flex . ,(substring pattern 0 -1)))))) (setup (:straight org) (:straight org-contrib) -- cgit 1.4.1-21-gabe81 From 79eb4dce2bc2b9a19f7811036b3c4c3b64cd4336 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:06:57 -0500 Subject: Prefix current candidate in Vertico with ":" --- init.el | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/init.el b/init.el index b848593..31fade2 100644 --- a/init.el +++ b/init.el @@ -1461,16 +1461,15 @@ if ripgrep is installed, otherwise `consult-grep'." (:also-load vertico-mouse) (vertico-mouse-mode +1) - ;; Workarounds! - ;; (with-eval-after-load 'org - ;; (when (version< org-version "9.5") - ;; (defun disable-selection () - ;; (when (eq minibuffer-completion-table #'org-tags-completion-function) - ;; (setq-local vertico-map minibuffer-local-completion-map - ;; completion-cycle-threshold nil - ;; completion-styles '(basic)))) - ;; (advice-add #'vertico--setup :before #'disable-selection))) - ) + ;; Prefix the current candidate with ": ". From Vertico wiki. + (advice-add #'vertico--format-candidate :around + (lambda (orig cand prefix suffix index _start) + (setq cand (funcall orig cand prefix suffix index _start)) + (concat + (if (= vertico--index index) + (propertize ": " 'face 'vertico-current) + " ") + cand)))) (setup (:straight vuiet) (:needs "youtube-dl" -- cgit 1.4.1-21-gabe81 From 1d364a90114f7043ad1d4d6f5ca5832ae53114ab Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 11 Aug 2021 22:52:34 -0500 Subject: Moving help back to C-h and F1 to consult-buffer --- init.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 31fade2..192a040 100644 --- a/init.el +++ b/init.el @@ -841,7 +841,7 @@ like a dumbass." ;; (:global "" keyboard-escape-quit)) ;; Remap C-h to DEL -- can be the "help" key - (define-key key-translation-map [?\C-h] [?\C-?]) + ;; (define-key key-translation-map [?\C-h] [?\C-?]) (:global "C-c t" acdw/insert-iso-date "C-z" nil)) @@ -931,6 +931,7 @@ if ripgrep is installed, otherwise `consult-grep'." ;; C-x bindings (`ctl-x-map') "C-x M-:" consult-complex-command "C-x b" consult-buffer + "" consult-buffer ; trying this out ... "C-x 4 b" consult-buffer-other-window "C-x 5 b" consult-buffer-other-frame ;; Custom M-# bindings for fast register access -- cgit 1.4.1-21-gabe81