From 7d59669752766ca469ceb37d1cfb21fe7e713fff Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 3 Sep 2022 05:30:08 +0100 Subject: attic --- attic/misc.el | 265 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 137 insertions(+), 128 deletions(-) (limited to 'attic') diff --git a/attic/misc.el b/attic/misc.el index f4e73b8..fe6a325 100644 --- a/attic/misc.el +++ b/attic/misc.el @@ -1,4 +1,5 @@ ;;; -*- lexical-binding: t; -*- + ;;; ace window (use-package ace-window :ensure t @@ -28,54 +29,62 @@ ("M-O" . ace-swap-window) ("C-x 4 t" . ace-swap-window))) -;;; sway -(defun jao-swaymsg (msg) - (shell-command (format "swaymsg '%s' >/dev/null" msg))) - -(defmacro jao-def-swaymsg (name msg) - `(defun ,(intern (format "jao-sway-%s" name)) () - (interactive) - (jao-swaymsg ,msg))) -(jao-def-swaymsg firefox "[app_id=firefox] focus") - -(defvar jao-sway-enabled - (and (eq window-system 'pgtk) (not jao-xmonad-enabled))) - -(defun jao-sway-set-wallpaper (f) - (jao-swaymsg (format "output * bg %s fill" f)) - (make-symbolic-link f "~/.wallpaper.sway" t)) - -(defun jao-sway-run-or-focus (cmd &optional ws) - (if (jao-shell-running-p "firefox") - (jao-swaymsg (format "[app_id=%s] focus" cmd)) - (jao-swaymsg (format "workspace %s" (or ws 2))) - (start-process-shell-command cmd nil cmd))) - -(defun jao-sway-run-or-focus-tidal () - (interactive) - (if (jao-shell-running-p "tidal-hifi") - (jao-swaymsg "[app_id=tidal-hifi] scratchpad show") - (start-process-shell-command "tidal-hifi" nil "tidal-hifi &") - (jao-sway-run-or-focus-tidal))) - -(defun jao-sway-run-or-focus-firefox () - (interactive) - (jao-sway-run-or-focus "firefox")) - -(defun jao-sway-enable () - (setq jao-browse-doc-use-emacs-p t) - (setq jao-wallpaper-random-wake nil) - (jao-trisect) - (jao-set-transparency 85) - (jao-themes-setup) - ;; (display-time-mode 1) - (global-set-key (kbd "s-f") #'jao-sway-run-or-focus-firefox) - (defalias 'jao-streaming-list #'jao-sway-run-or-focus-tidal) - (message "Welcome to sway")) - -(when jao-sway-enabled - (defalias 'x-change-window-property #'ignore) - (add-hook 'after-init-hook #'jao-sway-enable)) +;;; deft +(use-package deft + :ensure t + :after jao-org-notes + :commands deft + :init (setq deft-extensions '("org" "md") + deft-directory jao-org-notes-dir + deft-use-filename-as-title nil + deft-use-filter-string-for-name t + deft-file-naming-rules '((noslash . "-") + (nospace . "-") + (case-fn . downcase)) + deft-org-mode-title-prefix t + deft-recursive t + deft-recursive-ignore-dir-regexp (regexp-opt '("." ".." "attic")) + deft-strip-summary-regexp + (concat "\\([\n\t]" + "\\|^#\\+\\(title\\|created\\|date\\|author\\):.*$" + "\\|^#\\+\\(file\\)?tags: *\\)")) + :config (setq deft-strip-title-regexp + (concat "\\(^#\\+title: *\\)\\|" deft-strip-title-regexp)) + :bind (("" . deft))) + +;;; detached +(use-package detached + :ensure t + :init + (detached-init) + :config + (transient-define-prefix jao-transient-detached () + ["Detached sessions" + ("v" "view session output" detached-view-session) + ("a" "attach to a session" detached-attach-session) + ("=" "diff a session with another session" detached-diff-session) + ("c" "open the session output in compilation mode" detached-compile-session) + ("r" "rerun a session" detached-rerun-session) + ("i" "insert the session's command at point" detached-insert-session-command) + ("w" "copy the session's shell command" detached-copy-session-command) + ("W" "copy the session's output" detached-copy-session) + ("k" "kill an active session" detached-kill-session)]) + + :bind (;; Replace `async-shell-command' with `detached-shell-command' + ([remap async-shell-command] . detached-shell-command) + ;; Replace `compile' with `detached-compile' + ([remap compile] . detached-compile) + ([remap recompile] . detached-compile-recompile) + ;; Replace built in completion of sessions with `consult' + ([remap detached-open-session] . detached-consult-session) + ("s-d" . jao-transient-detached)) + :custom ((detached-show-output-on-attach t) + (detached-terminal-data-command system-type))) + +(defun jao-detached-exec (command) + (if (fboundp 'detached-create-session) + (detached-create-session command) + (jao-shell-exec command))) ;;; time display (setq display-time-world-list @@ -123,6 +132,86 @@ (message "%s = %s" v (format-time-string "%Y-%m-%d %H:%M:%S" (seconds-to-time (/ v 1000.0)))))) +;;; mu4e +(jao-load-path "mu4e") +(use-package mu4e + :init + (setq mu4e-attachment-dir (expand-file-name "~/var/download/attachments") + mu4e-change-filenames-when-moving nil + mu4e-completing-read-function 'completing-read + mu4e-display-update-status-in-modeline nil + mu4e-get-mail-command "true" ;; "run-mb.sh || [ $? -eq 1 ]" + mu4e-headers-show-threads t + mu4e-headers-sort-direction 'ascending + mu4e-headers-visible-columns 100 + mu4e-headers-visible-lines 12 + mu4e-hide-index-messages t + mu4e-index-cleanup t ;; don't do a full cleanup check + mu4e-index-lazy-check t ;; don't consider up-to-date dirs + mu4e-maildir "~/var/mail" + mu4e-split-view 'horizontal ;; 'vertical + mu4e-update-interval 300 + mu4e-use-fancy-chars nil + mu4e-user-mail-address-list jao-mails + mu4e-view-show-addresses t + mu4e-view-show-images t + mu4e-maildir-shortcuts '((:maildir "/jao/inbox" :key ?j) + (:maildir "/bigml/inbox" :key ?b)) + jao-mu4e-uninteresting-mail-query + (concat + "flag:unread AND NOT flag:trashed" + " AND NOT (maildir:/bigml/inbox OR maildir:/bigml/bugs OR" + " maildir:/bigml/support OR maildir:/jao/inbox)") + jao-mu4e-interesting-mail-query + (concat + "flag:unread AND NOT flag:trashed" + " AND (maildir:/bigml/inbox OR maildir:/bigml/bugs OR" + " maildir:/bigml/support OR maildir:/jao/inbox)") + mu4e-bookmarks + `((:name "Inbox" :query ,jao-mu4e-interesting-mail-query :key ?i) + (:name "Other messages" + :query ,jao-mu4e-uninteresting-mail-query + :key 117) + (:name "Today's messages" :query "date:today..now" + :key 116) + (:name "Last 7 days" :query "date:7d..now" :hide-unread t + :key 119) + (:name "Messages with PDFs" + :query "mime:application/pdf OR mime:x-application/pdf" + :key 112))) + + :config + (defun jao-mu4e--maildir (msg) + (when msg + (let ((md (mu4e-message-field msg :maildir))) + (when (string-match "/\\([^/]+\\)/.*" md) + (match-string 1 md))))) + + (defun jao-mu4e--refile-folder (name) + (lambda (msg) + (let ((md (jao-mu4e--maildir msg))) + (if (string= md name) + (concat "/jao/" name) + (format "/%s/%s" md name))))) + + (setq mu4e-sent-folder (jao-mu4e--refile-folder "sent")) + (setq mu4e-drafts-folder (jao-mu4e--refile-folder "drafts")) + (setq mu4e-trash-folder (jao-mu4e--refile-folder "trash")) + (setq mu4e-refile-folder (jao-mu4e--refile-folder "trove")) + + (setq mu4e-contexts nil) + + (setq mu4e-view-show-images t) + (when (fboundp 'imagemagick-register-types) + (imagemagick-register-types)) + + (define-key mu4e-view-mode-map [remap mu4e-view-verify-msg-popup] + 'epa-mail-verify) + + ;; View html message in browser (type aV) + (add-to-list 'mu4e-view-actions + '("ViewInBrowser" . mu4e-action-view-in-browser) t)) + ;;; twtxt (use-package twtxt :ensure t @@ -212,86 +301,6 @@ (goto-char (point-min)) (when (re-search-forward "^[Mm]essage-[Ii][Dd]: <]+\\)>?" nil t) (match-string 1)))) -;;; mu4e -(jao-load-path "mu4e") -(use-package mu4e - :init - (setq mu4e-attachment-dir (expand-file-name "~/var/download/attachments") - mu4e-change-filenames-when-moving nil - mu4e-completing-read-function 'completing-read - mu4e-display-update-status-in-modeline nil - mu4e-get-mail-command "true" ;; "run-mb.sh || [ $? -eq 1 ]" - mu4e-headers-show-threads t - mu4e-headers-sort-direction 'ascending - mu4e-headers-visible-columns 100 - mu4e-headers-visible-lines 12 - mu4e-hide-index-messages t - mu4e-index-cleanup t ;; don't do a full cleanup check - mu4e-index-lazy-check t ;; don't consider up-to-date dirs - mu4e-maildir "~/var/mail" - mu4e-split-view 'horizontal ;; 'vertical - mu4e-update-interval 300 - mu4e-use-fancy-chars nil - mu4e-user-mail-address-list jao-mails - mu4e-view-show-addresses t - mu4e-view-show-images t - mu4e-maildir-shortcuts '((:maildir "/jao/inbox" :key ?j) - (:maildir "/bigml/inbox" :key ?b)) - jao-mu4e-uninteresting-mail-query - (concat - "flag:unread AND NOT flag:trashed" - " AND NOT (maildir:/bigml/inbox OR maildir:/bigml/bugs OR" - " maildir:/bigml/support OR maildir:/jao/inbox)") - jao-mu4e-interesting-mail-query - (concat - "flag:unread AND NOT flag:trashed" - " AND (maildir:/bigml/inbox OR maildir:/bigml/bugs OR" - " maildir:/bigml/support OR maildir:/jao/inbox)") - mu4e-bookmarks - `((:name "Inbox" :query ,jao-mu4e-interesting-mail-query :key ?i) - (:name "Other messages" - :query ,jao-mu4e-uninteresting-mail-query - :key 117) - (:name "Today's messages" :query "date:today..now" - :key 116) - (:name "Last 7 days" :query "date:7d..now" :hide-unread t - :key 119) - (:name "Messages with PDFs" - :query "mime:application/pdf OR mime:x-application/pdf" - :key 112))) - - :config - (defun jao-mu4e--maildir (msg) - (when msg - (let ((md (mu4e-message-field msg :maildir))) - (when (string-match "/\\([^/]+\\)/.*" md) - (match-string 1 md))))) - - (defun jao-mu4e--refile-folder (name) - (lambda (msg) - (let ((md (jao-mu4e--maildir msg))) - (if (string= md name) - (concat "/jao/" name) - (format "/%s/%s" md name))))) - - (setq mu4e-sent-folder (jao-mu4e--refile-folder "sent")) - (setq mu4e-drafts-folder (jao-mu4e--refile-folder "drafts")) - (setq mu4e-trash-folder (jao-mu4e--refile-folder "trash")) - (setq mu4e-refile-folder (jao-mu4e--refile-folder "trove")) - - (setq mu4e-contexts nil) - - (setq mu4e-view-show-images t) - (when (fboundp 'imagemagick-register-types) - (imagemagick-register-types)) - - (define-key mu4e-view-mode-map [remap mu4e-view-verify-msg-popup] - 'epa-mail-verify) - - ;; View html message in browser (type aV) - (add-to-list 'mu4e-view-actions - '("ViewInBrowser" . mu4e-action-view-in-browser) t)) - ;;; snippets (defun jao-sway-run-or-focus-tidal () (interactive) -- cgit v1.2.3