summaryrefslogtreecommitdiffhomepage
path: root/attic
diff options
context:
space:
mode:
Diffstat (limited to 'attic')
-rw-r--r--attic/elisp/jao-maildir.el4
-rw-r--r--attic/elisp/jao-notmuch-gnus.el16
-rw-r--r--attic/elisp/misc.el372
-rw-r--r--attic/elisp/nnnm.el16
4 files changed, 383 insertions, 25 deletions
diff --git a/attic/elisp/jao-maildir.el b/attic/elisp/jao-maildir.el
index 18a1725..3078a95 100644
--- a/attic/elisp/jao-maildir.el
+++ b/attic/elisp/jao-maildir.el
@@ -90,8 +90,8 @@
0))
(defun jao-maildir--update-track-string (mbox)
- (when-let ((track (seq-find (lambda (td) (string-match-p (car td) mbox))
- jao-maildir--trackers)))
+ (when-let* ((track (seq-find (lambda (td) (string-match-p (car td) mbox))
+ jao-maildir--trackers)))
(let* ((label (cadr track))
(other (assoc-delete-all label jao-maildir--track-strings))
(cnt (jao-maildir--tracked-count track)))
diff --git a/attic/elisp/jao-notmuch-gnus.el b/attic/elisp/jao-notmuch-gnus.el
index 1576964..20defba 100644
--- a/attic/elisp/jao-notmuch-gnus.el
+++ b/attic/elisp/jao-notmuch-gnus.el
@@ -62,7 +62,7 @@
(defun jao-notmuch-gnus-show-tags ()
"Display in the echo area the tags of the current message."
(interactive)
- (when-let (id (jao-notmuch-gnus-message-id))
+ (when-let* ((id (jao-notmuch-gnus-message-id)))
(message "%s" (string-join (jao-notmuch-gnus-message-tags id) " "))))
(defun jao-notmuch-gnus-toggle-tags (tags &optional id current)
@@ -77,7 +77,7 @@
(defun jao-notmuch-gnus-tag-mark ()
"Remove the new tag for an article when it's marked as seen by Gnus."
- (when-let (id (jao-notmuch-gnus-message-id t))
+ (when-let* ((id (jao-notmuch-gnus-message-id t)))
(jao-notmuch-gnus-tag-message id '("-new") t)))
(add-hook 'gnus-mark-article-hook #'jao-notmuch-gnus-tag-mark)
@@ -189,12 +189,12 @@ Example:
(org-gnus-follow-link group id)))
(defun jao-notmuch-gnus-org-store ()
- (when-let (d (or (when (derived-mode-p 'notmuch-show-mode 'notmuch-tree-mode)
- (cons (notmuch-show-get-message-id)
- (notmuch-show-get-subject)))
- (when (derived-mode-p 'gnus-summary-mode 'gnus-article-mode)
- (cons (jao-notmuch-gnus-message-id)
- (gnus-summary-article-subject)))))
+ (when-let* ((d (or (when (derived-mode-p 'notmuch-show-mode 'notmuch-tree-mode)
+ (cons (notmuch-show-get-message-id)
+ (notmuch-show-get-subject)))
+ (when (derived-mode-p 'gnus-summary-mode 'gnus-article-mode)
+ (cons (jao-notmuch-gnus-message-id)
+ (gnus-summary-article-subject))))))
(org-link-store-props :type "mail"
:link (concat "mail:" (car d))
:description (concat "Mail: " (cdr d)))))
diff --git a/attic/elisp/misc.el b/attic/elisp/misc.el
index 2f1bcb0..c2a6bd3 100644
--- a/attic/elisp/misc.el
+++ b/attic/elisp/misc.el
@@ -600,7 +600,7 @@
;;; eldoc for magit status/log buffers
(defun jao-magit-eldoc-for-commit (_callback)
- (when-let ((commit (magit-commit-at-point)))
+ (when-let* ((commit (magit-commit-at-point)))
(with-temp-buffer
(magit-git-insert "show"
"--format=format:%an <%ae>, %ar"
@@ -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
@@ -908,7 +903,7 @@
(res (funcall fn)))
(while (and res tags) (setq res (seq-intersection res (funcall fn))))
(unless res (user-error "No notes found"))
- (when-let (f (completing-read "Select file: " (mapcar #'car res)))
+ (when-let* ((f (completing-read "Select file: " (mapcar #'car res))))
(find-file (cadr (assoc f res))))))
(defun jao-sway-run-or-focus-tidal ()
@@ -955,3 +950,366 @@
'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)
+
+;;; 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))))
+
+;;; ement
+(use-package ement
+ :disabled t
+ :ensure t
+ :init (setq ement-save-sessions t
+ ement-sessions-file (locate-user-emacs-file "cache/ement.el")
+ ement-room-avatars nil
+ ement-notify-dbus-p nil
+ ement-room-left-margin-width 0
+ ement-room-right-margin-width 11
+ ement-room-timestamp-format "%H:%M"
+ ement-room-timestamp-header-format "­­--------")
+
+ :custom ((ement-room-message-format-spec "(%S) %B%r%R %t"))
+
+ :config
+ (defun jao-ement-track (event room session)
+ (when (ement-notify--room-unread-p event room session)
+ (when-let* ((n (ement-room--buffer-name room))
+ (b (get-buffer n)))
+ (tracking-add-buffer b))))
+
+ (add-hook 'ement-event-hook #'jao-ement-track)
+ (jao-shorten-modes 'ement-room-mode)
+ (jao-tracking-cleaner "^\\*Ement Room: \\(.+\\)\\*" "@\\1"))
+
+;;;; lsp
+(use-package lsp-mode
+ :disabled t
+ ;; :ensure t
+ :commands lsp
+ :custom
+ ;; what to use when checking on-save. "check" is default, I prefer clippy
+ (lsp-rust-analyzer-cargo-watch-command "clippy")
+ (lsp-eldoc-render-all t)
+ (lsp-idle-delay 0.6)
+ ;; enable / disable the hints as you prefer:
+ (lsp-inlay-hint-enable t)
+ ;; These are optional configurations. See https://emacs-lsp.github.io/lsp-mode/page/lsp-rust-analyzer/#lsp-rust-analyzer-display-chaining-hints for a full list
+ (lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
+ (lsp-rust-analyzer-display-chaining-hints nil)
+ (lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
+ (lsp-rust-analyzer-display-closure-return-type-hints t)
+ (lsp-rust-analyzer-display-parameter-hints nil)
+ (lsp-rust-analyzer-display-reborrow-hints nil)
+ :config
+ (add-hook 'lsp-mode-hook 'lsp-ui-mode))
+
+(use-package lsp-ui
+ :disabled t
+ ;; :ensure t
+ :commands lsp-ui-mode
+ :custom
+ (lsp-ui-peek-always-show t)
+ (lsp-ui-sideline-show-hover t)
+ (lsp-ui-doc-enable t))
+;;; xbar
+(defvar jao-notmuch-xbar-queries
+ `((:name "" :query "tag:new and not tag:draft" :face jao-themes-f00)
+ (:name "i" :query "tag:new and tag:/inbox|write|drivel/"
+ :face jao-themes-warning)))
+
+(defvar jao-notmuch-mac-xbar t)
+
+(defun jao-notmuch-xbar ()
+ (let ((cnts (notmuch-hello-query-counts jao-notmuch-xbar-queries)))
+ (jao-shell-exec (format "echo '%s | color=#8b3626 | size=11' >/tmp/xbar"
+ (mapconcat 'jao-notmuch--qstr cnts " ")))))
diff --git a/attic/elisp/nnnm.el b/attic/elisp/nnnm.el
index 552e95c..561c09e 100644
--- a/attic/elisp/nnnm.el
+++ b/attic/elisp/nnnm.el
@@ -1,6 +1,6 @@
;;; nnnm.el --- Gnus backend for notmuch -*- lexical-binding: t; -*-
-;; Copyright (C) 2021 jao
+;; Copyright (C) 2021, 2026 jao
;; Author: jao <mail@jao.io>
;; Keywords: mail
@@ -47,8 +47,8 @@
(defun nnnm--find-query (name)
- (when-let (s (seq-find (lambda (s) (string= (plist-get s :name) name))
- nnnm-saved-searches))
+ (when-let* ((s (seq-find (lambda (s) (string= (plist-get s :name) name))
+ nnnm-saved-searches)))
(plist-get s :query)))
(defun nnnm--find-message-file (id)
@@ -60,11 +60,11 @@
(defun nnnm--article-data (article group)
(cond ((stringp article) (list article))
((numberp article)
- (when-let (data (nnnm--group-data group))
+ (when-let* ((data (nnnm--group-data group)))
(elt data (1- article))))))
(defun nnnm-article-to-file (article group)
- (when-let (d (nnnm--article-data article group))
+ (when-let* ((d (nnnm--article-data article group)))
(or (cadr d) (nnnm--find-message-file (car d)))))
(defun nnnm--count (query &optional context)
@@ -117,7 +117,7 @@
(gnus-set-active (nnnm--prefixed group server) (cons 1 n)))
(defun nnnm--update-group-data (group &optional server)
- (when-let (query (nnnm--find-query group))
+ (when-let* ((query (nnnm--find-query group)))
(let* ((data (or (nnnm--group-data group)
(mapcar #'list (nnnm--search query "NOT tag:new"))))
(ids (nnnm--search query "tag:new"))
@@ -158,7 +158,7 @@
(with-current-buffer nntp-server-buffer
(erase-buffer)
(dolist (s nnnm-saved-searches)
- (when-let (query (plist-get s :query))
+ (when-let* ((query (plist-get s :query)))
(let ((name (plist-get s :name))
(total (nnnm--count query)))
(insert (format "%s %d 1 y\n" name total))))))
@@ -173,7 +173,7 @@
(if (stringp (car sequence))
'headers
(dolist (article sequence)
- (when-let (file (nnnm-article-to-file article group))
+ (when-let* ((file (nnnm-article-to-file article group)))
(insert (format "221 %d Article retrieved.\n" article))
(save-excursion (nnheader-insert-head file))
(if (re-search-forward "\n\r?\n" nil t)