diff options
Diffstat (limited to 'attic/elisp/misc.el')
| -rw-r--r-- | attic/elisp/misc.el | 408 |
1 files changed, 403 insertions, 5 deletions
diff --git a/attic/elisp/misc.el b/attic/elisp/misc.el index 6484310..6c295d7 100644 --- a/attic/elisp/misc.el +++ b/attic/elisp/misc.el @@ -813,11 +813,6 @@ :diminish ((disable-mouse-global-mode . ""))) (global-disable-mouse-mode) -;;; tmr -(use-package tmr - :ensure t - :init - (setq tmr-sound-file "/usr/share/sounds/freedesktop/stereo/message.oga")) ;;; pdf-tools (use-package pdf-tools :ensure t @@ -892,6 +887,12 @@ "^\\*Slack - .*? : \\(MPIM: \\)?\\([^ ]+\\)\\( \\(T\\)\\)?.*" "\\2\\4") (jao-define-attached-buffer "\\*Slack .+ Edit Message [0-9].+" 20)) +;;; alert +(use-package alert + :ensure t + :init + (setq alert-default-style 'message ;; 'libnotify + alert-hide-all-notifications nil)) ;;; snippets (defun jao-org-notes-open-tags () "Search for a note file, matching all tags with completion." @@ -949,3 +950,400 @@ 'notmuch-tree-match-author-face 'notmuch-tree-no-match-author-face))) (propertize auth 'face face))) + +;; winttr + +(defun jao-weather (&optional wide) + (interactive "P") + (if (not wide) + (message "%s" + (jao-shell-string "curl -s" + "https://wttr.in/?format=%l++%m++%C+%c+%t+%w++%p")) + (jao-afio-goto-scratch) + (if-let ((b (get-buffer "*wttr*"))) + (progn (pop-to-buffer b) + (term-send-string (get-buffer-process nil) "clear;curl wttr.in\n")) + (jao-exec-in-term "curl wttr.in" "*wttr*")))) +(global-set-key (kbd "<f5>") #'jao-weather) + +;; so-long +(setq large-file-warning-threshold (* 200 1024 1024)) + +(use-package so-long + :ensure t + :diminish) +(global-so-long-mode 1) + +;;;; code reviews +(use-package code-review + :disabled t + :ensure t + :after forge + :bind (:map magit-status-mode-map + ("C-c C-r" . code-review-forge-pr-at-point))) + +;;;; jenkins +(use-package jenkins + :ensure t + :init + ;; one also needs jenkins-api-token, jenkins-username and jenkins-url + ;; optionally: jenkins-colwidth-id, jenkins-colwidth-last-status + (setq jenkins-colwidth-name 35) + :config + (defun jao-jenkins-first-job (&rest _) + (interactive) + (goto-char (point-min)) + (when (re-search-forward "^- Job" nil t) + (goto-char (match-beginning 0)))) + (add-hook 'jenkins-job-view-mode-hook #'jao-jenkins-first-job) + (advice-add 'jenkins-job-render :after #'jao-jenkins-first-job) + + (defun jenkins-refresh-console-output () + (interactive) + (let ((n (buffer-name))) + (when (string-match "\\*jenkins-console-\\([^-]+\\)-\\(.+\\)\\*$" n) + (jenkins-get-console-output (match-string 1 n) (match-string 2 n)) + (goto-char (point-max))))) + + :bind (:map jenkins-job-view-mode-map + (("n" . next-line) + ("p" . previous-line) + ("f" . jao-jenkins-first-job) + ("RET" . jenkins--show-console-output-from-job-screen)) + :map jenkins-console-output-mode-map + (("n" . next-line) + ("p" . previous-line) + ("g" . jenkins-refresh-console-output)))) + +;;; doric themes +(use-package doric-themes + :if (jao-is-darwin) + :ensure t + :demand t + :config + ;; These are the default values. + (setq doric-themes-to-toggle '(doric-light doric-marble)) + (setq doric-themes-to-rotate doric-themes-collection) + + (doric-themes-select 'doric-marble) + + (set-face-attribute 'default nil :family "Triplicate T4c" :height 120) + ;; (set-face-attribute 'default nil :family "0xProto" :height 110) + ;; (set-face-attribute 'default nil :family "Rec Mono Casual" :height 120) + ;; (set-face-attribute 'default nil :family "Rec Mono Linear" :height 120) + ;; (set-face-attribute 'default nil :family "Rec Mono Duotone" :height 120) + ;; (set-face-attribute 'default nil :family "Victor Mono" :height 120) + ;; (set-face-attribute 'variable-pitch nil :family "Aporetic Sans" :height 1.0) + ;; (set-face-attribute 'fixed-pitch nil :family "Aporetic Sans Mono" :height 1.0) + + :bind + (("<f5>" . doric-themes-toggle) + ("C-<f5>" . doric-themes-select) + ("M-<f5>" . doric-themes-rotate))) + +;;; gnuplot +(use-package gnuplot + :disabled t + :ensure t + :commands (gnuplot-mode gnuplot-make-buffer) + :init (add-to-list 'auto-mode-alist '("\\.gp$" . gnuplot-mode))) + +;;; rdrview +;; https://jiewawa.me/2024/04/another-way-of-integrating-mozilla-readability-in-emacs-eww/ +(define-minor-mode eww-rdrview-mode + "Toggle whether to use `rdrview' to make eww buffers more readable." + :lighter " R" + (if eww-rdrview-mode + (progn + (setq eww-retrieve-command '("rdrview" "-T" "title,sitename,body" "-H")) + (add-hook 'eww-after-render-hook #'eww-rdrview-update-title)) + (progn + (setq eww-retrieve-command nil) + (remove-hook 'eww-after-render-hook #'eww-rdrview-update-title)))) + +(defun eww-rdrview-update-title () + "Change title key in `eww-data' with first line of buffer. +It should be the title of the web page as returned by `rdrview'" + (save-excursion + (goto-char (point-min)) + (plist-put eww-data :title (string-trim (thing-at-point 'line t)))) + (eww--after-page-change)) + +(defun eww-rdrview-toggle-and-reload () + "Toggle `eww-rdrview-mode' and reload page in current eww buffer." + (interactive) + (if eww-rdrview-mode (eww-rdrview-mode -1) + (eww-rdrview-mode 1)) + (eww-reload)) + +(defun jao-eww-readable (rdrview) + (interactive "P" eww-mode) + (if rdrview + (eww-rdrview-toggle-and-reload) + (eww-readable))) + +;;; spotify +(jao-load-path "espotify") + +(use-package espotify + :demand t + :init (setq espotify-service-name "mopidy")) + +(use-package consult-spotify :demand t) + +(defalias 'jao-streaming-album #'consult-spotify-album) +(defalias 'jao-streaming-track #'consult-spotify-track) +(defalias 'jao-streaming-artist #'consult-spotify-artist) +(defalias 'jao-streaming-playlist #'consult-spotify-playlist) + +(jao-def-exec-in-term "ncmpcpp" "ncmpcpp" (jao-afio-goto-scratch)) + +;;; spt +(use-package jao-spt + :demand t + :config + (defun jao-spt-setup-aliases () + (setq espotify-play-uri-function #'jao-spt-play-uri) + (defalias 'jao-streaming-list #'jao-term-spt) + (defalias 'jao-streaming-lyrics #'jao-spt-show-lyrics) + (defalias 'jao-streaming-toggle #'jao-spt-toggle) + (defalias 'jao-streaming-next #'jao-spt-next) + (defalias 'jao-streaming-prev #'jao-spt-previous) + (defalias 'jao-streaming-current #'jao-spt-echo-current) + (defalias 'jao-streaming-seek #'jao-spt-seek) + (defalias 'jao-streaming-seek-back #'jao-spt-seek-back) + (defalias 'jao-streaming-volume #'jao-spt-vol) + (defalias 'jao-streaming-volume-down #'jao-spt-vol-down) + (defalias 'jao-streaming-like #'jao-spt-like) + (defalias 'jao-streaming-dislike #'jao-spt-dislike) + (defalias 'jao-streaming-toggle-shuffle #'jao-spt-toggle-shuffle))) + +(jao-def-exec-in-term "spt" "spt" (jao-afio-goto-scratch)) + +(defvar jao-spt-on t) + +(defun jao-streaming-toggle-player () + (interactive) + (if jao-spt-on + (progn (setq jao-mpris-player "playerctld") + (require 'jao-mpris) + (jao-mpris-setup-aliases)) + (jao-spt-setup-aliases) + (setq jao-mpris-player "spt")) + (setq jao-spt-on (not jao-spt-on)) + (message "%s activated " jao-mpris-player)) + +(jao-streaming-toggle-player) + +;;; mpd + mopidy +(use-package jao-mpc + :demand t + :commands jao-mpc-setup) + +(defvar jao-mopidy-port 6669) +(defvar jao-mpc-last-port jao-mpc-port) + +(defun jao-mpc-toggle-port () + (interactive) + (setq jao-mpc-port + (if (equal jao-mpc-port jao-mopidy-port) 6600 jao-mopidy-port) + jao-mpc-last-port jao-mpc-port)) + +(defsubst jao-mpc-mopidy-p () (equal jao-mpc-last-port jao-mopidy-port)) + +(jao-mpc-setup jao-mopidy-port 70) + +(defun jao-mpc-pport (&optional mop) + (cond ((or mop (jao-mpc-playing-p jao-mopidy-port)) jao-mopidy-port) + ((jao-mpc-playing-p) 6600) + (t jao-mpc-last-port))) + +(defmacro jao-defun-play (name &optional mpc-name) + (let ((arg (gensym))) + `(defun ,(intern (format "jao-player-%s" name)) (&optional ,arg) + (interactive "P") + (,(intern (format "jao-mpc-%s" (or mpc-name name))) + (setq jao-mpc-last-port (jao-mpc-pport ,arg)))))) + +(jao-defun-play toggle) +(jao-defun-play next) +(jao-defun-play previous) +(jao-defun-play stop) +(jao-defun-play echo echo-current-times) +(jao-defun-play list show-playlist) +(jao-defun-play info lyrics-track-data) +(jao-defun-play browse show-albums) +(jao-defun-play select-album) + +(defun jao-player-seek (delta) (jao-mpc-seek delta (jao-mpc-pport))) + +(defalias 'jao-player-connect 'jao-mpc-connect) +(defalias 'jao-player-play 'jao-mpc-play) + +;;; Mastodon +(use-package mastodon + :ensure t + :init + (setq mastodon-instance-url "https://mastodon.social" + mastodon-active-user "jao@gnu.org" + mastodon-group-notifications t + mastodon-images-in-notifs t + mastodon-tl-position-after-update nil + mastodon-toot-display-orig-in-reply-buffer t + mastodon-media--hide-sensitive-media nil) + :config + ;; (defun jao-mastodon--setup () + ;; (setq-local scroll-margin 12)) + + ;; (add-hook 'mastodon-mode-hook #'jao-mastodon--setup) + + (with-eval-after-load "ewww" + (define-key eww-mode-map (kbd "T") #'jao-mastodon-toot-url)) + + (defun jao-mastodon-toot-url () + (interactive) + (when-let (url (jao-url-around-point t)) + (jao-tracking-go-to-chats) + (mastodon-toot--compose-buffer nil nil nil url))) + + (defun jao-mastodon () + (interactive) + (jao-afio-goto-chats) + (mastodon)) + + ;; https://0x0.st/XJ14.txt + (jao-transient-major-mode mastodon + ["Timelines" + ("H" "home" mastodon-tl--get-home-timeline) + ("L" "local" mastodon-tl--get-local-timeline) + ("F" "federated" mastodon-tl--get-federated-timeline) + ("K" "bookmarks" mastodon-profile--view-bookmarks) + ("V" "favorites" mastodon-profile--view-favourites) + ("'" "followed tags" mastodon-tl--followed-tags-timeline) + ("@" "mentions" mastodon-notifications--get-mentions) + ("N" "notifications" mastodon-notifications-get) + ("\\" "of remote host" mastodon-tl--get-remote-local-timeline)] + + ;; u mastodon-tl--update + + ["Search" + ("s" "search" mastodon-search--query) + ("#" "tagged" mastodon-tl--get-tag-timeline) + ("\"" "followed tags" mastodon-tl--list-followed-tags) + ("I" "filter" mastodon-views--view-filters) + ("X" "lists" mastodon-views--view-lists)] + + ["Toots" + ("n" "next" mastodon-tl--goto-next-item :transient t) + ("p" "prev" mastodon-tl--goto-prev-item :transient t) + ("c" "spoiler" mastodon-tl--toggle-spoiler-text-in-toot :transient t) + ("T" "thread" mastodon-tl--thread) + ("b" "(un)boost" mastodon-toot--toggle-boost :transient t) + ("f" "(un)fav" mastodon-toot--toggle-favourite :transient t) + ("i" "(un)pin" mastodon-toot--pin-toot-toggle :transient t) + ("k" "(un)bookmark" mastodon-toot--toggle-bookmark :transient t) + ("v" "vote" mastodon-tl--poll-vote)] + + ;; Z mastodon-tl--report-to-mods + ;; o mastodon-toot--open-toot-url + + ["Own Toots" + ("r" "replay" mastodon-toot--reply) + ("t" "write" mastodon-toot) + ("e" "edit" mastodon-toot--edit-toot-at-point) + ("d" "delete" mastodon-toot--delete-toot) + ("D" "del & redraft" mastodon-toot--delete-and-redraft-toot) + ("E" "show edits" mastodon-toot--view-toot-edits)] + + ;; S mastodon-views--view-scheduled-toots + + ["Users" + ("W" "follow" mastodon-tl--follow-user) + ("R" "follow req" mastodon-views--view-follow-requests) + ("G" "suggestions" mastodon-views--view-follow-suggestions) + ("M" "mute user" mastodon-tl--mute-user) + ("B" "block user" mastodon-tl--block-user) + ("m" "message user" mastodon-tl--dm-user) + ;; "" + ;; ("," "favouriters" mastodon-toot--list-toot-favouriters) + ;; ("." "boosters" mastodon-toot--list-toot-boosters) + ] + + ;; S-RET mastodon-tl--unmute-user + ;; C-S-b mastodon-tl--unblock-user + + ["Profiles" + ("A" "author" mastodon-profile--get-toot-author) + ("P" "any user" mastodon-profile--show-user) + ("O" "own" mastodon-profile--my-profile) + ("U" "update own" mastodon-profile--update-user-profile-note)] + + ["Misc" + ("C" "copy URL" mastodon-toot--copy-toot-url) + ("?" "help" describe-mode) + ("q" "quit" transient-quit-one)])) + +;;; org-modern +(use-package org-modern + :ensure t + :init + (setq org-modern-fold-stars + '(("▶" . "▼") ("▷" . "▽") ("▶" . "▼") ("▹" . "▿") ("▸" . "▾"))) + + (define-derived-mode jao-org-inbox-mode org-mode + "Org inbox" + (org-indent-mode) + (org-modern-mode)) + + (add-to-list 'auto-mode-alist '("inbox\\.org\\'" . jao-org-inbox-mode)) + (add-hook 'org-agenda-finalize-hook #'org-modern-agenda)) + +;;; Gnus notify + +(defun jao-gnus--notify-strs () + (let* ((all (jao-gnus--unread-counts)) + (counts (cdr all)) + (labels (seq-keep (lambda (args) + (apply 'jao-gnus--unread-label counts args)) + jao-gnus-tracked-groups))) + (jao-when-darwin (jao-gnus--xbar-echo labels)) + labels)) + +(defvar jao-gnus-tracked-groups + (let ((feeds (thread-first + (directory-files mail-source-directory nil "feeds\\.[^e]") + (seq-difference + '("feeds.trove" "feeds.emacs" "feeds.emacs-devel"))))) + `(("nnml:jao\\.bigml" "B" jao-themes-f00) + ("nnml:jao\\.\\(inbox\\|trove\\)" "I" jao-themes-f01) + ("nnml:jao.write" "W" jao-themes-warning) + ("nnml:jao.[^ithwb]" "J" jao-themes-dimm) + ("nnml:jao.hacking" "H" jao-themes-dimm) + ;; (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm) + ;; ("feeds\\.emacs" "E" jao-themes-dimm) + ("nnml:feeds\\." "F" jao-themes-dimm) + ("nnml:local" "l" jao-themes-dimm) + ("nnrss:.*" "R" jao-themes-dimm) + ("^\\(gwene\\|gmane\\)\\." "N" jao-themes-dimm)))) + +(defun jao-gnus--unread-counts () + (seq-reduce (lambda (r g) + (let ((n (gnus-group-unread (car g)))) + (if (and (numberp n) (> n 0)) + (cons (+ n (car r)) + (cons (cons (car g) n) (cdr r))) + r))) + gnus-newsrc-alist + '(0))) + +(defun jao-gnus-unread-count () + (seq-reduce (lambda (c g) (+ c (or (gnus-group-unread (car g)) 0))) + gnus-newsrc-alist + 0)) + +(defun jao-gnus--unread-label (counts rx label face) + (let ((n (seq-reduce (lambda (n c) + (if (string-match-p rx (car c)) (+ n (cdr c)) n)) + counts + 0))) + (when (> n 0) `(:propertize ,(format "%s%d " label n) face ,face)))) |
