From b11adad984e8160e366d7e154d12c378a9545b9a Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 13 Dec 2021 10:29:50 -0600 Subject: Lots of changes, most interestingly browse-url stuff --- init.el | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 109 insertions(+), 24 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index e0cf8ae..5d756cd 100644 --- a/init.el +++ b/init.el @@ -25,8 +25,7 @@ ;; necessary for good functioning. In this block, I add extra ;; things or more "experimental" ones that might not belong in a ;; separate file. - (:global "M-o" 'other-buffer - "C-x C-k" 'kill-this-buffer) + (:global "C-x C-k" 'kill-this-buffer) ;; 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-?)) @@ -39,7 +38,7 @@ (:hook '+init-add-setup-to-imenu)) (setup (:require +key) - (+key-global-mode +1)) + (+key-setup)) (setup (:require auth-source) (:option auth-sources (list (private/ "authinfo") @@ -51,7 +50,8 @@ (:also-load +pulse) (:option pulse-flag nil pulse-delay 0.5 - pulse-iterations 1) + pulse-iterations 1 + (append +pulse-location-commands) 'lui-track-jump-to-indicator) (+pulse-location-mode +1)) (setup calendar @@ -168,7 +168,7 @@ (setup (:straight anzu) (:option anzu-cons-mode-line-p nil) (:+key [remap query-replace] 'anzu-query-replace-regexp - [remap query-replace-regexp] 'anzu-query-replace-regexp) + [remap query-replace-regexp] 'anzu-query-replace-regexp) (global-anzu-mode +1) (:bind-into isearch [remap isearch-query-replace] @@ -206,8 +206,8 @@ (circadian-setup)) (setup (:straight circe) - (:require _circe) - (:require +circe) + (:require _circe + +circe) (autoload '+irc "+circe" "Connect to IRC." t) ;; Formatting options @@ -315,7 +315,7 @@ ("C-M-#" . consult-register) ;; Other custom bindings ("M-y" . consult-yank-pop) - (" a" . consult-apropos) + (" a" . consult-apropos) ;; M-g bindings (goto-map) ("M-g e" . consult-compile-error) ("M-g f" . consult-flymake) ; or consult-flycheck @@ -339,7 +339,7 @@ ("M-s u" . consult-focus-lines) ;; Isearch integration ("M-s e" . consult-isearch-history))) - (global-set-key (kbd (car binding)) (cdr binding))) + (define-key +key-mode-map (kbd (car binding)) (cdr binding))) (with-eval-after-load 'isearch-mode (dolist (binding '(("M-e" . consult-isearch-history) ("M-s e" . consult-isearch-history) @@ -370,8 +370,8 @@ (setup (:straight crux) (:+key "C-o" 'crux-smart-open-line - "M-o" 'crux-other-window-or-switch-buffer - "C-x 4 t" 'crux-transpose-windows) + "M-o" 'crux-other-window-or-switch-buffer + "C-x 4 t" 'crux-transpose-windows) (el-patch-feature crux) (with-eval-after-load 'crux @@ -419,8 +419,8 @@ See also `crux-reopen-as-root-mode'." (setup (:straight embark) (:option prefix-help-command 'embark-prefix-help-command) (:+key "C-." 'embark-act - "M-." 'embark-dwim - " B" 'embark-bindings)) + "M-." 'embark-dwim + " B" 'embark-bindings)) (setup (:straight embark-consult) (:load-after consult embark) @@ -461,10 +461,12 @@ See also `crux-reopen-as-root-mode'." (gcmh-mode +1)) (setup (:straight helpful) - (:+key " f" 'helpful-callable - " v" 'helpful-variable - " k" 'helpful-key - "C-c C-d" 'helpful-at-point)) + (run-with-idle-timer 0.5 nil + 'require 'helpful) + (:+key " f" 'helpful-callable + " v" 'helpful-variable + " k" 'helpful-key + "C-c C-d" 'helpful-at-point)) (setup (:straight (hippie-completing-read :host github @@ -531,7 +533,7 @@ See also `crux-reopen-as-root-mode'." (setup (:straight mwim) (:+key "C-a" #'mwim-beginning - "C-e" #'mwim-end)) + "C-e" #'mwim-end)) (setup (:straight orderless) (:option completion-styles '(orderless))) @@ -589,6 +591,7 @@ See also `crux-reopen-as-root-mode'." org-log-into-drawer t org-outline-path-complete-in-steps nil org-pretty-entities t + org-pretty-entities-include-sub-superscripts nil org-refile-use-outline-path 'file org-special-ctrl-a/e t org-special-ctrl-k t @@ -666,6 +669,7 @@ See also `crux-reopen-as-root-mode'." +modeline-vc simple-modeline-segment-misc-info simple-modeline-segment-process + +modeline-text-scale +modeline-narrowed +modeline-minions +modeline-major-mode))) @@ -719,7 +723,7 @@ See also `crux-reopen-as-root-mode'." (setup (:straight undo-fu) (:+key "C-/" #'undo-fu-only-undo - "C-?" #'undo-fu-only-redo)) + "C-?" #'undo-fu-only-redo)) (setup (:straight undo-fu-session) (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" @@ -730,7 +734,8 @@ See also `crux-reopen-as-root-mode'." (setup (:straight (unfill :host github :repo "purcell/unfill" :fork (:host github :repo "duckwork/unfill"))) - (:+key "M-q" #'unfill-toggle)) + (:bind-into text-mode + "M-q" #'unfill-toggle)) (setup (:straight (vertico :host github @@ -765,7 +770,87 @@ See also `crux-reopen-as-root-mode'." (setup (:straight zzz-to-char) (:+key "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))))) + "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))))) + +(setup (:straight elfeed) + (:also-load +elfeed) + (:option elfeed-use-curl t + elfeed-curl-extra-arguments '("--insecure") + elfeed-show-unique-buffers t + elfeed-db-directory (sync/ "elfeed/db/" t)) + (:with-mode elfeed-show-mode + (:bind "SPC" '+elfeed-scroll-up-command + "S-SPC" '+elfeed-scroll-down-command))) + +(setup (:straight elfeed-org) + (:option rmh-elfeed-org-files (list (sync/ "elfeed/elfeed.org" t))) + (elfeed-org)) + +(setup (:straight (lin :host gitlab :repo "protesilaos/lin")) + (require 'lin) + (:hook-into dired-mode + elfeed-search-mode + git-rebase-mode + ibuffer-mode + ledger-report-mode + log-view-mode + magit-log-mode + notmuch-search-mode + notmuch-tree-mode + org-agenda-mode + tabulated-list-mode)) + + +(setup browse-url + (:also-load +browse-url) + (:option browse-url-secondary-browser-function (if (executable-find "firefox") + 'browse-url-firefox + 'browse-url-default-browser) + browse-url-new-window-flag nil + browse-url-firefox-arguments '("--new-tab") + browse-url-firefox-new-window-is-tab t) + ;; Set up URL handlers. + (+browse-url-set-handlers + (list + (cons (rx ; images + "." (or "jpeg" "jpg" "png") eos) + (lambda (&rest args) + (apply + (cond ((executable-find "feh") '+browse-url-with-feh) + ((executable-find "mpv") '+browse-image-with-mpv) + (t 'eww-browse-url)) + args))) + (cons (rx ; videos + (or "youtube.com" "youtu.be" "yewtu.be" + (seq "." (or "mp4" "gif" "mov" "MOV") eos))) + (lambda (&rest args) + (apply (if (executable-find "mpv") + 'browse-url-mpv + browse-url-secondary-browser-function) + args))) + (cons (rx ; non-eww-friendly websites + (or + "github.com" + "gitlab.com" + "google.com" + "imgur.com" + "pixelfed" + "reddit.com" + "taskiq" + "twitter.com" + )) + browse-url-secondary-browser-function) + (cons "." ; everything else + 'eww-browse-url))) + ;; Transform URLs before passing to `browse-url' + (:option +browse-url-transformations `((,(rx "//" (or "youtube.com" + "youtu.be")) + . "//yewtu.be"))) + (+browse-url-transform-url-global-mode +1)) + +(setup (:straight-when pdf-tools + (eq system-type 'gnu/linux)) + (pdf-tools-install)) -- cgit 1.4.1-21-gabe81