diff options
author | bd <bdunahu@operationnull.com> | 2024-10-27 21:11:19 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2024-10-27 21:11:19 -0400 |
commit | 05791ee8b63f37513fb1eaf1dcef77de5227994d (patch) | |
tree | 90c2c3838945b91f7ce26821b1f3d0d5a83db12c /.config/emacs/modules | |
parent | 70507e97d5a5523c2667638f09208d47fdbcf670 (diff) |
read desc: browsing+bookmarking interface, remove popper, no work...
browsing+bookmarking interface, remove popper, no workspaces only tabs, custom password-store, exwm use window title, colonq selector, theme changes
Diffstat (limited to '.config/emacs/modules')
-rw-r--r-- | .config/emacs/modules/bd--browse.el | 58 | ||||
-rw-r--r-- | .config/emacs/modules/bd--essentials.el | 15 | ||||
-rw-r--r-- | .config/emacs/modules/bd--exwm-windowing.el | 92 | ||||
-rw-r--r-- | .config/emacs/modules/bd--files.el | 21 | ||||
-rw-r--r-- | .config/emacs/modules/bd--gpg.el | 73 | ||||
-rw-r--r-- | .config/emacs/modules/bd--minibuffer.el | 8 | ||||
-rw-r--r-- | .config/emacs/modules/bd--shells.el | 4 | ||||
-rw-r--r-- | .config/emacs/modules/bd--tabs.el | 3 | ||||
-rw-r--r-- | .config/emacs/modules/bd--themes.el | 11 | ||||
-rw-r--r-- | .config/emacs/modules/bd--windows.el | 42 |
10 files changed, 170 insertions, 157 deletions
diff --git a/.config/emacs/modules/bd--browse.el b/.config/emacs/modules/bd--browse.el index 1dd5b4a..83bf0a2 100644 --- a/.config/emacs/modules/bd--browse.el +++ b/.config/emacs/modules/bd--browse.el @@ -2,10 +2,60 @@ ;;; Commentary: ;;; Code: +(require 'selector) +(require 'dash) -;; do not use an external browser -(setopt browse-url-browser-function 'eww-browse-url - shr-use-fonts t +(defvar bd/bookmarks nil) ;; in secret file +;;;; searching +(defun bd/browse (url &optional pref &rest _) + "Given PREF, launches URL in one of librewolf, torbrowser, +icecat, or eww." + (interactive) + (pcase pref + (0 (eww url)) + (1 (start-process "icecat" nil "icecat" "--new-window" url)) + (2 (start-process "torbrowser" nil "torbrowser" "--new-window" url)) + (_ (start-process "librewolf" nil "librewolf" "--new-window" url)))) +(setopt browse-url-browser-function 'bd/browse) + +(defun bd/selector-bookmarks () + (selector-source-create + "Bookmarks" + :candidates + (-map + (lambda (b) (selector-candidate-create (car b) :value (cdr b))) + bd/bookmarks) + :actions + (list (lambda (x) (apply #'bd/browse x))))) + +(defmacro bd/search-candidate (name url pref) + `(selector-candidate-create + ,(concat "Search " name) + :type 'dummy + :action (lambda (_) (browse-url (concat ,url (selector-input)) ,pref)))) + +(defun bd/selector-search () + (selector-source-create + "Browser" + :candidates + (list (bd/search-candidate "DuckDuckGo" "https://www.duckduckgo.com/?q=" 3) + (bd/search-candidate "Wikipedia" "https://en.wikipedia.org/w/index.php?search=" 3) + (bd/search-candidate "Invidious" "https://yewtu.be/search?q=" 0) + (bd/search-candidate "Urban Dictionary" "https://www.urbandictionary.com/define.php?term=" 1) + (bd/search-candidate "Archwiki" "https://wiki.archlinux.org/index.php?title=Special%3ASearch&search=" 1) + (bd/search-candidate "Web" "" 3)))) + +(defun bd/visit-bookmark () + "Select and `browse-url' a bookmark." + (interactive) + (unwind-protect + (selector + (list (bd/selector-bookmarks) + (bd/selector-search))))) + + +;;;; eww +(setopt shr-use-fonts t shr-cookie-policy nil shr-max-width 85 ;; send only user agent @@ -16,7 +66,7 @@ "youtube.com" "youtu.be")) browse-url-handlers - `((,(regexp-opt'("youtube.com" "youtu.be")) . + `((,(regexp-opt '("youtube.com" "youtu.be")) . (lambda (url &rest _) (message "Ludu %s" url) (start-process-shell-command "rip-video" nil (concat "rip-video " url)))))) diff --git a/.config/emacs/modules/bd--essentials.el b/.config/emacs/modules/bd--essentials.el index 04fc3a2..e8ea502 100644 --- a/.config/emacs/modules/bd--essentials.el +++ b/.config/emacs/modules/bd--essentials.el @@ -30,21 +30,6 @@ (advice-add command :after #'pulse-line)) -;;;; insecure passwording -(use-package pinentry - :config - (pinentry-start) - :custom - (pinentry-popup-prompt-window nil)) - -(defun pinentry-toggle () - "Stops and starts Pinentry service. Workaround -for a bug I've encountered." - (interactive) - (pinentry-stop) - (pinentry-start)) - - ;;;; defaults ;; basic editing (setopt kill-whole-line t diff --git a/.config/emacs/modules/bd--exwm-windowing.el b/.config/emacs/modules/bd--exwm-windowing.el index 1dc5056..ab5b243 100644 --- a/.config/emacs/modules/bd--exwm-windowing.el +++ b/.config/emacs/modules/bd--exwm-windowing.el @@ -19,68 +19,20 @@ (desktop-environment-volume-increment-slowly "+2%") (desktop-environment-volume-toggle-regexp nil)) - -(defun bd/exwm-update-class () - "Changes the buffer name to reflect the class name for -that buffer." - (exwm-workspace-rename-buffer exwm-class-name)) - -(defun bd/exwm-init-hook () - "Make workspace 1 the default startup workspace." - (exwm-workspace-switch-create 1)) - - -;;;; bookmarks, passwords -(defun insert-bookmark () - "Inserts a url or string from permanent -bookmark file. If an x window, place in kill-ring." - ;; note xdotool had issues with repeated keys when sending to windowid - (interactive) - (let ((url (car (last (split-string (choose-line-from-file "~/.local/bin/bookmarks.txt")))))) - (if (exwm--buffer->id (current-buffer)) - (kill-new url) - (insert url)))) - -(defun choose-line-from-file (file) - "Uses completion-framework to allow user to -select a line from a file." - (let* ((choices (read-file-into-list file))) - (completing-read "Recall: " choices))) - -(defun read-file-into-list (file) - (with-current-buffer - (find-file-noselect file) - (split-string - (save-restriction - (widen) - (buffer-substring-no-properties - (point-min) - (point-max))) - "\n" t))) - -(use-package password-store - :custom - (password-store-time-before-clipboard-restore 20)) - (use-package exwm :config - (add-hook 'exwm-init-hook #'bd/exwm-init-hook) - (add-hook 'exwm-update-class-hook #'bd/exwm-update-class) - ;; order is important - ;; (dolist (k '(("s-B" "icecat"))) - ;; (let ((f (lambda () (interactive) - ;; (save-window-excursion - ;; (start-process-shell-command (cadr k) nil (cadr k)))))) - ;; (exwm-input-set-key (kbd (car k)) f) - ;; (define-key exwm-mode-map (kbd (car k)) f))) + (defun bd/exwm-update-title () + "Changes the buffer name to reflect the class name for +that buffer." + (exwm-workspace-rename-buffer exwm-title)) + (add-hook 'exwm-update-title-hook #'bd/exwm-update-title) (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key) (exwm-enable) (server-start) :custom - (exwm-workspace-number 2) ;; two workspaces (exwm-input-prefix-keys - '(?\C-x + `(?\C-x ?\C-u ?\C-g ?\C-h @@ -90,9 +42,11 @@ select a line from a file." ?\M-` ?\M-& ?\M-: - )) + ,@(mapcar (lambda (i) + (kbd (concat "s-" (number-to-string i)))) + (number-sequence 0 9)))) (exwm-input-global-keys - `(([?\s-n] . other-window) + '(([?\s-n] . other-window) ([?\s-p] . (lambda () (interactive) (other-window -1))) @@ -107,20 +61,14 @@ select a line from a file." ([f10] . emms-next) ([print] . desktop-environment-screenshot-part) ([S-print] . desktop-environment-screenshot) - ([?\s-O] . insert-bookmark) - ([?\s-P] . password-store-copy) + ([?\s-O] . bd/visit-bookmark) + ([?\s-P] . bd/password) ([?\s-r] . exwm-reset) ([?\s-d] . toggle-current-window-dedication) ([?\s-q] . kill-current-buffer) ([?\s-x] . (lambda (command) (interactive (list (read-shell-command "s-x "))) - (start-process-shell-command command nil command))) - ,@(mapcar (lambda (i) - `(,(kbd (format "s-%d" i)) . - (lambda () - (interactive) - (exwm-workspace-switch-create ,i)))) - (number-sequence 0 9)))) + (start-process-shell-command command nil command))))) (exwm-input-simulation-keys '(([?\C-b] . [left]) ([?\C-f] . [right]) @@ -133,10 +81,12 @@ select a line from a file." ([?\C-d] . [delete]) ([?\C-k] . [S-end delete]) ([?\M-w] . [C-c]) - ([?\C-y] . [C-v]))) + ([?\C-y] . [C-v]) + ([?\M-d] . [C-delete]) + ([?\M-b] . [C-left]) + ([?\M-f] . [C-right])))) - (exwm-workspace-show-all-buffers t) - (exwm-layout-show-all-buffers t)) +(setopt tab-bar-select-tab-modifiers '(super)) (defvar new-mode-line nil) (defun set-new-mode-line () @@ -145,9 +95,9 @@ select a line from a file." (replace-regexp-in-string "%" "%%" (format " %s %s %s" - (shell-command-to-string "mail-string") - (shell-command-to-string "power-string") - (shell-command-to-string "t1-string"))))) + (shell-command-to-string "/home/bdunahu/.local/bin/mail-string 2>/dev/null") + (shell-command-to-string "/home/bdunahu/.local/bin/power-string 2>/dev/null") + (shell-command-to-string "/home/bdunahu/.local/bin/t1-string 2>/dev/null"))))) (defvar-local bd/external-mode-line '(:eval (when new-mode-line diff --git a/.config/emacs/modules/bd--files.el b/.config/emacs/modules/bd--files.el index b8a5f4a..6ea121b 100644 --- a/.config/emacs/modules/bd--files.el +++ b/.config/emacs/modules/bd--files.el @@ -3,14 +3,15 @@ ;;; Code: +(require 'recentf) (defmacro bd/defun-find-file-wrapper (name types open-f) `(defun ,name (f &rest args) "Wrapper around F (find-file), passing ARGS." (if (string-match (regexp-opt ,types) (or (file-name-extension (car args)) "")) - (progn - (,(eval open-f) (car args)) - (recentf-add-file (car args)) - nil) + (progn + (,(eval open-f) (car args)) + (recentf-add-file (car args)) + nil) (apply f args)))) ;;;; dired @@ -39,8 +40,8 @@ (start-process (concat "zathura (" (file-name-base file) ")") nil "zathura" (expand-file-name file))) (bd/defun-find-file-wrapper bd/pdf-find-file-wrapper - '("epub" "pdf") - #'bd/zathura) + '("epub" "pdf") + #'bd/zathura) (advice-add 'find-file :around #'bd/pdf-find-file-wrapper) ;; video @@ -50,8 +51,8 @@ (bd/defun-find-file-wrapper bd/video-find-file-wrapper - '("mkv" "mov" "mp4" "webm" "m4v" "wav" "mp3" "opus" "ogv" "flac") - #'bd/mpv) + '("mkv" "mov" "mp4" "webm" "m4v" "wav" "mp3" "opus" "ogv" "flac") + #'bd/mpv) (advice-add 'find-file :around 'bd/video-find-file-wrapper) ;; image @@ -59,8 +60,8 @@ "Open FILE with nsxiv" (start-process (concat "nsxiv (" (file-name-base file) ")") nil "nsxiv" (expand-file-name file))) (bd/defun-find-file-wrapper bd/image-find-file-wrapper - '("jpg" "jpeg" "png" "webp" "bmp" "ico" "gif" "JPG" "PNG") - #'bd/nsxiv) + '("jpg" "jpeg" "png" "webp" "bmp" "ico" "gif" "JPG" "PNG") + #'bd/nsxiv) (advice-add 'find-file :around 'bd/image-find-file-wrapper) diff --git a/.config/emacs/modules/bd--gpg.el b/.config/emacs/modules/bd--gpg.el new file mode 100644 index 0000000..f3d55cb --- /dev/null +++ b/.config/emacs/modules/bd--gpg.el @@ -0,0 +1,73 @@ +;;; -*- lexical-binding: t; -*- +;;; Commentary: +;;; Code: + + +(require 'f) + +(defvar bd/password-store-kill-ring-pointer nil + "The tail of the kill ring whose car is the password.") +(defvar bd/password-store-time-before-clear 10 + "The time before a killed password is cleared.") + +;;;; passwords +(defun bd/password-store-list () + "List password-store entries." + (mapcar (lambda (file) + (f-no-ext (f-relative file "~/.password-store/"))) + (f-files "~/.password-store" (lambda (file) (equal (f-ext file) "gpg")) t))) + +(defun bd/password-store-clear (id) + "Clears the most recent password copied to the kill ring." + (when bd/password-store-kill-ring-pointer + (setcar bd/password-store-kill-ring-pointer nil) + (kill-new "") + (setq bd/password-store-kill-ring-pointer nil) + (message "Cleared password for %s from the kill ring and system clipboard." id))) + +(defun bd/read-password (id) + "Read the password-store entry corresponding to ID." + (bd/password-store-clear "id") + (let ((find-file-hook (remq 'recentf-track-opened-file find-file-hook))) + (find-file (concat "~/.password-store/" id ".gpg")) + (goto-char 1) + (kill-new (buffer-substring-no-properties (line-beginning-position) (line-end-position))) + (setq bd/password-store-kill-ring-pointer kill-ring-yank-pointer) + (kill-buffer (current-buffer)) + (run-at-time bd/password-store-time-before-clear nil + (lambda () (funcall #'bd/password-store-clear id))) + (message "Copied password for %s to the kill ring and system clipboard. Will clear in %s seconds." + id bd/password-store-time-before-clear))) + +(defun bd/selector-passwords () + "Selector source for password-store passwords." + (selector-source-create + "Passwords" + :candidates + (bd/password-store-list) + :actions + (list #'bd/read-password))) + +(defun bd/password () + "Interactively select a password-store password." + (interactive) + (selector (list (bd/selector-passwords)))) + +;; pinentry +(use-package pinentry + :config + (pinentry-start) + :custom + (enable-recursive-minibuffers t) + (pinentry-popup-prompt-window nil)) + +(defun pinentry-toggle () + "Stops and starts Pinentry service. Workaround +for a bug I've encountered." + (interactive) + (pinentry-stop) + (pinentry-start)) + + +(provide 'bd--gpg) +;;; bd-gpg ends here diff --git a/.config/emacs/modules/bd--minibuffer.el b/.config/emacs/modules/bd--minibuffer.el index 66dffa5..02451bb 100644 --- a/.config/emacs/modules/bd--minibuffer.el +++ b/.config/emacs/modules/bd--minibuffer.el @@ -6,13 +6,9 @@ (setopt use-short-answers t vc-follow-symlinks t completion-ignore-case t - read-buffer-completion-ignore-case t - ;; required for exwm (pass) but - ;; always useful - enable-recursive-minibuffers t) + read-buffer-completion-ignore-case t) (minibuffer-depth-indicate-mode 1) - (use-package vertico :init (vertico-mode) @@ -43,7 +39,7 @@ ("H-s G" . consult-git-grep) ("H-s r" . consult-ripgrep) ("H-s l" . consult-line) - ("H-s i" . consult-info) + ("H-s i" . consult-info) ("H-s L" . consult-line-multi) ("H-s k" . consult-keep-lines) ("H-s u" . consult-focus-lines))) diff --git a/.config/emacs/modules/bd--shells.el b/.config/emacs/modules/bd--shells.el index dbb2f25..0bc41e2 100644 --- a/.config/emacs/modules/bd--shells.el +++ b/.config/emacs/modules/bd--shells.el @@ -44,6 +44,10 @@ clear the scrollback contents. Outputs banner message." (unless eshell-non-interactive-p (eval eshell-banner-message))))) +(defun eshell/open (file) + (interactive) + (find-file file)) + ;;;; shell (require 'shell) diff --git a/.config/emacs/modules/bd--tabs.el b/.config/emacs/modules/bd--tabs.el index 3ef18d8..f8ceab1 100644 --- a/.config/emacs/modules/bd--tabs.el +++ b/.config/emacs/modules/bd--tabs.el @@ -32,8 +32,7 @@ tab-bar-auto-width-max nil) ;;;; add useless text elements -(setopt tab-bar-tab-hints nil - tab-bar-select-tab-modifiers '(meta)) +(setopt tab-bar-tab-hints nil) (defun bd/tab-bar-name-function () (concat (tab-bar-tab-name-current) diff --git a/.config/emacs/modules/bd--themes.el b/.config/emacs/modules/bd--themes.el index 9f7f404..220b181 100644 --- a/.config/emacs/modules/bd--themes.el +++ b/.config/emacs/modules/bd--themes.el @@ -48,21 +48,18 @@ to.") (ef-themes-to-toggle '(ef-autumn ef-frost)) (ef-themes-common-palette-overrides - '((bg-mode-line bg-main) - (fg-mode-line fg-main) - (bg-dim bg-main) + '((bg-dim bg-main) (bg-alt bg-main) (bg-tab-bar bg-main) - (bg-tab-current bg-main) + (bg-tab-current bg-mode-line) (bg-tab-other bg-inactive))) - (ef-winter-palette-overrides - '((bg-main "#000000"))) (ef-bio-palette-overrides '((bg-main "#000000"))) (ef-autumn-palette-overrides '((bg-main "#000000")))) -(load-theme 'ef-autumn :no-confirm) +(load-theme 'ef-winter :no-confirm) + (provide 'bd--themes) ;;; bd-themes ends here diff --git a/.config/emacs/modules/bd--windows.el b/.config/emacs/modules/bd--windows.el index 5a338bf..282ca14 100644 --- a/.config/emacs/modules/bd--windows.el +++ b/.config/emacs/modules/bd--windows.el @@ -52,48 +52,6 @@ Due to a bug with guix-packaged emacs, only uses true-transparency on wayland." (add-to-list 'default-frame-alist '(alpha . (82 . 82)))) -(require 'project) -;;;; popper -(use-package popper - :demand t - :bind (("C-`" . 'popper-toggle-latest) - ("M-`" . 'popper-cycle) - ("C-M-`" . popper-toggle-type)) - :config - (popper-mode) - (popper-echo-mode) - :custom - (popper-reference-buffers - '( - ;; native - ("\\*Async Shell Command\\*.*" . hide) - compilation-mode - completion-list-mode - messages-buffer-mode - occur-mode - ("Output\\*$" . hide) - ;; info - help-mode - Info-mode - "^\\*slime-description.*\\*$" - ;; repls - geiser-repl-mode - slime-repl-mode - ;; shells - "^\\*eshell.*\\*$" eshell-mode - "^\\*shell.*\\*$" shell-mode - "^\\*term.*\\*$" term-mode - ;; magit - magit-diff-mode - magit-status-mode - ;; emms - emms-playlist-mode - )) - (popper-display-control 'nil) - (popper-mode-line nil) - (popper-group-function #'popper-group-by-project)) - - ;;;; shackle (use-package shackle :demand t |