From 4f72e23f72f9712999b8f629a4c62d6f78b65d3b Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 7 Aug 2021 15:05:16 -0500 Subject: Add twitter.com URL handling TODO: This could be smarter, e.g. not going to nitter if twitter.com/t.co is part of the URL query. --- init.el | 1 + lisp/acdw.el | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/init.el b/init.el index f31da5d..a4d8535 100644 --- a/init.el +++ b/init.el @@ -133,6 +133,7 @@ 'browse-url-mpv 'eww-browse-url)) ("google\\.com" . browse-url-default-browser) + ("\\(twitter\\.com\\|t\\.co\\)" . acdw/eww-browse-twitter-url) ("." . eww-browse-url))) ;; Buttonize gemini:// links. diff --git a/lisp/acdw.el b/lisp/acdw.el index 9d8c489..be12dd6 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -497,6 +497,15 @@ Then, build `browse-url-button-regexp' with the new protocol." (add-to-list 'acdw/button-protocols proto) (setq-default browse-url-button-regexp (acdw/build-button-url-regexp))) +;;; Browse-URL tweaks + +;; convert twitter.com to nitter +(defun acdw/eww-browse-twitter-url (url &rest args) + "Browse a Twitter.com URL using Nitter." + (let* ((nitter "nitter.snopyta.org") + (url (replace-regexp-in-string "twitter\\.com" nitter url))) + (eww-browse-url url args))) + ;;; Recentf renaming with dired ;; from ... somewhere. 'rjs', apparently? -- cgit 1.4.1-21-gabe81 From 87bdfcf43a0c39195319168461d69f8e74891193 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 7 Aug 2021 15:06:19 -0500 Subject: Truncate less of ERC nick --- init.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.el b/init.el index a4d8535..afd58ad 100644 --- a/init.el +++ b/init.el @@ -321,7 +321,7 @@ erc-kill-queries-on-quit t erc-kill-server-buffer-on-quit t erc-nick "acdw" - erc-nick-truncate (- erc-fill-static-center 2) + erc-nick-truncate (- erc-fill-static-center 1) erc-prompt (lambda () (acdw-erc/prompt)) erc-prompt-for-password nil ; use ~/.authinfo erc/servers -- cgit 1.4.1-21-gabe81 From 41b48c481471406470268209220019a4c3331a3f Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 7 Aug 2021 15:07:04 -0500 Subject: Add `acdw-org/count-words-stupidly' To count words in an Org-mode buffer, disregarding headings and drawers completely. --- init.el | 3 ++- lisp/acdw-org.el | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index afd58ad..880986a 100644 --- a/init.el +++ b/init.el @@ -1161,7 +1161,8 @@ if ripgrep is installed, otherwise `consult-grep'." "" acdw-org/org-table-copy-down "M-SPC M-SPC" insert-zero-width-space "C-c C-l" org-insert-link-dwim - "M-w" kill-ring-save-unfilled) + "M-w" kill-ring-save-unfilled + "M-=" acdw-org/count-words-stupidly) (with-eval-after-load 'org-export (add-to-list 'org-export-filter-final-output-functions diff --git a/lisp/acdw-org.el b/lisp/acdw-org.el index 41073a9..6a11c4d 100644 --- a/lisp/acdw-org.el +++ b/lisp/acdw-org.el @@ -304,6 +304,42 @@ the deletion might narrow the column." (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) + "Count words between START and END, ignoring a lot." + (interactive (list nil nil)) + (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)) + (forward-line)) + ;; Ignore headings + ((or (org-at-heading-p)) + (forward-line)) + ;; Ignore drawers + ((or (looking-at org-drawer-regexp) + (looking-at org-clock-drawer-re)) + (search-forward ":END:")) + ;; Count everything else + (t (setq words (1+ words)) + (forward-word-strictly)))))) + words)) + ((use-region-p) + (message "%d words in region" + (acdw-org/count-words-stupidly (region-beginning) + (region-end)))) + (t + (message "%d words in buffer" + (acdw-org/count-words-stupidly (point-min) + (point-max)))))) + ;;; Zero-width spaces ;; https://blog.tecosaur.com/tmio/2021-05-31-async.html#easy-zero-width -- cgit 1.4.1-21-gabe81 From f53bc679135fb9bca30fcb5fed57e05042360594 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 7 Aug 2021 15:08:01 -0500 Subject: Change acdw-modeline requirement location --- init.el | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/init.el b/init.el index 880986a..d226d77 100644 --- a/init.el +++ b/init.el @@ -1211,9 +1211,8 @@ if ripgrep is installed, otherwise `consult-grep'." (setup (:straight simple-modeline) (setup (:straight minions)) + (require 'acdw-modeline) (:option - ;; `acdw-org/count-words' is too slow to use in the modeline. - ;; (prepend acdw-modeline/word-count-modes) '(org-mode . acdw-org/count-words) simple-modeline-segments '((acdw-modeline/modified acdw-modeline/buffer-name acdw-modeline/vc-branch @@ -1227,8 +1226,6 @@ if ripgrep is installed, otherwise `consult-grep'." acdw-modeline/winum acdw-modeline/minions simple-modeline-segment-major-mode))) - - (require 'acdw-modeline) (simple-modeline-mode +1)) (setup (:straight sly) -- cgit 1.4.1-21-gabe81 From fbf108217494f9497168b0fe034a2880ec9fe25a Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 7 Aug 2021 15:08:29 -0500 Subject: Turn off ERC modeline when clocked in Less distracting. --- lisp/acdw-modeline.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index ccc07cb..db20b5a 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -32,7 +32,9 @@ (defun acdw-modeline/erc () "ERC indicator for the modeline." - (when (boundp 'erc-modified-channels-object) + (when (and (boundp 'erc-modified-channels-object) + (not (bound-and-true-p org-clock-current-task)) + ) (format-mode-line erc-modified-channels-object))) (defun acdw-modeline/god-mode-indicator () -- cgit 1.4.1-21-gabe81 From 3c7f8650359ce129ab6019f7db7d9d7723428ff7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 7 Aug 2021 15:08:53 -0500 Subject: Add space to word-count modeline Honestly I should make the format a customizable variable. --- lisp/acdw-modeline.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index db20b5a..6131484 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el @@ -118,6 +118,6 @@ Uses `acdw-modeline/word-count-modes' to determine which function to use." #'count-words)) (min (if (region-active-p) (region-beginning) (point-min))) (max (if (region-active-p) (region-end) (point-max)))) - (format "%dW" (funcall fn min max))))) + (format " %dW" (funcall fn min max))))) (provide 'acdw-modeline) -- cgit 1.4.1-21-gabe81