From 3fcbf3a238336621b159f1ffc0e99052315222ff Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 12:38:30 -0500 Subject: Merge two functions doing basically the same thing for Custom buffers --- init.el | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/init.el b/init.el index 69aafac..3fba01e 100644 --- a/init.el +++ b/init.el @@ -174,25 +174,31 @@ custom-unlispify-tag-names nil custom-variable-default-form 'lisp) - (defun unpackaged/custom-toggle-all-more-hide (&rest _) - "Toggle all \"More/Hide\" widgets in current buffer." - (interactive) - (widget-map-buttons (lambda (widget _) - (pcase (widget-get widget :off) - ("More" (widget-apply-action widget))) - nil))) - (advice-add 'custom-buffer-create - :after #'unpackaged/custom-toggle-all-more-hide) - - (defun acdw/custom-toggle-showing-all-values (&rest _) - "Toggle all \"Show Value\" widgets in current buffer." - (interactive) - (widget-map-buttons (lambda (widget _) - (pcase (widget-get widget :off) - ("Show Value" (widget-apply-action widget))) - nil))) - (advice-add 'custom-buffer-create - :after #'acdw/custom-toggle-showing-all-values)) + ;; `Custom-mode-hook' fires /before/ the widgets are built, so I have to + ;; install advice after the widgets are made. + (advice-add + 'custom-buffer-create :after + (defun custom-buffer@expand-widgets (&rest _) + "Expand descriptions and values of variables in `Custom-mode' buffers." + (interactive) + ;; "More/Hide" widgets (thanks alphapapa!) + (widget-map-buttons (lambda (widget _) + (pcase (widget-get widget :off) + ("More" (widget-apply-action widget))) + nil)) + ;; "Show Value" widgets (the little triangles) + (widget-map-buttons (lambda (widget _) + (pcase (widget-get widget :off) + ("Show Value" (widget-apply-action widget))) + nil)))) + + (add-hook ; thanks u/oantolin! + 'Custom-mode-hook + (defun custom-mode@imenu () + "Build `imenu' for `Custom-mode'." + (setq imenu-generic-expression + '(("Faces" "^\\(?:Show\\|Hide\\) \\(.*\\) face: \\[sample\\]" 1) + ("Variables" "^\\(?:Show Value\\|Hide\\) \\([^:\n]*\\)" 1)))))) (setup debugger (:hook visual-line-mode) -- cgit 1.4.1-21-gabe81 From f5e6987d8e12e9d3f8b74f73a44188d0e2e54684 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 12:38:45 -0500 Subject: Remove for consult-buffer --- init.el | 1 - 1 file changed, 1 deletion(-) diff --git a/init.el b/init.el index 3fba01e..5e27421 100644 --- a/init.el +++ b/init.el @@ -943,7 +943,6 @@ 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 From 8d8e56272eded6abff514ab08a8b515e63672561 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 12:39:31 -0500 Subject: Use `unfill' package and delete `kill-ring-save-unfilled' `acdw/copy-region-plain' takes care of what I want it to. --- init.el | 2 ++ lisp/acdw.el | 15 --------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/init.el b/init.el index 5e27421..703dc56 100644 --- a/init.el +++ b/init.el @@ -1466,6 +1466,8 @@ if ripgrep is installed, otherwise `consult-grep'." (global-undo-fu-session-mode +1)) +(setup (:straight unfill)) + (setup (:straight (unfocused :host github :repo "duckwork/unfocused")) diff --git a/lisp/acdw.el b/lisp/acdw.el index eab0719..4c17bcb 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -87,21 +87,6 @@ ARG). When called with multiple arguments or a list, it returns (save-restriction (unfill-region (point-min) (point-max)))))) -(defun kill-ring-save-unfilled (start end &optional region) - "Unfill, kill, then re-fill the region defined by START and END positions. -REGION is passed straight to `kill-ring-save'." - (interactive "*r") - (let ((sentence-end-double-space nil)) - (unfill-region start end) - (kill-ring-save - ;; A quick hack to try and ameliorate the "Args out of range" error when - ;; `unfill-region' removes some newlines. I'm not sure if this will work - ;; if calling from Lisp or other such nonsense. - (max start (point-min)) - (min end (point-max)) - region)) - (fill-region start end)) - (defmacro when-unfocused (name &rest forms) "Define a function NAME, executing FORMS, that fires when Emacs is unfocused." -- cgit 1.4.1-21-gabe81 From 4b3ebd99a0f0a3ea95e2d60c63d8d6f9273922e0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 12:40:52 -0500 Subject: Implement `with-eval-after-loads' macro --- init.el | 26 ++++++++++++-------------- lisp/acdw.el | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/init.el b/init.el index 703dc56..4209a6b 100644 --- a/init.el +++ b/init.el @@ -1009,15 +1009,14 @@ if ripgrep is installed, otherwise `consult-grep'." (:advise completing-read-multiple :filter-args #'crm-indicator)) - (with-eval-after-load 'vertico - (with-eval-after-load 'consult - (when (boundp 'consult-crm-map) - (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)))))) + (with-eval-after-loads (vertico consult) + (when (boundp 'consult-crm-map) + (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) @@ -1089,11 +1088,10 @@ if ripgrep is installed, otherwise `consult-grep'." #'which-key--hide-popup-ignore-command) embark-become-indicator embark-action-indicator) - (with-eval-after-load 'embark - (with-eval-after-load 'consult - (setup (:straight embark-consult) - (add-hook 'embark-collect-mode-hook - #'consult-preview-at-point-mode))))) + (with-eval-after-loads (embark consult) + (setup (:straight embark-consult) + (add-hook 'embark-collect-mode-hook + #'consult-preview-at-point-mode)))) (setup (:straight epithet) (add-hook 'Info-selection-hook #'epithet-rename-buffer) diff --git a/lisp/acdw.el b/lisp/acdw.el index 4c17bcb..2aa6c1f 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -108,6 +108,22 @@ is unfocused." ,@body) (message "%s... Done." ,message))) +(defmacro with-eval-after-loads (files &rest body) + "Execute BODY after FILES are loaded. +This macro simplifies `with-eval-after-load' for multiple nested +features." + (declare (indent 1) (debug (form def-body))) + (waterfall-list 'with-eval-after-load files body)) + +(defun waterfall-list (car list rest) + "Cons CAR with each element in LIST in a waterfall fashion, end with REST. +For use with the `with-eval-after-loads' function." + (cond ((atom list) `(,car ',list ,@rest)) + ((= 1 (length list)) `(,car ',(car list) ,@rest)) + (t + `(,car ',(car list) + ,(waterfall-list car (cdr list) rest))))) + ;;; Comment-or-uncomment-sexp ;; from https://endlessparentheses.com/a-comment-or-uncomment-sexp-command.html -- cgit 1.4.1-21-gabe81 From 9c2fd2848f0d28f57341428c0f2804ef0c2ee73b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 17:21:39 -0500 Subject: Remove comments --- init.el | 6 ------ 1 file changed, 6 deletions(-) diff --git a/init.el b/init.el index 4209a6b..0fddc6e 100644 --- a/init.el +++ b/init.el @@ -849,12 +849,6 @@ like a dumbass." "M-u" upcase-dwim "M-l" downcase-dwim) - ;; (when (display-graphic-p) - ;; (:global "" keyboard-escape-quit)) - - ;; Remap C-h to DEL -- can be the "help" key - ;; (define-key key-translation-map [?\C-h] [?\C-?]) - (:global "C-c t" acdw/insert-iso-date "C-z" nil)) -- cgit 1.4.1-21-gabe81 From 19462a9e3c43612f886ebd907e39419f86b4b662 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 18:00:02 -0500 Subject: Require `request' with `mastodon' --- init.el | 1 + 1 file changed, 1 insertion(+) diff --git a/init.el b/init.el index 0fddc6e..b959e9e 100644 --- a/init.el +++ b/init.el @@ -1196,6 +1196,7 @@ if ripgrep is installed, otherwise `consult-grep'." (setup (:straight (mastodon :host github :repo "mooseyboots/mastodon.el")) + (:straight request) (:option mastodon-instance-url "https://writing.exchange" mastodon-auth-source-file (car auth-sources) mastodon-client--token-file (acdw/dir "mastodon.plstore"))) -- cgit 1.4.1-21-gabe81 From 7cc1e86114bfe1127f8b4698583e36162c77748b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 14 Aug 2021 18:00:12 -0500 Subject: Merge `acdw-org/count-words' and `acdw-org/count-words-stupidly' I kept the second name, because really, it is a stupid function. --- lisp/acdw-org.el | 97 +++++++++++++++++--------------------------------------- 1 file changed, 29 insertions(+), 68 deletions(-) diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 189ac67..f8f23c6 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -243,74 +243,13 @@ the deletion might narrow the column." (org-table-copy-down n) (acdw-org/return-dwim n))) -(defun acdw-org/count-words (start end) - "Count words between START and END, respecting `org-mode' conventions." - (interactive (list nil nil)) - (require 'cl-lib) - (require 'ox) - (message "Counting words...") - (cond ((not (called-interactively-p 'any)) - (let ((words 0)) - (save-excursion - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (while (< (point) (point-max)) - (cond - ;; Ignore comments - ((or (org-at-comment-p) - (org-in-commented-heading-p)) nil) - ;; Ignore tables - ((org-at-table-p) nil) - ;; Ignore hyperlinks, but count the descriptions - ((looking-at org-bracket-link-analytic-regexp) - (when-let ((desc (match-string-no-properties 5))) - (save-match-data - (setq words (+ words - (length (remove "" - (org-split-string - desc "\\W"))))))) - (goto-char (match-end 0))) - ;; Ignore source code blocks - ((org-in-src-block-p) nil) - ;; Ignore footnotes - ((or (org-footnote-at-definition-p) - (org-footnote-at-reference-p)) - nil) - ;; else... check the context - (t (let ((contexts (org-context))) - (cond - ;; Ignore tags, TODO keywords, etc. - ((or (assoc :todo-keyword contexts) - (assoc :priority contexts) - (assoc :keyword contexts) - (assoc :checkbox contexts)) - nil) - ;; Ignore sections tagged :no-export - ((assoc :tags contexts) - (if (cl-intersection (org-get-tags-at) - org-export-exclude-tags - :test 'equal) - (org-forward-same-level 1) - nil)) - ;; else... count the word - (t (setq words (1+ words))))))) - (re-search-forward "\\w+\\W*"))) - words))) - ((use-region-p) - (message "%d words in region" - (acdw-org/count-words (region-beginning) (region-end)))) - (t - (message "%d words in buffer" - (acdw-org/count-words (point-min) (point-max)))))) - ;; This isn't the best code, but it'll do. (defun acdw-org/count-words-stupidly (start end &optional limit) "Count words between START and END, ignoring a lot. Since this function is, for some reason, pricy, the optional parameter LIMIT sets a word limit at which to stop counting. -Once the function hits that number, it'll return \"-LIMIT\" +Once the function hits that number, it'll return -LIMIT instead of the true count." (interactive (list nil nil)) (cond ((not (called-interactively-p 'any)) @@ -334,13 +273,35 @@ instead of the true count." ((or (looking-at org-drawer-regexp) (looking-at org-clock-drawer-re)) (search-forward ":END:" nil :noerror)) + ;; Ignore tables + ((org-at-table-p) (forward-line)) + ;; Ignore hyperlinks, but count the descriptions + ((looking-at org-bracket-link-analytic-regexp) + (when-let ((desc (match-string-no-properties 5))) + (save-match-data + (setq words (+ words + (length (remove "" + (org-split-string + desc "\\W"))))))) + (goto-char (match-end 0))) + ;; Ignore source blocks + ((org-in-src-block-p) (foreward-line)) ;; Count everything else - (t (setq words (1+ words)) - (if (and limit - (> words limit)) - (setq words limit - continue nil)) - (forward-word-strictly)))))) + (t + ;; ... unless it's in a few weird contexts + (let ((contexts (org-context))) + (cond ((or (assoc :todo-keyword contexts) + (assoc :priority contexts) + (assoc :keyword contexts) + (assoc :checkbox contexts)) + (forward-word-strictly)) + + (t (setq words (1+ words)) + (if (and limit + (> words limit)) + (setq words (- limit) + continue nil)) + (forward-word-strictly))))))))) words)) ((use-region-p) (message "%d words in region" -- cgit 1.4.1-21-gabe81 From c46149516f2499b7b7ca8a1424ebc4d1eabeeea9 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 15 Aug 2021 21:10:13 -0500 Subject: Change straight repo --- init.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.el b/init.el index b959e9e..edaf420 100644 --- a/init.el +++ b/init.el @@ -19,7 +19,7 @@ ;;; Setup ;;;; `setup' -(straight-use-package '(setup :host nil :repo "https://git.sr.ht/~zge/setup")) +(straight-use-package '(setup :host nil :repo "https://git.sr.ht/~pkal/setup")) (require 'setup) (setup setup -- cgit 1.4.1-21-gabe81 From 7dcb7e8ce0767b676fd9527c66e3bbe72247f731 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 15 Aug 2021 21:10:32 -0500 Subject: Move erc-hide-list to erc-track-exclude-types --- init.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index edaf420..9857b51 100644 --- a/init.el +++ b/init.el @@ -343,8 +343,7 @@ erc-fill-static-center 14 erc-format-nick-function #'erc-format-truncate-@nick erc-header-line-face-method #'erc/update-header-line-show-disconnected - erc-hide-list '("NICK" "MODE" "JOIN" "NICK" "PART" "QUIT" - "324" "329" "332" "333" "353" "477") + erc-hide-list '("NICK" "MODE" "JOIN" "PART" "QUIT") erc-interpret-controls-p t erc-interpret-mirc-color t erc-join-buffer 'bury @@ -362,7 +361,8 @@ (mapcar #'car erc-autojoin-channels-alist)) erc-server-coding-system '(utf-8 . utf-8) erc-track-exclude-types (append erc-hide-list - '("AWAY")) + '("AWAY" + "353" "324" "329" "332" "333" "477")) erc-track-exclude-server-buffer t erc-track-position-in-mode-line 'before-modes erc-track-visibility nil ; only the selected frame -- cgit 1.4.1-21-gabe81 From c9bcd38f9c4691ba6ad3d28af26f44a15a15cadd Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 15 Aug 2021 21:10:48 -0500 Subject: Um-lambdafy a variable --- init.el | 69 ++++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/init.el b/init.el index 9857b51..fdf3543 100644 --- a/init.el +++ b/init.el @@ -352,7 +352,7 @@ erc-kill-server-buffer-on-quit t erc-nick "acdw" erc-nick-truncate (- erc-fill-static-center 1) - erc-prompt (lambda () (acdw-erc/prompt)) + erc-prompt #'acdw-erc/prompt erc-prompt-for-password nil ; use ~/.authinfo erc-rename-buffers t erc-server erc-default-server @@ -1297,35 +1297,39 @@ if ripgrep is installed, otherwise `consult-grep'." (setup (:straight org) (:straight org-contrib) (require 'acdw-org) ; so I don't clutter up init.el - (:option org-adapt-indentation nil - org-catch-invisible-edits 'smart - org-clock-clocked-in-display 'mode-line - org-clock-string-limit 7 ; gives time and not title - org-confirm-babel-evaluate nil - org-ellipsis " …" - org-export-coding-system 'utf-8-unix - org-export-headline-levels 8 - org-export-with-section-numbers nil - org-export-with-smart-quotes t - org-export-with-sub-superscripts t - org-export-with-toc nil - org-fontify-done-headline t - org-fontify-quote-and-verse-blocks t - org-fontify-whole-heading-line t - org-hide-emphasis-markers t - org-html-coding-system 'utf-8-unix - org-imenu-depth 3 - org-outline-path-complete-in-steps nil - org-pretty-entities t - org-refile-use-outline-path 'file - org-special-ctrl-a/e t - org-special-ctrl-k t - org-src-fontify-natively t - org-src-tab-acts-natively t - org-src-window-setup 'current-window - org-startup-truncated nil - org-tags-column 0 ; (- 0 fill-column -3) - org-directory "~/org") + (:option + org-adapt-indentation nil + org-catch-invisible-edits 'smart + org-clock-clocked-in-display 'mode-line + org-clock-string-limit 7 ; gives time and not title + org-confirm-babel-evaluate nil + org-directory "~/org" + org-ellipsis " …" + org-export-coding-system 'utf-8-unix + org-export-headline-levels 8 + org-export-with-section-numbers nil + org-export-with-smart-quotes t + org-export-with-sub-superscripts t + org-export-with-toc nil + org-fontify-done-headline t + org-fontify-quote-and-verse-blocks t + org-fontify-whole-heading-line t + org-hide-emphasis-markers t + org-html-coding-system 'utf-8-unix + org-image-actual-width '(300) + org-imenu-depth 3 + org-outline-path-complete-in-steps nil + org-pretty-entities t + org-refile-use-outline-path 'file + org-special-ctrl-a/e t + org-special-ctrl-k t + org-src-fontify-natively t + org-src-tab-acts-natively t + org-src-window-setup 'current-window + org-startup-truncated nil + org-startup-with-inline-images t + org-tags-column 0 ; (- 0 fill-column -3) + ) (:bind "RET" acdw-org/return-dwim "" acdw-org/org-table-copy-down @@ -1344,7 +1348,10 @@ if ripgrep is installed, otherwise `consult-grep'." acdw/org-fix-lines-before-save) (advice-add 'org-delete-backward-char - :override #'acdw-org/delete-backward-char)) + :override #'acdw-org/delete-backward-char) + + (setup (:straight org-appear) + (:hook-into org-mode))) (setup (:straight paredit) -- cgit 1.4.1-21-gabe81