summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--attic/elisp/jao-notmuch-gnus.el226
-rw-r--r--attic/elisp/misc.el352
-rwxr-xr-xbin/notmuch-delete.sh6
-rwxr-xr-xbin/notmuch-gnus-tags.sh20
-rwxr-xr-xbin/notmuch-tags.sh109
-rw-r--r--custom/jao-custom-blog.el74
-rw-r--r--custom/jao-custom-browse.el200
-rw-r--r--custom/jao-custom-chats.el242
-rw-r--r--custom/jao-custom-completion.el7
-rw-r--r--custom/jao-custom-email.el33
-rw-r--r--custom/jao-custom-eww.el63
-rw-r--r--custom/jao-custom-exwm.el9
-rw-r--r--custom/jao-custom-gnus.el286
-rw-r--r--custom/jao-custom-mac.el22
-rw-r--r--custom/jao-custom-multimedia.el119
-rw-r--r--custom/jao-custom-notmuch.el134
-rw-r--r--custom/jao-custom-org.el82
-rw-r--r--custom/jao-custom-pdf.el83
-rw-r--r--custom/jao-custom-programming.el522
-rw-r--r--custom/jao-custom-shells.el6
-rw-r--r--custom/jao-custom-w3m.el2
-rw-r--r--custom/jao-custom-x11.el192
-rw-r--r--init.el2489
-rw-r--r--lib/doc/jao-doc-session.el29
-rw-r--r--lib/doc/jao-mac.el206
-rw-r--r--lib/doc/jao-org-focus.el120
-rw-r--r--lib/doc/jao-org-links.el6
-rw-r--r--lib/doc/jao-org-notes.el20
-rw-r--r--lib/doc/jao-pdf.el68
-rw-r--r--lib/eos/jao-afio.el21
-rw-r--r--lib/eos/jao-dirmon.el11
-rw-r--r--lib/eos/jao-minibuffer.el61
-rw-r--r--lib/eos/jao-mode-line.el23
-rw-r--r--lib/eos/jao-notify.el31
-rw-r--r--lib/eos/jao-r2e.el228
-rw-r--r--lib/jao-recoll.el76
-rw-r--r--lib/media/jao-mpc.el42
-rw-r--r--lib/media/jao-mpris.el32
-rw-r--r--lib/net/jao-eww-session.el19
-rw-r--r--lib/net/jao-notmuch-gnus.el28
-rw-r--r--lib/net/jao-notmuch.el8
-rw-r--r--lib/net/jao-url.el36
-rw-r--r--lib/net/randomsig.el9
-rw-r--r--lib/prog/jao-clojure.el186
-rw-r--r--lib/prog/jao-compilation.el4
-rw-r--r--lib/themes/jao-light-theme.el22
-rw-r--r--lib/themes/jao-themes.el38
48 files changed, 4213 insertions, 2390 deletions
diff --git a/.gitignore b/.gitignore
index 1800081..c86436b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,5 @@
/lib/media/espotify-embark.el
/lib/media/espotify.el
/site
-/bin/
/lib/net/signel.el
/lib/net/signel.shell
diff --git a/attic/elisp/jao-notmuch-gnus.el b/attic/elisp/jao-notmuch-gnus.el
new file mode 100644
index 0000000..1576964
--- /dev/null
+++ b/attic/elisp/jao-notmuch-gnus.el
@@ -0,0 +1,226 @@
+;;; jao-notmuch-gnus.el --- notmuch-gnus interoperability -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022 jao
+
+;; Author: jao <mail@jao.io>
+;; Keywords: mail
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Helper functions to work in Gnus with mail indexed by notmuch.
+
+;;; Code:
+
+(require 'gnus)
+(require 'ol-gnus)
+(require 'notmuch-show)
+
+;;; Tagging in notmuch from Gnus buffers
+
+(defun jao-notmuch-gnus--notmuch-id (id)
+ (when id (if (string-match "<\\(.+\\)>" id) (match-string 1 id) id)))
+
+(defun jao-notmuch-gnus-message-id (&optional no-show)
+ "Find the id of currently selected message in Gnus or notmuch."
+ (when (and (not no-show) (derived-mode-p 'gnus-summary-mode))
+ (save-window-excursion (gnus-summary-show-article)))
+ (cond (gnus-original-article-buffer
+ (with-current-buffer gnus-original-article-buffer
+ (jao-notmuch-gnus--notmuch-id (message-field-value "message-id"))))
+ ((derived-mode-p 'notmuch-show-mode 'notmuch-tree-mode)
+ (notmuch-show-get-message-id))))
+
+(defun jao-notmuch-gnus-message-tags (id)
+ "Ask notmuch for the tags of a message with the given ID."
+ (let ((cmd (format "notmuch search --output=tags 'id:%s'" id)))
+ (split-string (shell-command-to-string cmd))))
+
+(defun jao-notmuch-gnus-tag-message (&optional id tags no-log)
+ "Interactively add or remove tags to the current message."
+ (interactive)
+ (let* ((id (or id (jao-notmuch-gnus-message-id)))
+ (current (unless tags (jao-notmuch-gnus-message-tags id)))
+ (prompt (format "Change tags %s" (string-join current "/")))
+ (tags (or tags (notmuch-read-tag-changes current prompt))))
+ (notmuch-tag (concat "id:" id) tags)
+ (unless no-log
+ (message "%s -> %s" current (jao-notmuch-gnus-message-tags id)))))
+
+(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))
+ (message "%s" (string-join (jao-notmuch-gnus-message-tags id) " "))))
+
+(defun jao-notmuch-gnus-toggle-tags (tags &optional id current)
+ "Toggle the given TAGS list for the current Gnus message."
+ (let* ((id (or id (jao-notmuch-gnus-message-id)))
+ (current (or current (jao-notmuch-gnus-message-tags id)))
+ (tags (mapcar (lambda (x)
+ (concat (if (member x current) "-" "+") x))
+ tags)))
+ (notmuch-tag (concat "id:" id) tags)
+ (message "New tags: %s" (jao-notmuch-gnus-message-tags id))))
+
+(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))
+ (jao-notmuch-gnus-tag-message id '("-new") t)))
+
+(add-hook 'gnus-mark-article-hook #'jao-notmuch-gnus-tag-mark)
+
+(defun jao-notmuch-gnus--group-tags (group)
+ (when (string-match ".+:\\(.+\\)" group)
+ (split-string (match-string 1 group) "\\.")))
+
+(defun jao-notmuch-gnus-tag-on-move (op headers from to _d)
+ (when-let* ((to-tags (when to (jao-notmuch-gnus--group-tags to)))
+ (id (jao-notmuch-gnus--notmuch-id (mail-header-id headers))))
+ (if (eq op 'delete)
+ (let ((cur (seq-difference (jao-notmuch-gnus--group-tags from) to-tags)))
+ (jao-notmuch-gnus-toggle-tags (append cur to-tags) id cur))
+ (notmuch-tag (concat "id:" id)
+ (mapcar (lambda (x) (concat "+" x)) to-tags)))))
+
+(defun jao-notmuch-gnus-auto-tag ()
+ (add-hook 'gnus-summary-article-move-hook #'jao-notmuch-gnus-tag-on-move)
+ (add-hook 'gnus-summary-article-expire-hook #'jao-notmuch-gnus-tag-on-move))
+
+;;; Gnus search using notmuch
+
+(add-to-list 'gnus-search-expandable-keys "list")
+
+(cl-defmethod gnus-search-transform-expression ((engine gnus-search-notmuch)
+ (expr (head list)))
+ (format "List:%s" (gnus-search-transform-expression engine (cdr expr))))
+
+
+;;; Displaying search results in Gnus
+
+(defvar jao-notmuch-gnus-server "nnml"
+ "Name of the target Gnus server, e.g. nnml+mail.")
+
+(defvar jao-notmuch-gnus-mail-directory (expand-file-name "~/.emacs.d/gnus/Mail")
+ "Directory where Gnus stores its mail.")
+
+(defvar jao-notmuch-gnus-leafnode-directory (expand-file-name "~/var/news")
+ "Directory where leafnode stores its messages as seen by notmuch.")
+
+(defun jao-notmuch-gnus-file-to-group (file &optional maildir newsdir)
+ "Compute the Gnus group name from the given file name.
+Example:
+
+ IN: /home/jao/var/mail/jao/foo/cur/1259184569.M4818P3384.localhost,W=6921:2,S
+ OUT: nnml:jao.foo
+
+ IN: /home/jao/.emacs.d/gnus/Mail/jao.trove/32, /home/jao/.emacs.d/gnus/Mail/
+ OUT: nnml:jao.trove
+
+ IN: /home/jao/var/mail/gmane/foo/bar/100
+ OUT: nntp:gmane.foo.bar
+
+ IN: /home/jao/var/mail/bigml/cur/1259176906.M17483P24679.localhost,W=2488:2,S
+ OUT:nnimap:bigml/inbox"
+ (let* ((maildir (or maildir jao-notmuch-gnus-mail-directory))
+ (newsdir (or newsdir jao-notmuch-gnus-leafnode-directory))
+ (g (directory-file-name (file-name-directory file)))
+ (g (replace-regexp-in-string (file-name-as-directory maildir) "" g))
+ (g (replace-regexp-in-string (file-name-as-directory newsdir) "" g))
+ (nntp (string-match-p "^\\(gmane\\|gwene\\)/" g))
+ (g (cond (nntp (concat "nntp:" g))
+ ((file-name-directory g)
+ (replace-regexp-in-string "^\\([^/]+\\)/"
+ (concat jao-notmuch-gnus-server
+ ":\\1/")
+ (file-name-directory g) t))
+ (t (concat jao-notmuch-gnus-server ":" g))))
+ (g (replace-regexp-in-string "/" "." g))
+ (g (replace-regexp-in-string "[/.]$" "" g)))
+ (cond ((string-match ":$" g) (concat g "inbox"))
+ (nntp g)
+ (t (replace-regexp-in-string ":\\." ":" g)))))
+
+(defun jao-notmuch-gnus-id-to-file (id)
+ (when id
+ (let ((cmd (format "notmuch search --output=files %s" id)))
+ (string-trim (shell-command-to-string cmd)))))
+
+(defun jao-notmuch-gnus-goto-message (&optional msg-id filename)
+ "Open a summary buffer containing the current notmuch article."
+ (interactive)
+ (let* ((filename (or filename
+ (jao-notmuch-gnus-id-to-file msg-id)
+ (notmuch-show-get-filename)))
+ (group (when filename (jao-notmuch-gnus-file-to-group filename)))
+ (msg-id (or msg-id (notmuch-show-get-message-id)))
+ (msg-id (when msg-id (replace-regexp-in-string "^id:" "" msg-id))))
+ (if (and group msg-id)
+ (org-gnus-follow-link group msg-id)
+ (message "Couldn't get relevant infos for switching to Gnus."))))
+
+(defun jao-notmuch-gnus-engine (prefix config)
+ (let ((prefix (file-name-as-directory (expand-file-name prefix "~")))
+ (config (expand-file-name config gnus-home-directory)))
+ `(gnus-search-engine gnus-search-notmuch
+ (remove-prefix ,prefix)
+ (config-file ,config))))
+
+;;; Org links
+(defun jao-notmuch-gnus--fname (id)
+ (let ((cmd (format "notmuch search --output=files id:%s" id)))
+ (car (split-string (shell-command-to-string cmd)))))
+
+(defun jao-notmuch-gnus-org-follow (id)
+ (when-let* ((fname (jao-notmuch-gnus--fname id))
+ (group (jao-notmuch-gnus-file-to-group fname)))
+ (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)))))
+ (org-link-store-props :type "mail"
+ :link (concat "mail:" (car d))
+ :description (concat "Mail: " (cdr d)))))
+
+(org-link-set-parameters "mail"
+ :follow #'jao-notmuch-gnus-org-follow
+ :store #'jao-notmuch-gnus-org-store)
+
+(org-link-set-parameters "gnus" :store #'ignore)
+(org-link-set-parameters "notmuch" :store #'ignore)
+
+;;; consult-notmuch
+
+(with-eval-after-load "consult-notmuch"
+ (defun jao-notmuch-gnus--open-candidate (candidate)
+ "Open a notmuch-search completion candidate email in Gnus."
+ (message "candidate: %S" candidate)
+ (jao-notmuch-gnus-goto-message (consult-notmuch--thread-id candidate)))
+
+ (defun jao-gnus-consult-notmuch ()
+ "Run a consult-notmuch query that opens candidates in Gnus."
+ (interactive)
+ (jao-notmuch-gnus--open-candidate (consult-notmuch--search)))
+
+ (consult-customize jao-gnus-consult-notmuch :preview-key 'any))
+
+;;; .
+(provide 'jao-notmuch-gnus)
+;;; jao-notmuch-gnus.el ends here
diff --git a/attic/elisp/misc.el b/attic/elisp/misc.el
index 2f1bcb0..5021465 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
@@ -955,3 +950,350 @@
'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))
diff --git a/bin/notmuch-delete.sh b/bin/notmuch-delete.sh
new file mode 100755
index 0000000..fc230a5
--- /dev/null
+++ b/bin/notmuch-delete.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+# [[file:../mail.org::*delete shell script][delete shell script:1]]
+echo "Deleting $(notmuch count tag:deleted) files"
+notmuch search --output=files --format=text0 tag:deleted | xargs -r0 rm
+notmuch new 2>&1
+# delete shell script:1 ends here
diff --git a/bin/notmuch-gnus-tags.sh b/bin/notmuch-gnus-tags.sh
new file mode 100755
index 0000000..23e1358
--- /dev/null
+++ b/bin/notmuch-gnus-tags.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+# [[file:../mail.org::*notmuch tags][notmuch tags:1]]
+notmuch new
+[[ $1 ]] && notmuch compact
+
+for b in ~/.emacs.d/gnus/Mail/*; do
+ b="${b##*/}"
+ e="${b##*.}"
+ b="${b%.*}"
+ if [[ $e != $b ]]; then
+ notmuch tag "+$b" "+$e" -- tag:new and "folder:\"/(gnus/)?$b.$e/\"";
+ else
+ notmuch tag "+$b" -- tag:new and "folder:\"/(gnus/)?$b/\"";
+ fi
+done
+
+notmuch-tags.sh
+
+notmuch tag +trove folder:/trove/ and not tag:trove
+# notmuch tags:1 ends here
diff --git a/bin/notmuch-tags.sh b/bin/notmuch-tags.sh
new file mode 100755
index 0000000..03afc82
--- /dev/null
+++ b/bin/notmuch-tags.sh
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+for f in local feeds bigml jao; do
+ notmuch tag +$f -- tag:new and folder:$f
+done
+function tag_list () {
+ x=${2:-$1}
+ notmuch tag "+$1" -prog -drivel +lists "$3" "$4" -- "tag:new AND (List:$x OR Xref:$x)"
+}
+
+for l in clojure elixir idris haskell erlang pharo; do
+ tag_list $l
+done
+
+tag_list idris idris2
+tag_list pharo 6f667565c2569234585a7be77mc
+
+for l in haskellweekly commercialhaskell agda xmonad caml; do
+ tag_list haskell $l
+done
+
+for l in xmobar notmuch mailutils lobsters; do
+ tag_list $l
+done
+
+for l in kawa chicken guile gambit scheme chez racket; do
+ tag_list scheme $l
+done
+
+# emacsy lists
+for l in emacs-orgmode ding bbdb info-gnus-english; do
+ tag_list emacs $l
+done
+
+for l in emacs-devel emacs-diffs; do
+ tag_list $l $l -emacs
+ notmuch tag "+$l" -emacs -prog -- tag:new AND to:$l
+done
+
+tag_list emacs-bugs bug-gnu-emacs -emacs
+tag_list emacs-help help-gnu-emacs -emacs
+
+for l in consult embark vertico marginalia orderless corfu; do
+ tag_list emacs-github $l -emacs
+done
+
+tag_list hacking info-gnu
+tag_list mdk bug-mdk -hacking
+tag_list geiser geiser -scheme -emacs
+function tag_bigml {
+ query="(tag:bigml from:@bigml or to:@bigml) and tag:new and $1"
+ shift
+ notmuch tag -inbox $* -- $query
+}
+
+function tag_drivel {
+ for f in $*; do
+ tag_bigml "from:\"/.*($f).*/\"" +drivel -lists -deploys;
+ done
+}
+
+tag_bigml "tag:new" +bigml -jao
+tag_bigml "from:/.*uk/" +alba -drivel
+tag_bigml "from:mbmcommercial" +alba -drivel
+tag_bigml "to:info@bigml or from:/info/" +drivel
+
+tag_bigml "List:bigmlcom" +lists
+tag_bigml "List:whizzml" +lists
+tag_bigml "List:github" +lists
+tag_bigml "(List:bigmlcom/wintermute OR List:bigmlcom/universe)" +bugs -lists -drivel
+tag_bigml "List:support OR List:education" +support -inbox -drivel -lists
+tag_bigml "from:\"BigML Support Transcript\"" -new +deleted
+tag_bigml "from:production_reports@bigml.com" +deploys
+
+tag_bigml "subject:\"/.*(Confirmation code|Sameroom).*/\"" +drivel -lists
+tag_drivel "gotowebinar\\.com" "digit\\.fyi" "noreply" "no-reply"
+tag_drivel "slack\\.com" "globalvia\\." "ai-forum\\.com" "gsuite" "google voice"
+tag_drivel "techcrunch\\.com" "demos@" "cognitionx\\." "cogx"
+tag_drivel "events@" "marketing@" "security@" "info@"
+tag_drivel "getrevue.com" "calendar-notification" "ed\\.ac\\.uk"
+function killfile () {
+ notmuch tag -new -unread $2 -- tag:new AND $1
+}
+
+killfile "(tag:spam OR tag:trash)"
+
+killfile "from:incal@dataswamp.org"
+killfile "from:\"Planet Clojure: Eric Normand\""
+killfile "from:\"Planet Clojure: Ivan Grishaev\""
+
+killfile "subject:prefclean from:apt-listbugs"
+killfile "subject:open-thread AND Rss:astralcodexten" +1d
+killfile "subject:hidden-thread AND Rss:astralcodexten" +deleted
+
+gfeeds="grep -o -e feeds.*@localhost $HOME/.config/rss2email.cfg"
+for f in $($gfeeds | sort | uniq); do
+ ftag=$(echo $f | sed 's/feeds.\(.*\)@localhost/\1/');
+ notmuch tag +rss +feeds +$ftag -- tag:new AND folder:feeds AND to:$f
+done
+
+notmuch tag +write +jao -words -drivel -feeds \
+ -- "tag:new AND from:/campusdee?scrip?tura/"
+
+notmuch tag +logwatch -- "tag:new AND subject:logwatch"
+
+notmuch tag +mdk -- subject:mdk
+
+notmuch tag -drivel -new -unread -inbox +sent +jao -- \
+ "tag:new AND from:\"/mail@jao.io|jao@gnu.org|jaor@pm.me/\""
diff --git a/custom/jao-custom-blog.el b/custom/jao-custom-blog.el
index a11c5c0..7515440 100644
--- a/custom/jao-custom-blog.el
+++ b/custom/jao-custom-blog.el
@@ -1,34 +1,37 @@
;; -*- lexical-binding: t -*-
;;; Vars and setup
-(jao-load-path "org-static-blog")
-(when (> emacs-major-version 26) (use-package htmlize :ensure t))
-(defvar jao-blog-base-dir "~/doc/jao.io")
+(use-package htmlize :ensure t)
+
+(defvar jao-blog-base-dir (expand-file-name "www" jao-doc-dir))
+(defvar jao-blog-publish-dir (expand-file-name "jao.io" jao-blog-base-dir))
(defun jao-blog-dir (p) (expand-file-name p jao-blog-base-dir))
+(defun jao-blog-publish-dir (p) (expand-file-name p jao-blog-publish-dir))
+
+
+(defvar jao-org-blog-tag-files
+ (seq-difference (directory-files (jao-blog-publish-dir "blog") nil "tag-.*")
+ "tag-norss.html"))
+
+(defvar jao-org-blog-tags
+ (mapcar (lambda (f)
+ (string-match "tag-\\(.+\\)\\.html" f)
+ (format "<a href=\"/blog/%s\">%s</a>"
+ f (match-string 1 f)))
+ jao-org-blog-tag-files))
+
+(defvar jao-org-blog-tag-rss
+ (mapcar (lambda (f)
+ (string-match "\\(.+\\)-rss\\.xml" f)
+ (format "<a href=\"/blog/%s\">%s</a>"
+ f (match-string 1 f)))
+ (directory-files (jao-blog-publish-dir "blog") nil ".*-rss.xml")))
-(setq jao-org-blog-tag-files
- (seq-difference (directory-files (jao-blog-dir "blog") nil "tag-.*")
- "tag-norss.html")
-
- jao-org-blog-tags
- (mapcar (lambda (f)
- (string-match "tag-\\(.+\\)\\.html" f)
- (format "<a href=\"/blog/%s\">%s</a>"
- f (match-string 1 f)))
- jao-org-blog-tag-files)
-
- jao-org-blog-tag-rss
- (mapcar (lambda (f)
- (string-match "\\(.+\\)-rss\\.xml" f)
- (format "<a href=\"/blog/%s\">%s</a>"
- f (match-string 1 f)))
- (directory-files (jao-blog-dir "blog") nil ".*-rss.xml"))
-
- jao-org-blog-tag-names
- (mapcar (lambda (f)
- (string-match "tag-\\(.+\\)\\.html" f)
- (match-string 1 f))
- jao-org-blog-tag-files))
+(defvar jao-org-blog-tag-names
+ (mapcar (lambda (f)
+ (string-match "tag-\\(.+\\)\\.html" f)
+ (match-string 1 f))
+ jao-org-blog-tag-files))
;;; Header
(setq org-static-blog-page-header
@@ -94,7 +97,7 @@
org-static-blog-publish-title "programming (and other) musings"
org-static-blog-posts-directory (jao-blog-dir "posts/")
org-static-blog-drafts-directory (jao-blog-dir "pages/")
- org-static-blog-publish-directory (jao-blog-dir "blog/")
+ org-static-blog-publish-directory (jao-blog-publish-dir "blog/")
org-static-blog-rss-extra "" ; "<author>mail@jao.io</author>\n"
org-static-blog-rss-max-entries 30
org-static-blog-rss-excluded-tag "norss"
@@ -117,11 +120,7 @@
;;; New entries
(defun jao-org-blog-publish-file (fname)
- (interactive (list (read-file-name "Publish: "
- nil
- (buffer-file-name)
- t
- (buffer-file-name))))
+ (interactive (list (read-file-name "Publish: " nil (buffer-file-name) t)))
(let ((geiser-active-implementations '(guile))
(geiser-default-implementation 'guile)
(whitespace-style nil))
@@ -152,12 +151,11 @@
;;; Drafts
(defun jao-org-static-blog-update-date ()
(interactive)
- (when (y-or-n-p "Update date? ")
- (goto-char (point-min))
- (when (re-search-forward "^#\\+date: " nil t)
- (delete-line)
- (insert (format-time-string "<%Y-%m-%d %H:%M>"))
- (save-buffer))))
+ (goto-char (point-min))
+ (when (re-search-forward "^#\\+date: " nil t)
+ (org-kill-line)
+ (insert (format-time-string "<%Y-%m-%d %H:%M>"))
+ (save-buffer)))
(defun jao-org-static-blog-create-new-draft ()
(interactive)
diff --git a/custom/jao-custom-browse.el b/custom/jao-custom-browse.el
new file mode 100644
index 0000000..0f4ae65
--- /dev/null
+++ b/custom/jao-custom-browse.el
@@ -0,0 +1,200 @@
+;; -*- lexical-binding: t -*-
+
+;;; Deps
+(require 'jao-url)
+
+;;; variables
+(defvar jao-browse-doc-use-emacs-p t)
+(defvar jao-browse-url-function nil)
+(defvar jao-browse-url-external-function nil)
+
+;;; url around point
+
+(defun jao--url-prompt (&optional prefix)
+ (let* ((def (jao-url-around-point t))
+ (prompt (concat prefix "URL" (if def (format " (%s): " def) ": "))))
+ (read-string prompt nil nil def)))
+
+;;; downloads using wget
+(defun jao-wget--get-title (filename)
+ (or (and (derived-mode-p 'w3m-mode) (w3m-current-title))
+ (plist-get eww-data :title)
+ (and (not (string-blank-p (or filename "")))
+ (subst-char-in-string ?- ?
+ (capitalize (file-name-base filename))))))
+
+(defun jao-wget (url &optional user pwd)
+ "Download URL using wget and kill a link for an org note."
+ (let* ((def (file-name-nondirectory url))
+ (pmt (format "Save %s to: " url))
+ (read-file-name-function nil)
+ (dest (expand-file-name
+ (read-file-name pmt jao-sink-dir nil nil def)))
+ (title (jao-wget--get-title dest))
+ (src-url (or (jao-url-around-point t) (file-name-directory url)))
+ (auth (when (and user pwd)
+ `(,(format "--http-user=%s" user)
+ ,(format "--http-password=%s" pwd))))
+ (lnk (concat "doc:" (file-name-nondirectory dest))))
+ (switch-to-buffer-other-window (get-buffer-create "*downloads*"))
+ (erase-buffer)
+ (kill-new (format "%s (from %s)"
+ (org-link-make-string lnk title)
+ (org-link-make-string src-url "here")))
+ (apply 'make-term `("downloads" "wget" nil ,@auth "-O" ,dest ,url))))
+
+(defun jao-download (url &optional pws)
+ "Download URL using wget"
+ (interactive (list (jao--url-prompt)))
+ (when url
+ (let ((usr (and pws (read-string "Login name: ")))
+ (pwd (and pws (read-passwd "Password: "))))
+ (jao-wget url usr pwd))))
+
+(with-eval-after-load "embark"
+ (define-key embark-url-map (kbd "d") #'jao-download))
+
+;;; video
+(defvar jao-video--url-rx
+ (format "^https?://\\(?:www\\.\\)?%s/.+"
+ (regexp-opt '("youtu.be"
+ "youtube.com"
+ "blip.tv"
+ "vimeo.com"
+ "infoq.com")
+ t)))
+
+(defvar jao-video--ext-rx
+ (format "^https?://.+/.+\\.%s" (regexp-opt '("mp3" "webm" "mp4"))))
+
+(defun jao-video--url-p (url)
+ (or (string-match-p jao-video--url-rx url)
+ (string-match-p jao-video--ext-rx url)))
+
+(defun jao--remote-run (url prg)
+ (let ((args (format "%s %s" prg (shell-quote-argument url))))
+ (start-process-shell-command prg nil args)))
+
+(defun jao--mpv (url &rest _args) (jao--remote-run url "mpv"))
+(defun jao--vlc (url &rest _args) (jao--remote-run url "vlc"))
+
+(defvar jao--video-player 'jao--mpv)
+
+(defun jao-view-video (url)
+ "Tries to stream a video from the current or given URL"
+ (interactive (list (jao--url-prompt "Video ")))
+ (when url (funcall jao--video-player url)))
+
+(defun jao-maybe-view-video (url &rest _ignored)
+ (interactive)
+ (let ((w (read-char "View video (v) or web page (w)? ")))
+ (cond ((eq w ?v) (jao-view-video url))
+ ((eq w ?w) (funcall jao-browse-url-function url))
+ (t (message "Aborted")))))
+
+;;; web browsers
+(defun jao-www--buffer-p (b)
+ (with-current-buffer b
+ (or (derived-mode-p 'w3m-mode 'eww-mode)
+ (and (boundp 'exwm-class-name)
+ (member exwm-class-name '("vlc" "mpv"))))))
+
+;;; browse-url
+(require 'browse-url)
+
+(setq browse-url-generic-program (jao-d-l "open" "firefox"))
+
+(defun jao-browse-with-external-browser (&rest url)
+ "Browse with external hogging"
+ (interactive "s")
+ (let ((url (or (car url) (jao-url-around-point))))
+ (if (not url)
+ (message "No URL at point")
+ (cond ((and (jao-exwm-enabled-p) (fboundp 'jao-exwm-firefox))
+ (jao-exwm-firefox))
+ (jao-river-enabled (jao-river-to-ws 2))
+ (jao-sway-enabled (jao-sway-firefox)))
+ (browse-url-generic url))))
+
+(setq jao-browse-url-external-function 'jao-browse-with-external-browser)
+
+(defun jao--fln (url)
+ (shell-quote-argument
+ (if (string-match "^[^:]*:/*?\\(/?[^/].*\\)" url)
+ (match-string-no-properties 1 url)
+ url)))
+
+(defun jao--browse-doc (url &rest _ignored)
+ (let* ((url (substring-no-properties url))
+ (file (jao--fln url)))
+ (when file
+ (unless (file-exists-p file)
+ (error "File %s does not exist" file))
+ (jao-open-doc file))))
+
+(defun jao--make-file-rx (exts)
+ (format "file:/?/?.+\\.%s$" (regexp-opt exts)))
+
+(defvar jao--see-exts (jao--make-file-rx '("jpg" "jpeg" "png")))
+
+(defvar jao--doc-exts
+ (jao--make-file-rx '("ps" "ps.gz" "pdf" "dvi" "djvu" "chm")))
+
+(defvar jao-browse-url-wget-exts
+ '("ps" "pdf" "dvi" "djvu" "zip" "gz" "tgz"))
+
+(defvar jao-browse-external-domains
+ '("github.com" "gitlab.com" "slack.com" "spotify.com" "drive.google.com"
+ "meet.google.com" "docs.google.com" "x.com" "twitter.com"
+ "t.com" "linkedin.com" "bigml.com" "slack.com" "zoom.us"))
+
+(defvar jao-browse--external-regexp
+ (format "https?://\\(.+\\.\\)*%s\\(/.*\\)?"
+ (regexp-opt jao-browse-external-domains)))
+
+(defun jao-wget--regexp ()
+ (concat "^http[s]?://.+\\(\\."
+ (mapconcat 'identity jao-browse-url-wget-exts "\\|\\.")
+ "\\)\\'"))
+
+(defun jao--see (url &rest _r)
+ (start-process-shell-command "see" nil (format "see %s" (jao--fln url))))
+
+(defun jao--find-file-other-window (url &rest _)
+ (find-file-other-window (jao--fln url)))
+
+(defvar jao-browse--sound-rx
+ (format "^https?://.*/.*\\.%s" (regexp-opt '("mp3" "flv"))))
+
+(defun jao-browse-play-sound-url (url &rest _)
+ (jao-mpc-add-or-play-url url))
+
+(defun jao-browse-url-browse (&rest args)
+ (apply jao-browse-url-function args))
+
+(jao-d-l
+ (setq browse-url-handlers
+ `((jao-video--url-p . jao-mac-open)
+ (,jao--doc-exts . jao-mac-open)
+ (,jao--see-exts . jao-mac-open)
+ ("^file://?.+\\.html?$" . ,jao-browse-url-function)
+ ("^file://?" . jao--find-file-other-window)
+ (,jao-browse--external-regexp . ,jao-browse-url-external-function)
+ (,jao-browse--sound-rx . jao-browse-play-sound-url)
+ ("." . jao-browse-url-browse)))
+ (setq browse-url-handlers
+ `((jao-video--url-p . jao-maybe-view-video)
+ (,jao--doc-exts . jao--browse-doc)
+ (,jao--see-exts . jao--see)
+ ("^file://?.+\\.html?$" . ,jao-browse-url-function)
+ ("^file://?" . jao--find-file-other-window)
+ (,jao-browse--external-regexp . ,jao-browse-url-external-function)
+ ("^https?://.*\\.gotomeeting\\.com\\.*" . browse-url-chrome)
+ (,jao-browse--sound-rx . jao-browse-play-sound-url)
+ (,(jao-wget--regexp) . jao-download)
+ ("." . jao-browse-url-browse))))
+
+
+(provide 'jao-custom-browse)
+
+;;; jao-custom-browse.el ends here
diff --git a/custom/jao-custom-chats.el b/custom/jao-custom-chats.el
new file mode 100644
index 0000000..c2105c6
--- /dev/null
+++ b/custom/jao-custom-chats.el
@@ -0,0 +1,242 @@
+;; -*- lexical-binding: t -*-
+
+
+;;;; circe
+(defvar jao-libera-channels ())
+(defvar jao-oftc-channels ())
+(defvar jao-bitlbee-channels ())
+(defvar jao-slack-channels ())
+
+(use-package circe
+ :ensure t
+ :bind (:map circe-channel-mode-map
+ (("C-c C-a" . lui-track-jump-to-indicator)))
+ :init
+ (setq circe-chat-buffer-name "{target} - {network}"
+ circe-default-realname "https://jao.io"
+ circe-default-part-message ""
+ circe-default-quit-message ""
+ circe-ignore-list nil
+ circe-server-coding-system '(undecided . undecided)
+ circe-server-killed-confirmation 'ask-and-kill-all
+ circe-server-auto-join-default-type :after-auth
+ circe-server-buffer-name "{network} - {host}:{port}"
+ circe-format-say "({nick}) {body}"
+ circe-format-self-say "(jao) {body}"
+ circe-new-buffer-behavior 'ignore
+ circe-new-buffer-behavior-ignore-auto-joins t
+ circe-nickserv-ghost-style 'after-auth
+ circe-prompt-string ": "
+ circe-completion-suffix ", "
+ circe-reduce-lurker-spam t
+
+ circe-lagmon-mode-line-format-string "" ;; "%.0f "
+ circe-lagmon-mode-line-unknown-lag-string "" ;; "? "
+ circe-lagmon-timer-tick 120
+ circe-lagmon-reconnect-interval 180
+
+ lui-max-buffer-size 30000
+ lui-fill-column 80
+ lui-time-stamp-position 'right
+ lui-time-stamp-format "%H:%M"
+ lui-flyspell-p nil
+
+ lui-track-indicator (if window-system 'fringe 'bar)
+ lui-track-behavior 'before-tracking-next-buffer)
+ :config
+
+ (defsubst jao-circe-nick-no ()
+ (if (derived-mode-p 'circe-query-mode)
+ 2
+ (length (circe-channel-nicks))))
+
+ (defsubst jao-circe-netowrk ()
+ (or (plist-get lui-logging-format-arguments :network) ""))
+
+ (define-minor-mode jao-circe-user-number-mode ""
+ :lighter (:eval (format " [%s]" (jao-circe-nick-no))))
+
+ (defun jao-circe-channel-hook ()
+ (when jao-mode-line-in-minibuffer
+ (setq header-line-format
+ '(" %b" (:eval (format "@%s - %s nicks"
+ (jao-circe-netowrk)
+ (jao-circe-nick-no))))))
+ (jao-circe-user-number-mode 1))
+
+ (add-hook 'circe-channel-mode-hook #'jao-circe-channel-hook)
+ (add-hook 'circe-query-mode-hook #'jao-circe-channel-hook)
+
+ (defun circe-command-RECOVER (&rest _ignore)
+ "Recover nick"
+ (jao-with-auth "freenode" u p
+ (circe-command-MSG "nickserv" (format "IDENTIFY %s %s" u p))
+ (circe-command-MSG "nickserv" (format "GHOST %s" u))
+ (circe-command-MSG "nickserv" (format "RELEASE %s" u))
+ (circe-command-NICK u)))
+
+ (defun circe-command-NNICKS (&rest _)
+ "Echo number of nicks"
+ (circe-display-server-message
+ (format "%d nicks in this channel" (jao-circe-nick-no))))
+
+ (defun circe-command-SENDFILE (line)
+ "/sendfile for localslackirc"
+ (circe-command-QUOTE (format "sendfile %s" line)))
+
+ (advice-add 'circe-command-NAMES :after #'circe-command-NNICKS)
+
+ (defun jao-circe-reconnect-unmonitored ()
+ (interactive)
+ (dolist (b (buffer-list))
+ (with-current-buffer b
+ (when (and (derived-mode-p 'circe-server-mode)
+ circe-lagmon-disabled)
+ (circe-reconnect)))))
+
+ (add-to-list 'jao-sleep-awake-functions #'jao-circe-reconnect-unmonitored)
+
+ (setq circe-network-options
+ (list (jao-with-auth "libera" u p
+ (list "Libera Chat" :nick u :channels jao-libera-channels
+ :tls t :sasl-username u :sasl-password p))
+ (jao-with-auth "oftc" u p
+ (list "OFTC"
+ :nick u :channels jao-oftc-channels :nickserv-password p
+ :tls t :sasl-username u :sasl-password p))
+ (jao-with-auth "bitlbee" u p
+ (list "Bitlbee" :host "127.0.0.1" :nick u
+ :channels jao-bitlbee-channels :lagmon-disabled t
+ :nickserv-password u :user p))))
+
+ (jao-shorten-modes 'circe-channel-mode
+ 'circe-server-mode
+ 'circe-query-mode)
+
+ (enable-circe-display-images)
+ (enable-lui-track)
+ (circe-lagmon-mode))
+
+;;;; telegram
+(use-package telega
+ :ensure t
+ :custom
+ (telega-use-tracking-for '(unmuted) ;; '(or unmuted mention)
+ telega-rainbow-color-custom-for nil
+ telega-msg-rainbow-title nil
+ telega-sticker-set-download t
+ telega-symbol-checkmark "·"
+ telega-symbol-heavy-checkmark "×"
+ telega-symbol-verified "*")
+ :config
+ (define-key global-map (kbd "C-c C-t") telega-prefix-map)
+ (setq telega-chat-show-avatars nil
+ telega-chat-prompt-insexp '(telega-ins "> ")
+ telega-completing-read-function #'completing-read
+ telega-root-show-avatars nil
+ telega-emoji-use-images nil
+ telega-temp-dir "/tmp/telega"
+ telega-symbol-horizontal-bar
+ (propertize "-" 'face 'jao-themes-f00)
+ telega-symbol-vertical-bar
+ (propertize "| " 'face 'jao-themes-dimm)
+ telega-mode-line-string-format
+ '(:eval (telega-mode-line-unread-unmuted))
+ telega-use-images (display-graphic-p)
+ telega-open-file-function #'jao--see
+ telega-open-message-as-file
+ (unless (display-graphic-p) '(photo video animation)))
+ (with-eval-after-load "tracking"
+ (jao-shorten-modes 'telega-chat-mode)
+ (jao-tracking-faces 'telega-tracking))
+ (telega-mode-line-mode 1))
+
+(defun jao-telega ()
+ (interactive)
+ (jao-tracking-go-to-chats)
+ (if (get-buffer telega-root-buffer-name)
+ (pop-to-buffer telega-root-buffer-name)
+ (telega)))
+
+;;;; 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"))
+
+;;;; startup
+(defun jao-chats (&optional p)
+ (interactive "P")
+ (when (or p (y-or-n-p "Connect to telegram? "))
+ (telega))
+ (when (and (fboundp 'ement-connect) (or p (y-or-n-p "Connect to matrix? ")))
+ (unless (get-buffer "*Ement Rooms*")
+ (jao-with-auth "matrix.org" u p (ement-connect :user-id u :password p))))
+ ;; (when (and (fboundp 'mastodon) (or p (y-or-n-p "Connect to mastodon? ")))
+ ;; (mastodon))
+ (dolist (c '(("Libera Chat" . "irc.libera.chat:6697")))
+ (unless (get-buffer (cdr c))
+ (when (or p (y-or-n-p (format "Connect to %s? " (car c))))
+ (circe (car c))))))
+
+(defun jao-all-chats ()
+ (interactive)
+ (when jao-tracking-use-scratch
+ (jao-afio-goto-chats)
+ (delete-other-windows))
+ (jao-chats t))
+
+(defun jao-chats-telega ()
+ (interactive)
+ (jao-buffer-same-mode '(telega-root-mode telega-chat-mode)))
+
+(defun jao-chats-slack ()
+ (interactive)
+ (jao-buffer-same-mode 'slack-message-buffer-mode))
+
+(defun jao-chats-irc ()
+ (interactive)
+ (jao-buffer-same-mode '(circe-channel-mode circe-query-mode erc-mode)))
+
+;;;; consult narrowing
+(defvar jao-chat-buffer-source
+ (list :name "chats"
+ :category 'buffer
+ :action (lambda (b) (jao-afio-pop-to-buffer 0 b))
+ :hidden t
+ :narrow (cons ?c "chats")
+ :items (jao-consult--mode-buffers 'erc-mode
+ 'circe-channel-mode
+ 'circe-query-mode
+ 'signel-chat-mode
+ 'slack-message-buffer-mode
+ 'slack-thread-message-buffer-mode
+ 'telega-root-mode
+ 'telega-chat-mode
+ 'ement-room-mode
+ 'ement-room-list-mode)))
+(with-eval-after-load "consult"
+ (jao-consult-add-buffer-source 'jao-chat-buffer-source))
+
+
+(provide 'jao-custom-chats)
diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el
index 9524e23..98b853c 100644
--- a/custom/jao-custom-completion.el
+++ b/custom/jao-custom-completion.el
@@ -1,5 +1,7 @@
;; -*- lexical-binding: t; -*-
+(require 'jao-r2e)
+
;;; builtin completion
(setq tab-always-indent 'complete
read-extended-command-predicate #'command-completion-default-include-p
@@ -126,8 +128,7 @@
("M-g e" . consult-error)
("M-s m" . consult-multi-occur)
("M-y" . consult-yank-pop)
- ("C-s" . isearch-forward)
- ("<help> a" . consult-apropos))
+ ("C-s" . isearch-forward))
:custom ((consult-preview-key (kbd "`")))
@@ -309,7 +310,7 @@
(define-key embark-url-map (kbd "RET") #'jao-embark-url)
(define-key embark-url-map (kbd "f") #'browse-url-firefox)
-(define-key embark-url-map (kbd "x") #'jao-rss-subscribe)
+(define-key embark-url-map (kbd "x") #'jao-r2e-subscribe)
(define-key embark-url-map (kbd "m") 'jao-browse-with-external-browser)
(define-key embark-url-map (kbd "p") 'jao-mpc-add-or-play-url)
diff --git a/custom/jao-custom-email.el b/custom/jao-custom-email.el
index a3d1a92..2e886ff 100644
--- a/custom/jao-custom-email.el
+++ b/custom/jao-custom-email.el
@@ -2,16 +2,15 @@
;;; main email system
(require 'jao-afio)
-(setq jao-afio-mail-function 'gnus)
-;; (setq jao-afio-mail-function 'notmuch)
+(setq jao-afio-mail-function (jao-d-l 'gnus 'notmuch))
(defvar jao-notmuch-enabled (eq jao-afio-mail-function 'notmuch))
;;; personal emails and others
(defvar jao-mails)
-(defvar jao-extra-mails)
+(defvar jao-extra-mails nil)
(defvar jao-mails-regexp (regexp-opt jao-mails))
-
+(defvar jao-maildir (jao-d-l "~/Documents/mail" "~/var/mail"))
;;; gnus
(setq gnus-init-file "~/.emacs.d/gnus.el"
gnus-home-directory "~/.emacs.d/gnus"
@@ -21,7 +20,7 @@
message-directory (expand-file-name "Mail" gnus-home-directory)
mail-source-directory (expand-file-name "Mail" gnus-home-directory))
;;; proton
-(use-package jao-proton-utils)
+(jao-when-linux (use-package jao-proton-utils))
;;; message mode
;;;; customization
@@ -180,7 +179,7 @@
(when (require 'randomsig nil t)
(define-key message-mode-map (kbd "C-c s") 'randomsig-replace-sig)
(define-key message-mode-map (kbd "C-c S") 'randomsig-select-sig)
- (setq randomsig-dir (expand-file-name "~/etc/config/emacs"))
+ (setq randomsig-dir gnus-home-directory)
(setq randomsig-files '("signatures.txt"))
;; or (setq randomsig-files (randomsig-search-sigfiles))
;; or (setq randomsig-files 'randomsig-search-sigfiles)
@@ -210,16 +209,21 @@
(setq smtpmail-smtp-service 587))
(defun jao-sendmail-local ()
- (setq send-mail-function 'sendmail-send-it)
+ (setq send-mail-function 'smtpmail-send-it) ;; send-mail-function
+ ;; (setq sendmail-program "/usr/sbin/sendmail")
(setq smtpmail-auth-supported nil) ;; (cram-md5 plain login)
(setq smtpmail-servers-requiring-authorization nil)
(setq smtpmail-smtp-user nil)
(setq smtpmail-smtp-server "127.0.0.1")
(setq smtpmail-smtp-service 25))
+(defun jao-sendmail-send-it ()
+ (with-temp-message "Sending email..."
+ (sendmail-send-it)))
+
(defun jao-sendmail-msmtp ()
(setq send-mail-function 'sendmail-send-it
- sendmail-program "/usr/bin/msmtp"
+ sendmail-program (executable-find "msmtp")
mail-specify-envelope-from t
message-sendmail-envelope-from 'header
mail-envelope-from 'header))
@@ -232,6 +236,7 @@
:ensure t
:init (setq bbdb-complete-name-allow-cycling t
bbdb-completion-display-record nil
+ bbdb-dedicated-window t
bbdb-gui t
bbdb-message-all-addresses t
bbdb-complete-mail-allow-cycling t
@@ -262,6 +267,18 @@
("Cc" . ,jao-mails-regexp)
("BCc" . ,jao-mails-regexp))
bbdb-ignore-message-alist bbdb-auto-notes-ignore-messages)
+
+ (setq bbdb-layout-alist
+ '((one-line (order phone mail-alias mail notes)
+ (name-end . 24)
+ (toggle . t))
+ (multi-line (omit uuid creation-date timestamp name-format name-face)
+ (toggle . t)
+ (indentation . 4))
+ (pop-up-multi-line
+ (omit uuid creation-date timestamp name-format name-face)
+ (indentation . 4))
+ (full-multi-line (indentation . 4))))
:config
(add-hook 'message-setup-hook 'bbdb-mail-aliases)
;; (add-hook 'bbdb-notice-mail-hook 'bbdb-auto-notes)
diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el
index 1b766c9..221f442 100644
--- a/custom/jao-custom-eww.el
+++ b/custom/jao-custom-eww.el
@@ -1,5 +1,7 @@
;; -*- lexical-binding: t -*-
+(require 'jao-r2e)
+
;;; integration with browse-url and afio
(defun jao-eww-browse-url (url &rest _r)
"Browse URL using eww."
@@ -22,9 +24,10 @@
;;; multipart html renderer
(defun jao-shr-html-renderer (handle)
- (let ((fill-column nil)
- (shr-width 150)
- (shr-max-width 150))
+ (let* ((w (min 120 (- (window-width) 10)))
+ (fill-column nil)
+ (shr-width w)
+ (shr-max-width w))
(mm-shr handle)))
(setq mm-text-html-renderer #'jao-shr-html-renderer)
@@ -157,42 +160,19 @@
(pop-to-buffer buff)
(goto-char (point-min))))
-;;; 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))
;;; auto-readable
(defvar jao-eww-auto-readable-urls
- (regexp-opt '("guardian.co.uk" "theguardian.com" "github.com" "eldiario.es")))
+ (regexp-opt '("guardian.co.uk"
+ "theguardian.com"
+ "github.com"
+ "eldiario.es")))
(defun jao-eww-autoread ()
(when (string-match-p jao-eww-auto-readable-urls (or (eww-current-url)))
(eww-readable)))
(add-hook 'eww-after-render-hook #'jao-eww-autoread)
+
;;; package
(use-package shr
:custom ((shr-width nil)
@@ -210,12 +190,7 @@ It should be the title of the web page as returned by `rdrview'"
(eww-download-directory jao-sink-dir)
(eww-header-line-format " %u")
(eww-form-checkbox-selected-symbol "☒")
- (eww-buffer-name-length 180)
- ;; (eww-readable-urls '("guardian\\.co\\.uk"
- ;; "theguardian\\.com"
- ;; "eldiario\\.es"
- ;; "theconversation"))
- )
+ (eww-buffer-name-length 180))
:config
(with-eval-after-load "org" (require 'ol-eww nil t))
@@ -226,12 +201,6 @@ It should be the title of the web page as returned by `rdrview'"
(when (not (string-blank-p s)) (format "%s" s))))
(setq eww-auto-rename-buffer #'jao-eww-buffer-name)
- (defun jao-eww-readable (rdrview)
- (interactive "P" eww-mode)
- (if rdrview
- (eww-rdrview-toggle-and-reload)
- (eww-readable)))
-
:bind (:map eww-mode-map (("b" . eww-back-url)
("B" . eww-forward-url)
("d" . jao-download)
@@ -242,7 +211,7 @@ It should be the title of the web page as returned by `rdrview'"
("o" . jao-eww-browse)
("O" . jao-eww-browse-new)
("r" . jao-eww-reload)
- ("R" . jao-eww-readable)
+ ("R" . eww-readable)
("s" . eww-search-words)
("S" . jao-eww-browse-new)
("T" . jao-mastodon-toot-url)
@@ -250,7 +219,7 @@ It should be the title of the web page as returned by `rdrview'"
("U" . jao-eww-reopen-new)
("w" . jao-eww-to-org)
("q" . jao-eww-close)
- ("x" . jao-rss-subscribe)
+ ("x" . jao-r2e-subscribe)
("y" . jao-eww-copy-link)
("\\" . eww-view-source)
("C-c C-w" . jao-eww-close)
@@ -276,8 +245,8 @@ It should be the title of the web page as returned by `rdrview'"
(prog1 (apply fn args)
(when (and p (> (point) p)) (jao-shr--kill-nl p)))))
-(advice-add 'shr-tag-img :around #'jao-shr-tag-img)
-(advice-add 'shr-insert :around #'jao-shr-insert)
+;; (advice-add 'shr-tag-img :around #'jao-shr-tag-img)
+;; (advice-add 'shr-insert :around #'jao-shr-insert)
;; (advice-remove 'shr-tag-img #'jao-shr-tag-img)
;; (advice-remove 'shr-insert #'jao-shr-insert)
diff --git a/custom/jao-custom-exwm.el b/custom/jao-custom-exwm.el
index e5c67f8..ac88ec1 100644
--- a/custom/jao-custom-exwm.el
+++ b/custom/jao-custom-exwm.el
@@ -154,10 +154,10 @@
(exwm-systemtray-mode 1)
(defun jao-exwm--watch-tray (sym newval op where)
- (setq jao-minibuffer-right-margin (* 2 (length newval)))
+ (setq jao-minibuffer-right-margin (/ newval (string-pixel-width "a")))
(jao-minibuffer-refresh))
-(add-variable-watcher 'exwm-systemtray--list #'jao-exwm--watch-tray)
+(add-variable-watcher 'exwm-systemtray-width #'jao-exwm--watch-tray)
;; Switch to buffer / app
(defvar-local jao-exwm--name nil)
@@ -194,7 +194,9 @@
(defun jao-exwm-switch-to-next-x ()
(interactive)
- (let ((bfs (seq-filter (lambda (b) (buffer-local-value 'exwm-class-name b))
+ (let ((bfs (seq-filter (lambda (b)
+ (with-current-buffer b
+ (derived-mode-p 'exwm-mode)))
(buffer-list (window-frame)))))
(when (car bfs) (switch-to-buffer (car (reverse bfs))))))
@@ -530,6 +532,7 @@
([f9] . jao-bright-show)))
;; (customize-set-variable 'exwm-input-global-keys exwm-input-global-keys)
+(exwm-wm-mode)
;;; .
(provide 'jao-custom-exwm)
diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el
index 70823ef..597ef85 100644
--- a/custom/jao-custom-gnus.el
+++ b/custom/jao-custom-gnus.el
@@ -30,11 +30,13 @@
nndraft-directory (jao-gnus-dir "drafts")
nnrss-directory (jao-gnus-dir "rss"))
+(setq gnus-uncacheable-groups "^nnml")
+
;;; looks
;;;; verbosity
(setq gnus-verbose 4)
;;;; geometry
-(defvar jao-gnus-use-three-panes t)
+(defvar jao-gnus-use-three-panes (not jao-notmuch-enabled))
(defvar jao-gnus-groups-width 50)
(defvar jao-gnus-wide-width 190)
@@ -42,17 +44,13 @@
gnus-generate-tree-function 'gnus-generate-horizontal-tree
gnus-tree-minimize-window nil)
-(when jao-gnus-use-three-panes
-
- ;; (dolist (m '(calendar-mode org-agenda-mode gnus-group-mode))
- ;; (add-to-list 'display-buffer-alist `((major-mode . ,m) (dedicated t))))
-
- (setq calendar-left-margin 6)
+(setq calendar-left-margin 6)
- (let ((side-bar '(vertical 1.0
+(defun jao-gnus-use-three-panes ()
+ (let ((side-bar `(vertical 1.0
("inbox.org" 0.4)
("*Org Agenda*" 1.0)
- ("*Calendar*" 8)))
+ ("*Calendar*" ,(jao-d-l 9 8))))
(wide-len jao-gnus-wide-width)
(groups-len jao-gnus-groups-width)
(summary-len (- jao-gnus-wide-width jao-gnus-groups-width)))
@@ -88,59 +86,63 @@
(article 100)
,side-bar)))))
+(defun jao-gnus-use-two-panes ()
+ (let ((wide-len jao-gnus-wide-width)
+ (groups-len jao-gnus-groups-width)
+ (summary-len (- jao-gnus-wide-width jao-gnus-groups-width))
+ (msg-edit '(horizontal 1.0
+ (message 1.0 point)
+ (vertical 0.5
+ ("*Org Agenda*" 0.5)
+ ("inbox.org" 1.0)))))
+ (gnus-add-configuration
+ `(article
+ (horizontal 1.0
+ (vertical ,groups-len (group 1.0))
+ (vertical 1.0
+ (summary 0.25 point)
+ (article 1.0)))))
+
+ (gnus-add-configuration
+ `(group (horizontal 1.0
+ (group 0.5 point)
+ (vertical 1.0
+ ("*Org Agenda*" 1.0)
+ ("*Calendar*" 9)))))
+
+ (gnus-add-configuration
+ `(summary
+ (horizontal 1.0
+ (vertical ,groups-len (group 1.0))
+ (vertical 1.0 (summary 1.0 point)))))
+
+ (gnus-add-configuration `(message ,msg-edit))
+
+ (gnus-add-configuration `(forward ,msg-edit))
+
+ (gnus-add-configuration `(reply-yank ,msg-edit))
+
+ (gnus-add-configuration
+ `(reply (horizontal 1.0
+ (message ,(- wide-len 100) point)
+ (article 1.0))))))
+
+(if jao-gnus-use-three-panes
+ (jao-gnus-use-three-panes)
+ (jao-gnus-use-two-panes))
+
;;;; no blue icon
(advice-add 'gnus-mode-line-buffer-identification :override #'identity)
(setq gnus-mode-line-image-cache nil)
;;; search
(setq gnus-search-use-parsed-queries nil
- gnus-search-notmuch-raw-queries-p nil
+ gnus-search-notmuch-raw-queries-p t
gnus-permanently-visible-groups "^nnselect:.*"
gnus-search-ignored-newsgroups "nndraft.*\\|nnselect.*")
-(with-eval-after-load "gnus-search"
- (defclass gnus-search-recoll (gnus-search-indexed)
- ((separator :type string :initform ".")
- (program :initform "recoll")
- (raw-queries-p :initform t)))
-
- (cl-defmethod gnus-search-indexed-extract ((_engine gnus-search-recoll))
- (prog1 (and (looking-at "^file://\\(.+\\)$") (list (match-string 1) 100))
- (forward-line 1)))
-
- (cl-defmethod gnus-search-transform-expression ((_engine gnus-search-recoll)
- expr)
- expr)
-
- (cl-defmethod gnus-search-indexed-search-command ((engine gnus-search-recoll)
- (qstring string)
- query
- &optional groups)
- (let* ((subdir (slot-value engine 'remove-prefix))
- (sep (slot-value engine 'separator))
- (gdirs (mapcar (lambda (g)
- (let ((g (gnus-group-short-name g)))
- (replace-regexp-in-string "\\." sep g)))
- (or groups
- (and (not (string= "" subdir)) (list subdir)))))
- (dirsq (and gdirs
- (concat "("
- (mapconcat (lambda (d) (format "dir:%s" d))
- gdirs " OR ")
- ")")))
- (qstring (if (string-prefix-p "id:" qstring)
- (replace-regexp-in-string "<\\|>" "\"" qstring)
- qstring))
- (qstring (if (cdr (assoc 'thread query))
- (concat qstring " OR "
- (replace-regexp-in-string "id:\"" "ref:\""
- qstring))
- qstring))
- (qstring (replace-regexp-in-string " or " " OR " qstring))
- (qstring (replace-regexp-in-string " and " " AND " qstring))
- (q (format "mime:message %s (%s)" dirsq qstring)))
- ;; (message "query is: %s -- %S" q query)
- `("-b" "-t" "-q" ,q))))
+(use-package jao-recoll
+ :if (jao-is-linux))
;; (add-to-list 'gnus-parameters '("^nnselect:.*" (nnselect-rescan . t)))
@@ -194,26 +196,42 @@
nnml-get-new-mail t
nnml-directory message-directory)
+(defvar jao-local-mail-sources
+ (append (mapcar (lambda (f)
+ `(maildir :path ,(expand-file-name f jao-maildir)))
+ '("local/" "feeds/"))
+ (jao-when-darwin '((file :path "/var/mail/jao")))))
+
+(defun jao-pm-label-mail-sources (pwd &rest labels)
+ (mapcar (lambda (b)
+ `(imap :server "127.0.0.1" :port 1143
+ :user "jaor@pm.me" :password ,pwd
+ :stream starttls :predicate "1:*"
+ :fetchflag "\\Deleted \\Seen"
+ :mailbox ,(concat "Labels/#" b)))
+ (or labels '("inbox" "drivel" "hacking" "bills" "prog" "words"))))
+
+(defun jao-pm-folder-mail-sources (pwd &rest folders)
+ (mapcar (lambda (b)
+ `(imap :server "127.0.0.1" :port 1143
+ :user "jaor@pm.me" :password ,pwd
+ :stream starttls :predicate ""
+ :fetchflag ""
+ :mailbox ,(if b (concat "Folders/" b) "INBOX")))
+ (or folders '(nil "drivel" "hacking" "bills" "prog" "words"))))
+
(setq mail-sources
(let* ((pwd (auth-source-pick-first-password :host "proton-bridge"))
- (mds (mapcar (lambda (f)
- `(maildir :path ,(expand-file-name f "~/var/mail/")))
- '("local/" "feeds/")))
- (ims (mapcar (lambda (b)
- `(imap :server "127.0.0.1" :port 1143
- :user "mail@jao.io" :password ,pwd
- :stream starttls :predicate "1:*"
- :fetchflag "\\Deleted \\Seen"
- :mailbox ,(concat "Labels/#" b)))
- '("inbox" "drivel" "hacking" "bills"
- "bigml" "prog" "words"))))
- (append mds ims)))
+ (ims (jao-pm-label-mail-sources pwd)))
+ (append jao-local-mail-sources ims)))
(when jao-gnus-use-nnml
- (add-to-list
- 'gnus-secondary-select-methods
- `(nnml "" (gnus-search-engine gnus-search-recoll
- (remove-prefix ,(jao-gnus-dir "Mail/"))))))
+ (let ((prefix (expand-file-name "gnus/" jao-maildir)))
+ (add-to-list
+ ;; `(nnml "" ,(jao-recoll-gnus-search-engine (jao-gnus-dir "Mail/")))
+ 'gnus-secondary-select-methods
+ `(nnml "" (gnus-search-engine gnus-search-notmuch
+ (remove-prefix ,prefix))))))
(when jao-gnus-use-nnml
(dolist (p jao-gnus-nnml-group-params)
@@ -239,10 +257,12 @@
;;; groups
(setq gnus-group-line-format
- " %m%S%p%3y%P%* %~(pad-right 30)G %B\n"
+ " %m%S%p%3y%P%* %~(pad-right 25)G %B\n"
;; " %m%S%p%P:%~(pad-right 35)c %3y %B\n"
;; " %m%S%p%3y%P%* %~(pad-right 30)C %B\n"
- gnus-topic-line-format "%i[ %(%{%n%}%) -- %A ]%v\n"
+ ;; gnus-topic-line-format "%i[ %(%{%n%}%) -- %A ]%v\n"
+ gnus-face-2 'jao-themes-f11
+ gnus-topic-line-format "%i %2{%~(pad-right 8)n ┄┄ %A%v%}\n"
gnus-group-uncollapsed-levels 2
gnus-auto-select-subject 'unread
gnus-large-newsgroup 2000)
@@ -318,12 +338,14 @@
"\n"))
(defun jao-gnus--set-summary-line (&optional w)
- (let* ((d (if jao-gnus-use-three-panes (+ jao-gnus-groups-width 11) 12))
- (w (- (or w (window-width)) d)))
+ (let* ((d (if jao-gnus-use-three-panes
+ (+ jao-gnus-groups-width 11)
+ (+ jao-gnus-groups-width 12)))
+ (w (or w (if jao-gnus-use-three-panes (window-width) (frame-width))))
+ (w (- w d)))
(setq gnus-summary-line-format (format jao-gnus--summary-line-fmt w))))
(add-hook 'gnus-select-group-hook 'jao-gnus--set-summary-line)
-;; (jao-gnus--set-summary-line 187)
(add-to-list 'nnmail-extra-headers 'Cc)
(add-to-list 'nnmail-extra-headers 'BCc)
@@ -447,13 +469,19 @@
(use-package org-capture
:config
(add-to-list 'org-capture-templates
+ '("x" "arXiv" entry (file "notes/physics/arxiv.org")
+ "* %(jao-gnus-subject)\n\n %i\n\n %(jao-gnus-org-url)"
+ :immediate-finish t)
+ t)
+ (add-to-list 'org-capture-templates
'("X" "arXiv" entry (file "notes/physics/arxiv.org")
- "* %:subject\n\n(jao-gnus-org-paragraph \"%i\")"
+ "* %(jao-gnus-subject)\n\n%(jao-gnus-org-paragraph \"%i\")"
:immediate-finish t)
t)
(org-capture-upgrade-templates org-capture-templates))
(defvar jao-gnus-org-url nil)
+(defun jao-gnus-org-url () jao-gnus-org-url)
(defun jao-gnus-org-paragraph (x)
(with-temp-buffer
(insert " " (string-trim (or x "")) "\n ")
@@ -462,22 +490,27 @@
(goto-char (point-max))
(open-rectangle 0 (point))
(concat (buffer-string) "\n " (or jao-gnus-org-url ""))))
+(defvar jao-gnus-subject nil)
+(defun jao-gnus-subject () jao-gnus-subject)
(defun jao-gnus-arXiv-capture ()
(interactive)
(unless (derived-mode-p '(gnus-summary-mode)) (gnus-article-show-summary))
- (setq jao-subject (gnus-summary-article-subject))
+ (setq jao-gnus-subject (gnus-summary-article-subject))
(gnus-summary-select-article-buffer)
(gnus-article-goto-part 0)
- (setq-local transient-mark-mode 'lambda)
- (set-mark (point))
- (forward-paragraph)
- (save-excursion
- (when (re-search-forward "^Link" nil t)
- (beginning-of-line)
- (setq jao-gnus-org-url (org-eww-url-below-point))))
- (org-capture nil "X")
- (set-mark (point))
+ (let ((transient-mark-mode t))
+ (set-mark (point))
+ (forward-paragraph)
+ (or (and (save-excursion
+ (when (re-search-forward "^Link" nil t)
+ (beginning-of-line)
+ (setq jao-gnus-org-url (org-eww-url-below-point))))
+ (org-capture nil "X"))
+ (and (save-excursion
+ (when (re-search-forward "^URL: " nil t)
+ (setq jao-gnus-org-url (thing-at-point-url-at-point))))
+ (org-capture nil "x"))))
(gnus-article-show-summary))
;;; article
@@ -494,6 +527,7 @@
(setq gnus-single-article-buffer nil)
(setq gnus-article-update-lapsed-header 60)
(setq gnus-article-update-date-headers 60)
+(setq gnus-article-truncate-lines t)
(with-eval-after-load "gnus-art"
(setq gnus-visible-headers
@@ -558,7 +592,7 @@
(save-excursion
(goto-char (point-min))
(when (or (search-forward-regexp "^Via: h" nil t)
- (search-forward-regexp "^URL: h" nil t)
+ (search-forward-regexp "^URL:[\n ]h" nil t)
(and (search-forward-regexp "^Link$" nil t)
(not (beginning-of-line))))
(cond (external (jao-browse-with-external-browser))
@@ -580,7 +614,7 @@
(gnus-summary-select-article-buffer)
(save-excursion
(goto-char (point-min))
- (let ((offset (or (and (search-forward-regexp "^Enclosure: " nil t) 2)
+ (let ((offset (or (and (search-forward-regexp "^Enclosure: ?" nil t) 2)
(and (search-forward-regexp "^Enclosure$" nil t) -2))))
(when offset (forward-char offset))
(if-let ((url (jao-url-around-point)))
@@ -611,18 +645,32 @@
(defun jao-gnus--scan ()
(let ((inhibit-message t))
(gnus-demon-scan-news)
+ (jao-shell-exec "notmuch-gnus-tags.sh")
+ (when-let* ((a (get-buffer "*Org Agenda*")))
+ (with-current-buffer a (org-agenda-redo-all)))
+ (jao-gnus--notify)))
+
+(defun jao-gnus--scan-local-mail ()
+ (let ((inhibit-message nil))
+ (message "Scanning local news in demon...")
+ (let ((mail-sources jao-local-mail-sources))
+ (gnus-demon-scan-news))
(jao-gnus--notify)))
(defun jao-gnus-add-demon ()
(interactive)
(gnus-demon-add-handler 'jao-gnus--scan 5 1))
+(defun jao-gnus-remove-demon ()
+ (interactive)
+ (gnus-demon-remove-handler 'jao-gnus--scan))
+
(jao-gnus-add-demon)
(gnus-demon-init)
;; this is, in theory, not needed; but at some point in the way to emacs
;; version 31 this idle timers have ceased to work after a sleep/awake cycle
-(add-to-list 'jao-sleep-awake-functions #'jao-gnus-add-demon)
+(jao-when-linux (add-to-list 'jao-sleep-awake-functions #'jao-gnus-add-demon))
;;; add-ons
;;;; notifications
@@ -630,18 +678,16 @@
(defvar jao-gnus-tracked-groups
(let ((feeds (thread-first
(directory-files mail-source-directory nil "feeds\\.[^e]")
- (seq-difference '("feeds.trove")))))
- `(("nnml:bigml\\.inbox" "B" jao-themes-f00)
- ("nnml:bigml\\.alba" "A" jao-themes-f00)
- ("nnml:bigml\\.bugs" "b" jao-themes-error)
- ("nnml:bigml\\.support" "S" default)
+ (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:bigml\\.[^aibs]" "W" jao-themes-dimm)
- ("nnml:jao.hacking" "H" jao-themes-dimm)
("nnml:jao.write" "W" jao-themes-warning)
- ("nnml:jao.[^isthw]" "J" jao-themes-dimm)
- (,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm)
- ("feeds\\.e" "E" jao-themes-dimm)
+ ("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))))
@@ -649,9 +695,17 @@
(defun jao-gnus--unread-counts ()
(seq-reduce (lambda (r g)
(let ((n (gnus-group-unread (car g))))
- (if (and (numberp n) (> n 0)) (cons (cons (car g) n) r) r)))
+ (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)
@@ -662,12 +716,20 @@
(defvar jao-gnus--notify-strs ())
+(defun jao-gnus--xbar-echo (labels)
+ (jao-shell-exec
+ (let* ((ls (mapconcat (lambda (x) (plist-get x :propertize)) labels " "))
+ (m (when ls (format "%s | color=#8b3626 | size=11" ls))))
+ (format "echo '%s' >/tmp/xbar" (or m " ")))))
+
(defun jao-gnus--notify-strs ()
- (let ((counts (jao-gnus--unread-counts)))
- (seq-filter #'identity
- (seq-map (lambda (args)
- (apply 'jao-gnus--unread-label counts args))
- jao-gnus-tracked-groups))))
+ (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))
(defun jao-gnus--notify ()
(setq jao-gnus--notify-strs (jao-gnus--notify-strs))
@@ -689,6 +751,7 @@
(jao-gnus--notify)))
(add-hook 'gnus-summary-exit-hook #'jao-gnus--on-summary-exit)
+(add-hook 'gnus-exit-group-hook #'jao-gnus--notify)
;;;; open mail file in gnus
(defun jao-gnus-file-to-group (file &optional maildir newsdir m-server n-server)
@@ -725,6 +788,7 @@
;;;; afio
(defun jao-gnus--on-afio-switch ()
(when (derived-mode-p 'gnus-group-mode)
+ (jao-gnus--notify)
(let ((no (or (gnus-group-unread (gnus-group-group-name)) 0)))
(unless (> no 0) (gnus-group-first-unread-group)))))
@@ -765,12 +829,17 @@
'("message/rfc822" . jao-gnus-goto-file))))
;;;; notmuch
(use-package jao-notmuch-gnus
- :demand t)
+ :demand t
+ :init
+ (jao-when-darwin
+ (setq jao-notmuch-gnus-mail-directory
+ (expand-file-name "gnus" jao-maildir))))
(jao-load-path "consult-notmuch")
(use-package consult-notmuch
- :bind (:map gnus-group-mode-map ("S" . #'jao-gnus-consult-notmuch)))
+ :ensure t
+ :bind (:map gnus-group-mode-map ("/" . #'jao-gnus-consult-notmuch)))
;;; keyboard shortcuts
(define-key gnus-article-mode-map "i" 'jao-gnus-show-images)
@@ -783,3 +852,6 @@
(define-key gnus-summary-mode-map "e" 'jao-gnus-open-enclosure)
(define-key gnus-summary-mode-map "\C-l" nil)
(define-key gnus-group-mode-map "a" 'jao-gnus-refresh-workspace)
+
+(jao-when-darwin
+ (define-key gnus-group-mode-map "O" 'jao-mac-open-nnw))
diff --git a/custom/jao-custom-mac.el b/custom/jao-custom-mac.el
new file mode 100644
index 0000000..05c5c4b
--- /dev/null
+++ b/custom/jao-custom-mac.el
@@ -0,0 +1,22 @@
+;;; jao-custom-brew.el --- Setup for mac env -*- lexical-binding: t; -*-
+
+(setenv "HOMEBREW_PREFIX" "/opt/homebrew")
+(setenv "HOMEBREW_CELLAR" "/opt/hombrew/Cellar")
+(setenv "HOMEBREW_REPOSITORY" "/opt/homebrew")
+
+(setenv "GUILE_LOAD_PATH" "/opt/homebrew/share/guile/site/3.0")
+(setenv "GUILE_LOAD_COMPILED_PATH" "/opt/homebrew/lib/guile/3.0/site-ccache")
+(setenv "GUILE_SYSTEM_EXTENSIONS_PATH" "/opt/homebrew/lib/guile/3.0/extensions")
+
+(dolist (p '("/Applications/Emacs.app/Contents/MacOS/bin-arm64-11"
+ "/Applications/Emacs.app/Contents/MacOS/libexec-arm64-11"
+ "/opt/homebrew/sbin"
+ "/opt/homebrew/bin"
+ "~/.local/bin"
+ "/Library/TeX/texbin"))
+ (jao-exec-path p))
+
+(add-to-list 'Info-directory-list "/opt/homebrew/share/info")
+
+(provide 'jao-custom-mac)
+;;; jao-custom-mac.el ends here
diff --git a/custom/jao-custom-multimedia.el b/custom/jao-custom-multimedia.el
new file mode 100644
index 0000000..aab9cf1
--- /dev/null
+++ b/custom/jao-custom-multimedia.el
@@ -0,0 +1,119 @@
+;; -*- lexical-binding: t -*-
+
+;;; utilities
+
+(defun jao-mixer-get-level (&optional dev nomsg)
+ (interactive)
+ (let* ((dev (or dev "Master"))
+ (s (shell-command-to-string (format "amixer sget %s" dev)))
+ (s (car (last (split-string s "\n" t)))))
+ (when (string-match ".*Front .*\\[\\([0-9]+\\)%\\] .*" s)
+ (let ((level (match-string 1 s)))
+ (unless nomsg (message "%s level: %s%%" dev level))
+ (string-to-number level)))))
+
+(defun jao-mixer-set (dev v)
+ (jao-shell-exec* t "amixer" "sset" dev v)
+ (jao-mixer-get-level dev))
+
+(defun jao-mixer-master-toggle ()
+ (interactive)
+ (jao-mixer-set "Master" "toggle"))
+
+(defun jao-mixer-master-up ()
+ (interactive)
+ (jao-mixer-set "Master" "10%+"))
+
+(defun jao-mixer-master-down ()
+ (interactive)
+ (jao-mixer-set "Master" "10%-"))
+
+(defun jao-mixer-capture-up ()
+ (interactive)
+ (jao-mixer-set "Capture" "10%+"))
+
+(defun jao-mixer-capture-down ()
+ (interactive)
+ (jao-mixer-set "Capture" "10%-"))
+
+(jao-shell-def-exec jao-audio-applet "pasystray")
+
+(defun jao-toggle-audio-applet ()
+ (interactive)
+ (or (jao-shell-kill-p "paystray") (jao-audio-applet)))
+
+(global-set-key (kbd "<f4>") #'jao-toggle-audio-applet)
+
+;;; streaming aliases
+(defalias 'jao-streaming-list #'ignore)
+(defalias 'jao-streaming-like #'ignore)
+(defalias 'jao-streaming-dislike #'ignore)
+(defalias 'jao-streaming-toggle-shuffle #'ignore)
+(defalias 'jao-streaming-lyrics #'ignore)
+(defalias 'jao-streaming-toggle #'ignore)
+(defalias 'jao-streaming-next #'ignore)
+(defalias 'jao-streaming-prev #'ignore)
+(defalias 'jao-streaming-current #'ignore)
+(defalias 'jao-streaming-seek #'ignore)
+(defalias 'jao-streaming-seek-back #'ignore)
+(defalias 'jao-streaming-volume #'ignore)
+(defalias 'jao-streaming-volume-down #'ignore)
+
+(defun jao-toggle-pasystray-applet ()
+ (interactive)
+ (or (jao-shell-kill-p "pasystray") (jao-shell-exec "pasystray")))
+
+(transient-define-prefix jao-transient-streaming ()
+ [:description
+ (lambda () (format "Streaming using %s" jao-mpris-player))
+ ;; ["Search" :if jao-mpris-mopidy-p
+ ;; ("a" "album" jao-streaming-album)
+ ;; ("A" "artist" jao-streaming-artist)
+ ;; ("t" "track" jao-streaming-track)
+ ;; ("P" "playlist" jao-streaming-playlist)]
+ ["Play"
+ ("s" "toggle" jao-streaming-toggle)
+ ("n" "next" jao-streaming-next)
+ ("p" "previous" jao-streaming-prev)
+ ("T" "toggle player" jao-streaming-toggle-player)]
+ ["Seek & shout"
+ ("f" "seek fwd" jao-streaming-seek :transient t)
+ ("F" "seek bwd" jao-streaming-seek-back :transient t)
+ ("u" "up" jao-streaming-volume :transient t)
+ ("d" "down" jao-streaming-volume-down :transient t)]
+ ["Browse"
+ ;; ("l" "playing list" jao-streaming-list :if jao-mpris-mopidy-p)
+ ("L" "lyrics" jao-streaming-lyrics)
+ ("w" "currently playing" jao-streaming-current)]
+ ;; ["Act" :if jao-mpris-mopidy-p
+ ;; ("k" "like" jao-streaming-like)
+ ;; ("K" "dislike" jao-streaming-dislike)
+ ;; ("S" "toggle shuffle" jao-streaming-toggle-shuffle)]
+ ]
+ )
+
+;;; mpris
+(defun jao-mpris-lyrics (&optional force)
+ (interactive "P")
+ (jao-show-lyrics force #'jao-mpris-artist-title))
+
+(use-package jao-mpris :demand t)
+
+(defun jao-mpris-setup-aliases ()
+ (setq espotify-play-uri-function #'espotify-play-uri-with-dbus)
+ ;; (setq jao-mpris-player "mopidy")
+ (defalias 'jao-streaming-list #'jao-mpc-show-playlist)
+ (defalias 'jao-streaming-lyrics #'jao-mpris-lyrics)
+ (defalias 'jao-streaming-toggle #'jao-mpris-play-pause)
+ (defalias 'jao-streaming-next #'jao-mpris-next)
+ (defalias 'jao-streaming-prev #'jao-mpris-previous)
+ (defalias 'jao-streaming-current #'jao-mpris-show-osd)
+ (defalias 'jao-streaming-seek #'jao-mpris-seek)
+ (defalias 'jao-streaming-seek-back #'jao-mpris-seek-back)
+ (defalias 'jao-streaming-volume #'jao-mpris-vol)
+ (defalias 'jao-streaming-volume-down #'jao-mpris-vol-down))
+
+(jao-mpris-register "playerctld" :session 70)
+
+;;; - provide
+(provide 'jao-custom-multimedia)
diff --git a/custom/jao-custom-notmuch.el b/custom/jao-custom-notmuch.el
index 42d9e12..1297284 100644
--- a/custom/jao-custom-notmuch.el
+++ b/custom/jao-custom-notmuch.el
@@ -12,11 +12,14 @@
(:name "W"
:query "tag:new and tag:bigml and not tag:\"/support|bugs|inbox/\""
:face default)
- (:name "I" :query "tag:new and tag:jao and tag:inbox" :face jao-themes-warning)
- (:name "W" :query "tag:new and tag:jao and tag:write" :face jao-themes-warning)
+ (:name "I" :query "tag:new and tag:jao and tag:inbox"
+ :face jao-themes-warning)
+ (:name "W" :query "tag:new and tag:jao and tag:write"
+ :face jao-themes-warning)
(:name "J"
- :query ,(concat "tag:new and tag:jao and not "
- "tag:\"/local|hacking|draft|inbox|prog|words|write/\"")
+ :query
+ ,(concat "tag:new and tag:jao and not "
+ "tag:\"/local|hacking|draft|inbox|prog|words|write/\"")
:face default)
(:name "H" :query "tag:new and tag:hacking and not tag:\"/emacs/\"")
(:name "E" :query "tag:new and tag:\"/emacs/\"")
@@ -95,13 +98,13 @@
(setq notmuch-hello-sections nil notmuch-saved-searches nil)
-(jao-notmuch-def-searches bigml
- `(,(jao-notmuch--q "bigml" "inbox" "bi")
- ,(jao-notmuch--q "bigml" "alba" "ba")
- ,(jao-notmuch--q "bigml" "support" "bs")
- ,(jao-notmuch--q "bigml" "bugs" "bb")
- ,(jao-notmuch--q "bigml" "drivel" "bd")
- ,(jao-notmuch--q "bigml" "lists" "bl")))
+;; (jao-notmuch-def-searches bigml
+;; `(,(jao-notmuch--q "bigml" "inbox" "bi")
+;; ,(jao-notmuch--q "bigml" "alba" "ba")
+;; ,(jao-notmuch--q "bigml" "support" "bs")
+;; ,(jao-notmuch--q "bigml" "bugs" "bb")
+;; ,(jao-notmuch--q "bigml" "drivel" "bd")
+;; ,(jao-notmuch--q "bigml" "lists" "bl")))
(jao-notmuch-def-searches inbox
`(,(jao-notmuch--q "jao" "inbox" "ji")
@@ -109,7 +112,8 @@
,(jao-notmuch--qn "jao" "write" "jw" '("tag:write"))
,(jao-notmuch--q "jao" "drivel" "jd")
,(jao-notmuch--q "jao" "mdk" "jm")
- ,(jao-notmuch--qn "jao" "hacking" "jh" '("tag:hacking" "not tag:\"/emacs/\""))
+ ,(jao-notmuch--qn "jao" "hacking" "jh"
+ '("tag:hacking" "not tag:\"/emacs/\""))
,(jao-notmuch--qn "jao" "local" "jl" '("tag:local"))))
(jao-notmuch-def-searches news
@@ -120,7 +124,7 @@
(jao-notmuch-def-searches prog
(append (mapcar #'jao-notmuch--sq
- '( "lobsters" "clojure" "lisp" "scheme"
+ '("lobsters" "clojure" "lisp" "scheme"
"haskell" "idris" "erlang" "pharo"))
`(,(jao-notmuch--qn "feeds" "prog" "fp"
'("tag:prog" "not tag:\"/emacs/\"")))))
@@ -166,7 +170,8 @@
'("jao" "hacking" "feeds" "bills")))
(jao-notmuch-def-searches nil
- '((:query "not tag:trove and not tag:bigml" :name "jao/untroved" :search-type tree)
+ '((:query "not tag:trove and not tag:bigml" :name "jao/untroved"
+ :search-type tree)
(:query "tag:sent and tag:bigml" :name "bigml/sent" :search-type tree)
(:query "tag:sent and not tag:bigml" :name "jao/sent" :search-type tree)
(:query "*" :name "messages" :search-type tree)))
@@ -185,11 +190,6 @@
'("new" "unread" "flagged" "signed" "sent" "attachment" "forwarded" "inbox"
"encrypted" "gmane" "gnus" "feeds" "rss" "mce" "trove" "prog" "emacs"))
-(defun jao-notmuch--subtags (tag &rest excl)
- (let* ((cmd (concat "notmuch search --output=tags tag:" tag))
- (ts (split-string (shell-command-to-string cmd))))
- (seq-difference ts (append jao-notmuch--shared-tags (cons tag excl)))))
-
(setq notmuch-archive-tags '("+trove" "-new" "-drivel" "-words" "-inbox")
notmuch-show-mark-read-tags '("-new" "-unread")
notmuch-tag-formats
@@ -199,9 +199,9 @@
("signed")
("new" "·")
("replied" "↩" (propertize tag 'face '(:family "Fira Code")))
- ("sent" "🛪")
- ("attachment" "📎")
- ("deleted" "🗙" (propertize tag 'face '(:underline nil ,@e)))
+ ("sent" "↑")
+ ("attachment" "⧺")
+ ("deleted" "⛒" (propertize tag 'face '(:underline nil ,@e)))
("flagged" "✓")
("jao" "j")
("bigml" "b")
@@ -245,7 +245,7 @@
(when jao-notmuch-enabled
(define-key message-mode-map (kbd "C-c C-d") #'notmuch-draft-postpone)
- (setq message-directory "~/var/mail/"
+ (setq message-directory (file-name-as-directory jao-maildir)
message-auto-save-directory "/tmp"
mail-user-agent 'message-user-agent))
@@ -501,8 +501,12 @@
(add-hook 'notmuch-tree-process-exit-functions #'jao-notmuch-tree--sentinel)
- (advice-add 'notmuch-tree :before #'jao-notmuch-before-tree)
- (advice-add 'notmuch-tree-quit :after #'jao-notmuch-after-tree-quit)
+ (defun jao-notmuch-use-two-panes ()
+ (interactive)
+ (advice-add 'notmuch-tree :before #'jao-notmuch-before-tree)
+ (advice-add 'notmuch-tree-quit :after #'jao-notmuch-after-tree-quit))
+
+ (when jao-notmuch-enabled (jao-notmuch-use-two-panes))
:bind (:map notmuch-tree-mode-map
(("b" . jao-notmuch-browse-urls)
@@ -613,46 +617,48 @@
(when jao-notmuch-enabled (setq mm-text-html-renderer 'shr))
;;; consult
-(jao-load-path "consult-notmuch")
-(require 'consult-notmuch)
-(setq consult-notmuch-newest-first t)
-(consult-customize consult-notmuch :preview-key 'any)
-
-(defvar jao-consult-notmuch-history nil)
-
-(defvar jao-mailbox-folders '("bigml" "jao"))
-
-(defun jao-consult-notmuch-folder (&optional tree folder)
- (interactive "P")
- (let* ((folder (if folder
- (file-name-as-directory folder)
- (completing-read "Group: "
- jao-mailbox-folders
- nil nil nil
- jao-consult-notmuch-history
- ".")))
- (folder (replace-regexp-in-string "/\\(.\\)" ".\\1" folder))
- (init (read-string "Initial query: "))
- (init (format "folder:/%s/ %s" folder init)))
- (if tree (consult-notmuch-tree init) (consult-notmuch init))))
-
-(with-eval-after-load "notmuch-hello"
- (define-key notmuch-hello-mode-map "f" #'jao-consult-notmuch-folder))
+(jao-when-linux
+ (jao-load-path "consult-notmuch")
+ (require 'consult-notmuch)
+ (setq consult-notmuch-newest-first t)
+ (consult-customize consult-notmuch :preview-key 'any)
+
+ (defvar jao-consult-notmuch-history nil)
+
+ (defvar jao-mailbox-folders '("bigml" "jao"))
+
+ (defun jao-consult-notmuch-folder (&optional tree folder)
+ (interactive "P")
+ (let* ((folder (if folder
+ (file-name-as-directory folder)
+ (completing-read "Group: "
+ jao-mailbox-folders
+ nil nil nil
+ jao-consult-notmuch-history
+ ".")))
+ (folder (replace-regexp-in-string "/\\(.\\)" ".\\1" folder))
+ (init (read-string "Initial query: "))
+ (init (format "folder:/%s/ %s" folder init)))
+ (if tree (consult-notmuch-tree init) (consult-notmuch init))))
+
+ (with-eval-after-load "notmuch-hello"
+ (define-key notmuch-hello-mode-map "f" #'jao-consult-notmuch-folder)))
;;; recoll
-(defun jao-notmuch-open-file (fname &optional _page)
- (with-temp-buffer
- (insert-file-contents-literally fname)
- (goto-char (point-min))
- (and (re-search-forward "^Message-ID: <\\([^>]+\\)>$" nil t)
- (notmuch-show (concat "id:" (match-string 1))))))
-
-(when jao-notmuch-enabled
- (with-eval-after-load "org"
- (org-link-set-parameters "message" :follow #'jao-notmuch-open-file))
-
- (with-eval-after-load "consult-recoll"
- (add-to-list 'consult-recoll-open-fns
- '("message/rfc822" . jao-notmuch-open-file))))
+(jao-when-linux
+ (defun jao-notmuch-open-file (fname &optional _page)
+ (with-temp-buffer
+ (insert-file-contents-literally fname)
+ (goto-char (point-min))
+ (and (re-search-forward "^Message-ID: <\\([^>]+\\)>$" nil t)
+ (notmuch-show (concat "id:" (match-string 1))))))
+
+ (when jao-notmuch-enabled
+ (with-eval-after-load "org"
+ (org-link-set-parameters "message" :follow #'jao-notmuch-open-file))
+
+ (with-eval-after-load "consult-recoll"
+ (add-to-list 'consult-recoll-open-fns
+ '("message/rfc822" . jao-notmuch-open-file)))))
;;; .
(provide 'jao-custom-notmuch)
diff --git a/custom/jao-custom-org.el b/custom/jao-custom-org.el
index 4d2e622..bf82bcc 100644
--- a/custom/jao-custom-org.el
+++ b/custom/jao-custom-org.el
@@ -1,7 +1,7 @@
;; -*- lexical-binding: t -*-
;;; General configuration
-(defvar jao-org-dir (expand-file-name "~/doc/org"))
+(defvar jao-org-dir (expand-file-name "org" jao-doc-dir))
(use-package org
:ensure t
@@ -22,7 +22,6 @@
org-enforce-todo-dependencies t
org-fast-tag-selection-single-key 'expert
org-insert-heading-respect-content nil ;; for C-RET
- ;; org-list-demote-modify-bullet '(("+" . "-") ("-" . "+") ("*" . "+"))
org-link-frame-setup
'((gnus . (lambda (&optional x) (jao-open-gnus-frame)))
(file . find-file-other-window))
@@ -30,6 +29,8 @@
org-modules '(bibtex info eww eshell git-link)
org-odd-levels-only t
org-outline-path-complete-in-steps nil
+ org-persist-directory (expand-file-name "cache/org-persist"
+ user-emacs-directory)
org-refile-allow-creating-parent-nodes 'confirm
org-refile-targets '((nil :maxlevel . 5)
(org-agenda-files :maxlevel . 5))
@@ -51,30 +52,42 @@
org-gnus-prefer-web-links nil))
;;; Agenda
+(defun jao-org-agenda-fmt-date (date)
+ (org-agenda-format-date-aligned date))
+
(setq org-agenda-custom-commands
- '(("j" agenda "" ((org-agenda-ndays 14)
- (org-agenda-overriding-header " ")))
+ '(("j" agenda "" ((org-agenda-overriding-header "Agenda \n")
+ (org-agenda-ndays-to-span 14)))
("w" todo "WAITING" nil)
("W" agenda "" ((org-agenda-ndays 21))))
org-agenda-files (mapcar (lambda (f)
(expand-file-name f jao-org-dir))
- '("inbox.org" "bigml.org"))
+ '("inbox.org"))
org-agenda-block-separator " "
org-agenda-breadcrumbs-separator "•"
org-agenda-current-time-string "•" ;; "*"
- ;; '((daily today require-timed)
- ;; (800 1000 1200 1400 1600 1800 2000) "" "·")
+ org-agenda-format-date #'jao-org-agenda-fmt-date
org-agenda-hide-tags-regexp ".*"
org-agenda-include-diary t
org-agenda-include-inactive-timestamps t
org-agenda-inhibit-startup nil
+ org-agenda-prefix-format
+ '((agenda . " %i %?-12t% s")
+ (todo . " %i %-12:c")
+ (tags . " %i %-12:c")
+ (search . " %i %-12:c"))
org-agenda-restore-windows-after-quit t
org-agenda-show-all-dates t
org-agenda-skip-deadline-if-done t
- org-agenda-skip-scheduled-if-done nil
+ org-agenda-skip-scheduled-if-done t
+ org-agenda-skip-timestamp-if-done t
+ org-agenda-skip-timestamp-if-deadline-is-shown t
+ org-agenda-skip-scheduled-if-deadline-is-shown t
org-agenda-span 14
- org-agenda-start-on-weekday nil
- org-agenda-time-grid '((daily require-timed) () "" "·")
+ ;; org-agenda-start-on-weekday nil
+ ;; ;; org-agenda-time-grid '((daily require-timed) () "" "·")
+ ;; '((daily today require-timed)
+ ;; (800 1000 1200 1400 1600 1800 2000) "" "·")
org-agenda-window-setup 'current-window)
(defun jao-org-agenda ()
@@ -82,16 +95,20 @@
(org-agenda nil "j"))
(defun jao-org-agenda-hook ()
- (setq-local cursor-in-non-selected-windows nil))
+ (when-let* ((w (get-buffer-window "*Org Agenda*")))
+ (set-window-margins w 2 1)
+ (with-current-buffer (window-buffer w)
+ (setq-local cursor-in-non-selected-windows nil
+ line-spacing 0.2))))
-(add-hook 'org-agenda-mode-hook #'jao-org-agenda-hook)
+(add-hook 'org-agenda-finalize-hook #'jao-org-agenda-hook)
(add-to-list 'display-buffer-alist
- '("\\*Org Agenda\\*"
+ '((major-mode . org-agenda-mode)
(display-buffer-reuse-window)
+ (window-parameters (mode-line-format . none))
(body-function . (lambda (w) (set-window-margins w 2 1)))))
-
;;; Capture templates
(setq org-capture-templates
'(("t" "TODO" entry
@@ -99,7 +116,7 @@
"* TODO %?\n %i%a" :prepend t)
("r" "REPLY" entry
(file+headline "inbox.org" "Todo")
- "* REPLY %:subject%?\n %t\n %i%a" :prepend t)
+ "* REPLY %a\n %t\n %?" :prepend t)
("a" "Appointment" entry
(file+olp "inbox.org" "Appointments")
"* %^T %?\n %a" :time-prompt t)
@@ -140,10 +157,9 @@
(use-package org-fragtog
:after org
:ensure t
+ :demand t
:hook ((org-mode . org-fragtog-mode)))
-(require 'org-fragtog)
-
(setq org-format-latex-options
`(:foreground default
:background
@@ -160,6 +176,9 @@
(require 'ox-latex)
+;;; Export (org)
+(require 'ox-org)
+
;;; Export (minted and pandoc)
(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
@@ -167,10 +186,6 @@
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
-;; (use-package ox-pandoc
-;; :after org
-;; :ensure t)
-
;;; Babel and literate programming
(setq org-src-window-setup 'other-window) ;; current-window
(require 'org-tempo nil t) ;; <s TAB for 9.2 and later
@@ -192,9 +207,12 @@
(python . t)
(scheme .t)
(shell . t)
+ (C . t)
;; (prolog . t)
))
+(jao-define-attached-buffer "\\*Org Src\\( .*\\)?\\*" 0.5)
+
;;; Org cliplink (link from clipboard)
(use-package org-cliplink
:ensure t
@@ -275,7 +293,12 @@
(define-key doc-view-mode-map (kbd "C-c o") #'jao-org-pdf-goto-org)
(define-key doc-view-mode-map (kbd "C-c O") #'jao-org-pdf-goto-org*))
-;; eldoc
+;;;; mac links
+(jao-when-darwin
+ (use-package org-mac-link
+ :ensure t))
+
+;;; eldoc
(defun jao-org-eldoc--hook ()
(set (make-local-variable 'eldoc-documentation-function)
'jao-org-link-at-point)
@@ -290,6 +313,14 @@
(org-show-subtree))))
(add-hook 'org-mode-hook 'jao-org--show-if-hidden t)
+;;; jao-org-focus
+(use-package jao-org-focus
+ :after org
+ :config
+ (with-eval-after-load "jao-custom-completion"
+ (jao-consult-add-buffer-source 'jao-org-focus-consult-buffer-source))
+ :bind ((:map org-mode-map (("C-M-o" . jao-org-focus)))))
+
;;; Keybindings
(define-key mode-specific-map [?a] 'org-agenda)
(define-key org-mode-map "\C-cv" 'jao-org-copy-link-at-point)
@@ -298,7 +329,9 @@
(define-key org-mode-map "\C-cE" 'jao-insert-eww-link)
(define-key org-mode-map "\C-cW" 'jao-insert-eww-link)
(define-key org-mode-map "\C-c'" 'org-edit-src-code)
-(define-key org-mode-map "\C-cO" 'outline-hide-other)
+(define-key org-mode-map (kbd "C-c O") 'org-toggle-narrow-to-subtree)
+(define-key org-mode-map (kbd "C-x C-n") 'org-next-link)
+(define-key org-mode-map (kbd "C-x C-p") 'org-previous-link)
(global-set-key "\C-cr" 'org-capture)
(global-set-key "\C-c\C-l" 'org-store-link)
;; (global-set-key "\C-cL" 'org-insert-link-global)
@@ -306,7 +339,8 @@
(jao-transient-major-mode+ org
["Links"
- ("le" "insert current eww link" jao-insert-eww-link)
+ ("le" "insert current eww link" jao-insert-eww-link :if jao-is-linux)
+ ("lm" "insert mac link" org-mac-link-get-link :if jao-is-darwin)
("lf" "insert link from clipboard" org-cliplink)
("lc" "copy link at point" jao-org-copy-link-at-point)])
diff --git a/custom/jao-custom-pdf.el b/custom/jao-custom-pdf.el
new file mode 100644
index 0000000..50612bf
--- /dev/null
+++ b/custom/jao-custom-pdf.el
@@ -0,0 +1,83 @@
+;; -*- lexical-binding: t -*-
+
+;;;; open pdfs
+(use-package saveplace-pdf-view
+ :ensure t
+ :demand t
+ :after doc-view)
+
+(use-package jao-pdf
+ :demand t
+ :config
+ (setq jao-open-doc-fun 'jao-find-or-open)
+ (setq jao-org-open-pdf-fun jao-open-doc-fun))
+
+;;;; doc-view
+(use-package doc-view
+ :init
+ (setq doc-view-cache-directory "~/.emacs.d/cache/docview"
+ doc-view-resolution 110
+ doc-view-continuous t
+ doc-view-conversion-refresh-interval 1
+ doc-view-mupdf-use-svg t)
+ (defalias 'jao-doc-view-externally
+ (jao-d-l 'jao-mac-open-in-skim 'jao-open-with-zathura))
+ :hook ((doc-view-mode . jao-doc-session-mark))
+ :bind (:map doc-view-mode-map
+ ("j" . doc-view-next-line-or-next-page)
+ ("J" . doc-view-search-next-match)
+ ("k" . doc-view-previous-line-or-previous-page)
+ ("K" . doc-view-search-previous-match)
+ ("z" . jao-doc-view-externally)))
+
+(use-package jao-doc-session :demand t)
+
+(use-package jao-doc-view
+ :demand t
+ :bind (:map doc-view-mode-map
+ ("b" . jao-doc-view-back)
+ ("B" . jao-doc-view-forward)
+ ("S" . jao-doc-session-save)
+ ("u" . jao-doc-view-visit-url)))
+
+;;;; transient
+(defun jao-org-pdf-goto-org-linking ()
+ (interactive)
+ (jao-org-pdf-goto-org 4))
+
+(jao-transient-major-mode doc-view
+ ["Notes"
+ ("o" "notes file" jao-org-pdf-goto-org)
+ ("O" "notes file, linking" jao-org-pdf-goto-org-linking)]
+ ["Navigation"
+ ("b" "back jump" jao-doc-view-back)
+ ("B" "forward jump" jao-doc-view-back)
+ ("u" "visit URL" jao-doc-view-visit-url)]
+ ["Slices"
+ ("cb" "bounding box" doc-view-set-slice-from-bounding-box)
+ ("cm" "using mouse" doc-view-set-slice-using-mouse)]
+ ["Session"
+ ("s" "load session" jao-afio-open-pdf-session)
+ ("S" "save session" jao-doc-session-save)
+ ("d" "visit cache directory" doc-view-dired-cache)]
+ ["External viewers"
+ ("z" "open with zathura" jao-open-with-zathura :if jao-is-linux)
+ ("z" "open with skim" jao-mac-open-in-skim :if jao-is-darwin)])
+
+(with-eval-after-load "pdf-view"
+ (jao-transient-major-mode pdf-view
+ ["Notes"
+ ("o" "notes file" jao-org-pdf-goto-org)
+ ("O" "notes file, linking" jao-org-pdf-goto-org-linking)]
+ ["Navigation"
+ ("b" "back jump" pdf-history-backward)
+ ("f" "forward jump" pdf-history-forward)]
+ ["Session"
+ ("s" "load session" jao-afio-open-pdf-session)
+ ("S" "save session" jao-doc-session-save)]
+ ["External viewers"
+ ("z" "open with zathura" jao-open-with-zathura)]))
+
+;; (transient-get-suffix 'jao-transient-pdf-view '(0 -1))
+
+(provide 'jao-custom-pdf)
diff --git a/custom/jao-custom-programming.el b/custom/jao-custom-programming.el
new file mode 100644
index 0000000..61e51ea
--- /dev/null
+++ b/custom/jao-custom-programming.el
@@ -0,0 +1,522 @@
+;; -*- lexical-binding: t -*-
+
+;;; Programming
+;;;; automatic modes
+(add-to-list 'auto-mode-alist '("\\.mix\\'" . hexl-mode))
+(add-to-list 'auto-mode-alist '("\\.m4\\'" . m4-mode))
+(add-to-list 'auto-mode-alist '("\\.am\\'" . makefile-mode))
+(add-to-list 'auto-mode-alist '("\\.pl\\'\\|\\.pm\\'" . cperl-mode))
+
+;;;; symbol overlay
+(use-package symbol-overlay
+ :ensure t
+ :config
+ (defun jao-symbol-reveal (&rest _)
+ (when outline-minor-mode (outline-show-entry)))
+ (advice-add 'symbol-overlay-basic-jump :after 'jao-symbol-reveal)
+
+ (defun jao-symbol-put-and-next ()
+ (interactive)
+ (symbol-overlay-put)
+ (symbol-overlay-jump-next))
+
+ (defun jao-symbol-put-and-prev ()
+ (interactive)
+ (symbol-overlay-put)
+ (symbol-overlay-jump-prev))
+
+ :bind (:map prog-mode-map (("M-i" . symbol-overlay-put)
+ ("M-n" . jao-symbol-put-and-next)
+ ("M-p" . jao-symbol-put-and-prev)))
+ :hook (prog-mode . symbol-overlay-mode)
+ :diminish " ^")
+
+;;;; eglot
+(use-package eglot
+ :bind (:map eglot-mode-map (("C-h ." . jao-eldoc-toggle))))
+
+;;;; paredit and parens
+(require 'paren)
+(show-paren-mode t)
+(setq show-paren-context-when-offscreen t
+ show-paren-when-point-inside-paren nil)
+
+(use-package paredit
+ :ensure t
+ :commands paredit-mode
+ :hook ((pie-mode . paredit-mode)
+ (scheme-mode . paredit-mode)
+ (clojure-mode . paredit-mode)
+ (emacs-lisp-mode . paredit-mode)
+ ;; (eval-expression-minibuffer-setup . paredit-mode)
+ (lisp-interaction-mode . disable-paredit-mode))
+ :diminish ((paredit-mode . " þ")))
+
+;;;; diff/ediff
+(setq ediff-split-window-function 'split-window-horizontally)
+(setq ediff-make-buffers-readonly-at-startup nil)
+(setq ediff-window-setup-function 'ediff-setup-windows-plain)
+(setq ediff-keep-variants nil)
+
+;;;; compilation
+;;;;; compilation mode options
+(require 'compile)
+(setq compilation-scroll-output t)
+(setq compilation-error-regexp-alist
+ (remove 'omake compilation-error-regexp-alist))
+;; (add-hook 'compilation-mode-hook #'visual-line-mode)
+
+;;;;; mode line (no "Compiling"!)
+(require 'compile)
+(diminish 'compilation-minor-mode " ‡")
+(when (< emacs-major-version 27)
+ (setcdr (assq 'compilation-in-progress minor-mode-alist) '(" ‡")))
+(when (> emacs-major-version 26)
+ (setcdr (assq 'compilation-in-progress mode-line-modes) '("‡ ")))
+
+;;;;; colorizing compilation buffer
+(setq compilation-message-face 'default)
+(require 'ansi-color)
+(defun endless/colorize-compilation ()
+ "Colorize from `compilation-filter-start' to `point'."
+ (let ((inhibit-read-only t))
+ (ansi-color-apply-on-region
+ compilation-filter-start (point))))
+
+(add-hook 'compilation-filter-hook #'endless/colorize-compilation)
+
+;;;;; compilation commands
+(use-package jao-compilation
+ :commands jao-compilation-setup
+ :bind (("C-c C" . compile)
+ ("C-c c" . jao-compile)))
+(jao-compilation-setup)
+
+;;;;; next error
+(setq next-error-find-buffer-function
+ #'next-error-buffer-on-selected-frame
+ next-error-verbose t)
+
+;;;; flymake
+(use-package flymake
+ :ensure t
+ :custom ((flymake-mode-line-format '(" " flymake-mode-line-counters)))
+ :config
+ (jao-define-attached-buffer "^\\*Flymake diagnostics .*\\*\\'")
+
+ (transient-define-prefix jao-transient-flymake ()
+ ["Flymake"
+ ("d" "show diagnostics" flymake-show-buffer-diagnostics)
+ ("i" "show diagnostic" flymake-show-diagnostic)
+ ("n" "next error" flymake-goto-next-error)
+ ("p" "previous error" flymake-goto-prev-error)
+ ("c" "consult flymake" consult-flymake)])
+
+ :bind (:map flymake-mode-map (("M-m" . jao-transient-flymake))))
+
+;;;; workarounds
+(setq c-type-finder-time-slot nil)
+
+;;;; outline minor mode
+(use-package outline
+ :init (setq outline-minor-mode-use-buttons nil
+ outline-minor-mode-use-margins nil
+ outline-minor-mode-cycle t))
+
+(defvar-local jao-outline-folded nil)
+(dolist (v '(4 5 outline-show-only-headings))
+ (add-to-list 'safe-local-variable-values `(outline-default-state . ,v)))
+
+(defun jao-outline-minor-mode-hide-all (&optional arg)
+ (interactive "P")
+ (outline-hide-sublevels (if arg 5 4)))
+
+(defun jao-outline-minor-expand-all ()
+ (when jao-outline-minor-mode (outline-show-all)))
+
+(defun jao-outline-minor-mode-toogle-fold (&optional arg)
+ (interactive "P")
+ (if (setq jao-outline-folded (not jao-outline-folded))
+ (jao-outline-minor-mode-hide-all arg)
+ (jao-outline-minor-expand-all)))
+
+(use-package outline-minor-faces
+ :ensure t
+ :after outline)
+
+(define-minor-mode jao-outline-minor-mode
+ "Minor outline mode for programming languages"
+ :lighter ""
+ :keymap `((,(kbd "C-c C-n") . outline-next-visible-heading)
+ (,(kbd "C-c C-p") . outline-previous-visible-heading)
+ (,(kbd "C-c o") . consult-outline)
+ (,(kbd "<f3>") . jao-outline-minor-mode-toogle-fold))
+ (if jao-outline-minor-mode
+ (progn (setq-local outline-level #'outline-level
+ outline-regexp (format "[%s]\\{3,\\} " comment-start))
+ (outline-minor-mode 1)
+ (outline-minor-faces-mode 1))
+ (outline-minor-mode -1)
+ (outline-minor-faces-mode -1)))
+
+(add-hook 'find-function-after-hook #'jao-outline-minor-expand-all)
+
+;;; Programming languages
+;;;; Elisp
+(add-hook 'emacs-lisp-mode-hook #'jao-outline-minor-mode)
+
+(use-package edit-list :ensure t)
+;; (use-package package-lint :ensure t)
+;; (use-package tree-inspector :ensure t)
+
+(defun elisp-disassemble (function)
+ (interactive (list (function-called-at-point)))
+ (disassemble function))
+
+(defun elisp-pp (sexp)
+ (with-output-to-temp-buffer "*Pp Eval Output*"
+ (pp sexp)
+ (with-current-buffer standard-output
+ (emacs-lisp-mode))))
+
+(defun elisp-macroexpand (form)
+ (interactive (list (form-at-point 'sexp)))
+ (elisp-pp (macroexpand form)))
+
+(defun elisp-macroexpand-all (form)
+ (interactive (list (form-at-point 'sexp)))
+ (elisp-pp (macroexpand-all form)))
+
+(defun elisp-find-definition (name)
+ (interactive (list (thing-at-point 'symbol)))
+ (cond (name
+ (let ((symbol (intern-soft name))
+ (search (lambda (fun sym)
+ (let* ((r (save-excursion (funcall fun sym)))
+ (buffer (car r))
+ (point (cdr r)))
+ (cond ((not point)
+ (error "Found no definition for %s in %s"
+ name buffer))
+ (t
+ (switch-to-buffer buffer)
+ (goto-char point)
+ (recenter 1)))))))
+ (cond ((fboundp symbol)
+ (xref-push-marker-stack)
+ (funcall search 'find-function-noselect symbol))
+ ((boundp symbol)
+ (xref-push-marker-stack)
+ (funcall search 'find-variable-noselect symbol))
+ (t
+ (message "Symbol not bound: %S" symbol)))))
+ (t (message "No symbol at point"))))
+
+
+(defun elisp-bytecompile-and-load ()
+ (interactive)
+ (or buffer-file-name
+ (error "The buffer must be saved in a file first"))
+ (require 'bytecomp)
+ ;; Recompile if file or buffer has changed since last compilation.
+ (when (and (buffer-modified-p)
+ (y-or-n-p (format "save buffer %s first? " (buffer-name))))
+ (save-buffer))
+ (let ((filename (expand-file-name buffer-file-name)))
+ (with-temp-buffer
+ (byte-compile-file filename))))
+
+(use-package elisp-mode
+ :bind (:map emacs-lisp-mode-map
+ (("C-c C-M" . emacs-lisp-macroexpand)
+ ("C-c C-m" . elisp-macroexpand-all)
+ ("C-c C-k" . elisp-bytecompile-and-load)
+ ;; ("C-c C-p" . pp-eval-last-sexp)
+ ("M-." . elisp-find-definition)
+ ("M-," . pop-tag-mark)
+ ("C-c <" . lc-show-package-summary))))
+
+;;;; Clojure
+(use-package clojure-mode
+ :ensure t
+ :hook (clojure-mode . jao-clojure--fix-things)
+ :config
+ (defun jao-clojure--fix-things ()
+ (setq-local completion-styles '(basic partial-completion emacs22))
+ (eldoc-mode 1)
+ (setq mode-name "λ"))
+
+ (defun jao-kaocha-file-name ()
+ (let* ((filename (match-string 2))
+ (path (replace-regexp-in-string "\\." "/" (match-string 1))))
+ (substring-no-properties (concat "test/" path filename))))
+
+ (defconst jao-kaocha-compilation-error
+ '(kaocha-error
+ "^FAIL in \\(.+\\.\\)[^ ]+ (\\([^:]+\\.clj[cs]?\\):\\([0-9]+\\))"
+ jao-kaocha-file-name 3))
+
+ (use-package compile
+ :config
+ (add-to-list 'compilation-error-regexp-alist-alist
+ jao-kaocha-compilation-error)))
+
+(use-package jao-clojure
+ :demand t
+ :after cider-test
+ :bind (:map clojure-mode-map (("C-c o" . jao-clojure-other-file))))
+
+(use-package cider
+ :ensure t
+ :commands cider-mode
+ :init (setq cider-annotate-completion-candidates t
+ cider-auto-select-error-buffer nil
+ cider-auto-select-test-report-buffer nil
+ cider-clojure-cli-aliases ":test"
+ cider-eldoc-display-for-symbol-at-point t
+ cider-eldoc-ns-function #'identity ;; #'cider-last-ns-segment
+ cider-enrich-classpath nil
+ cider-lein-parameters "repl :headless :host localhost"
+ cider-mode-line " ÷"
+ cider-prompt-for-symbol nil
+ cider-repl-history-file
+ (expand-file-name "~/.emacs.d/cache/cider.history")
+ cider-repl-pop-to-buffer-on-connect nil
+ cider-repl-use-pretty-printing t
+ cider-show-error-buffer 'except-in-repl
+ cider-test-show-report-on-success nil
+ cider-use-fringe-indicators nil
+ cider-use-overlays nil
+ clojure-docstring-fill-column 72
+ nrepl-prompt-to-kill-server-buffer-on-quit nil)
+ :bind (("<f3>" . cider-selector)))
+
+(with-eval-after-load "cider-test"
+ (advice-add 'cider-scale-background-color :override
+ (lambda () (frame-parameter nil 'background-color)))
+ (setq cider-test-items-background-color
+ (frame-parameter nil 'background-color)))
+
+(use-package cider-macroexpansion
+ :after cider
+ :diminish " µ")
+
+;;;; Geiser
+(defun jao-org--set-geiser-impl () (setq-local geiser-repl--impl 'guile))
+(add-hook 'org-mode-hook #'jao-org--set-geiser-impl)
+
+(jao-load-path "geiser")
+;; (package-vc-install-from-checkout ...)
+(use-package geiser
+ :demand t
+ :init
+ (setq geiser-repl-history-filename "~/.emacs.d/cache/geiser-history"
+ geiser-repl-startup-time 20000
+ geiser-debug-auto-display-images t
+ geiser-log-verbose t)
+ :config
+ (dolist (m '(geiser-repl-mode geiser-doc-mode geiser-debug-mode))
+ (jao-define-attached-buffer `(major-mode . ,m) 0.4)))
+
+(jao-load-path "geiser-guile")
+(use-package geiser-guile)
+
+(jao-load-path "geiser-chez")
+(use-package geiser-chez
+ :init (setq geiser-chez-binary (jao-d-l "chez" "scheme")))
+
+;; (jao-load-path "geiser/mit")
+;; (use-package geiser-mit)
+
+;; (jao-load-path "geiser/chicken")
+;; (use-package geiser-chicken)
+
+;; (jao-load-path "geiser/chibi")
+;; (use-package geiser-chibi)
+
+;; (jao-load-path "geiser/gambit")
+;; (use-package geiser-gambit)
+
+;; (jao-load-path "geiser/gauche")
+;; (use-package geiser-gauche)
+
+;;;; Haskell
+;;;;; packages
+;; (jao-load-path "haskell-mode")
+
+(use-package haskell-mode
+ :ensure t
+ :custom
+ ((inferior-haskell-find-project-root t)
+ (haskell-check-remember-last-command-p nil)
+ (haskell-completing-read-function 'completing-read)
+ (haskell-font-lock-symbols nil)
+ (haskell-hoogle-command "hoogle")
+ (haskell-interactive-popup-errors t)
+ (haskell-process-auto-import-loaded-modules t)
+ (haskell-process-log t)
+ (haskell-process-suggest-remove-import-lines t)
+ (haskell-process-suggest-hoogle-imports t)
+ (haskell-process-type 'cabal-repl)
+ (haskell-process-use-presentation-mode t)
+ (haskell-stylish-on-save nil)
+ (haskell-tags-on-save t))
+
+ :init
+ ;; For use with M-x align
+ (require 'align)
+ (add-to-list 'align-rules-list
+ '(haskell-types
+ (regexp . "\\(\\s-+\\)\\(::\\|∷\\)\\s-+")
+ (modes quote (haskell-mode haskell-literate-mode))))
+ (add-to-list 'align-rules-list
+ '(haskell-assignment
+ (regexp . "\\(\\s-+\\)=\\s-+")
+ (modes quote (haskell-mode haskell-literate-mode))))
+ (add-to-list 'align-rules-list
+ '(haskell-arrows
+ (regexp . "\\(\\s-+\\)\\(->\\|→\\)\\s-+")
+ (modes quote (haskell-mode haskell-literate-mode))))
+ (add-to-list 'align-rules-list
+ '(haskell-left-arrows
+ (regexp . "\\(\\s-+\\)\\(<-\\|←\\)\\s-+")
+ (modes quote (haskell-mode haskell-literate-mode))))
+
+ :config
+ (defun jao-haskell-hoogle (no-info)
+ (interactive "P")
+ (haskell-hoogle (format "%s" (haskell-ident-at-point)) (not no-info)))
+
+ (put 'haskell-process-args-cabal-repl
+ 'safe-local-variable
+ (apply-partially #'seq-every-p #'stringp))
+
+ (defun jao-haskell-eldoc (cb)
+ (let ((msg (or (haskell-doc-current-info--interaction t)
+ (haskell-doc-sym-doc (haskell-ident-at-point))
+ "")))
+ (funcall cb (replace-regexp-in-string "[\n ]+" " " msg))))
+
+ (setq tags-revert-without-query t)
+
+ (defun jao-haskell-mode ()
+ (require 'haskell-doc)
+ (setq-local eldoc-documentation-function 'eldoc-documentation-default
+ eldoc-documentation-functions '(jao-haskell-eldoc))
+ (eldoc-mode))
+
+ (dolist (h '(jao-haskell-mode
+ haskell-decl-scan-mode
+ haskell-indentation-mode
+ interactive-haskell-mode))
+ (add-hook 'haskell-mode-hook h))
+
+ (add-hook 'haskell-presentation-mode-hook (lambda () (whitespace-mode -1)))
+
+ :bind (:map haskell-mode-map
+ (("C-c C-d" . jao-haskell-hoogle)
+ ("C-c C-s" . haskell-session-change-target)
+ ("C-c h" . haskell-hoogle)
+ ("C-c t" . haskell-doc-show-type)
+ ("C-c C-e" . haskell-command-insert-language-pragma)
+ ("C-M-n" . flymake-goto-next-error)
+ ("C-M-p" . flymake-goto-prev-error)
+ ("<f3>" . haskell-session-kill))))
+
+(jao-when-linux
+ (use-package hlint-refactor
+ :ensure t
+ :after haskell-mode
+ :hook ((haskell-mode . hlint-refactor-mode))
+ :bind (:map haskell-mode-map (("C-M-h" . 'hlint-refactor-refactor-at-point)
+ ("C-M-S-h" . 'hlint-refactor-refactor-buffer)))
+ :diminish)
+
+ (use-package flymake-hlint
+ :ensure t
+ :after haskell-mode
+ :hook ((haskell-mode . flymake-hlint-load))))
+
+(use-package consult-hoogle
+ :ensure t)
+
+(require 'haskell)
+
+(diminish 'interactive-haskell-mode " λ")
+(diminish 'haskell-doc-mode)
+(diminish 'haskell-decl-scan-mode)
+
+(jao-define-attached-buffer "\\*hoogle\\*.*")
+(jao-define-attached-buffer '(major-mode . haskell-interactive-mode) 0.33)
+(jao-define-attached-buffer '(major-mode . haskell-presentation-mode) 0.25)
+
+;;;;; transient
+(jao-transient-major-mode haskell
+ ["Imports"
+ ("in" "Navigate imports" haskell-navigate-imports)
+ ("if" "Format imports" haskell-mode-format-imports)
+ ("is" "Sort imports" haskell-sort-imports)
+ ("ia" "Align imports" haskell-align-imports)]
+ ["Session"
+ ("s" "Change the session's target" haskell-session-change-target)]
+ ["Code"
+ ("e" "insert language pragma" haskell-command-insert-language-pragma)
+ ("v" "visit cabal file" haskell-cabal-visit-file)
+ ("h" "hoogle" jao-haskell-hoogle)
+ ("t" "show type" haskell-doc-show-type)]
+ ["Flymake"
+ ("n" "next error" flymake-goto-next-error)
+ ("p" "previous error" flymake-goto-prev-error)])
+
+;;;; Pie
+;; (jao-load-path "pie")
+;; (use-package pie
+;; :commands (pie-mode))
+
+;;;; Prolog
+;; (use-package ediprolog :ensure t)
+
+(use-package prolog
+ :disabled t
+ :ensure t
+ :commands (run-prolog prolog-mode mercury-mode)
+ :init (progn
+ (setq prolog-system 'swi)
+ (add-to-list 'auto-mode-alist '("\\.pl$" . prolog-mode))
+ (setq prolog-consult-string '((t "[%f].")))
+ (setq prolog-program-name
+ '(((getenv "EPROLOG") (eval (getenv "EPROLOG")))
+ (eclipse "eclipse")
+ (mercury nil)
+ (sicstus "sicstus")
+ (swi "swipl")
+ (t "prolog")))))
+
+;;;; Python
+;; (use-package virtualenvwrapper
+;; :ensure t
+;; :config
+;; (venv-initialize-eshell)
+;; (jao-compilation-env "VIRTUAL_ENV"))
+
+;;;; Javascript
+
+(use-package typescript-mode
+ :ensure t
+ :custom ((typescript-indent-level 2)))
+;;;; Applescript
+
+(jao-when-darwin
+ (use-package ob-applescript
+ :after org
+ :ensure t
+ :demand t)
+
+ (use-package apples-mode
+ :ensure t
+ :init
+ (add-to-list 'auto-mode-alist
+ '("\\.\\(applescri\\|sc\\)pt\\'" . apples-mode))))
+
+;;; -
+(provide 'jao-custom-programming)
diff --git a/custom/jao-custom-shells.el b/custom/jao-custom-shells.el
new file mode 100644
index 0000000..eaae13c
--- /dev/null
+++ b/custom/jao-custom-shells.el
@@ -0,0 +1,6 @@
+;; -*- lexical-binding: t -*-
+
+
+
+
+(provide 'jao-custom-shells)
diff --git a/custom/jao-custom-w3m.el b/custom/jao-custom-w3m.el
index 43b9e2d..f532e8b 100644
--- a/custom/jao-custom-w3m.el
+++ b/custom/jao-custom-w3m.el
@@ -198,7 +198,7 @@
("v" . jao-view-video)
("q" . w3m-delete-buffer)
("w" . org-w3m-copy-for-org-mode)
- ("x" . jao-rss-subscribe)
+ ("x" . jao-r2e-subscribe)
("y" . w3m-print-current-url))))
;;; textsec
diff --git a/custom/jao-custom-x11.el b/custom/jao-custom-x11.el
new file mode 100644
index 0000000..b72fe0b
--- /dev/null
+++ b/custom/jao-custom-x11.el
@@ -0,0 +1,192 @@
+;; -*- lexical-binding: t -*-
+
+;;; x11 utils
+(defun jao-xdotool (arg-or-wait &rest args)
+ (apply 'jao-shell-exec*
+ (if (stringp arg-or-wait) "xdotool" arg-or-wait)
+ (if (stringp arg-or-wait) arg-or-wait "xdotool")
+ args))
+
+(defsubst jao-xdotool-string (&rest args)
+ (apply 'jao-shell-string "xdotool" args))
+
+(defsubst jao-x11-focused-id () (jao-xdotool-string "getwindowfocus"))
+
+(defsubst jao-x11-window-name (&optional wid)
+ (jao-xdotool-string "getwindowname" (or wid (jao-x11-focused-id))))
+
+(defsubst jao-x11-search-window (title)
+ (jao-xdotool-string "search" "--name" title))
+
+(defsubst jao-x11-goto-ws (n) (jao-xdotool t "set_desktop" (format "%s" n)))
+
+;;; exwm
+(defun jao-exwm-enable ()
+ (require 'jao-custom-exwm)
+ (setq jao-exwm-enabled t)
+ (display-time-mode -1)
+ (jao-ednc-setup 95)
+ (x-change-window-property "_XMONAD_TRAYPAD" "" nil nil nil nil 0)
+ (jao-mode-line-add-to-minibuffer-left 90)
+ (jao-xmobar-restart)
+ (jao-trisect t))
+
+;;; xmonad
+(defun jao-xmonad-enable ()
+ (setq jao-browse-doc-use-emacs-p (display-graphic-p))
+ (setq jao-mode-line-in-minibuffer nil)
+ (display-battery-mode -1)
+ (jao-trisect)
+ (message "Welcome to xmonad"))
+
+(when jao-xmonad-enabled
+ (add-hook 'after-init-hook #'jao-xmonad-enable))
+
+;;; wayland
+
+(use-package jao-wayland :demand t)
+
+(defun jao-wayland-enable ()
+ (interactive)
+ (defalias 'x-change-window-property #'ignore)
+ (jao-trisect)
+ (message "Welcome to wayland"))
+
+(defun jao-river-enable ()
+ (jao-wayland-enable)
+ (when (jao-shell-running-p "i3bar-river")
+ (jao-tracking-set-log ""))
+ (message "Welcome to river"))
+
+(when jao-river-enabled
+ (add-hook 'after-init-hook #'jao-river-enable t))
+
+(when jao-sway-enabled
+ (add-hook 'after-init-hook #'jao-wayland-enable t))
+
+;;; wallpaper
+(defvar jao-wallpaper-dir "~/.wallpapers/")
+
+(defvar jao-wallpaper-random-candidates
+ '("wallpaper.jpg" "wallpaper2.jpg"))
+
+(defvar jao-wallpaper-random-candidates-light
+ '("wallpaper.jpg" "wallpaper2.jpg"))
+
+(defvar jao-wallpaper-random-wake t
+ "Set to t for getting a new wallpaper on awaking from sleep")
+
+(defun jao-set-wallpaper (&optional path)
+ (interactive)
+ (let ((current (format "~/.wallpaper.%s" (jao-colors-scheme))))
+ (when-let ((f (or (and path (expand-file-name path))
+ (read-file-name "Image: "
+ jao-wallpaper-dir
+ (file-symlink-p current)
+ t))))
+ (make-symbolic-link f current t)
+ (cond (jao-river-enabled (jao-river-set-wallpaper f))
+ (jao-sway-enabled (jao-sway-set-wallpaper f))
+ (t (shell-command-to-string (format "xwallpaper --zoom %s" f)))))))
+
+(defun jao-set-random-wallpaper ()
+ (interactive)
+ (when (or (called-interactively-p 'interactive)
+ jao-wallpaper-random-wake)
+ (let* ((ws (if (jao-colors-scheme-dark-p)
+ jao-wallpaper-random-candidates
+ jao-wallpaper-random-candidates-light))
+ (f (seq-random-elt ws)))
+ (jao-set-wallpaper (expand-file-name f jao-wallpaper-dir))
+ (message "%s" f))))
+
+(add-to-list 'jao-sleep-awake-functions #'jao-set-random-wallpaper)
+
+;;; screensaver and lock
+(defun jao-screensaver-enabled ()
+ (string= (jao-shell-string "xdg-screensaver status") "enabled"))
+
+(defvar jao-screensaver--wid nil)
+(defun jao-screensaver-toggle ()
+ (interactive)
+ (if (jao-screensaver-enabled)
+ (let ((wid (jao-x11-focused-id)))
+ (setq jao-screensaver--wid wid)
+ (jao-shell-exec* t "xdg-screensaver" "suspend" wid))
+ (jao-shell-exec* t "xdg-screensaver" "resume" jao-screensaver--wid)
+ (setq jao-screensaver--wid nil))
+ (jao-notify (format "Screensaver %s"
+ (jao-shell-string "xdg-screensaver status"))))
+
+(jao-shell-def-exec jao-xlock-screen "xdg-screensaver" "activate")
+(jao-shell-def-exec jao-suspend "sudo" "systemctl" "suspend")
+(jao-shell-def-exec jao-poweroff "sudo" "systemctl" "poweroff")
+
+(defun jao-lock-screen ()
+ (interactive)
+ (if jao-wayland-enabled
+ (shell-command "swaylock -i ~/.lockimage")
+ (jao-xlock-screen)))
+
+(transient-define-prefix jao-transient-sleep ()
+ ["Sleep"
+ ("l" "lock screen" jao-lock-screen)
+ ("z" "sleep" jao-suspend)
+ ("u" (lambda ()
+ (if (jao-screensaver-enabled) "suspend screensaver" "resume screensaver"))
+ jao-screensaver-toggle)
+ ("poof" "power-off" jao-poweroff)])
+
+;;; X clipboard
+(setq select-enable-clipboard t
+ select-enable-primary t
+ selection-timeout 100
+ xterm-select-active-regions t)
+
+(use-package xclip
+ :ensure t
+ :init (setq xclip-method (if jao-wayland-enabled 'wl-copy 'xclip)))
+
+(unless (display-graphic-p) (xclip-mode 1))
+
+;;; pop-up frames
+(defun jao-open-in-x-frame (&optional width height)
+ (interactive)
+ (make-frame `((window-system . x)
+ (name . "emacs popup")
+ (width . ,(or width (window-width)))
+ (height . ,(or height (window-height)))))
+ (define-key (current-local-map) "q" #'delete-frame))
+
+;;; xmobar
+(defun jao-xmobar-kill ()
+ (interactive)
+ (shell-command "killall xmobar-single"))
+
+(defun jao-xmobar-restart ()
+ (interactive)
+ (jao-xmobar-kill)
+ (start-process "" nil "xmobar-single" "-d"))
+
+(use-package tab-bar
+ :init (setq tab-bar-close-button-show nil
+ tab-bar-show (> emacs-major-version 28)
+ tab-bar-format ()))
+
+(use-package xmobar
+ :init (setq xmobar-tab-bar t
+ xmobar-tab-split "*"
+ xmobar-tab-bar-format
+ (if window-system
+ '(xmobar-left-string
+ tab-bar-format-align-right
+ xmobar-right-string)
+ '(xmobar-left-string
+ xmobar-elastic-space
+ xmobar-right-string))
+ xmobar-command
+ (if window-system '("xmobar-emacs" "-TAnsi") "xmobar-emacs")))
+
+
+;;; - provide
+(provide 'jao-custom-x11)
diff --git a/init.el b/init.el
index 4f54b41..f694359 100644
--- a/init.el
+++ b/init.el
@@ -1,8 +1,26 @@
;; -*- lexical-binding: t; -*-
+;;; Portability macros
+(defmacro jao-syscase (clauses)
+ (let ((cls (assoc system-type clauses)))
+ (when cls `(progn ,@(cdr cls)))))
+
+(defmacro jao-d-l (darw linux)
+ `(jao-syscase ((darwin ,darw) (gnu/linux ,linux))))
+
+(defmacro jao-when-darwin (&rest body)
+ `(jao-syscase ((darwin ,@body))))
+
+(defmacro jao-when-linux (&rest body)
+ `(jao-syscase ((gnu/linux ,@body))))
+
+(defun jao-is-linux () (jao-when-linux t))
+(defun jao-is-darwin () (jao-when-darwin t))
+
;;; Initialisation
;;;; Bootstrap and use package
-(defvar jao-emacs-dir (expand-file-name "~/etc/emacs"))
+(defvar jao-emacs-dir
+ (expand-file-name (jao-d-l "~/.emacs.d/config" "~/etc/emacs")))
(setq package-user-dir
(expand-file-name (format "~/.emacs.d/elpa.%s" emacs-major-version))
@@ -33,7 +51,7 @@
warning-suppress-types '((comp)))
;;; Paths
-(defvar jao-local-lisp-dir "~/lib/elisp"
+(defvar jao-local-lisp-dir (jao-d-l "~/.local/lib/elisp" "~/lib/elisp")
"Directory for external elisp libraries and repos")
(defvar jao-data-dir (expand-file-name "data" jao-emacs-dir)
@@ -41,10 +59,12 @@
(defun jao-data-file (file) (expand-file-name file jao-data-dir))
-(setq jao-org-dir (expand-file-name "~/doc/org"))
+(defvar jao-doc-dir (expand-file-name (jao-d-l "~/Documents" "~/doc")))
+
+(setq jao-org-dir (expand-file-name "org" jao-doc-dir))
(defvar jao-sink-dir
- (file-name-as-directory (expand-file-name "~/doc/sink"))
+ (file-name-as-directory (expand-file-name "sink" jao-doc-dir))
"Directory used for downloads and such.")
(defvar jao-site-dir (expand-file-name "site" jao-emacs-dir))
@@ -59,7 +79,8 @@
(defun jao-exec-path (dir)
(let ((fn (expand-file-name dir)))
- (add-to-list 'exec-path fn nil)
+ (setq exec-path (remove fn exec-path))
+ (add-to-list 'exec-path fn)
(setenv "PATH" (concat fn ":" (getenv "PATH")))))
(defun jao-load-path (subdir)
@@ -78,10 +99,14 @@
(dolist (f (directory-files libd t "^[^.]+$"))
(when (file-directory-p f) (add-to-list 'load-path f))))
-(defvar jao-info-dir (expand-file-name "~/doc/info"))
+(defvar jao-info-dir (expand-file-name "info" jao-doc-dir))
(require 'info)
(add-to-list 'Info-directory-list jao-info-dir)
+(jao-when-darwin (require 'jao-custom-mac))
+
+(jao-exec-path (expand-file-name "bin" jao-emacs-dir))
+
;;;; custom location of custom.el and co.
(setq custom-file (jao-site-el "custom"))
(load custom-file)
@@ -90,13 +115,9 @@
(setq custom-raised-buttons nil)
;;; Preamble
-;;;; preamble (pre.el)
(jao-load-site-el "pre")
;;; System Utilities
-;;;; persist
-(require 'persist)
-
;;;; (no) backups
(setq vc-make-backup-files nil
make-backup-files nil)
@@ -132,7 +153,7 @@
(setq use-short-answers t)
(setq inhibit-startup-message t)
-(setq visible-bell t)
+(setq visible-bell (jao-is-linux))
;;;; server
(setenv "EDITOR" "emacsclient")
@@ -146,59 +167,77 @@
(inhibit-remote-files)
;;;; sleep/awake
-(use-package jao-sleep)
-(jao-sleep-dbus-register)
+(use-package jao-sleep
+ :if (jao-is-linux)
+ :demand t
+ :config (jao-sleep-dbus-register))
;;;; process runners
(use-package jao-shell
:demand t
- :config (jao-shell-def-exec jao-trayer "trayer.sh")
:bind (("s-r" . jao-shell-exec)))
;;;; app launcher
-(jao-load-path "app-launcher")
-(use-package app-launcher
- :bind (("s-R" . app-launcher-run-app)))
+(jao-when-linux
+ (jao-load-path "app-launcher")
+ (use-package app-launcher
+ :bind (("s-R" . app-launcher-run-app))))
;;;; brightness control
-(jao-shell-def-exec jao-bright-set-up "brightnessctl" "-q" "s" "5%+")
-(jao-shell-def-exec jao-bright-set-down "brightnessctl" "-q" "s" "5%-")
+(jao-when-linux
+ (jao-shell-def-exec jao-bright-set-up "brightnessctl" "-q" "s" "5%+")
+ (jao-shell-def-exec jao-bright-set-down "brightnessctl" "-q" "s" "5%-")
-(defun jao-brightness ()
- (string-trim (or (cadr (jao-shell-cmd-lines "brightnessctl")) "(Unknown)")))
+ (defun jao-brightness ()
+ (string-trim (or (cadr (jao-shell-cmd-lines "brightnessctl")) "(Unknown)")))
-(defun jao-bright-show ()
- (interactive)
- (message "%s" (jao-brightness)))
+ (defun jao-bright-show ()
+ (interactive)
+ (message "%s" (jao-brightness)))
-(defun jao-bright-up ()
- (interactive)
- (jao-shell-exec "brightnessctl -q s 5%%+" t)
- (jao-bright-show))
+ (defun jao-bright-up ()
+ (interactive)
+ (jao-shell-exec "brightnessctl -q s 5%%+" t)
+ (jao-bright-show))
-(defun jao-bright-down ()
- (interactive)
- (jao-shell-exec "brightnessctl -q s 5%%-" t)
- (jao-bright-show))
+ (defun jao-bright-down ()
+ (interactive)
+ (jao-shell-exec "brightnessctl -q s 5%%-" t)
+ (jao-bright-show)))
;;;; keyboard
-(when (> emacs-major-version 27)
- (use-package repeat
- :config (setq repeat-echo-function 'repeat-echo-mode-line
- repeat-exit-key "SHIFT"
- repeat-exit-timeout 2))
+(jao-when-darwin
+ (setq mac-command-modifier 'meta)
+ (setq mac-option-modifier 'super)
+ (global-set-key (kbd "£") [?#]))
+
+(use-package repeat
+ :demand t
+ :config
+ (setq repeat-echo-function 'repeat-echo-mode-line
+ repeat-exit-key "SHIFT"
+ repeat-exit-timeout 2)
(repeat-mode))
-(defun jao-kb-toggle (&optional lyt)
- (interactive)
- (shell-command-to-string (or lyt
- (if (jao-kb-toggled-p)
- "setxkbmap us"
- "setxkbmap us -variant intl"))))
+(jao-when-linux
+ (defun jao-kb-toggle (&optional lyt)
+ (interactive)
+ (shell-command-to-string (or lyt
+ (if (jao-kb-toggled-p)
+ "setxkbmap us"
+ "setxkbmap us -variant intl"))))
-(defun jao-kb-toggled-p ()
- (not (string-empty-p
- (shell-command-to-string "setxkbmap -query|grep variant"))))
+ (defun jao-set-uk-kb (&optional lyt)
+ (interactive)
+ (jao-kb-toggle "setxkbmap gb"))
+
+ (defun jao-kb-disable-laptop ()
+ (interactive)
+ (jao-shell-exec "xinput float 13"))
+
+ (defun jao-kb-toggled-p ()
+ (not (string-empty-p
+ (shell-command-to-string "setxkbmap -query|grep variant")))))
(customize-set-variable 'default-input-method "catalan-prefix")
;; http://mbork.pl/2022-03-07_Transient_input_method
@@ -209,7 +248,7 @@
;;;; transient
(use-package transient
- :init (setq transient-show-popup t) ;; 2.0
+ :init (setq transient-show-popup t)
:demand t
:config
(transient-bind-q-to-quit))
@@ -240,9 +279,12 @@
;;;; disk monitoring
(use-package jao-dirmon
+ :if (jao-is-linux)
:commands jao-dirmon-report)
+
;;;; mailcap
(use-package mailcap
+ :if (jao-is-linux)
:config
(add-to-list 'mailcap-mime-extensions '(".JPEG" . "image/jpeg"))
(add-to-list 'mailcap-mime-extensions '(".JPG" . "image/jpeg"))
@@ -270,18 +312,31 @@
("imv-wayland \"%s\"" "image/.*" jao-wayland-enabled)
("imv-x11 \"%s\"" "image/.*")))))
+;;;; tmr
+(jao-when-linux
+ (use-package tmr
+ :ensure t
+ :init
+ (setq tmr-sound-file
+ (jao-when-linux "/usr/share/sounds/freedesktop/stereo/message.oga"))
+ :config (tmr-mode-line-mode 1)))
+
;;; Crypto
;;;; PGP, EPG, passwords
-(setq auth-source-debug nil)
-
-(require 'auth-source)
-(add-to-list 'auth-source-protocols '(local "local"))
-(setq auth-sources '("~/.emacs.d/authinfo.gpg" "~/.netrc"))
+(use-package auth-source
+ :init
+ (setq auth-source-debug nil
+ auth-sources '("~/.emacs.d/authinfo.gpg" "~/.netrc"))
+ :config
+ (add-to-list 'auth-source-protocols '(local "local"))
+ (jao-when-darwin (add-to-list 'auth-sources 'macos-keychain-generic)))
(use-package epa-file
- :init (setq epa-file-cache-passphrase-for-symmetric-encryption t)
+ :demand t
+ :init (setq epa-file-cache-passphrase-for-symmetric-encryption t
+ epa-file-encrypt-to "A247C4780736A6156BC8DA748C081D34D321D881"
+ plstore-encrypt-to epa-file-encrypt-to)
:config (epa-file-enable))
-(require 'epa-file)
(defun jao--get-user/password (h)
(let ((item (car (auth-source-search :type 'netrc :host h :max 1))))
@@ -324,7 +379,7 @@
(make-glyph-code ?│)))
;;;; transparency
-(defvar jao-transparent-only-bg (> emacs-major-version 28))
+(defvar jao-transparent-only-bg (jao-is-linux))
(defvar jao-frames-default-alpha
(cond ((eq window-system 'pgtk) 85)
@@ -352,11 +407,11 @@
(let ((level (if jao-transparent-frame 100 jao-frames-default-alpha)))
(jao-set-transparency level all)))
-(jao-set-transparency)
+(jao-when-linux (jao-set-transparency))
;;;; themes
(defun jao-colors-scheme-dark-p ()
- (equal "dark" (getenv "JAO_COLOR_SCHEME")))
+ (and (jao-is-linux) (equal "dark" (getenv "JAO_COLOR_SCHEME"))))
(defun jao-colors-scheme ()
(if (jao-colors-scheme-dark-p) 'dark 'light))
@@ -366,13 +421,20 @@
(setq custom-theme-directory
(expand-file-name "lib/themes" jao-emacs-dir))
-(require 'jao-themes)
-
(defvar jao-theme-dark 'jao-dark)
(defvar jao-theme-light 'jao-light)
(defvar jao-theme-term-dark 'modus-vivendi)
(defvar jao-theme-term-light 'jao-light-term)
+(use-package jao-themes
+ :demand t
+ :init
+ (setq jao-themes-default-family (jao-d-l "RobotoMono Nerd Font" "Hack")
+ jao-themes-default-size (jao-d-l 10 9)
+ jao-themes-default-variable-pitch-family
+ (jao-d-l "Helvetica" "Iosevka Etoile")
+ jao-themes-default-variable-pitch-size (jao-d-l 12 9)))
+
(defun jao-themes-setup ()
(let* ((dark (jao-colors-scheme-dark-p))
(theme (cond ((and dark window-system) jao-theme-dark)
@@ -381,7 +443,7 @@
(t jao-theme-term-light))))
(load-theme theme t)
(modify-all-frames-parameters `((font . ,jao-themes-default-face)))))
-
+(modify-all-frames-parameters `((font . "RobotoMono Nerd Font-10")))
(jao-themes-setup)
;;; Help system
@@ -429,12 +491,16 @@
(if (jao-colors-scheme-dark-p)
(setq jao-minibuffer-active-buffer-line-color "azure4"
jao-minibuffer-inactive-buffer-line-color "grey25")
- (setq jao-minibuffer-active-buffer-line-color "burlywood3"
- jao-minibuffer-inactive-buffer-line-color "grey65"))
- (setq jao-minibuffer-adaptive-alignment nil)
+ (setq jao-minibuffer-active-buffer-line-color
+ (jao-d-l "#cfcfcf" "burlywood3")
+ jao-minibuffer-inactive-buffer-line-color
+ (jao-d-l "#dfdfdf" "grey65")))
+ (setq jao-minibuffer-adaptive-alignment nil
+ jao-minibuffer-info-face-alt 'jao-themes-dimm)
:commands (jao-minibuffer-add-variable
jao-minibuffer-refresh
- jao-minibuffer-mode))
+ jao-minibuffer-mode
+ jao-minibuffer-mode-line-mode))
(setq enable-recursive-minibuffers t)
(require 'mb-depth)
@@ -443,7 +509,7 @@
(setq minibuffer-default-prompt-format " (default %s)")
(minibuffer-electric-default-mode 1)
-(jao-minibuffer-mode 1)
+(jao-minibuffer-mode)
;;; Mode line
;;;; config
@@ -457,14 +523,6 @@
(line-number-mode -1)
(column-number-mode -1)
-;;;; jao-mode-line
-(defvar jao-mode-line-in-minibuffer t)
-
-(use-package jao-mode-line
- :commands (jao-mode-line-add-to-minibuffer-left
- jao-mode-line-add-to-minibuffer-right
- jao-mode-line-remove-from-minibuffer))
-
;;;; time display
(setq world-clock-list
'(("Europe/London" "Edinburgh")
@@ -495,7 +553,12 @@
(seconds-to-time (/ v 1000.0))))))
;;;; mode line toggle
+(defvar jao-mode-line-in-minibuffer (display-graphic-p))
+
(use-package jao-mode-line
+ :commands (jao-mode-line-add-to-minibuffer-left
+ jao-mode-line-add-to-minibuffer-right
+ jao-mode-line-remove-from-minibuffer)
:init
(when (and window-system (not jao-mode-line-in-minibuffer))
(add-to-list 'after-make-frame-functions #'jao-mode-line-hide-inactive)
@@ -517,26 +580,31 @@
;;;; battery
(use-package battery
- :init (setq battery-load-low 15
- battery-load-critical 8
- battery-mode-line-limit 40
- battery-echo-area-format
- "%L %r %B (%p%% load, remaining time %t)"
- battery-mode-line-format " 🔋%b%p% "))
-
-(with-eval-after-load "jao-minibuffer"
- (if jao-mode-line-in-minibuffer
- (display-battery-mode 1)
- (jao-minibuffer-add-variable 'battery-mode-line-string 80)))
+ :init
+ (setq battery-load-low 15
+ battery-load-critical 8
+ battery-mode-line-limit 40
+ battery-echo-area-format
+ "%L %r %B (%p%% load, remaining time %t)"
+ battery-mode-line-format " 🔋%b%p% ")
+
+ (with-eval-after-load "jao-minibuffer"
+ (if jao-mode-line-in-minibuffer
+ (display-battery-mode 1)
+ (jao-when-linux
+ (jao-minibuffer-add-variable 'battery-mode-line-string 80))))
+ :config
+ (jao-when-darwin (display-battery-mode 1)))
;;; Notifications
;;;; jao-notify
(use-package jao-notify
:demand t
- :init (setq jao-notify-use-messages t))
+ :init (setq jao-notify-use-messages (jao-d-l 'mac t)))
;;;; tracking
(use-package tracking
+ :ensure t
:demand t
:init (setq tracking-position 'before-modes
tracking-frame-behavior nil
@@ -544,21 +612,23 @@
tracking-max-mode-line-entries 10
tracking-sort-faces-first t
tracking-shorten-modes '())
- :config
- (setq erc-track-enable-keybindings nil))
+ :config (setq erc-track-enable-keybindings nil))
(use-package jao-tracking
:demand t
- :init (setq jao-tracking-bkg (if (jao-colors-scheme-dark-p) "grey20" "grey93"))
+ :init
+ (setq jao-tracking-bkg (if (jao-colors-scheme-dark-p) "grey20" "grey93"))
:config (jao-tracking-setup t))
;;;; ednc
-(use-package ednc
- :ensure t
- :diminish nil)
+(jao-when-linux
+ (use-package ednc
+ :ensure t
+ :diminish nil))
(use-package jao-ednc
+ :if (jao-is-linux)
:demand t
:init (setq jao-ednc-use-tracking nil)
:commands (jao-ednc-setup)
@@ -575,7 +645,7 @@
("i" "invoke last action" jao-ednc-invoke-last-action)])
(global-set-key (kbd "s-n") #'jao-transient-ednc))
-;;; Calendar, diary, weather
+;;; Calendar, diary
;;;; diary
(setq diary-file (expand-file-name "diary" jao-org-dir)
diary-display-function 'diary-fancy-display
@@ -586,75 +656,58 @@
(add-hook 'diary-list-entries-hook 'diary-sort-entries t)
;;;; calendar
-(setq appt-display-format nil)
-(appt-activate 1)
-(setq calendar-latitude 55.9533
- calendar-longitude -3.1883
- calendar-left-margin 4
- calendar-location-name "Edinburgh, Scotland"
- calendar-mark-diary-entries-flag t
- calendar-week-start-day 1 ;; 0 sunday
- calendar-date-echo-text '(format "ISO date: %s"
- (calendar-iso-date-string
- (list month day year))))
-
-(setq calendar-holidays
- '((holiday-fixed 1 1 "New Year's Day")
- (holiday-fixed 4 1 "April Fools' Day")
- (holiday-float 5 0 2 "Mother's Day")
- (holiday-fixed 3 19 "Father's Day")
- (holiday-float 11 4 4 "Thanksgiving")
- (holiday-fixed 12 25 "Christmas")
- (holiday-chinese-new-year)
- (solar-equinoxes-solstices)
- (holiday-sexp calendar-daylight-savings-starts
- (format "Daylight Saving Time Begins %s"
- (solar-time-string
- (/ calendar-daylight-savings-starts-time
- (float 60))
- calendar-standard-time-zone-name)))
- (holiday-sexp calendar-daylight-savings-ends
- (format "Daylight Saving Time Ends %s"
- (solar-time-string
- (/ calendar-daylight-savings-ends-time
- (float 60))
- calendar-daylight-time-zone-name)))))
-(add-to-list 'display-buffer-alist
- `(,(regexp-quote diary-fancy-buffer)
- (display-buffer-at-bottom)
- (window-parameters (mode-line-format . none))
- (window-height . fit-window-to-buffer)))
+(use-package calendar
+ :init
+ (setq appt-display-format nil
+ calendar-latitude 55.9533
+ calendar-longitude -3.1883
+ calendar-left-margin 4
+ calendar-location-name "Edinburgh, Scotland"
+ calendar-mark-diary-entries-flag t
+ calendar-week-start-day 1 ;; 0 sunday
+ calendar-date-echo-text '(format "ISO date: %s"
+ (calendar-iso-date-string
+ (list month day year))))
+ (setq calendar-holidays
+ '((holiday-fixed 1 1 "New Year's Day")
+ (holiday-fixed 4 1 "April Fools' Day")
+ (holiday-float 5 0 2 "Mother's Day")
+ (holiday-fixed 3 19 "Father's Day")
+ (holiday-float 11 4 4 "Thanksgiving")
+ (holiday-fixed 12 25 "Christmas")
+ (holiday-chinese-new-year)
+ (solar-equinoxes-solstices)
+ (holiday-sexp calendar-daylight-savings-starts
+ (format "Daylight Saving Time Begins %s"
+ (solar-time-string
+ (/ calendar-daylight-savings-starts-time
+ (float 60))
+ calendar-standard-time-zone-name)))
+ (holiday-sexp calendar-daylight-savings-ends
+ (format "Daylight Saving Time Ends %s"
+ (solar-time-string
+ (/ calendar-daylight-savings-ends-time
+ (float 60))
+ calendar-daylight-time-zone-name)))))
+
+ (setq org-calendar-insert-diary-entry-key nil
+ org-agenda-diary-file 'diary-file)
-(defun jao-diary--select ()
- (switch-to-buffer diary-fancy-buffer))
+ :config
+ (appt-activate 1)
+ (calendar-set-date-style 'european)
-(add-hook 'diary-fancy-display-mode-hook #'jao-diary--select)
-(setq org-calendar-insert-diary-entry-key nil
- org-agenda-diary-file 'diary-file)
+ (add-to-list 'display-buffer-alist
+ `(,(regexp-quote diary-fancy-buffer)
+ (display-buffer-at-bottom)
+ (window-parameters (mode-line-format . none))
+ (window-height . fit-window-to-buffer)))
-;;;; 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)
-
-;;; Files, dired and scratch buffer
-;;;; so-long
-(setq large-file-warning-threshold (* 200 1024 1024))
-
-;; (use-package so-long
-;; :ensure t
-;; :diminish)
-;; (global-so-long-mode 1)
+ (defun jao-diary--select ()
+ (switch-to-buffer diary-fancy-buffer))
+
+ (add-hook 'diary-fancy-display-mode-hook #'jao-diary--select))
;;;; persistent scratch
(use-package persistent-scratch
@@ -662,23 +715,32 @@
:config (persistent-scratch-setup-default))
;;;; dired
+(use-package ls-lisp
+ :if (jao-is-darwin)
+ :demand t
+ :init (setq ls-lisp-use-insert-directory-program nil
+ ls-lisp-dirs-first t))
+
(use-package dired
:init
(setq dired-recursive-deletes 'top
dired-recursive-copies 'top
dired-listing-switches "-alhF --group-directories-first"
- ls-lisp-dirs-first t
dired-dwim-target t
dired-kill-when-opening-new-dired-buffer t
dired-mouse-drag-files t
- wdired-create-parent-directories t
- dired-guess-shell-alist-user
+ wdired-create-parent-directories t)
+
+ (jao-when-linux
+ (setq dired-guess-shell-alist-user
'(;; ("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open")
("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open")
- (".*" "xdg-open")))
+ (".*" "xdg-open"))))
(put 'dired-find-alternate-file 'disabled nil)
+
:hook (dired-mode . turn-on-gnus-dired-mode)
+
:bind (:map dired-mode-map
("C-c C-r" . wdired-change-to-wdired-mode)
("C-M-m" . gnus-dired-attach)))
@@ -698,7 +760,6 @@
;;;; wgrep
(use-package wgrep :ensure t)
-(require 'wgrep)
;;;; executable scripts
(add-hook 'after-save-hook
@@ -777,56 +838,62 @@
(require 'jao-custom-completion)
;;;; recoll
-(jao-load-path "consult-recoll")
-
-(defun jao-recoll-format (title url _mtype)
- (let* ((u (replace-regexp-in-string "file://" "" url))
- (u (replace-regexp-in-string "/home/jao/" "" u))
- (u (replace-regexp-in-string
- "\\(doc\\|org/doc\\|.emacs.d/gnus/Mail\\|var/mail\\)/" "" u)))
- (format "%s (%s)" ;; "%s (%s, %s)"
- title
- (propertize u 'face 'jao-themes-f01)
- ;; (propertize mtype 'face 'jao-themes-f01)
- )))
-
-(defun jao-recoll-open-html (file &optional _page)
- (if (string-match-p "\.epub\\'" file)
- (find-file file)
- (jao-afio-goto-www)
- (if jao-afio-use-w3m (w3m-find-file file) (eww-open-file file))))
-
-(defun jao-recoll-open-pdf (file &optional page)
- (if (string-match-p "/gnus/Mail/" file)
- (funcall (or (cdr (assoc-string "message/rfc822" consult-recoll-open-fns))
- 'find-file)
- file
- page)
- (jao-open-doc file page)))
-
-(defun jao-recoll-consult-messages ()
- (interactive)
- (consult-recoll "mime:message "))
-
-(defun jao-recoll-consult-docs ()
- (interactive)
- (consult-recoll (format "dir:%s/doc " jao-org-dir)))
-
-(defun jao-recoll-consult-notes ()
- "Use consult-recoll to search notes."
- (interactive)
- (consult-recoll (format "dir:%s " jao-org-notes-dir)))
+(jao-when-linux (jao-load-path "consult-recoll"))
(use-package consult-recoll
+ :if (jao-is-linux)
:commands (consult-recoll consult-recoll-embark-setup)
- :init (setq consult-recoll-open-fns
- '(("application/pdf" . jao-recoll-open-pdf)
- ("text/html" . jao-recoll-open-html))
- consult-recoll-search-flags 'query
- consult-recoll-inline-snippets t
- consult-recoll-format-candidate #'jao-recoll-format)
+ :init
+ (defun jao-recoll-format (title url _mtype)
+ (let* ((u (replace-regexp-in-string "file://" "" url))
+ (u (replace-regexp-in-string "/home/jao/" "" u))
+ (u (replace-regexp-in-string
+ "\\(doc\\|org/doc\\|.emacs.d/gnus/Mail\\|var/mail\\)/" "" u)))
+ (format "%s (%s)" ;; "%s (%s, %s)"
+ title
+ (propertize u 'face 'jao-themes-f01)
+ ;; (propertize mtype 'face 'jao-themes-f01)
+ )))
+
+ (defun jao-recoll-open-html (file &optional _page)
+ (if (string-match-p "\.epub\\'" file)
+ (find-file file)
+ (jao-afio-goto-www)
+ (if jao-afio-use-w3m (w3m-find-file file) (eww-open-file file))))
+
+ (defun jao-recoll-open-pdf (file &optional page)
+ (if (string-match-p "/gnus/Mail/" file)
+ (funcall
+ (or (cdr (assoc-string "message/rfc822" consult-recoll-open-fns))
+ 'find-file)
+ file
+ page)
+ (jao-open-doc file page)))
+
+ (defun jao-recoll-consult-messages ()
+ (interactive)
+ (consult-recoll "mime:message "))
+
+ (defun jao-recoll-consult-docs ()
+ (interactive)
+ (consult-recoll (format "dir:%s/doc " jao-org-dir)))
+
+ (defun jao-recoll-consult-notes ()
+ "Use consult-recoll to search notes."
+ (interactive)
+ (consult-recoll (format "dir:%s " jao-org-notes-dir)))
+
+ (setq consult-recoll-open-fns
+ '(("application/pdf" . jao-recoll-open-pdf)
+ ("text/html" . jao-recoll-open-html))
+ consult-recoll-search-flags 'query
+ consult-recoll-inline-snippets t
+ consult-recoll-format-candidate #'jao-recoll-format)
+
:config
+
(consult-customize consult-recoll :preview-key 'any)
+ (with-eval-after-load "embark" (consult-recoll-embark-setup))
(transient-define-prefix jao-transient-recoll ()
["Consult recoll queries"
@@ -837,8 +904,6 @@
:bind (("s-r" . #'jao-transient-recoll)))
-(with-eval-after-load "embark" (consult-recoll-embark-setup))
-
;;; Buffers
;;;; cursor and mark
(transient-mark-mode -1)
@@ -908,13 +973,12 @@
(global-set-key (kbd "C-c C-b") #'jao-buffer-same-mode-cmd)
;;;; projects
-(use-package project :demand t)
-(global-set-key "\C-xp" 'jao-prev-window)
+;; (use-package project :demand t)
+;; (use-package list-projects :ensure t)
;;;; buffer quit function (the triple ESC)
(setq buffer-quit-function (lambda () t))
-
;;;; redisplay escape hatch
;; (setq max-redisplay-ticks 2250000)
;;;; scrolling
@@ -930,6 +994,45 @@
scroll-step 1
redisplay-skip-fontification-on-input nil))
+(jao-when-linux
+ (use-package ultra-scroll
+ :ensure t
+ :init
+ (setq scroll-conservatively 101 ; or whatever value you prefer, since v0.4
+ scroll-margin 0) ; important: scroll-margin>0 not yet supported
+ :config
+ (ultra-scroll-mode 1)))
+
+;;;; show diffs when running C-x s
+(add-to-list 'save-some-buffers-action-alist
+ `("d"
+ ,(lambda (buffer)
+ (diff-buffer-with-file (buffer-file-name buffer)))
+ "show diff between the buffer and its file"))
+
+;;;; copy buffer file name
+;; https://stackoverflow.com/questions/18812938/copy-full-file-path-into-copy-paste-clipboard
+(defun copy-buffer-file-name-as-kill (choice)
+ "Copy the buffer-file-name to the kill-ring"
+ (interactive "cCopy Buffer Name (F) Full, (D) Directory, (N) Name")
+ (let ((new-kill-string)
+ (name (if (eq major-mode 'dired-mode)
+ (dired-get-filename)
+ (or (buffer-file-name) ""))))
+ (cond ((eq choice ?f)
+ (setq new-kill-string name))
+ ((eq choice ?d)
+ (setq new-kill-string (file-name-directory name)))
+ ((eq choice ?n)
+ (setq new-kill-string (file-name-nondirectory name)))
+ (t (message "Quit")))
+ (when new-kill-string
+ (message "%s copied" new-kill-string)
+ (kill-new new-kill-string))))
+
+;;;; warnings display
+(setq warning-display-at-bottom nil)
+
;;; Windows
;;;; splitting and switch
(setq split-height-threshold 80
@@ -988,6 +1091,8 @@
(global-set-key (format "\C-c%s" (1+ n)) (jao-nth-window n)))
'(0 1 2 3 4 5 6 7 8))
+(global-set-key "\C-xp" 'jao-prev-window)
+
;; transposing windows
(defun transpose-windows (arg)
"Transpose the buffers shown in two windows."
@@ -1013,7 +1118,13 @@
`((horizontal-scroll-bars . nil)
(vertical-scroll-bars . nil)
(scroll-bar-width . 0)
- (menu-bar . nil)))
+ (menu-bar . nil)
+ ,@(jao-when-darwin '((internal-border-width . 5)
+ (width . 163)
+ (height . 63)
+ ;; (right-divider-width . 6)
+ ;; (bottom-divider-width . 6)
+ ))))
;;;; frame layout, title, etc
(setq frame-title-format '("%b - emacs"))
@@ -1022,8 +1133,10 @@
(menu-bar-mode -1)
+(setq ns-pop-up-frames nil)
+
;; (setting it to nil avoids mouse wrapping after other-frame)
-(setq focus-follows-mouse (and window-system t))
+(setq focus-follows-mouse (and (jao-is-linux) window-system t))
(use-package scroll-bar)
(set-scroll-bar-mode nil)
@@ -1041,27 +1154,32 @@
;;;; afio
(use-package jao-afio
:demand t
- :config (jao-afio-setup (not window-system))
+ :config
+ (jao-afio-setup (or (not window-system) (jao-is-darwin)))
+ (add-hook 'jao-afio-switch-hook 'jao-minibuffer-refresh t)
+
+ (defun jao-current--frame-id ()
+ (propertize (cond ((and (fboundp 'jao-exwm-enabled)
+ (jao-exwm-enabled-p)
+ (not (bound-and-true-p jao-exwm--use-afio))
+ (boundp 'exwm-workspace-current-index))
+ (format "F%s" exwm-workspace-current-index))
+ ;; (jao-afio-use-frames "")
+ (t (format "%s" (or (jao-afio-frame-name) ""))))
+ 'face 'font-lock-warning-face))
+ (jao-minibuffer-add-variable '(jao-current--frame-id) 100)
+
+ (setq frame-title-format '("emacs - " (:eval (jao-afio-frame-name))))
+
+ (jao-when-linux
+ (global-set-key (kbd "C-c t") #'jao-afio-goto-chats))
+
:bind (("C-c f" . 'jao-afio-goto-main)
("C-c g" . 'jao-afio-goto-mail)
("C-c w" . 'jao-afio-goto-www)
("C-c z" . 'jao-afio-goto-docs)
- ("C-c t" . 'jao-afio-goto-chats)
("C-c 0" . 'jao-afio-goto-scratch)
("M-o" . 'jao-afio-toggle)))
-(add-hook 'jao-afio-switch-hook 'jao-minibuffer-refresh t)
-
-(defun jao-current--frame-id ()
- (propertize (cond ((and (fboundp 'jao-exwm-enabled)
- (jao-exwm-enabled-p)
- (not (bound-and-true-p jao-exwm--use-afio))
- (boundp 'exwm-workspace-current-index))
- (format "F%s" exwm-workspace-current-index))
- (t jao-afio-use-frames (or (jao-afio-frame-name) ""))
- (t (format "%s" (or (jao-afio-frame-no) ""))))
- 'face 'font-lock-warning-face))
-
-(jao-minibuffer-add-variable '(jao-current--frame-id) 100)
;;; Writing and writing modes
;;;; copyright notices
@@ -1122,9 +1240,9 @@
:custom ((ispell-personal-dictionary
(expand-file-name "~/.emacs.d/ispell.dict"))))
-(use-package reverso
- :ensure t
- :init (setq reverso-languages '(english spanish french german)))
+;; (use-package reverso
+;; :ensure t
+;; :init (setq reverso-languages '(english spanish french german)))
;; (use-package wordreference
;; :ensure t
@@ -1191,358 +1309,20 @@
(setq LaTeX-biblatex-use-Biber t)
(setq bibtex-dialect 'biblatex)
:config
- (add-hook 'TeX-after-compilation-finished-functions 'TeX-revert-document-buffer)
+ (add-hook 'TeX-after-compilation-finished-functions
+ 'TeX-revert-document-buffer)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex))
;;; Browsing
-;;;; variables
-(defvar jao-browse-doc-use-emacs-p t)
-(defvar jao-browse-url-function nil)
-(defvar jao-browse-url-external-function nil)
-
-;;;; url around point
-(defun jao-url-around-point (&optional current-url)
- (or (and (fboundp 'w3m-anchor) (w3m-anchor))
- (shr-url-at-point nil)
- (ffap-url-at-point)
- (thing-at-point 'url)
- (when current-url
- (or (and (fboundp 'w3m-anchor) (w3m-anchor))
- (and (derived-mode-p 'eww-mode) (plist-get eww-data :url))))))
-
-(defun jao--url-prompt (&optional prefix)
- (let* ((def (jao-url-around-point t))
- (prompt (concat prefix "URL" (if def (format " (%s): " def) ": "))))
- (read-string prompt nil nil def)))
-
-;;;; downloads using wget
-(defun jao-wget--get-title (filename)
- (or (and (derived-mode-p 'w3m-mode) (w3m-current-title))
- (plist-get eww-data :title)
- (and (not (string-blank-p (or filename "")))
- (subst-char-in-string ?- ? (capitalize (file-name-base filename))))))
-
-(defun jao-wget (url &optional user pwd)
- "Download URL using wget and kill a link for an org note."
- (let* ((def (file-name-nondirectory url))
- (pmt (format "Save %s to: " url))
- (read-file-name-function nil)
- (dest (expand-file-name
- (read-file-name pmt jao-sink-dir nil nil def)))
- (title (jao-wget--get-title dest))
- (src-url (or (jao-url-around-point t) (file-name-directory url)))
- (auth (when (and user pwd)
- `(,(format "--http-user=%s" user)
- ,(format "--http-password=%s" pwd))))
- (lnk (concat "doc:" (file-name-nondirectory dest))))
- (switch-to-buffer-other-window (get-buffer-create "*downloads*"))
- (erase-buffer)
- (kill-new (format "%s (from %s)"
- (org-link-make-string lnk title)
- (org-link-make-string src-url "here")))
- (apply 'make-term `("downloads" "wget" nil ,@auth "-O" ,dest ,url))))
-
-(defun jao-download (url &optional pws)
- "Download URL using wget"
- (interactive (list (jao--url-prompt)))
- (when url
- (let ((usr (and pws (read-string "Login name: ")))
- (pwd (and pws (read-passwd "Password: "))))
- (jao-wget url usr pwd))))
-
-(with-eval-after-load "embark"
- (define-key embark-url-map (kbd "d") #'jao-download))
-
-;;;; video
-(defvar jao-video--url-rx
- (format "^https?://\\(?:www\\.\\)?%s/.+"
- (regexp-opt '("youtu.be"
- "youtube.com"
- "blip.tv"
- "vimeo.com"
- "infoq.com")
- t)))
-
-(defvar jao-video--ext-rx
- (format "^https?://.+/.+\\.%s" (regexp-opt '("mp3" "webm" "mp4"))))
-
-(defun jao-video--url-p (url)
- (or (string-match-p jao-video--url-rx url)
- (string-match-p jao-video--ext-rx url)))
-
-(defun jao--remote-run (url prg)
- (let ((args (format "%s %s" prg (shell-quote-argument url))))
- (start-process-shell-command prg nil args)))
-
-(defun jao--mpv (url &rest _args) (jao--remote-run url "mpv"))
-(defun jao--vlc (url &rest _args) (jao--remote-run url "vlc"))
-
-(defvar jao--video-player 'jao--mpv)
-
-(defun jao-view-video (url)
- "Tries to stream a video from the current or given URL"
- (interactive (list (jao--url-prompt "Video ")))
- (when url (funcall jao--video-player url)))
-
-(defun jao-maybe-view-video (url &rest _ignored)
- (interactive)
- (if (y-or-n-p "View video (y) or web page (n)? ")
- (jao-view-video url)
- (funcall jao-browse-url-function url)))
-
-;;;; web browsers
-(defun jao-www--buffer-p (b)
- (with-current-buffer b
- (or (derived-mode-p 'w3m-mode 'eww-mode)
- (and (boundp 'exwm-class-name)
- (member exwm-class-name '("vlc" "mpv"))))))
+(require 'jao-custom-browse)
(require 'jao-custom-eww)
-;; (require 'jao-custom-w3m)
-
-;;;; browse-url
-(require 'browse-url)
-
-(setq browse-url-generic-program "~/bin/firehog")
-
-(defun jao-browse-with-external-browser (&rest url)
- "Browse with external hogging"
- (interactive "s")
- (let ((url (or (car url) (jao-url-around-point))))
- (if (not url)
- (message "No URL at point")
- (cond ((and (jao-exwm-enabled-p) (fboundp 'jao-exwm-firefox))
- (jao-exwm-firefox))
- (jao-river-enabled (jao-river-to-ws 2))
- (jao-sway-enabled (jao-sway-firefox)))
- (browse-url-generic url))))
-(setq jao-browse-url-external-function 'jao-browse-with-external-browser)
-
-(defun jao--fln (url)
- (shell-quote-argument
- (if (string-match "^[^:]*:/*?\\(/?[^/].*\\)" url)
- (match-string-no-properties 1 url)
- url)))
-
-(defun jao--browse-doc (url &rest _ignored)
- (let* ((url (substring-no-properties url))
- (file (jao--fln url)))
- (when file
- (unless (file-exists-p file)
- (error "File %s does not exist" file))
- (jao-open-doc file))))
-
-(defun jao--make-file-rx (exts)
- (format "file:/?/?.+\\.%s$" (regexp-opt exts)))
-
-(defvar jao--see-exts (jao--make-file-rx '("jpg" "jpeg" "png")))
-
-(defvar jao--doc-exts
- (jao--make-file-rx '("ps" "ps.gz" "pdf" "dvi" "djvu" "chm")))
-
-(defvar jao-browse-url-wget-exts
- '("ps" "pdf" "dvi" "djvu" "zip" "gz" "tgz"))
-
-(defvar jao-browse-external-domains
- '("github.com" "gitlab.com" "slack.com" "spotify.com" "drive.google.com"
- "meet.google.com" "docs.google.com" "x.com" "twitter.com"
- "t.com" "linkedin.com" "bigml.com" "slack.com" "zoom.us"))
-
-(defvar jao-browse--external-regexp
- (format "https?://.*%s\\(/.*\\)?"
- (regexp-opt jao-browse-external-domains)))
-
-(defun jao-wget--regexp ()
- (concat "^http[s]?://.+\\(\\."
- (mapconcat 'identity jao-browse-url-wget-exts "\\|\\.")
- "\\)\\'"))
-
-(defun jao--see (url &rest _r)
- (start-process-shell-command "see" nil (format "see %s" (jao--fln url))))
-
-(defun jao--find-file-other-window (url &rest _)
- (find-file-other-window (jao--fln url)))
-
-(defvar jao-browse--sound-rx
- (format "^https?://.*/.*\\.%s" (regexp-opt '("mp3" "flv"))))
-
-(defun jao-browse-play-sound-url (url &rest _)
- (jao-mpc-add-or-play-url url))
-
-(defun jao-browse-url-browse (&rest args)
- (apply jao-browse-url-function args))
-
-(setq browse-url-handlers
- `((jao-video--url-p . jao-maybe-view-video)
- (,jao--doc-exts . jao--browse-doc)
- (,jao--see-exts . jao--see)
- ("^file://?.+\\.html?$" . ,jao-browse-url-function)
- ("^file://?" . jao--find-file-other-window)
- (,jao-browse--external-regexp . ,jao-browse-url-external-function)
- ("^https?://.*\\.gotomeeting\\.com\\.*" . browse-url-chrome)
- (,jao-browse--sound-rx . jao-browse-play-sound-url)
- (,(jao-wget--regexp) . jao-download)
- ("." . jao-browse-url-browse)))
-
-(when (< emacs-major-version 28)
- (setf (alist-get 'jao-video--url-p browse-url-handlers nil t) nil)
- (setq browse-url-browser-function browse-url-handlers))
-
-;;;; subscribe to rss using r2e
-(autoload 'View-quit "view")
-
-(defun jao-rss--find-url ()
- (save-excursion
- (when (derived-mode-p 'w3m-mode 'eww-mode)
- (if (fboundp 'w3m-view-source) (w3m-view-source) (eww-view-source)))
- (goto-char (point-min))
- (when (re-search-forward
- "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" nil t)
- (let ((url (save-excursion
- (when (re-search-forward
- "href=\"\\([^\n\"]+\\)\"" nil t)
- (match-string-no-properties 1))))
- (title (when (re-search-forward
- "\\(?:title=\"\\([^\n\"]+\\)\" +\\)" nil t)
- (match-string-no-properties 1))))
- (cond ((derived-mode-p 'w3m-view-mode) (w3m-view-source))
- ((string-match-p ".*\\*eww-source\\b.*" (buffer-name))
- (View-quit)))
- (when url (cons url (or title "")))))))
-
-(defun jao-rss2e-append (name url mbox)
- (with-current-buffer (find-file-noselect "~/.config/rss2email.cfg")
- (goto-char (point-max))
- (insert "[feed." name "]\nurl = " url)
- (insert "\nto = " mbox "+" name "@localhost")
- (insert "\nmaildir-mailbox = " mbox "\n\n")
- (save-buffer)))
-
-(defun jao-rss--feeds-dirs ()
- (mapcar (lambda (d) (cadr (split-string d "\\.")))
- (directory-files "~/.emacs.d/gnus/Mail/" nil "^feeds")))
-
-(defun jao-rss-subscribe (url)
- "Subscribe to a given RSS URL. If URL not given, look for it."
- (interactive (list (or (jao-url-around-point)
- (jao-rss--find-url)
- (read-string "Feed URL: "))))
- (let* ((url+title (ensure-list url))
- (url (car url+title))
- (title (cdr url+title)))
- (unless url (error "No feeds found"))
- (let ((url (if (string-match "^feed:" url) (substring url 5) url)))
- (when (y-or-n-p (format "Subscribe to <%s>? " url))
- (let* ((name (read-string "Feed name: " title))
- (cats (cons "prog" (jao-notmuch--subtags "feeds")))
- (cat (completing-read "Category: " cats nil t))
- (subs (format "r2e add %s '%s' feeds.%s@localhost"
- name url cat)))
- ;; (jao-rss2e-append name url cat)
- (shell-command-to-string subs)
- (shell-command (format "r2e run %s" name)))))))
;;; PDFs and other docs
-;;;; open pdfs
-(use-package jao-pdf :demand t)
-(use-package saveplace-pdf-view
- :ensure t
- :demand t
- :after doc-view)
-
-(setq jao-open-doc-fun 'jao-find-or-open)
-(setq jao-org-open-pdf-fun 'jao-find-or-open)
-
-(defun jao-zathura-open (file page)
- (let ((id (jao-x11-search-window (jao-pdf-zathura-title-rx file))))
- (if (string-blank-p id)
- (progn
- (when jao-xmonad-enabled (jao-x11-goto-ws 2))
- (jao-shell-exec (jao-pdf-zathura-open-cmd file page)))
- (let* ((page (if page (format " && xdotool type %dg" page) ""))
- (cmd (format "xdotool windowactivate %s%s" id page)))
- (jao-shell-exec cmd t)))))
-
-(defun jao-x11-zathura-goto-org (&optional title no-ask)
- (let ((title (or title (jao-shell-string "xdotool"
- "getactivewindow"
- "getwindowname"))))
- (jao-org-open-from-zathura title no-ask)))
-
-(defun jao-find-or-open (file &optional page height)
- (cond ((and jao-browse-doc-use-emacs-p window-system)
- (let* ((buffs (buffer-list))
- (b (catch 'done
- (while buffs
- (when (string-equal (buffer-file-name (car buffs)) file)
- (throw 'done (car buffs)))
- (setq buffs (cdr buffs))))))
- (jao-afio-goto-docs)
- (if b (pop-to-buffer b) (find-file file))
- (when page (jao-doc-view-goto-page page height))))
- (jao-river-enabled (jao-river-open-with-zathura file page))
- (jao-sway-enabled (jao-sway-open-with-zathura file page))
- (t (jao-zathura-open file page))))
-
-(defun jao-open-doc (&optional file page height)
- (interactive)
- (when-let (file (or file
- (read-file-name "Document: "
- (concat jao-org-dir "/doc/"))))
- (funcall jao-open-doc-fun file page height)))
+;;;; doc view &co.
-(defun jao-select-pdf ()
- (interactive)
- (jao-buffer-same-mode '(pdf-view-mode doc-view-mode)
- #'jao-afio-goto-docs))
-
-(defun jao-open-with-zathura ()
- (interactive)
- (when-let (f buffer-file-name)
- (let ((p (jao-doc-view-current-page)))
- (cond (jao-river-enabled (jao-river-open-with-zathura f p))
- (jao-sway-enabled (jao-sway-open-with-zathura f p))
- (t (jao-zathura-open f p))))))
-
-;; doc:// links for browse-url
-(defun jao-open-doc-url (url &rest _)
- (when (string-match "doc://\\([^?]+\\)\\(\\?.*\\)?" url)
- (let ((file (match-string 1 url))
- (page (when-let* ((qs (match-string 2 url))
- (long (> (length qs) 1))
- (ps (url-parse-query-string (substring qs 1)))
- (pn (cadr (assoc "page" ps))))
- (string-to-number pn))))
- (jao-open-doc (expand-file-name (concat "doc/" file) jao-org-dir) page))))
-
-(add-to-list 'browse-url-handlers (cons "^doc://.+" 'jao-open-doc-url))
-
-;;;; doc-view
-(use-package doc-view
- :init
- (setq doc-view-cache-directory "~/.emacs.d/cache/docview"
- doc-view-resolution 110
- doc-view-continuous t
- doc-view-conversion-refresh-interval 1
- doc-view-mupdf-use-svg t)
- :hook ((doc-view-mode . jao-doc-session-mark))
- :bind (:map doc-view-mode-map
- ("j" . doc-view-next-line-or-next-page)
- ("J" . doc-view-scroll-up-or-next-page)
- ("k" . doc-view-previous-line-or-previous-page)
- ("K" . doc-view-scroll-down-or-previous-page)
- ("z" . jao-open-with-zathura)))
-
-(use-package jao-doc-session :demand t)
-
-(use-package jao-doc-view
- :demand t
- :bind (:map doc-view-mode-map
- ("b" . jao-doc-view-back)
- ("B" . jao-doc-view-forward)
- ("S" . jao-doc-session-save)
- ("u" . jao-doc-view-visit-url)))
+(require 'jao-custom-pdf)
;;;; epub
(use-package nov
@@ -1556,46 +1336,8 @@
(jao-doc-session-mark nov-file-name))
(add-hook 'nov-mode-hook #'jao-nov-register-session))
-;;;; transient
-(defun jao-org-pdf-goto-org-linking ()
- (interactive)
- (jao-org-pdf-goto-org 4))
-
-(jao-transient-major-mode doc-view
- ["Notes"
- ("o" "notes file" jao-org-pdf-goto-org)
- ("O" "notes file, linking" jao-org-pdf-goto-org-linking)]
- ["Navigation"
- ("b" "back jump" jao-doc-view-back)
- ("B" "forward jump" jao-doc-view-back)
- ("u" "visit URL" jao-doc-view-visit-url)]
- ["Slices"
- ("cb" "bounding box" doc-view-set-slice-from-bounding-box)
- ("cm" "using mouse" doc-view-set-slice-using-mouse)]
- ["Session"
- ("s" "load session" jao-afio-open-pdf-session)
- ("S" "save session" jao-doc-session-save)
- ("d" "visit cache directory" doc-view-dired-cache)]
- ["External viewers"
- ("z" "open with zathura" jao-open-with-zathura)])
-
-(with-eval-after-load "pdf-view"
- (jao-transient-major-mode pdf-view
- ["Notes"
- ("o" "notes file" jao-org-pdf-goto-org)
- ("O" "notes file, linking" jao-org-pdf-goto-org-linking)]
- ["Navigation"
- ("b" "back jump" pdf-history-backward)
- ("f" "forward jump" pdf-history-forward)]
- ["Session"
- ("s" "load session" jao-afio-open-pdf-session)
- ("S" "save session" jao-doc-session-save)]
- ["External viewers"
- ("z" "open with zathura" jao-open-with-zathura)]))
-
-;; (transient-get-suffix 'jao-transient-pdf-view '(0 -1))
-
;;; Email
+
(require 'jao-custom-email)
;;; Shells and terms
@@ -1617,8 +1359,8 @@
:init (setq jao-use-eat t
eat-kill-buffer-on-exit t
eat-enable-yank-to-terminal t)
- :hook ((eshell-mode . eat-eshell-mode)
- (eshell-mode . eat-eshell-visual-command-mode))
+ ;; :hook ((eshell-mode . eat-eshell-mode)
+ ;; (eshell-mode . eat-eshell-visual-command-mode))
:diminish ((eat-eshell-mode . "")))
;;;; term
@@ -1758,17 +1500,11 @@
(use-package eshell-autojump :ensure t)
;;;;; completion
-(defun jao-eshell-completion-capf ()
- (let* ((b (save-excursion (eshell-bol) (point)))
- (c (bash-completion-dynamic-complete-nocomint b (point) t)))
- (when (and c (listp c))
- (append c '(:exclusive no)))))
(defun jao-eshell--set-up-completion ()
- (setq-local completion-styles '(basic partial-completion)
- completion-at-point-functions
- '(jao-eshell-completion-capf
- pcomplete-completions-at-point t)))
+ (setq-local completion-styles '(basic partial-completion))
+ (add-hook 'completion-at-point-functions
+ 'bash-completion-capf-nonexclusive nil t))
(use-package bash-completion
:ensure t
@@ -1784,11 +1520,11 @@
;;;;; workarounds
;; at some point, bash completion started insertig the TAB
;; after the commands ends
-(defun jao-eshell--clean-prompt ()
- (eshell-bol)
- (ignore-errors (kill-line)))
+;; (defun jao-eshell--clean-prompt ()
+;; (eshell-bol)
+;; (ignore-errors (kill-line)))
-(add-hook 'eshell-after-prompt-hook 'jao-eshell--clean-prompt)
+;; (add-hook 'eshell-after-prompt-hook 'jao-eshell--clean-prompt)
;;;;; keybindings
(defun jao-eshell--kbds ()
@@ -1820,13 +1556,20 @@
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
(global-diff-hl-mode 1)
-(unless (display-graphic-p) (diff-hl-margin-mode 1))
+;; (unless (display-graphic-p) (diff-hl-margin-mode 1))
;;;; magit/forge
(use-package magit
:ensure t
:commands magit-status
:init
+ (setq magit-repository-directories
+ (jao-d-l
+ '(("/Users/jao/Projects" . 3))
+ '(("/home/jao/usr/bigml" . 2)
+ ("/home/jao/usr/jao" . 3)
+ ("/usr/local/src" . 1))))
+
(setq magit-status-initial-section nil
magit-define-global-key-bindings nil
magit-completing-read-function 'magit-builtin-completing-read
@@ -1838,10 +1581,6 @@
magit-omit-untracked-dir-contents t
magit-process-connection-type nil
magit-push-always-verify nil
- magit-repository-directories
- '(("/home/jao/usr/bigml" . 2)
- ("/home/jao/usr/jao" . 3)
- ("/usr/local/src" . 1))
magit-save-repository-buffers 'dontask
magit-section-visibility-indicator '("…" . t)
magit-status-buffer-switch-function 'switch-to-buffer
@@ -1858,536 +1597,21 @@
(use-package embark-vc :ensure t)
:bind ((:map forge-topic-mode-map ("M-w" . copy-region-as-kill))))
-
-;;;; 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)))
-
;;;; other git packages
(use-package git-timemachine :ensure t)
-(use-package consult-git-log-grep
- :ensure t
- :custom (consult-git-log-grep-open-function #'magit-show-commit)
- :bind (("C-c K" . consult-git-grep)))
+;; (use-package consult-git-log-grep
+;; :ensure t
+;; :custom (consult-git-log-grep-open-function #'magit-show-commit)
+;; :bind (("C-c K" . consult-git-grep)))
;; git config --local git-link.remote / git-link.branch
(use-package git-link :ensure t)
(use-package git-modes :ensure t)
-;;;; 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))))
-
;;; Programming
-;;;; automatic modes
-(add-to-list 'auto-mode-alist '("\\.mix\\'" . hexl-mode))
-(add-to-list 'auto-mode-alist '("\\.m4\\'" . m4-mode))
-(add-to-list 'auto-mode-alist '("\\.am\\'" . makefile-mode))
-(add-to-list 'auto-mode-alist '("\\.pl\\'\\|\\.pm\\'" . cperl-mode))
-
-;;;; symbol overlay
-(use-package symbol-overlay
- :ensure t
- :config
- (defun jao-symbol-reveal (&rest _)
- (when outline-minor-mode (outline-show-entry)))
- (advice-add 'symbol-overlay-basic-jump :after 'jao-symbol-reveal)
- (defun jao-symbol-put-and-next ()
- (interactive)
- (symbol-overlay-put)
- (symbol-overlay-jump-next))
-
- (defun jao-symbol-put-and-prev ()
- (interactive)
- (symbol-overlay-put)
- (symbol-overlay-jump-prev))
-
- :bind (:map prog-mode-map (("M-i" . symbol-overlay-put)
- ("M-n" . jao-symbol-put-and-next)
- ("M-p" . jao-symbol-put-and-prev)))
- :hook (prog-mode . symbol-overlay-mode)
- :diminish " ^")
-
-;;;; eglot
-(use-package eglot
- :bind (:map eglot-mode-map (("C-h ." . jao-eldoc-toggle))))
-
-;;;; paredit and parens
-(require 'paren)
-(show-paren-mode t)
-(setq show-paren-context-when-offscreen t
- show-paren-when-point-inside-paren nil)
-
-(use-package paredit
- :ensure t
- :commands paredit-mode
- :hook ((pie-mode . paredit-mode)
- (scheme-mode . paredit-mode)
- (clojure-mode . paredit-mode)
- (emacs-lisp-mode . paredit-mode)
- ;; (eval-expression-minibuffer-setup . paredit-mode)
- (lisp-interaction-mode . disable-paredit-mode))
- :diminish ((paredit-mode . " þ")))
-
-;;;; diff/ediff
-(setq ediff-split-window-function 'split-window-horizontally)
-(setq ediff-make-buffers-readonly-at-startup nil)
-(setq ediff-window-setup-function 'ediff-setup-windows-plain)
-(setq ediff-keep-variants nil)
-
-;;;; compilation
-;;;;; compilation mode options
-(require 'compile)
-(setq compilation-scroll-output t)
-(setq compilation-error-regexp-alist
- (remove 'omake compilation-error-regexp-alist))
-;; (add-hook 'compilation-mode-hook #'visual-line-mode)
-
-;;;;; mode line (no "Compiling"!)
-(require 'compile)
-(diminish 'compilation-minor-mode " ‡")
-(when (< emacs-major-version 27)
- (setcdr (assq 'compilation-in-progress minor-mode-alist) '(" ‡")))
-(when (> emacs-major-version 26)
- (setcdr (assq 'compilation-in-progress mode-line-modes) '("‡ ")))
-
-;;;;; colorizing compilation buffer
-(setq compilation-message-face 'default)
-(require 'ansi-color)
-(defun endless/colorize-compilation ()
- "Colorize from `compilation-filter-start' to `point'."
- (let ((inhibit-read-only t))
- (ansi-color-apply-on-region
- compilation-filter-start (point))))
-
-(add-hook 'compilation-filter-hook #'endless/colorize-compilation)
-
-;;;;; compilation commands
-(use-package jao-compilation
- :commands jao-compilation-setup
- :bind (("C-c C" . compile)
- ("C-c c" . jao-compile)))
-(jao-compilation-setup)
-
-;;;;; next error
-(setq next-error-find-buffer-function
- #'next-error-buffer-on-selected-frame
- next-error-verbose t)
-
-;;;; flymake
-(use-package flymake
- :ensure t
- :custom ((flymake-mode-line-format '(" " flymake-mode-line-counters)))
- :config
- (jao-define-attached-buffer "^\\*Flymake diagnostics .*\\*\\'")
-
- (transient-define-prefix jao-transient-flymake ()
- ["Flymake"
- ("d" "show diagnostics" flymake-show-buffer-diagnostics)
- ("i" "show diagnostic" flymake-show-diagnostic)
- ("n" "next error" flymake-goto-next-error)
- ("p" "previous error" flymake-goto-prev-error)
- ("c" "consult flymake" consult-flymake)])
-
- :bind (:map flymake-mode-map (("M-m" . jao-transient-flymake))))
-
-;;;; workarounds
-(setq c-type-finder-time-slot nil)
-
-;;;; outline minor mode
-(use-package outline
- :init (setq outline-minor-mode-use-buttons nil
- outline-minor-mode-use-margins nil
- outline-minor-mode-cycle t))
-
-(defvar-local jao-outline-folded nil)
-(dolist (v '(4 5 outline-show-only-headings))
- (add-to-list 'safe-local-variable-values `(outline-default-state . ,v)))
-
-(defun jao-outline-minor-mode-hide-all (&optional arg)
- (interactive "P")
- (outline-hide-sublevels (if arg 5 4)))
-
-(defun jao-outline-minor-expand-all ()
- (when jao-outline-minor-mode (outline-show-all)))
-
-(defun jao-outline-minor-mode-toogle-fold (&optional arg)
- (interactive "P")
- (if (setq jao-outline-folded (not jao-outline-folded))
- (jao-outline-minor-mode-hide-all arg)
- (jao-outline-minor-expand-all)))
-
-(use-package outline-minor-faces
- :ensure t
- :after outline)
-
-(define-minor-mode jao-outline-minor-mode
- "Minor outline mode for programming languages"
- :lighter ""
- :keymap `((,(kbd "C-c C-n") . outline-next-visible-heading)
- (,(kbd "C-c C-p") . outline-previous-visible-heading)
- (,(kbd "C-c o") . consult-outline)
- (,(kbd "<f3>") . jao-outline-minor-mode-toogle-fold))
- (if jao-outline-minor-mode
- (progn (setq-local outline-level #'outline-level
- outline-regexp (format "[%s]\\{3,\\} " comment-start))
- (outline-minor-mode 1)
- (outline-minor-faces-mode 1))
- (outline-minor-mode -1)
- (outline-minor-faces-mode -1)))
-
-(add-hook 'find-function-after-hook #'jao-outline-minor-expand-all)
-
-;;; Programming languages
-;;;; Elisp
-(add-hook 'emacs-lisp-mode-hook #'jao-outline-minor-mode)
-
-(use-package edit-list :ensure t)
-(use-package package-lint :ensure t)
-;; (use-package tree-inspector :ensure t)
-
-(defun elisp-disassemble (function)
- (interactive (list (function-called-at-point)))
- (disassemble function))
-
-(defun elisp-pp (sexp)
- (with-output-to-temp-buffer "*Pp Eval Output*"
- (pp sexp)
- (with-current-buffer standard-output
- (emacs-lisp-mode))))
-
-(defun elisp-macroexpand (form)
- (interactive (list (form-at-point 'sexp)))
- (elisp-pp (macroexpand form)))
-
-(defun elisp-macroexpand-all (form)
- (interactive (list (form-at-point 'sexp)))
- (elisp-pp (macroexpand-all form)))
-
-(defun elisp-find-definition (name)
- (interactive (list (thing-at-point 'symbol)))
- (cond (name
- (let ((symbol (intern-soft name))
- (search (lambda (fun sym)
- (let* ((r (save-excursion (funcall fun sym)))
- (buffer (car r))
- (point (cdr r)))
- (cond ((not point)
- (error "Found no definition for %s in %s"
- name buffer))
- (t
- (switch-to-buffer buffer)
- (goto-char point)
- (recenter 1)))))))
- (cond ((fboundp symbol)
- (xref-push-marker-stack)
- (funcall search 'find-function-noselect symbol))
- ((boundp symbol)
- (xref-push-marker-stack)
- (funcall search 'find-variable-noselect symbol))
- (t
- (message "Symbol not bound: %S" symbol)))))
- (t (message "No symbol at point"))))
-
-
-(defun elisp-bytecompile-and-load ()
- (interactive)
- (or buffer-file-name
- (error "The buffer must be saved in a file first"))
- (require 'bytecomp)
- ;; Recompile if file or buffer has changed since last compilation.
- (when (and (buffer-modified-p)
- (y-or-n-p (format "save buffer %s first? " (buffer-name))))
- (save-buffer))
- (let ((filename (expand-file-name buffer-file-name)))
- (with-temp-buffer
- (byte-compile-file filename))))
-
-(use-package elisp-mode
- :bind (:map emacs-lisp-mode-map
- (("C-c C-M" . emacs-lisp-macroexpand)
- ("C-c C-m" . elisp-macroexpand-all)
- ("C-c C-k" . elisp-bytecompile-and-load)
- ;; ("C-c C-p" . pp-eval-last-sexp)
- ("M-." . elisp-find-definition)
- ("M-," . pop-tag-mark)
- ("C-c <" . lc-show-package-summary))))
-
-;;;; Clojure
-(use-package clojure-mode
- :ensure t
- :config
- (defun jao-clojure--fix-things ()
- (setq-local completion-styles '(basic partial-completion emacs22))
- (eldoc-mode 1)
- (setq mode-name "λ"))
- :hook (clojure-mode . jao-clojure--fix-things))
-
-(use-package cider
- :ensure t
- :commands cider-mode
- :init (setq cider-annotate-completion-candidates t
- cider-auto-select-error-buffer nil
- cider-auto-select-test-report-buffer nil
- cider-eldoc-display-for-symbol-at-point t
- cider-eldoc-ns-function #'identity ;; #'cider-last-ns-segment
- cider-enrich-classpath nil
- cider-lein-parameters "repl :headless :host localhost"
- cider-mode-line " ÷"
- cider-prompt-for-symbol nil
- cider-repl-history-file
- (expand-file-name "~/.emacs.d/cache/cider.history")
- cider-repl-pop-to-buffer-on-connect nil
- cider-repl-use-pretty-printing t
- cider-show-error-buffer 'except-in-repl
- cider-test-show-report-on-success nil
- cider-use-fringe-indicators nil
- cider-use-overlays nil
- clojure-docstring-fill-column 72
- nrepl-prompt-to-kill-server-buffer-on-quit nil)
- :bind (("<f3>" . cider-selector)))
-
-(with-eval-after-load "cider-test"
- (advice-add 'cider-scale-background-color :override
- (lambda () (frame-parameter nil 'background-color)))
- (setq cider-test-items-background-color
- (frame-parameter nil 'background-color)))
-
-(use-package cider-macroexpansion
- :after cider
- :diminish " µ")
-
-;;;; Geiser
-(defun jao-org--set-geiser-impl () (setq-local geiser-repl--impl 'guile))
-(add-hook 'org-mode-hook #'jao-org--set-geiser-impl)
-
-(jao-load-path "geiser")
-;; (package-vc-install-from-checkout ...)
-(use-package geiser
- :demand t
- :init
- (setq geiser-repl-history-filename "~/.emacs.d/cache/geiser-history"
- geiser-repl-startup-time 20000
- geiser-debug-auto-display-images t
- geiser-log-verbose t)
- :config
- (dolist (m '(geiser-repl-mode geiser-doc-mode geiser-debug-mode))
- (jao-define-attached-buffer `(major-mode . ,m) 0.4)))
-
-(jao-load-path "geiser-guile")
-(use-package geiser-guile)
-
-(jao-load-path "geiser-chez")
-(use-package geiser-chez)
-
-;; (jao-load-path "geiser/mit")
-;; (use-package geiser-mit)
-
-;; (jao-load-path "geiser/chicken")
-;; (use-package geiser-chicken)
-
-;; (jao-load-path "geiser/chibi")
-;; (use-package geiser-chibi)
-
-;; (jao-load-path "geiser/gambit")
-;; (use-package geiser-gambit)
-
-;; (jao-load-path "geiser/gauche")
-;; (use-package geiser-gauche)
-
-;;;; Haskell
-;;;;; packages
-;; (jao-load-path "haskell-mode")
-
-(use-package haskell-mode
- :ensure t
- :custom
- ((inferior-haskell-find-project-root t)
- (haskell-check-remember-last-command-p nil)
- (haskell-completing-read-function 'completing-read)
- (haskell-font-lock-symbols nil)
- (haskell-hoogle-command "hoogle")
- (haskell-interactive-popup-errors t)
- (haskell-process-auto-import-loaded-modules t)
- (haskell-process-log t)
- (haskell-process-suggest-remove-import-lines t)
- (haskell-process-suggest-hoogle-imports t)
- (haskell-process-type 'cabal-repl)
- (haskell-process-use-presentation-mode t)
- (haskell-stylish-on-save nil)
- (haskell-tags-on-save t))
-
- :init
- ;; For use with M-x align
- (require 'align)
- (add-to-list 'align-rules-list
- '(haskell-types
- (regexp . "\\(\\s-+\\)\\(::\\|∷\\)\\s-+")
- (modes quote (haskell-mode haskell-literate-mode))))
- (add-to-list 'align-rules-list
- '(haskell-assignment
- (regexp . "\\(\\s-+\\)=\\s-+")
- (modes quote (haskell-mode haskell-literate-mode))))
- (add-to-list 'align-rules-list
- '(haskell-arrows
- (regexp . "\\(\\s-+\\)\\(->\\|→\\)\\s-+")
- (modes quote (haskell-mode haskell-literate-mode))))
- (add-to-list 'align-rules-list
- '(haskell-left-arrows
- (regexp . "\\(\\s-+\\)\\(<-\\|←\\)\\s-+")
- (modes quote (haskell-mode haskell-literate-mode))))
-
- :config
- (defun jao-haskell-hoogle (no-info)
- (interactive "P")
- (haskell-hoogle (format "%s" (haskell-ident-at-point)) (not no-info)))
-
- (put 'haskell-process-args-cabal-repl
- 'safe-local-variable
- (apply-partially #'seq-every-p #'stringp))
-
- (defun jao-haskell-eldoc (cb)
- (let ((msg (or (haskell-doc-current-info--interaction t)
- (haskell-doc-sym-doc (haskell-ident-at-point))
- "")))
- (funcall cb (replace-regexp-in-string "[\n ]+" " " msg))))
-
- (setq tags-revert-without-query t)
-
- (defun jao-haskell-mode ()
- (require 'haskell-doc)
- (setq-local eldoc-documentation-function 'eldoc-documentation-default
- eldoc-documentation-functions '(jao-haskell-eldoc))
- (eldoc-mode))
-
- (dolist (h '(jao-haskell-mode
- haskell-decl-scan-mode
- haskell-indentation-mode
- interactive-haskell-mode))
- (add-hook 'haskell-mode-hook h))
-
- (add-hook 'haskell-presentation-mode-hook (lambda () (whitespace-mode -1)))
-
- :bind (:map haskell-mode-map
- (("C-c C-d" . jao-haskell-hoogle)
- ("C-c C-s" . haskell-session-change-target)
- ("C-c h" . haskell-hoogle)
- ("C-c t" . haskell-doc-show-type)
- ("C-c C-e" . haskell-command-insert-language-pragma)
- ("C-M-n" . flymake-goto-next-error)
- ("C-M-p" . flymake-goto-prev-error)
- ("<f3>" . haskell-session-kill))))
-
-(use-package hlint-refactor
- :ensure t
- :after haskell-mode
- :hook ((haskell-mode . hlint-refactor-mode))
- :bind (:map haskell-mode-map (("C-M-h" . 'hlint-refactor-refactor-at-point)
- ("C-M-S-h" . 'hlint-refactor-refactor-buffer)))
- :diminish)
-
-(use-package flymake-hlint
- :ensure t
- :after haskell-mode
- :hook ((haskell-mode . flymake-hlint-load)))
-
-
-(use-package consult-hoogle
- :ensure t)
-
-(require 'haskell)
-
-(diminish 'interactive-haskell-mode " λ")
-(diminish 'haskell-doc-mode)
-(diminish 'haskell-decl-scan-mode)
-
-(jao-define-attached-buffer "\\*hoogle\\*.*")
-(jao-define-attached-buffer '(major-mode . haskell-interactive-mode) 0.33)
-(jao-define-attached-buffer '(major-mode . haskell-presentation-mode) 0.25)
-
-;;;;; transient
-(jao-transient-major-mode haskell
- ["Imports"
- ("in" "Navigate imports" haskell-navigate-imports)
- ("if" "Format imports" haskell-mode-format-imports)
- ("is" "Sort imports" haskell-sort-imports)
- ("ia" "Align imports" haskell-align-imports)]
- ["Session"
- ("s" "Change the session's target" haskell-session-change-target)]
- ["Code"
- ("e" "insert language pragma" haskell-command-insert-language-pragma)
- ("v" "visit cabal file" haskell-cabal-visit-file)
- ("h" "hoogle" jao-haskell-hoogle)
- ("t" "show type" haskell-doc-show-type)]
- ["Flymake"
- ("n" "next error" flymake-goto-next-error)
- ("p" "previous error" flymake-goto-prev-error)])
-
-;;;; Pie
-(jao-load-path "pie")
-(use-package pie
- :demand t
- :commands (pie-mode))
-
-;;;; Prolog
-;; (use-package ediprolog :ensure t)
-
-(use-package prolog
- :ensure t
- :commands (run-prolog prolog-mode mercury-mode)
- :init (progn
- (setq prolog-system 'swi)
- (add-to-list 'auto-mode-alist '("\\.pl$" . prolog-mode))
- (setq prolog-consult-string '((t "[%f].")))
- (setq prolog-program-name
- '(((getenv "EPROLOG") (eval (getenv "EPROLOG")))
- (eclipse "eclipse")
- (mercury nil)
- (sicstus "sicstus")
- (swi "swipl")
- (t "prolog")))))
-
-;;;; Python
-(use-package virtualenvwrapper
- :ensure t
- :config
- (venv-initialize-eshell)
- (jao-compilation-env "VIRTUAL_ENV"))
+(require 'jao-custom-programming)
;;; Text/data formats
;;;; json
@@ -2396,34 +1620,28 @@
(use-package yaml-mode :disabled t :ensure t)
;;; Graphics
-;;;; images
(setq image-use-external-converter t
image-cache-eviction-delay 120)
(setq widget-image-enable nil)
-;;;; gnuplot
-(use-package gnuplot
- :disabled t
- :ensure t
- :commands (gnuplot-mode gnuplot-make-buffer)
- :init (add-to-list 'auto-mode-alist '("\\.gp$" . gnuplot-mode)))
-
;;; Network
+;;;; r2e
+
+(use-package jao-r2e
+ :init (setq jao-r2e-confirm-toggle nil))
+
;;;; nm applet
-(jao-shell-def-exec jao-nm-applet "nm-applet")
+(jao-when-linux
+ (jao-shell-def-exec jao-nm-applet "nm-applet")
-(defun jao-toggle-nm-applet ()
- (interactive)
- (or (jao-shell-kill-p "nm-applet") (jao-nm-applet)))
+ (defun jao-toggle-nm-applet ()
+ (interactive)
+ (or (jao-shell-kill-p "nm-applet") (jao-nm-applet))))
;;;; bluetooth
-(use-package bluetooth :ensure t)
-
-;;;; vpn
-(use-package jao-mullvad :demand t)
+(jao-when-linux (use-package bluetooth :ensure t))
;;;; ssh
-(use-package tramp)
(defun jao-tramp-hosts ()
(seq-uniq
(mapcan (lambda (x)
@@ -2438,607 +1656,95 @@
(jao-exec-in-term (format "ssh %s" h) (format "*ssh %s*" h))))
;;; Chats
-;;;; circe
-(defvar jao-libera-channels ())
-(defvar jao-oftc-channels ())
-(defvar jao-bitlbee-channels ())
-(defvar jao-slack-channels ())
-
-(use-package circe
- :ensure t
- :bind (:map circe-channel-mode-map
- (("C-c C-a" . lui-track-jump-to-indicator)))
- :init
- (setq circe-chat-buffer-name "{target}"
- circe-default-realname "https://jao.io"
- circe-default-part-message ""
- circe-default-quit-message ""
- circe-ignore-list nil
- circe-server-coding-system '(undecided . undecided)
- circe-server-killed-confirmation 'ask-and-kill-all
- circe-server-auto-join-default-type :after-auth
- circe-format-say "({nick}) {body}"
- circe-format-self-say "(jao) {body}"
- circe-new-buffer-behavior 'ignore
- circe-new-buffer-behavior-ignore-auto-joins t
- circe-nickserv-ghost-style 'after-auth
- circe-prompt-string ": "
- circe-completion-suffix ", "
- circe-reduce-lurker-spam t
-
- circe-lagmon-mode-line-format-string "" ;; "%.0f "
- circe-lagmon-mode-line-unknown-lag-string "" ;; "? "
- circe-lagmon-timer-tick 120
- circe-lagmon-reconnect-interval 180
-
- lui-max-buffer-size 30000
- lui-fill-column 80
- lui-time-stamp-position 'right
- lui-time-stamp-format "%H:%M"
- lui-flyspell-p nil
-
- lui-track-indicator (if window-system 'fringe 'bar)
- lui-track-behavior 'before-tracking-next-buffer)
- :config
+(jao-when-linux (require 'jao-custom-chats))
- (defsubst jao-circe-nick-no () (length (circe-channel-nicks)))
-
- (define-minor-mode jao-circe-user-number-mode ""
- :lighter (:eval (format " [%s]" (jao-circe-nick-no))))
-
- (defun jao-circe-channel-hook ()
- (when jao-mode-line-in-minibuffer
- (setq header-line-format
- '(" %b" (:eval (format " - %s nicks" (jao-circe-nick-no))))))
- (jao-circe-user-number-mode 1))
-
- (add-hook 'circe-channel-mode-hook #'jao-circe-channel-hook)
-
- (defun circe-command-RECOVER (&rest _ignore)
- "Recover nick"
- (jao-with-auth "freenode" u p
- (circe-command-MSG "nickserv" (format "IDENTIFY %s %s" u p))
- (circe-command-MSG "nickserv" (format "GHOST %s" u))
- (circe-command-MSG "nickserv" (format "RELEASE %s" u))
- (circe-command-NICK u)))
-
- (defun circe-command-NNICKS (&rest _)
- "Echo number of nicks"
- (circe-display-server-message
- (format "%d nicks in this channel" (jao-circe-nick-no))))
-
- (defun circe-command-SENDFILE (line)
- "/sendfile for localslackirc"
- (circe-command-QUOTE (format "sendfile %s" line)))
-
- (advice-add 'circe-command-NAMES :after #'circe-command-NNICKS)
-
- (setq circe-network-options
- (list (jao-with-auth "libera" u p
- (list "Libera Chat" :nick u :channels jao-libera-channels
- :tls t :sasl-username u :sasl-password p))
- (jao-with-auth "oftc" u p
- (list "OFTC"
- :nick u :channels jao-oftc-channels :nickserv-password p
- :tls t :sasl-username u :sasl-password p))
- (jao-with-auth "bitlbee" u p
- (list "Bitlbee" :host "127.0.0.1" :nick u
- :channels jao-bitlbee-channels :lagmon-disabled t
- :nickserv-password u :user p))
- (list "localslack" :host "127.0.0.1" :nick "jao"
- :channels jao-slack-channels :port 9007
- :lagmon-disabled t)
- (list "recoveryou" :host "127.0.0.1" :nick "jao"
- :port 9008 :lagmon-disabled t)))
-
- (jao-shorten-modes 'circe-channel-mode
- 'circe-server-mode
- 'circe-query-mode)
-
- (enable-circe-display-images)
- (enable-lui-track)
- (circe-lagmon-mode))
-
-;;;; telegram
-(use-package telega
- :ensure t
- :custom
- (telega-use-tracking-for '(unmuted) ;; '(or unmuted mention)
- telega-rainbow-color-custom-for nil
- telega-msg-rainbow-title nil
- telega-sticker-set-download t
- telega-symbol-checkmark "·"
- telega-symbol-heavy-checkmark "×"
- telega-symbol-verified "*")
- :config
- (define-key global-map (kbd "C-c C-t") telega-prefix-map)
- (setq telega-chat-show-avatars nil
- telega-chat-prompt-insexp '(telega-ins "> ")
- telega-completing-read-function #'completing-read
- telega-root-show-avatars nil
- telega-emoji-use-images nil
- telega-temp-dir "/tmp/telega"
- telega-symbol-horizontal-bar
- (propertize "-" 'face 'jao-themes-f00)
- telega-symbol-vertical-bar
- (propertize "| " 'face 'jao-themes-dimm)
- telega-mode-line-string-format
- '(:eval (telega-mode-line-unread-unmuted))
- telega-use-images (display-graphic-p)
- telega-open-file-function #'jao--see
- telega-open-message-as-file
- (unless (display-graphic-p) '(photo video animation)))
- (with-eval-after-load "tracking"
- (jao-shorten-modes 'telega-chat-mode)
- (jao-tracking-faces 'telega-tracking))
- (telega-mode-line-mode 1))
-
-(defun jao-telega ()
- (interactive)
- (jao-tracking-go-to-chats)
- (if (get-buffer telega-root-buffer-name)
- (pop-to-buffer telega-root-buffer-name)
- (telega)))
-
-;;;; 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"))
-
-;;;; mastodon
-(use-package mastodon
- :ensure t
- :init
- (setq mastodon-instance-url "https://fosstodon.org"
- mastodon-active-user "jao@gnu.org"
- mastodon-tl-position-after-update nil
- mastodon-toot-display-orig-in-reply-buffer t)
- :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)])
-
-;;;; startup
-(defun jao-chats (&optional p)
- (interactive "P")
- (when (or p (y-or-n-p "Connect to telegram? "))
- (telega))
- (when (and (fboundp 'ement-connect) (or p (y-or-n-p "Connect to matrix? ")))
- (unless (get-buffer "*Ement Rooms*")
- (jao-with-auth "matrix.org" u p (ement-connect :user-id u :password p))))
- (when (and (fboundp 'mastodon) (or p (y-or-n-p "Connect to mastodon? ")))
- (mastodon))
- (when (or p (y-or-n-p "Connect to libera? "))
- (unless (get-buffer "irc.libera.chat:6697")
- (circe "Libera Chat")))
- (when (or p (y-or-n-p "Connect to localslack? "))
- (unless (get-buffer "127.0.0.1:9007")
- (circe "localslack")))
- (when (or p (y-or-n-p "Connect to recoveryou? "))
- (unless (get-buffer "127.0.0.1:9008")
- (circe "recoveryou"))))
-
-(defun jao-all-chats ()
- (interactive)
- (when jao-tracking-use-scratch
- (jao-afio-goto-chats)
- (delete-other-windows))
- (jao-chats t))
-
-(defun jao-chats-telega ()
- (interactive)
- (jao-buffer-same-mode '(telega-root-mode telega-chat-mode)))
-
-(defun jao-chats-slack ()
- (interactive)
- (jao-buffer-same-mode 'slack-message-buffer-mode))
-
-(defun jao-chats-irc ()
- (interactive)
- (jao-buffer-same-mode '(circe-channel-mode circe-query-mode erc-mode)))
-
-;;;; consult narrowing
-(defvar jao-chat-buffer-source
- (list :name "chats"
- :category 'buffer
- :action (lambda (b) (jao-afio-pop-to-buffer 0 b))
- :hidden t
- :narrow (cons ?c "chats")
- :items (jao-consult--mode-buffers 'erc-mode
- 'circe-channel-mode
- 'circe-query-mode
- 'signel-chat-mode
- 'slack-message-buffer-mode
- 'slack-thread-message-buffer-mode
- 'telega-root-mode
- 'telega-chat-mode
- 'ement-room-mode
- 'ement-room-list-mode)))
-(with-eval-after-load "consult"
- (jao-consult-add-buffer-source 'jao-chat-buffer-source))
;;; Multimedia
-;;;; video
-(use-package ready-player :ensure t)
-(ready-player-mode 1)
-;;;; mixer
-(defun jao-mixer-get-level (&optional dev nomsg)
- (interactive)
- (let* ((dev (or dev "Master"))
- (s (shell-command-to-string (format "amixer sget %s" dev)))
- (s (car (last (split-string s "\n" t)))))
- (when (string-match ".*Front .*\\[\\([0-9]+\\)%\\] .*" s)
- (let ((level (match-string 1 s)))
- (unless nomsg (message "%s level: %s%%" dev level))
- (string-to-number level)))))
-
-(defun jao-mixer-set (dev v)
- (jao-shell-exec* t "amixer" "sset" dev v)
- (jao-mixer-get-level dev))
-
-(defun jao-mixer-master-toggle ()
- (interactive)
- (jao-mixer-set "Master" "toggle"))
-(defun jao-mixer-master-up ()
- (interactive)
- (jao-mixer-set "Master" "10%+"))
-
-(defun jao-mixer-master-down ()
- (interactive)
- (jao-mixer-set "Master" "10%-"))
-
-(defun jao-mixer-capture-up ()
- (interactive)
- (jao-mixer-set "Capture" "10%+"))
-
-(defun jao-mixer-capture-down ()
- (interactive)
- (jao-mixer-set "Capture" "10%-"))
-
-(jao-shell-def-exec jao-audio-applet "pasystray")
-
-(defun jao-toggle-audio-applet ()
- (interactive)
- (or (jao-shell-kill-p "paystray") (jao-audio-applet)))
-
-(global-set-key (kbd "<f4>") #'jao-toggle-audio-applet)
-
-;;;; streaming aliases
-(defalias 'jao-streaming-list #'ignore)
-(defalias 'jao-streaming-like #'ignore)
-(defalias 'jao-streaming-dislike #'ignore)
-(defalias 'jao-streaming-toggle-shuffle #'ignore)
-(defalias 'jao-streaming-lyrics #'ignore)
-(defalias 'jao-streaming-toggle #'ignore)
-(defalias 'jao-streaming-next #'ignore)
-(defalias 'jao-streaming-prev #'ignore)
-(defalias 'jao-streaming-current #'ignore)
-(defalias 'jao-streaming-seek #'ignore)
-(defalias 'jao-streaming-seek-back #'ignore)
-(defalias 'jao-streaming-volume #'ignore)
-(defalias 'jao-streaming-volume-down #'ignore)
-
-;;;; mpris
-(defun jao-mpris-lyrics (&optional force)
- (interactive "P")
- (jao-show-lyrics force #'jao-mpris-artist-title))
-
-(defun jao-mpris-mopidy-p () (string= "mopidy "jao-mpris-player))
-
-(defun jao-mpc-mopidy-playlist ()
- (interactive)
- (jao-mpc-show-playlist jao-mopidy-port))
-
-(use-package jao-mpris :demand t)
-
-(defun jao-mpris-setup-aliases ()
- (setq espotify-play-uri-function #'espotify-play-uri-with-dbus)
- ;; (setq jao-mpris-player "mopidy")
- (defalias 'jao-streaming-list #'jao-mpc-mopidy-playlist)
- (defalias 'jao-streaming-lyrics #'jao-mpris-lyrics)
- (defalias 'jao-streaming-toggle #'jao-mpris-play-pause)
- (defalias 'jao-streaming-next #'jao-mpris-next)
- (defalias 'jao-streaming-prev #'jao-mpris-previous)
- (defalias 'jao-streaming-current #'jao-mpris-show-osd)
- (defalias 'jao-streaming-seek #'jao-mpris-seek)
- (defalias 'jao-streaming-seek-back #'jao-mpris-seek-back)
- (defalias 'jao-streaming-volume #'jao-mpris-vol)
- (defalias 'jao-streaming-volume-down #'jao-mpris-vol-down))
-
-(jao-mpris-register "playerctld" :session 70)
-;; (jao-mpris-register "mopidy" :session 70)
+(jao-when-linux (require 'jao-custom-multimedia))
;;;; mpc
(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)))
+ :demand t)
(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))))))
+ (,(intern (format "jao-mpc-%s" (or mpc-name name)))))))
(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 echo echo-current)
(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)))
+(defun jao-player-seek (delta) (jao-mpc-seek delta))
(defalias 'jao-player-connect 'jao-mpc-connect)
(defalias 'jao-player-play 'jao-mpc-play)
-;;;; 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)
-
-;;;; music transients
-(require 'jao-lyrics)
-(setq jao-lyrics-info-function #'jao-player-info)
+(use-package jao-lyrics
+ :init
+ (setq jao-lyrics-info-function #'jao-player-info
+ jao-lyrics-cache-dir (jao-d-l "~/Documents/lyrics" "~/.lyrics")))
(defun jao-player-seek-10 () (interactive) (jao-player-seek 10))
(defun jao-player-seek--10 () (interactive) (jao-player-seek -10))
-(defun jao-streaming-clear () (interactive) (jao-mpc-clear jao-mopidy-port))
+(defun jao-streaming-clear () (interactive) (jao-mpc-clear))
(defun jao-streaming-echo-current ()
(interactive)
- (jao-mpc-echo-current jao-mopidy-port))
+ (jao-d-l (let ((inhibit-message t)) (jao-mpc-notify))
+ (jao-mpc-echo-current)))
(defun jao-streaming-show-playlist ()
(interactive)
- (jao-mpc-show-playlist jao-mopidy-port))
+ (jao-mpc-show-playlist))
(use-package jao-random-album
:demand t
:config
(defun jao--notify-album (album)
- (unless jao-minibuffer-mode
- (jao-notify album "Next album" jao-notify-audio-icon))
- (jao-minibuffer-refresh))
+ (if jao-minibuffer-mode
+ (jao-minibuffer-refresh)
+ (jao-notify album "Next album" jao-notify-audio-icon "")))
(setq jao-random-album-notify #'jao--notify-album))
-(defun jao-toggle-pasystray-applet ()
- (interactive)
- (or (jao-shell-kill-p "pasystray") (jao-shell-exec "pasystray")))
-
-(transient-define-prefix jao-transient-streaming ()
- [:description
- (lambda () (format "Streaming using %s" jao-mpris-player))
- ["Search" :if jao-mpris-mopidy-p
- ("a" "album" jao-streaming-album)
- ("A" "artist" jao-streaming-artist)
- ("t" "track" jao-streaming-track)
- ("P" "playlist" jao-streaming-playlist)]
- ["Play"
- ("s" "toggle" jao-streaming-toggle)
- ("n" "next" jao-streaming-next)
- ("p" "previous" jao-streaming-prev)
- ("T" "toggle player" jao-streaming-toggle-player)]
- ["Seek & shout"
- ("f" "seek fwd" jao-streaming-seek :transient t)
- ("F" "seek bwd" jao-streaming-seek-back :transient t)
- ("u" "up" jao-streaming-volume :transient t)
- ("d" "down" jao-streaming-volume-down :transient t)]
- ["Browse"
- ("l" "playing list" jao-streaming-list :if jao-mpris-mopidy-p)
- ("L" "lyrics" jao-streaming-lyrics)
- ("w" "currently playing" jao-streaming-current)]
- ["Act" :if jao-mpris-mopidy-p
- ("k" "like" jao-streaming-like)
- ("K" "dislike" jao-streaming-dislike)
- ("S" "toggle shuffle" jao-streaming-toggle-shuffle)]])
-
(transient-define-prefix jao-transient-media ()
[["Play"
("m" "toggle" jao-player-toggle)
("n" "next" jao-player-next)
("p" "previous" jao-player-previous)
- ("s" "select album" jao-player-select-album)]
+ ("S" "play stream" jao-mpc-play-stream)]
["Seek and search"
("f" "seek fwd" jao-player-seek-10 :transient t)
("F" "seek bwd" jao-player-seek--10 :transient t)
- ("a" "search album" jao-mpc-select-album)
- ("S" "play stream" jao-mpc-play-stream)]
+ ("a" "search album" jao-mpc-select-album)]
["Browse"
- ("b" "browse" jao-player-browse)
- ("l" "show play list" jao-player-list)
- ("L" "show lyrics" jao-show-lyrics)
- ("w" "now playing" jao-player-echo)]
+ ("b" "browse albums" jao-player-browse)
+ ("l" "show play list" jao-player-list)]
+ ["Now playing"
+ ("w" "now playing" jao-streaming-echo-current)
+ ("e" "echo now play" jao-player-echo)
+ ("L" "show lyrics" jao-show-lyrics)]
[:description
(lambda ()
- (message "%s %s"
- (if (jao-mpc-mopidy-p) "mopidy" "mpd")
- (if (jao-mpc-playing-p)
- (jao-mpc--current-timestr t)
- (jao-mpc--current-str)))
+ (message "mpd %s" (if (jao-mpc-playing-p)
+ (jao-mpc--current-timestr t)
+ (jao-mpc--current-str)))
(format "Master %s%%" (jao-mixer-get-level nil t)))
+ :if jao-is-linux
("d" "down" jao-mixer-master-down :transient t)
("u" "up" jao-mixer-master-up :transient t)
("M" "toggle" jao-mixer-master-toggle)]
[:description
(lambda () (format "Capture %s%%" (jao-mixer-get-level "Capture" t)))
+ :if jao-is-linux
("D" "down" jao-mixer-capture-down :transient t)
("U" "up" jao-mixer-capture-up :transient t)]
["Utilities"
@@ -3047,217 +1753,49 @@
("r" (lambda ()
(concat (if jao-random-album-active "dis" "en") "able random album"))
jao-random-album-toggle)
- ;; ("P" (lambda () (concat "Toggle to " (if (jao-mpc-mopidy-p) "mpd" "mopidy")))
- ;; jao-mpc-toggle-port)
- ("P" "pasystray" jao-toggle-pasystray-applet)]])
+ ("P" "pasystray" jao-toggle-pasystray-applet :if jao-is-linux)]])
(global-set-key (kbd "s-m") #'jao-transient-media)
-;;; Graphical window system
-;;;; x11 utils
-(defun jao-xdotool (arg-or-wait &rest args)
- (apply 'jao-shell-exec*
- (if (stringp arg-or-wait) "xdotool" arg-or-wait)
- (if (stringp arg-or-wait) arg-or-wait "xdotool")
- args))
-
-(defsubst jao-xdotool-string (&rest args)
- (apply 'jao-shell-string "xdotool" args))
-
-(defsubst jao-x11-focused-id () (jao-xdotool-string "getwindowfocus"))
+(jao-mpc-setup nil (jao-when-linux 70))
-(defsubst jao-x11-window-name (&optional wid)
- (jao-xdotool-string "getwindowname" (or wid (jao-x11-focused-id))))
-
-(defsubst jao-x11-search-window (title)
- (jao-xdotool-string "search" "--name" title))
-
-(defsubst jao-x11-goto-ws (n) (jao-xdotool t "set_desktop" (format "%s" n)))
+;;; Graphical window system
-;;;; exwm
(defvar jao-exwm-enabled nil)
(defun jao-exwm-enabled-p () jao-exwm-enabled)
-(defun jao-exwm-enable ()
- (require 'jao-custom-exwm)
- (setq jao-exwm-enabled t)
- (display-time-mode -1)
- (jao-ednc-setup 95)
- (exwm-enable)
- (x-change-window-property "_XMONAD_TRAYPAD" "" nil nil nil nil 0)
- (jao-mode-line-add-to-minibuffer-left 90)
- (jao-xmobar-restart)
- (jao-trisect t))
-
-;;;; xmonad
-(defvar jao-xmonad-enabled (string= "xmonad" (or (getenv "wm") "")))
+(defvar jao-xmonad-enabled
+ (jao-when-linux (string= "xmonad" (or (getenv "wm") ""))))
(defun jao-xmonad-enabled-p () jao-xmonad-enabled)
-(defun jao-xmonad-enable ()
- (setq jao-browse-doc-use-emacs-p (display-graphic-p))
- (setq jao-mode-line-in-minibuffer nil)
- (display-battery-mode -1)
- (jao-trisect)
- (message "Welcome to xmonad"))
-
-(when jao-xmonad-enabled
- (add-hook 'after-init-hook #'jao-xmonad-enable))
-
-;;;; wayland
-
-(use-package jao-wayland :demand t)
-
-(defun jao-wayland-enable ()
- (interactive)
- (defalias 'x-change-window-property #'ignore)
- (jao-trisect)
- (message "Welcome to wayland"))
+(defvar jao-wayland-enabled
+ (jao-when-linux (string= "wayland" (or (getenv "XDG_SESSION_TYPE") ""))))
-(defun jao-river-enable ()
- (jao-wayland-enable)
- (when (jao-shell-running-p "i3bar-river")
- (jao-tracking-set-log ""))
- (message "Welcome to river"))
+(defvar jao-river-enabled
+ (jao-when-linux (jao-shell-running-p "river")))
-(when jao-river-enabled
- (add-hook 'after-init-hook #'jao-river-enable t))
+(jao-when-darwin
+ (defvar jao-sway-enabled nil)
+ (defun jao-wayland-enabled-p () nil)
+ (defun jao-river-enabled-p () nil))
-(when jao-sway-enabled
- (add-hook 'after-init-hook #'jao-wayland-enable t))
-
-;;;; wallpaper
-(defvar jao-wallpaper-dir "~/.wallpapers/")
-
-(defvar jao-wallpaper-random-candidates
- '("wallpaper.jpg" "wallpaper2.jpg"))
-
-(defvar jao-wallpaper-random-candidates-light
- '("wallpaper.jpg" "wallpaper2.jpg"))
-
-(defvar jao-wallpaper-random-wake t
- "Set to t for getting a new wallpaper on awaking from sleep")
-
-(defun jao-set-wallpaper (&optional path)
- (interactive)
- (let ((current (format "~/.wallpaper.%s" (jao-colors-scheme))))
- (when-let ((f (or (and path (expand-file-name path))
- (read-file-name "Image: "
- jao-wallpaper-dir
- (file-symlink-p current)
- t))))
- (make-symbolic-link f current t)
- (cond (jao-river-enabled (jao-river-set-wallpaper f))
- (jao-sway-enabled (jao-sway-set-wallpaper f))
- (t (shell-command-to-string (format "xwallpaper --zoom %s" f)))))))
-
-(defun jao-set-random-wallpaper ()
- (interactive)
- (when (or (called-interactively-p 'interactive)
- jao-wallpaper-random-wake)
- (let* ((ws (if (jao-colors-scheme-dark-p)
- jao-wallpaper-random-candidates
- jao-wallpaper-random-candidates-light))
- (f (seq-random-elt ws)))
- (jao-set-wallpaper (expand-file-name f jao-wallpaper-dir))
- (message "%s" f))))
-
-(add-to-list 'jao-sleep-awake-functions #'jao-set-random-wallpaper)
-
-;;;; screensaver and lock
-(defun jao-screensaver-enabled ()
- (string= (jao-shell-string "xdg-screensaver status") "enabled"))
-
-(defvar jao-screensaver--wid nil)
-(defun jao-screensaver-toggle ()
- (interactive)
- (if (jao-screensaver-enabled)
- (let ((wid (jao-x11-focused-id)))
- (setq jao-screensaver--wid wid)
- (jao-shell-exec* t "xdg-screensaver" "suspend" wid))
- (jao-shell-exec* t "xdg-screensaver" "resume" jao-screensaver--wid)
- (setq jao-screensaver--wid nil))
- (jao-notify (format "Screensaver %s"
- (jao-shell-string "xdg-screensaver status"))))
-
-(jao-shell-def-exec jao-xlock-screen "xdg-screensaver" "activate")
-(jao-shell-def-exec jao-suspend "sudo" "systemctl" "suspend")
-(jao-shell-def-exec jao-poweroff "sudo" "systemctl" "poweroff")
-
-(defun jao-lock-screen ()
- (interactive)
- (if jao-wayland-enabled
- (shell-command "swaylock -i ~/.lockimage")
- (jao-xlock-screen)))
-
-(transient-define-prefix jao-transient-sleep ()
- ["Sleep"
- ("l" "lock screen" jao-lock-screen)
- ("z" "sleep" jao-suspend)
- ("u" (lambda ()
- (if (jao-screensaver-enabled) "suspend screensaver" "resume screensaver"))
- jao-screensaver-toggle)
- ("poof" "power-off" jao-poweroff)])
-
-;;;; X clipboard
-(setq select-enable-clipboard t
- select-enable-primary t
- selection-timeout 100
- xterm-select-active-regions t)
-
-(use-package xclip
- :ensure t
- :init (setq xclip-method (if jao-wayland-enabled 'wl-copy 'xclip)))
-
-(unless (display-graphic-p) (xclip-mode 1))
-
-;;;; pop-up frames
-(defun jao-open-in-x-frame (&optional width height)
- (interactive)
- (make-frame `((window-system . x)
- (name . "emacs popup")
- (width . ,(or width (window-width)))
- (height . ,(or height (window-height)))))
- (define-key (current-local-map) "q" #'delete-frame))
-
-;;;; xmobar
-(defun jao-xmobar-kill ()
- (interactive)
- (shell-command "killall xmobar-single"))
-
-(defun jao-xmobar-restart ()
- (interactive)
- (jao-xmobar-kill)
- (start-process "" nil "xmobar-single" "-d"))
-
-(use-package tab-bar
- :init (setq tab-bar-close-button-show nil
- tab-bar-show (> emacs-major-version 28)
- tab-bar-format ()))
-
-(use-package xmobar
- :init (setq xmobar-tab-bar t
- xmobar-tab-split "*"
- xmobar-tab-bar-format
- (if window-system
- '(xmobar-left-string
- tab-bar-format-align-right
- xmobar-right-string)
- '(xmobar-left-string
- xmobar-elastic-space
- xmobar-right-string))
- xmobar-command
- (if window-system '("xmobar-emacs" "-TAnsi") "xmobar-emacs")))
+(jao-d-l
+ (setq jao-minibuffer-info-face 'jao-themes-dimm)
+ (jao-mode-line-add-to-minibuffer-left 90)
+ (require 'jao-custom-x11))
;;; Global transients
(defun jao-list-packages ()
(interactive)
- (jao-afio-goto-scratch)
+ (jao-afio-goto-scratch t)
(package-list-packages))
(defun jao-window-system-p ()
- (or jao-exwm-enabled jao-xmonad-enabled jao-wayland-enabled))
+ (or (not (jao-is-linux))
+ jao-exwm-enabled jao-xmonad-enabled jao-wayland-enabled))
-(defun jao-x11-p () (or jao-exwm-enabled jao-xmonad-enabled))
+(defun jao-x11-p ()
+ (jao-when-linux (or jao-exwm-enabled jao-xmonad-enabled)))
(defun jao-reveal ()
(interactive)
@@ -3268,49 +1806,105 @@
(jao-def-exec-in-term "aptitude" "aptitude" (jao-afio-goto-scratch))
(jao-def-exec-in-term "htop" "htop" (jao-afio-goto-scratch))
-(transient-define-prefix jao-transient-utils ()
- "Global operations."
- [["Notes"
- ("n" "create new note" jao-org-notes-create)
- ("/" "open note" jao-org-notes-open)
- ("\\" "open note by tags" jao-org-notes-consult-tags)
- ("g" "ripgrep notes" jao-org-notes-consult-ripgrep)]
- ["Documents"
- ("dd" "go to doc" jao-select-pdf :if display-graphic-p)
- ("do" "open doc" jao-open-doc)
- ("dr" "search docs with recoll" jao-recoll-consult-docs)]
- ["Monitors"
- ("p" "htop" jao-term-htop)
- ("P" "pasytray" jao-toggle-pasystray-applet)
- ("x" "restart i3bar" jao-river-restart-i3bar :if jao-river-enabled-p)
- ("x" "restart xmobar" jao-xmobar-restart :if jao-exwm-enabled-p)
- ("x" "kill xmobar" jao-xmobar-kill :if jao-xmonad-enabled-p)]
- ["Network"
- ("s" "ssh" jao-ssh)
- ("b" "bluetooth" bluetooth-list-devices)
- ("c" "connect chats" jao-all-chats)
- ("m" "proton bridge" run-proton-bridge)
- ("v" "view video" jao-view-video)]
- ["Chats"
- ("t" "telegram" jao-chats-telega)
- ("i" "irc" jao-chats-irc)
- ("M" "mastodon" jao-mastodon)
- ("T" "telegram rooster" jao-telega)]
- ["Window system" :if jao-window-system-p
- ("w" "set wallpaper" jao-set-wallpaper)
- ("W" "set radom wallpaper" jao-set-random-wallpaper)
- ("B u" (lambda ()
- (let ((b (jao-brightness)))
- (format "bright up %s" (and (string-match ".*\\((.+)\\).*" b)
- (match-string 1 b)))))
- jao-bright-up :transient t)
- ("B d" "bright down" jao-bright-down :transient t)]
- ["Helpers"
- ("a" "aptitude" jao-term-aptitude)
- ("l" "packages" jao-list-packages)
- ("r" "reveal" jao-reveal)
- ("k" (lambda () (concat "keyboard" (when (jao-kb-toggled-p) "*")))
- jao-kb-toggle :if jao-x11-p)]])
+(jao-d-l
+ (progn
+ (defun jao-open-firefox () (interactive) (jao-mac-open "-a Firefox"))
+ (defun jao-open-nnw () (interactive) (jao-mac-open "-a NetNewsWire"))
+ (defun jao-open-safari () (interactive) (jao-mac-open "-a Safari"))
+ (defun jao-open-telegram () (interactive) (jao-mac-open "-a Telegram"))
+ (global-set-key (kbd "s-f") #'jao-open-safari)
+ ;; (global-set-key (kbd "s-n") #'jao-open-nnw)
+ (global-set-key (kbd "s-t") #'jao-open-telegram)
+
+ (defun jao-safari-internal-browse ()
+ (interactive)
+ (when-let ((url (jao-safari-current-url)))
+ (jao-browse-url-browse url)))
+
+ (transient-define-prefix jao-transient-utils ()
+ "Global operations."
+ [["Notes"
+ ("nn" "create new note" jao-org-notes-create)
+ ("no" "open note" jao-org-notes-open)
+ ("nt" "open note by tags" jao-org-notes-consult-tags)
+ ("ng" "ripgrep notes" jao-org-notes-consult-ripgrep)]
+ ["Documents"
+ ("d" "go to doc" jao-select-pdf)
+ ("o" "open doc" jao-open-doc)
+ ("c" "view cache" doc-view-dired-cache)]
+ ["External"
+ ("xn" "browse NNW article" jao-nnw-browse-current-article)
+ ("xs" "browse safary article" jao-safari-internal-browse)
+ ("xk" "open skim doc" jao-skim-open-current-doc)
+ ("xe" "choose an emoji" ns-do-show-character-palette)]
+ ["Blog"
+ ("bn" "create post" jao-org-static-blog-create-new-post)
+ ("bd" "create draft" jao-org-static-blog-create-new-draft)
+ ("be" "edit draft" jao-org-static-blog-edit-draft)]
+ ["Afio"
+ ("g" "mail" jao-afio-goto-mail)
+ ("z" "docs" jao-afio-goto-docs)
+ ("w" "wwww" jao-afio-goto-www)
+ ("f" "main" jao-afio-goto-main)]
+ ["Network"
+ ("s" "ssh" jao-ssh)
+ ("r" "r2e" jao-r2e)]
+ ["Utilities"
+ ("m" "mpc" jao-transient-media)
+ ("l" "packages" jao-list-packages)
+ ("p" "passwords" password-store-menu)
+ ("F" "copy buffer file name" copy-buffer-file-name-as-kill)]]))
+
+ (transient-define-prefix jao-transient-utils ()
+ "Global operations."
+ [["Notes"
+ ("n" "create new note" jao-org-notes-create)
+ ("/" "open note" jao-org-notes-open)
+ ("\\" "open note by tags" jao-org-notes-consult-tags)
+ ("g" "ripgrep notes" jao-org-notes-consult-ripgrep)]
+ ["Documents"
+ ("dd" "go to doc" jao-select-pdf :if display-graphic-p)
+ ("do" "open doc" jao-open-doc)
+ ("dr" "search docs with recoll" jao-recoll-consult-docs)]
+ ["Monitors"
+ ("p" "list projects" list-projects)
+ ;; ("p" "htop" jao-term-htop)
+ ("P" "pasytray" jao-toggle-pasystray-applet)
+ ("x" "restart i3bar" jao-river-restart-i3bar :if jao-river-enabled-p)
+ ("x" "restart xmobar" jao-xmobar-restart :if jao-exwm-enabled-p)
+ ("x" "kill xmobar" jao-xmobar-kill :if jao-xmonad-enabled-p)]
+ ["Network"
+ ("s" "ssh" jao-ssh)
+ ("b" "bluetooth" bluetooth-list-devices)
+ ("c" "connect chats" jao-all-chats)
+ ("m" "proton bridge" run-proton-bridge)]
+ ["Chats"
+ ("i" "irc" jao-chats-irc)
+ ("M" "mastodon" jao-mastodon)
+ ("T" "telegram rooster" jao-telega)]
+ ["Window system" :if jao-window-system-p
+ ("w" "set wallpaper" jao-set-wallpaper)
+ ("W" "set radom wallpaper" jao-set-random-wallpaper)
+ ("B u" (lambda ()
+ (let ((b (jao-brightness)))
+ (format "bright up %s" (and (string-match ".*\\((.+)\\).*" b)
+ (match-string 1 b)))))
+ jao-bright-up :transient t)
+ ("B d" "bright down" jao-bright-down :transient t)]
+ ["Utilities"
+ ("a" "aptitude" jao-term-aptitude)
+ ("l" "packages" jao-list-packages)
+ ("v" "view video" jao-view-video)]
+ ["Timers"
+ ("t t" "set new" tmr)
+ ("t c" "cancel" tmr-cancel)
+ ("t l" "list" tmr-list-timers)]
+ ["Helpers"
+ ;; ("r" "reveal" jao-reveal)
+ ("r" "translate" reverso)
+ ("f" "copy buffer file name" copy-buffer-file-name-as-kill)
+ ("k" (lambda () (concat "keyboard" (when (jao-kb-toggled-p) "*")))
+ jao-kb-toggle :if jao-x11-p)]]))
(global-set-key (kbd "s-w") #'jao-transient-utils)
@@ -3325,7 +1919,8 @@
(global-set-key "\C-cq" #'auto-fill-mode)
(global-set-key "\C-xr\M-w" #'kill-rectangle-save)
(global-set-key "\C-c\C-z" #'comment-or-uncomment-region)
- (global-set-key "\C-z" #'comment-or-uncomment-region))
+ (global-set-key "\C-z" #'comment-or-uncomment-region)
+ (jao-when-darwin (global-set-key (kbd "M-`") 'other-frame)))
(jao-global-keybindings)
diff --git a/lib/doc/jao-doc-session.el b/lib/doc/jao-doc-session.el
index 877a8cb..df7e994 100644
--- a/lib/doc/jao-doc-session.el
+++ b/lib/doc/jao-doc-session.el
@@ -1,6 +1,6 @@
;;; jao-doc-session.el --- persistent document sessions -*- lexical-binding: t; -*-
-;; Copyright (C) 2022, 2024 jao
+;; Copyright (C) 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: docs
@@ -20,15 +20,18 @@
;;; Code:
-(persist-defvar jao-doc-session nil "Documents session")
+(define-multisession-variable jao-doc--session nil)
-(defvar-local jao-doc-session--is-doc nil)
+(defun jao-doc-session () (multisession-value jao-doc--session))
+
+(defvar-local jao-doc-session-is-doc nil
+ "Locally marks a buffer as belonging to a session.
+
+See also `jao-doc-session-mark'.")
(defun jao-doc-session-is-doc (&optional buffer)
"Check whether the given or current buffer belong to the doc session."
- (buffer-local-value 'jao-doc-session--is-doc (or buffer (current-buffer))))
-
-(defun jao-doc-session (&optional file) jao-doc-session)
+ (buffer-local-value 'jao-doc-session-is-doc (or buffer (current-buffer))))
(defun jao-doc-session-save (&optional skip-current force)
"Traverse all current buffers and update the value of `jao-doc-session'."
@@ -36,24 +39,24 @@
(let ((docs '())
(cb (and skip-current (current-buffer))))
(dolist (b (buffer-list))
- (when-let (fs (and (not (eq cb b)) (jao-doc-session-is-doc b)))
+ (when-let* ((fs (and (not (eq cb b)) (jao-doc-session-is-doc b)))
+ (fs (if (listp fs) fs (list (buffer-file-name b)))))
(dolist (f fs) (add-to-list 'docs f))))
(when (or force (> (length docs) 0))
- (setq jao-doc-session docs))))
+ (setf (multisession-value jao-doc--session) docs))))
(defun jao-doc-session-mark (&optional path)
"Mark the current buffer's file, or PATH, as persistent across sessions."
- (unless (listp jao-doc-session--is-doc)
- (setq jao-doc-session--is-doc (ensure-list jao-doc-session--is-doc)))
- (cl-pushnew (or path (buffer-file-name)) jao-doc-session--is-doc)
+ (unless (listp jao-doc-session-is-doc)
+ (setq jao-doc-session-is-doc (ensure-list jao-doc-session-is-doc)))
+ (cl-pushnew (or path (buffer-file-name)) jao-doc-session-is-doc)
(jao-doc-session-save))
(defun jao-doc-session--maybe-save ()
(when (jao-doc-session-is-doc) (jao-doc-session-save t)))
-(defvar jao-doc-session-inhibit-save nil)
-
(add-hook 'kill-buffer-hook #'jao-doc-session--maybe-save)
+(add-hook 'kill-emacs-hook #'jao-doc-session-save)
(provide 'jao-doc-session)
;;; jao-doc-session.el ends here
diff --git a/lib/doc/jao-mac.el b/lib/doc/jao-mac.el
new file mode 100644
index 0000000..d2e5290
--- /dev/null
+++ b/lib/doc/jao-mac.el
@@ -0,0 +1,206 @@
+;;; jao-mac.el --- Running applescript. -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2025 Jose Antonio Ortega Ruiz
+
+;; Author: Jose Antonio Ortega Ruiz <mail@jao.io>
+;; Keywords: lisp
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+(require 'jao-shell)
+
+;;; applescript
+(defun jao-mac-applescript-prepare (&rest lines)
+ (let ((script (mapconcat 'identity lines "\r"))
+ (start))
+ (while (string-match "\n" script)
+ (setq script (replace-match "\r" t t script)))
+ (while (string-match "'" script start)
+ (setq start (+ 2 (match-beginning 0))
+ script (replace-match "\\'" t t script)))
+ script))
+
+(defun jao-mac-run-applescript (script)
+ (string-trim (shell-command-to-string (format "osascript -e '%s'" script))))
+
+(defun jao-mac-run-applescript* (&rest lines)
+ (jao-mac-run-applescript (apply #'jao-mac-applescript-prepare lines)))
+
+(defun jao-mac-tell-app (app &rest script-lines)
+ (let* ((app-id (string-split app))
+ (id (if (> (length app-id) 1) (car app-id) ""))
+ (app (if (> (length app-id) 1) (cadr app-id) (car app-id)))
+ (pre (list (format "tell application %s %S" id app)))
+ (post '("end tell\n")))
+ (apply #'jao-mac-run-applescript* (append pre script-lines post))))
+
+;;; open
+
+(defun jao-mac-open (thing &rest args)
+ "Invoke open after formatting thing with args, using `format'"
+ (jao-shell-exec (format "open %s" (apply #'format thing args))))
+
+(defun jao-mac-open-in-skim (&optional file page height)
+ (interactive)
+ (let* ((file (if file (expand-file-name file) (buffer-file-name)))
+ (page (or page (and (derived-mode-p 'doc-view-mode)
+ (doc-view-current-page)))))
+ (jao-mac-open "skim://%s%s" file (if page (format "#page=%s" page) ""))))
+
+;; https://alvinalexander.com/macos/applescript-how-to-open-pdf-file-in-preview-go-to-page/
+;; This will work as long as Preview is the default app for the file at hand.
+(defun jao-mac-open-in-preview (&optional file page height)
+ (interactive)
+ (let ((file (if file (expand-file-name file) (buffer-file-name)))
+ (page (or page (and (derived-mode-p 'doc-view-doc)
+ (doc-view-current-page)))))
+ (jao-mac-run-applescript*
+ (format "tell application id \"com.apple.Preview\" to open (POSIX file %S)\r\r"
+ (file-truename file))
+ "delay 1"
+ "tell application \"System Events\""
+ "keystroke \"g\" using {option down, command down}"
+ (format "keystroke %s" (or page 1))
+ "delay 0.1\rkeystroke return\rend tell")))
+
+;;; notifications
+
+(defun jao-mac-notify (title subtitle msg)
+ (jao-mac-run-applescript*
+ (format "display notification %S with title %S subtitle %S"
+ msg title subtitle)))
+
+;;; Skim
+(defvar jao-skim--current-file-script
+ (jao-mac-applescript-prepare
+ "tell application \"Skim\""
+ " try"
+ " set theD to front document"
+ " set theP to (path of theD)"
+ " set thePg to (get index of current page of theD)"
+ " return (theP & \"::\" & thePg)"
+ " on error"
+ " return \"\""
+ " end try"
+ "end tell"))
+
+(defun jao-skim-current-doc ()
+ "Returns a list of path and page number for the current Skim doc."
+ (when-let* ((p (jao-mac-run-applescript jao-skim--current-file-script)))
+ (let ((ps (split-string p "::")))
+ (list (car ps) (string-to-number (cadr ps))))))
+
+(defun jao-skim-open-current-doc ()
+ (interactive)
+ (when-let* ((ps (jao-skim-current-doc)))
+ (apply 'jao-open-doc ps)))
+
+;;; NetNewsWire
+
+(defvar jao-nnw--current-article-script
+ (jao-mac-applescript-prepare
+ "tell application \"NetNewsWire\""
+ "try"
+ "return (the url of the current article)"
+ "on error"
+ "return \"\""
+ "end try"
+ "end tell"))
+
+(defun jao-nnw-current-article ()
+ "The URL of the current article in NetNewsWire"
+ (jao-mac-run-applescript jao-nnw--current-article-script))
+
+(defun jao-nnw-browse-current-article ()
+ "Browse the URL of the current NNW article."
+ (interactive)
+ (if-let* ((url (jao-nnw-current-article)))
+ (unless (string-empty-p url)
+ (browse-url url))
+ (message "No article selected in NetNewsWire")))
+
+(defvar jao-nnw--label-cmd
+ "lsappinfo info -app NetNewsWire -only StatusLabel")
+
+(defun jao-nnw-unread-count ()
+ "A very hacky, yet efficient, way of getting NNW's badge."
+ (let ((s (shell-command-to-string jao-nnw--label-cmd)))
+ (when (string-match ".*=\"\\([0-9]+\\)\" ." s)
+ (string-to-number (match-string 1 s)))))
+
+(defun jao-mac-open-nnw ()
+ (interactive)
+ (jao-mac-open "-a NetNewsWire"))
+
+;;; Safari
+(defun jao-safari-current-url ()
+ (jao-mac-tell-app "Safari" "return URL of current tab of window 1"))
+
+(defun jao-safari-browse-current ()
+ "Browse the URL of the current Safari topmost document."
+ (interactive)
+ (browse-url (jao-safari-current-url)))
+
+;;; Firefox
+(defvar jao-ffox--current-url-script
+ (jao-mac-applescript-prepare
+ "tell application \"Firefox\""
+ " activate"
+ " delay 0.15"
+ " tell application \"System Events\""
+ " keystroke \"l\" using command down"
+ " delay 0.20"
+ " keystroke \"c\" using command down"
+ " end tell"
+ " delay 0.5"
+ "end tell"
+ "return the clipboard"))
+
+(defun jao-firefox-current-url ()
+ (let ((res (jao-mac-run-applescript jao-ffox--current-url-script)))
+ (jao-mac-run-applescript "tell application \"Emacs\" to activate")
+ res))
+
+(defun jao-firefox-open ()
+ (interactive)
+ (jao-mac-open "-a Firefox"))
+
+;;; DevonThink
+
+(defun jao-devon-tell (&rest script-lines)
+ (apply #'jao-mac-tell-app "id DNtp" script-lines ))
+
+(defun jao-devon-find-url (file)
+ (jao-devon-tell
+ "repeat with db in databases"
+ (format "set res to lookup records with path %S in db"
+ (file-truename file))
+ "if res /= {} then return the reference URL of (item 1 of res)"
+ "end repeat"
+ "return \"\""))
+
+(defun jao-devon-show-search (s)
+ (jao-devon-tell (format "show search %S" s) "activate"))
+
+(defun jao-devon-open (file &optional page height)
+ (let ((url (jao-devon-find-url file)))
+ (if (string-empty-p (or url ""))
+ (let ((jao-browse-doc-use-emacs-p t))
+ (jao-find-or-open file page height))
+ (let* ((p (if page (format "?page=%s" (- page 1)) ""))
+ (u (format "%s%s" url p)))
+ (jao-mac-open "%s%s" url p)))))
+
+(provide 'jao-mac)
+;;; jao-mac.el ends here
diff --git a/lib/doc/jao-org-focus.el b/lib/doc/jao-org-focus.el
new file mode 100644
index 0000000..13f1201
--- /dev/null
+++ b/lib/doc/jao-org-focus.el
@@ -0,0 +1,120 @@
+;;; jao-org-focus.el --- focusing on org subtrees -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2025 Jose Antonio Ortega Ruiz
+
+;; Author: Jose Antonio Ortega Ruiz <mail@jao.io>
+;; Keywords: docs
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Miscellanous utilities for working with org files
+
+(require 'org)
+
+;;; focus on subtree
+(defvar-local jao-org-focus--parent nil)
+(defvar-local jao-org-focus--section nil)
+
+(defun jao-org-focus ()
+ "Pop creatingly to an indirect buffer focused on the encloing subtree.
+
+When invoked on an indirect buffer, pops back to its base."
+ (interactive)
+ (if-let* ((b (get-buffer (or jao-org-focus--parent ""))))
+ (pop-to-buffer b)
+ (when-let* ((elem (org-element-at-point))
+ (header (if (eq 'headline (org-element-type elem))
+ elem
+ (org-previous-visible-heading 1)
+ (org-element-at-point)))
+ (title (org-element-property :title header))
+ (parent (buffer-name))
+ (bname (format "%s [%s]" title parent)))
+ (if-let* ((b (get-buffer bname)))
+ (pop-to-buffer b)
+ (clone-indirect-buffer bname t)
+ (org-focus-child-mode)
+ (setq jao-org-focus--parent parent
+ jao-org-focus--section title)
+ (org-narrow-to-subtree)
+ (show-subtree)))))
+
+(defun jao-org-focus-redisplay ()
+ "Redisplay a focused buffer.
+
+Useful when its parent has been reorganised and the narrowing is out of
+sync."
+ (interactive)
+ (when-let* ((title jao-org-focus--section))
+ (widen)
+ (goto-char (point-min))
+ (when (re-search-forward (format "\\*+ %s" title) nil t)
+ (org-narrow-to-subtree)
+ (goto-char (point-min)))))
+
+(defun jao-org-focus-redisplay-children ()
+ "Find focused children and redisplay them."
+ (interactive)
+ (dolist (b (jao-org-focus-list))
+ (with-current-buffer b (jao-org-focus-redisplay))))
+
+(defun jao-org-focus-list (&optional any-parent)
+ "List of buffers that are focusing on a subtree of this one or its parent."
+ (let ((n (or jao-org-focus--parent (buffer-name))))
+ (seq-filter (lambda (b)
+ (let ((p (buffer-local-value 'jao-org-focus--parent b)))
+ (and p (or any-parent (string= n p)))))
+ (buffer-list))))
+
+(defvar jao-org-focus--focused-history nil)
+
+(defun jao-org-focus-switch (arg)
+ "Read with completion a focused child and pop to it.
+
+With arg, offer to switch to all children, regardless of their parent."
+ (interactive "P")
+ (let ((fl (mapcar 'buffer-name (jao-org-focus-list arg))))
+ (unless fl (error "No focused children"))
+ (pop-to-buffer
+ (completing-read "Focused child: " fl
+ nil t nil 'jao-org-focus--focused-history))))
+
+(defvar jao-org-focus-consult-buffer-source
+ `(:name "Focus buffers"
+ :category jao-org-focus-buffers
+ :action switch-to-buffer
+ :hidden t
+ :narrow ,(cons ?o "focus")
+ :history jao-org-focus--focused-history
+ :items ,(lambda () (mapcar 'buffer-name (jao-org-focus-list t)))))
+
+(define-minor-mode org-focus-mode
+ "A mode where keeping track of focused children is on by default."
+ :lighter " ◎"
+ :keymap '(("\C-cl" . jao-org-focus-switch)
+ ("\C-cR" . jao-org-focus-redisplay)
+ ("\C-co" . jao-org-focus))
+ (if org-focus-mode
+ (add-hook 'after-save-hook #'jao-org-focus-redisplay-children nil t)
+ (remove-hook 'after-save-hook #'jao-org-focus-redisplay-children t)))
+
+(define-minor-mode org-focus-child-mode
+ "A mode for the children of a focused org buffer."
+ :lighter " ◉"
+ :keymap org-focus-mode-map)
+
+(provide 'jao-org-focus)
+;;; jao-org.el ends here
diff --git a/lib/doc/jao-org-links.el b/lib/doc/jao-org-links.el
index 88c0561..5f2304a 100644
--- a/lib/doc/jao-org-links.el
+++ b/lib/doc/jao-org-links.el
@@ -17,7 +17,7 @@
(funcall (or jao-org-open-pdf-fun #'jao-org--default-open) path page height))
(defun jao-org-links--open-pdf (link)
- "Open LINK in pdf-view-mode."
+ "Open LINK using `jaor-org-open-pdf-fn'."
(cond ((string-match "\\(.*\\)::\\([0-9]*\\)\\+\\+\\([[0-9]\\.*[0-9]*\\)" link)
(let* ((path (match-string 1 link))
(page (string-to-number (match-string 2 link)))
@@ -116,6 +116,10 @@
;;;###autoload
(defun jao-org-pdf-goto-org* () (interactive) (jao-org-pdf-goto-org t))
+(defun jao-org-org-to-pdf-file ()
+ (expand-file-name (concat "doc/" (file-name-base buffer-file-name) ".pdf")
+ (file-name-directory jao-org-notes-dir)))
+
;;;###autoload
(defun jao-org-goto-pdf ()
(interactive)
diff --git a/lib/doc/jao-org-notes.el b/lib/doc/jao-org-notes.el
index 43b8c09..bd45723 100644
--- a/lib/doc/jao-org-notes.el
+++ b/lib/doc/jao-org-notes.el
@@ -1,6 +1,6 @@
;;; jao-org-notes.el --- A simple system for org note taking -*- lexical-binding: t; -*-
-;; Copyright (C) 2020, 2021, 2022, 2024 jao
+;; Copyright (C) 2020, 2021, 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: tools
@@ -57,7 +57,11 @@
(string-to-number (cadr m))))
(defun jao-org-notes--matches (lines)
- (mapcar (lambda (l) (jao-org-notes--clean-match (split-string l "\0" t))) lines))
+ (seq-keep (lambda (l)
+ (let ((m (split-string (or l "") "\0" t)))
+ (when (and (car m) (cadr m))
+ (jao-org-notes--clean-match m))))
+ lines))
(defun jao-org-notes--grep-rx (rx &rest rg-args)
(let ((default-directory jao-org-notes-dir))
@@ -74,11 +78,12 @@
(defun jao-org-notes--consult-rg (prompt &optional cat no-req cmd initial)
(let ((default-directory (expand-file-name (or cat "") jao-org-notes-dir)))
(consult--read
- (consult--async-command #'jao-org-notes--rg-title-or-tags
- (consult--async-transform jao-org-notes--matches))
+ (consult--async-pipeline
+ (consult--process-collection #'jao-org-notes--rg-title-or-tags)
+ (consult--async-transform #'jao-org-notes--matches))
:prompt prompt
- :initial (consult--async-split-initial (or initial ""))
- :add-history (concat (consult--async-split-initial (thing-at-point 'symbol)))
+ :initial (or initial "")
+ :add-history (thing-at-point 'symbol)
:require-match (not no-req)
:category 'jao-org-notes-lookup
:group 'jao-org-notes--consult-group
@@ -211,7 +216,8 @@
(defun jao-org-notes-setup (mnemonic)
"Set up the notes system, providing a mnemonic character for its org template."
(setq org-capture-templates
- (add-to-list 'org-capture-templates (jao-org-notes--template mnemonic))
+ (add-to-list 'org-capture-templates
+ (jao-org-notes--template mnemonic))
jao-org-notes--tags (jao-org-notes-all-tags))
(when (fboundp 'org-capture-upgrade-templates)
(org-capture-upgrade-templates org-capture-templates)))
diff --git a/lib/doc/jao-pdf.el b/lib/doc/jao-pdf.el
index 1ee74bc..079beff 100644
--- a/lib/doc/jao-pdf.el
+++ b/lib/doc/jao-pdf.el
@@ -1,6 +1,6 @@
;;; jao-pdf.el --- utilities for pdf files -*- lexical-binding: t; -*-
-;; Copyright (C) 2022 jao
+;; Copyright (C) 2022, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: docs
@@ -96,5 +96,71 @@
(defun jao-pdf-zathura-org-link (title)
(jao-pdf--zathura-link (jao-pdf-zathura-file-info title)))
+(defun jao-zathura-open (file page)
+ (let ((id (jao-x11-search-window (jao-pdf-zathura-title-rx file))))
+ (if (string-blank-p id)
+ (progn
+ (when jao-xmonad-enabled (jao-x11-goto-ws 2))
+ (jao-shell-exec (jao-pdf-zathura-open-cmd file page)))
+ (let* ((page (if page (format " && xdotool type %dg" page) ""))
+ (cmd (format "xdotool windowactivate %s%s" id page)))
+ (jao-shell-exec cmd t)))))
+
+;;; Mac
+
+(jao-when-darwin (require 'jao-mac))
+
+;;; Open doc functions
+
+(defun jao-find-or-open (file &optional page height)
+ (cond ((and jao-browse-doc-use-emacs-p window-system)
+ (let* ((buffs (buffer-list))
+ (b (catch 'done
+ (while buffs
+ (when (string-equal (buffer-file-name (car buffs)) file)
+ (throw 'done (car buffs)))
+ (setq buffs (cdr buffs))))))
+ (jao-afio-goto-docs)
+ (if b (pop-to-buffer b) (find-file file))
+ (when page (jao-doc-view-goto-page page height))))
+ (jao-river-enabled (jao-river-open-with-zathura file page))
+ (jao-sway-enabled (jao-sway-open-with-zathura file page))
+ (t (jao-zathura-open file page))))
+
+(defun jao-open-doc (&optional file page height)
+ (interactive)
+ (when-let (file (or file
+ (read-file-name "Document: "
+ (concat jao-org-dir "/doc/"))))
+ (funcall jao-open-doc-fun file page height)))
+
+(defun jao-select-pdf ()
+ (interactive)
+ (jao-buffer-same-mode '(pdf-view-mode doc-view-mode org-mode)
+ #'jao-afio-goto-docs))
+
+(defun jao-open-with-zathura ()
+ (interactive)
+ (when-let (f buffer-file-name)
+ (let ((p (jao-doc-view-current-page)))
+ (cond (jao-river-enabled (jao-river-open-with-zathura f p))
+ (jao-sway-enabled (jao-sway-open-with-zathura f p))
+ (t (jao-zathura-open f p))))))
+
+;;; doc:// links for browse-url
+
+(defun jao-open-doc-url (url &rest _)
+ (when (string-match "doc://\\([^?]+\\)\\(\\?.*\\)?" url)
+ (let ((file (match-string 1 url))
+ (page (when-let* ((qs (match-string 2 url))
+ (long (> (length qs) 1))
+ (ps (url-parse-query-string (substring qs 1)))
+ (pn (cadr (assoc "page" ps))))
+ (string-to-number pn))))
+ (jao-open-doc (expand-file-name (concat "doc/" file) jao-org-dir) page))))
+
+(add-to-list 'browse-url-handlers (cons "^doc://.+" 'jao-open-doc-url))
+
+
(provide 'jao-pdf)
;;; jao-pdf.el ends here
diff --git a/lib/eos/jao-afio.el b/lib/eos/jao-afio.el
index b588989..162a1b7 100644
--- a/lib/eos/jao-afio.el
+++ b/lib/eos/jao-afio.el
@@ -1,6 +1,6 @@
;;; jao-afio.el --- workspaces in just one frame -*- lexical-binding: t; -*-
-;; Copyright (C) 2020, 2021, 2022, 2024 jao
+;; Copyright (C) 2020, 2021, 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: frames
@@ -41,7 +41,7 @@
(interactive)
(jao-afio--current-config ?c)
(if jao-afio-use-frames
- (set-frame-name "W1")
+ (set-frame-name (jao-afio-frame-name ?c))
(window-configuration-to-register ?c)))
(defun jao-afio--check-frame ()
@@ -71,12 +71,11 @@
;;;###autoload
(defun jao-afio-open-pdf-session (&optional docs)
(interactive)
- (let ((jao-doc-session-inhibit-save t))
- (dolist (doc (or docs (jao-doc-session)))
- (when (and doc (file-exists-p doc))
- (if (jao-pdf-is-pdf-file doc) (jao-open-doc doc) (find-file doc))
- (other-window 1)))
- (other-window 1)))
+ (dolist (doc (or docs (jao-doc-session)))
+ (when (and doc (file-exists-p doc))
+ (if (jao-pdf-is-pdf-file doc) (jao-open-doc doc) (find-file doc))
+ (other-window 1)))
+ (other-window 1))
(defun jao-afio-open-doc ()
(interactive)
@@ -122,10 +121,10 @@
;;;###autoload
(defun jao-afio-open-gnus ()
(interactive)
- (delete-other-windows)
(jao-org-agenda)
(calendar)
(find-file (expand-file-name "inbox.org" org-directory))
+ (delete-other-windows)
(gnus)
(jao-gnus--set-summary-line))
@@ -196,7 +195,7 @@
(select-frame-set-input-focus (or f (make-frame)))
(when (setq reset (or reset (not f)))
(set-frame-name
- (format "W%s" (or (jao-afio-frame-no next) next)))))
+ (format "%s" (or (jao-afio-frame-name next) next)))))
(window-configuration-to-register (jao-afio--current-config))
(when (and (not reset) (get-register next))
(ignore-errors (jump-to-register next)))
@@ -228,7 +227,7 @@
(defun jao-afio-goto-scratch (&optional one-win)
(interactive "P")
- (jao-afio--goto-frame ?s nil)
+ (jao-afio--goto-frame ?s one-win)
(when one-win (delete-other-windows)))
(defun jao-afio-goto-chats (&optional reset)
diff --git a/lib/eos/jao-dirmon.el b/lib/eos/jao-dirmon.el
index 0edb3a3..6a897d3 100644
--- a/lib/eos/jao-dirmon.el
+++ b/lib/eos/jao-dirmon.el
@@ -1,6 +1,6 @@
;;; jao-dirmon.el --- little utility to monitor disk usage -*- lexical-binding: t; -*-
-;; Copyright (C) 2022, 2024 jao
+;; Copyright (C) 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: tools
@@ -30,8 +30,13 @@
(define-multisession-variable jao-dirmon-last '())
+(defvar jao-dirmon-roots '("/var/local" "~"))
+
(defun jao-dirmon-dirs ()
- (jao-shell-cmd-lines "find ~ -mindepth 2 -maxdepth 3 -type d"))
+ (mapcan (lambda (d)
+ (jao-shell-cmd-lines
+ (format "find %s -mindepth 2 -maxdepth 3 -type d" d)))
+ jao-dirmon-roots))
(defun jao-dirmon-sizes ()
(mapcar (lambda (f)
@@ -71,7 +76,7 @@
(dolist (c current)
(let ((d (- (cdr c) (alist-get (car c) old 0 nil #'string=))))
(when (> (abs d) jao-dirmon-threshold)
- (push c high))))
+ (push (cons (car c) d) high))))
(setq jao-dirmon-last-delta high)
(jao-dirmon--show-deltas old current jao-dirmon-last-delta)
jao-dirmon-last-delta))
diff --git a/lib/eos/jao-minibuffer.el b/lib/eos/jao-minibuffer.el
index 42cef74..629ce8d 100644
--- a/lib/eos/jao-minibuffer.el
+++ b/lib/eos/jao-minibuffer.el
@@ -1,6 +1,6 @@
;;; jao-minibuffer.el --- using the minibuffer to report status -*- lexical-binding: t; -*-
-;; Copyright (C) 2020, 2021, 2022, 2024 jao
+;; Copyright (C) 2020, 2021, 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: extensions
@@ -34,25 +34,27 @@
(defvar jao-minibuffer-active-buffer-line-color "azure4")
(defvar jao-minibuffer-inactive-buffer-line-color "grey25")
(defvar jao-minibuffer-inhibit nil)
+(defvar jao-minibuffer-info-face 'default)
+(defvar jao-minibuffer-info-face-alt 'default)
(defconst jao-minibuffer--name " *Minibuf-0*")
(defun jao-minibuffer--trim (s w)
(if (< (string-width (or s "")) w)
(format (format "%%%ds" (if jao-minibuffer-align-right w (- w))) s)
- (substring s 0 (min w (length s)))))
+ (substring s 0 (min w (string-width s)))))
(defun jao-minibuffer--width ()
(cond ((numberp jao-minibuffer-frame-width) jao-minibuffer-frame-width)
(jao-minibuffer-maximized-frames-p (frame-width))
(t (min (frame-width) (window-width (minibuffer-window))))))
-(defun jao-minibuffer--format-info (&optional info)
- (let* ((info (or info jao-minibuffer-info))
- (info (if jao-minibuffer-align-right info (reverse info))))
- (mapconcat #'string-trim
- (seq-remove #'string-blank-p (mapcar 'format-mode-line info))
- " ")))
+(defun jao-minibuffer--format-info (&optional info alt-p)
+ (let* ((face (if alt-p jao-minibuffer-info-face-alt jao-minibuffer-info-face))
+ (info (or info jao-minibuffer-info))
+ (info (if jao-minibuffer-align-right info (reverse info)))
+ (info (seq-remove #'string-blank-p (mapcar 'format-mode-line info))))
+ (propertize (mapconcat #'string-trim info " ") 'face face)))
(defun jao-minibuffer--aligned (w)
(let* ((msg (jao-minibuffer--format-info))
@@ -79,7 +81,8 @@
(defun jao-minibuffer--format-msg (msg)
(let* ((msgs (mapcar #'jao-minibuffer--strip-prev (split-string msg "\n" t)))
- (msgs (cl-remove-if (lambda (s) (get-text-property 0 'invisible s)) msgs))
+ (msgs
+ (seq-remove (lambda (s) (get-text-property 0 'invisible s)) msgs))
(prefix (jao-minibuffer--prefix msgs))
(msg (or (car (last msgs)) ""))
(w (string-width msg)))
@@ -91,14 +94,11 @@
(when jao-minibuffer-mode
(or (and (string= jao-minibuffer--name (or (buffer-name) "")) msg)
jao-minibuffer-inhibit
- (let* ((info (and jao-minibuffer-msg-info
- (jao-minibuffer--format-info jao-minibuffer-msg-info)))
- (info (or (and info msg (propertize info 'face 'jao-themes-dimm))
- info))
- (sep (if msg " - " ""))
- (pref (when info
- (let ((len (+ (length info) (length sep))))
- (format (format "\n%%%ds" len) ""))))
+ (and (not jao-minibuffer-msg-info) msg)
+ (let* ((info (jao-minibuffer--format-info jao-minibuffer-msg-info t))
+ (sep (if (string-blank-p (or msg "")) "" " - "))
+ (pref (let ((len (+ (string-width info) (string-width sep))))
+ (format (format "\n%%%ds" len) "")))
(msg (if (and msg pref)
(replace-regexp-in-string "\n" pref msg)
msg))
@@ -141,10 +141,10 @@
:global t :lighter "" :group 'jao
(if jao-minibuffer-mode
(progn ;; (advice-add 'select-window :after #'jao-minibuffer-refresh)
- (advice-add 'select-window :after #'jao-minibuffer--adjust-alignment)
- (advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh)
- (setq clear-message-function #'jao-minibuffer--clear-message)
- (jao-minibuffer-refresh))
+ (advice-add 'select-window :after #'jao-minibuffer--adjust-alignment)
+ (advice-add 'force-mode-line-update :after #'jao-minibuffer-refresh)
+ (setq clear-message-function #'jao-minibuffer--clear-message)
+ (jao-minibuffer-refresh))
(advice-remove 'select-window #'jao-minibuffer-refresh)
(advice-remove 'force-mode-line-update #'jao-minibuffer-refresh)
(setq clear-message-function nil)
@@ -164,5 +164,24 @@
(not jao-minibuffer-adaptive-alignment))
(jao-minibuffer-refresh))
+(define-minor-mode jao-minibuffer-mode-line-mode
+ "Show info in mode line instead of minibuffer"
+ :global t :lighter "" :group 'jao
+ (let ((e '(" " (:eval jao-minibuffer-info))))
+ (if jao-minibuffer-mode-line-mode
+ (add-to-list 'global-mode-string e)
+ (setq global-mode-string (delete e global-mode-string)))))
+
+(defvar jao-minibuffer--title-format nil)
+
+(define-minor-mode jao-minibuffer-frame-title-mode
+ "Show info in frame title instead of minibuffer"
+ :global t :lighter "" :group 'jao
+ (when (not jao-minibuffer--title-format)
+ (setq jao-minibuffer--title-format frame-title-format))
+ (if jao-minibuffer-frame-title-mode
+ (setq frame-title-format '("emacs - " (:eval jao-minibuffer-info)))
+ (setq frame-title-format jao-minibuffer--title-format)))
+
(provide 'jao-minibuffer)
;;; jao-minibuffer.el ends here
diff --git a/lib/eos/jao-mode-line.el b/lib/eos/jao-mode-line.el
index e4f64c0..d3388e4 100644
--- a/lib/eos/jao-mode-line.el
+++ b/lib/eos/jao-mode-line.el
@@ -1,6 +1,6 @@
;;; jao-mode-line.el --- mode-line info -*- lexical-binding: t; -*-
-;; Copyright (C) 2022 jao
+;; Copyright (C) 2022, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: convenience
@@ -31,7 +31,7 @@
;;;; mode line toggle
(defun jao-mode-line--face-height (face &optional all)
(let* ((h (face-attribute face :height (window-frame)))
- (nh (if (eq 'unspecified h) 1 'unspecified)))
+ (nh (if (eq 'unspecified h) 10 'unspecified)))
(set-face-attribute face (when (not all) (window-frame)) :height nh)))
(defun jao-mode-line--set-inactive-face (x frame)
@@ -41,7 +41,7 @@
;;;###autoload
(defun jao-mode-line-toggle (&optional all)
(interactive "P")
- (jao-mode-line--face-height 'mode-line all))
+ (jao-mode-line--face-height 'mode-line-active all))
;;;###autoload
(defun jao-mode-line-toggle-inactive (&optional all)
@@ -62,7 +62,7 @@
;;;###autoload
(defun jao-mode-line-hide-inactive (frame)
- (jao-mode-line--set-inactive-face 1 frame))
+ (jao-mode-line--set-inactive-face 10 frame))
;;;###autoload
(defun jao-mode-line-show-inactive (frame)
@@ -85,8 +85,6 @@
'gnus-article-mode
'gnus-summary-mode)
mode-line-buffer-identification)
- ;; ((derived-mode-p 'circe-channel-mode)
- ;; (format "%s [%d]" (buffer-name) (length (circe-channel-nicks))))
((not (null eww-data))
(or (plist-get eww-data :title) "No title"))
(t "%b"))))
@@ -108,7 +106,7 @@
;;;; mode line in minibuffer
-(defvar jao-mode-line--old-format nil)
+(defvar jao-mode-line--old-format mode-line-format)
(defvar jao-mode-line--face nil)
(defvar jao-mode-line--inactive-face nil)
(defvar jao-mode-line--props
@@ -127,15 +125,18 @@
(if inactive jao-mode-line--inactive-face jao-mode-line--face)))
(defun jao-mode-line-adjust-faces ()
- (let ((bg (and (display-graphic-p) (frame-parameter nil 'background-color)))
+ (interactive)
+ (let ((bg (and (display-graphic-p)
+ (frame-parameter nil 'background-color)))
(ol (and (display-graphic-p) jao-minibuffer-active-buffer-line-color))
- (ul (and (display-graphic-p) jao-minibuffer-inactive-buffer-line-color)))
+ (ul (and (display-graphic-p)
+ jao-minibuffer-inactive-buffer-line-color)))
(jao-mode-line--extract-face nil)
(jao-mode-line--extract-face t)
- (set-face-attribute 'mode-line nil :box nil :height 1
+ (set-face-attribute 'mode-line-active nil :box nil :height 10
:background bg :foreground bg
:overline ol :underline ul :extend t)
- (set-face-attribute 'mode-line-inactive nil :box nil :height 1
+ (set-face-attribute 'mode-line-inactive nil :box nil :height 10
:background bg :foreground bg
;; :overline bg
:underline ul :extend t)))
diff --git a/lib/eos/jao-notify.el b/lib/eos/jao-notify.el
index 623b8cc..8389b3a 100644
--- a/lib/eos/jao-notify.el
+++ b/lib/eos/jao-notify.el
@@ -1,6 +1,6 @@
;; jao-notify.el -- Interacting with notification daemon
-;; Copyright (c) 2017, 2019, 2020, 2021, 2024 Jose Antonio Ortega Ruiz
+;; Copyright (c) 2017, 2019, 2020, 2021, 2024, 2025 Jose Antonio Ortega Ruiz
;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
;; Start date: Sun Jan 08, 2017 20:24
@@ -17,21 +17,30 @@
(defvar jao-notify-audio-icon (jao-data-file "music-player-icon.png"))
(declare-function notifications-notify "notifications")
+(declare-function alert "alert")
+(declare-function jao-mac-notify "jao-mac")
;; "/usr/share/icons/Papirus/64x64/mimetypes/audio-x-generic.svg"
;; "/usr/share/icons/Tango/scalable/mimetypes/audio-x-generic.svg"
-(defun jao-notify (msg &optional title icon)
+(defun jao-notify (msg &optional title icon subtitle)
(let ((title (when (and title (not (string-blank-p title))) title)))
- (if jao-notify-use-messages
- (message "%s%s%s" (or title "") (if title ": " "") (or msg ""))
- (let* ((args `(:timeout ,jao-notify-timeout))
- (args (append args
- (if title `(:title ,title :body ,msg) `(:title ,msg))))
- (args (if (and (stringp icon) (file-exists-p icon))
- (append args `(:app-icon ,(format "%s" icon)))
- args)))
- (apply 'notifications-notify args)))))
+ (cond ((eq jao-notify-use-messages t)
+ (message "%s%s%s" (or title "") (if title ": " "") (or msg "")))
+ ((eq jao-notify-use-messages 'notification)
+ (let* ((args `(:timeout ,jao-notify-timeout))
+ (args (append args
+ (if title
+ `(:title ,title :body ,msg)
+ `(:title ,msg))))
+ (args (if (and (stringp icon) (file-exists-p icon))
+ (append args `(:app-icon ,(format "%s" icon)))
+ args)))
+ (apply 'notifications-notify args)))
+ ((eq jao-notify-use-messages 'alert)
+ (alert msg :title title :icon icon :never-persist t))
+ ((eq jao-notify-use-messages 'mac)
+ (jao-mac-notify title subtitle msg)))))
(provide 'jao-notify)
diff --git a/lib/eos/jao-r2e.el b/lib/eos/jao-r2e.el
new file mode 100644
index 0000000..09b4504
--- /dev/null
+++ b/lib/eos/jao-r2e.el
@@ -0,0 +1,228 @@
+;;; jao-r2e.el --- List of rss2email subscriptions -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2025 Jose Antonio Ortega Ruiz
+
+;; Author: Jose Antonio Ortega Ruiz <mail@jao.io>
+;; Keywords: news
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+(require 'jao-url)
+
+(autoload 'View-quit "view")
+(autoload 'eww-view-source "eww")
+(autoload 'jao-notmuch-subtags "jao-notmuch")
+
+(defvar jao-r2e-confirm-toggle nil)
+
+(defconst jao-r2e--buffer "*r2e*")
+(defun jao-r2e--buffer ()
+ (with-current-buffer (get-buffer-create jao-r2e--buffer)
+ (unless (derived-mode-p 'jao-r2e-mode)
+ (jao-r2e-mode))
+ (current-buffer)))
+
+(defvar jao-r2e-mode-map
+ (let ((map (make-keymap)))
+ (suppress-keymap map)
+ (define-key map [?q] 'bury-buffer)
+ (define-key map [?n] 'next-line)
+ (define-key map [?p] 'previous-line)
+ (define-key map [?N] 'jao-r2e-next)
+ (define-key map [?P] 'jao-r2e-prev)
+ (define-key map [?g] 'jao-r2e-list)
+ (define-key map [?s] 'jao-r2e-subscribe)
+ (define-key map [?t] 'jao-r2e-toggle)
+ (define-key map [?D] 'jao-r2e-delete)
+ (define-key map [?u] 'jao-r2e-recover)
+ (define-key map [?y] 'jao-r2e-kill-url)
+ (define-key map [?x] 'jao-r2e-list-subscribed)
+ map))
+
+;;;###autoload
+(defun jao-r2e-mode ()
+ "A very simple mode to show the output of r2e commands."
+ (interactive)
+ (kill-all-local-variables)
+ (buffer-disable-undo)
+ (use-local-map jao-r2e-mode-map)
+ ;; (setq-local font-lock-defaults '(jao-r2e-font-lock-keywords))
+ (setq-local truncate-lines t)
+ (setq-local next-line-add-newlines nil)
+ (setq major-mode 'jao-r2e-mode)
+ (setq mode-name "r2e")
+ (read-only-mode 1))
+
+(defun jao-r2e--do (things &optional buffer)
+ "Execute a r2e command THINGS in the given BUFFER."
+ (let ((b (or buffer (pop-to-buffer (jao-r2e--buffer)))))
+ (let ((inhibit-read-only t)
+ (cmd (format "r2e %s" things)))
+ (unless buffer
+ (with-current-buffer b (delete-region (point-min) (point-max))))
+ (with-temp-message (format "Running: %s ...." cmd)
+ (shell-command cmd b))
+ (unless buffer (read-only-mode 1)))))
+
+(defconst jao-r2e--feed-rx
+ "^\\([0-9]+\\): \\[\\( \\|\\*\\)\\] \\([^ ]+\\) (\\(.+\\) -> \\(.+\\))")
+
+(defun jao-r2e--feed-at-point ()
+ (beginning-of-line)
+ (when-let* ((m (looking-at jao-r2e--feed-rx)))
+ (list (match-string 1)
+ (match-string 3)
+ (string= "*" (match-string 2))
+ (match-string 4)
+ (match-string 5))))
+
+(defun jao-r2e ()
+ (interactive)
+ (pop-to-buffer (jao-r2e--buffer))
+ (when (looking-at-p "^$")
+ (jao-r2e-list)))
+
+(defun jao-r2e-list ()
+ (interactive)
+ (jao-r2e--do "list"))
+
+(defun jao-r2e-list-subscribed (arg)
+ "Show only subscribed (unsubscribed with arg) feeds."
+ (interactive "P")
+ (jao-r2e-list)
+ (let ((inhibit-read-only t))
+ (flush-lines (if arg ".*\\[\\*\\].*" ".*\\[ \\].*"))))
+
+(defun jao-r2e--srx (opp)
+ (when-let* ((f (jao-r2e--feed-at-point)))
+ (let ((a (if opp (not (caddr f)) (caddr f))))
+ (format "^[0-9]+: \\[%s\\] " (if a "\\*" " ")))))
+
+(defun jao-r2e-next (opp)
+ "Next feed with the same (or opposite) status."
+ (interactive "P")
+ (when-let* ((rx (jao-r2e--srx opp)))
+ (next-line)
+ (when (re-search-forward rx nil t)
+ (beginning-of-line))))
+
+(defun jao-r2e-prev (opp)
+ "Previous feed with the same (or opposite) status."
+ (interactive "P")
+ (when-let* ((rx (jao-r2e--srx opp)))
+ (when (re-search-backward rx nil t)
+ (beginning-of-line))))
+
+(defun jao-r2e-kill-url ()
+ "Copy as kill the URL of the feed at point."
+ (interactive)
+ (let ((url (cadddr (jao-r2e--feed-at-point))))
+ (if (not url)
+ (error "No feed at point")
+ (kill-new url)
+ (message "%s" url))))
+
+(defun jao-r2e-toggle ()
+ (interactive)
+ (let ((f (jao-r2e--feed-at-point)))
+ (unless f (error "No feed at point"))
+ (let ((p (point))
+ (no (car f))
+ (name (cadr f))
+ (act (if (caddr f) "pause" "unpause")))
+ (when (or (not jao-r2e-confirm-toggle)
+ (yes-or-no-p (format "%s '%s'? " act name)))
+ (with-temp-buffer
+ (jao-r2e--do (format "%s %s" act no) (current-buffer)))
+ (jao-r2e-list)
+ (goto-char p)))))
+
+(define-multisession-variable jao-r2e-deleted-feeds '()
+ "List of rss2email feeds deleted at some point.")
+
+(defun jao-r2e--deleted () (multisession-value jao-r2e-deleted-feeds))
+
+(defun jao-r2e-delete ()
+ "Delete feed at point. Use `jao-r2e-recover' to undelete."
+ (interactive)
+ (let ((f (jao-r2e--feed-at-point)))
+ (unless f (error "No feed at point"))
+ (let ((p (point))
+ (no (car f))
+ (entry (cdr f)))
+ (when (yes-or-no-p (format "Delete feed '%s'" (car entry)))
+ (setf (multisession-value jao-r2e-deleted-feeds)
+ (cons entry (remove entry (jao-r2e--deleted))))
+ (with-temp-buffer
+ (jao-r2e--do (format "delete %s" no) (current-buffer)))
+ (jao-r2e-list)
+ (goto-char p)))))
+
+(defun jao-r2e-recover ()
+ (interactive)
+ (when (seq-empty-p (jao-r2e--deleted))
+ (error "No feeds recoverable at this point."))
+ (let* ((entries (jao-r2e--deleted))
+ (feed (completing-read "Recover feed: " entries)))
+ (when-let* ((ps (assoc feed entries))
+ (url (caddr ps))
+ (mail (car (last ps)))
+ (cat (when (string-match "feeds\\.\\(.+\\)@localhost" mail)
+ (match-string 1 mail))))
+ (jao-r2e-subscribe (list url feed) cat t)
+ (setf (multisession-value jao-r2e-deleted-feeds) (remove ps entries)))))
+
+(defun jao-r2e--find-url ()
+ (save-excursion
+ (when (derived-mode-p 'w3m-mode 'eww-mode)
+ (if (fboundp 'w3m-view-source) (w3m-view-source) (eww-view-source)))
+ (goto-char (point-min))
+ (when (re-search-forward
+ "type=\"application/\\(?:atom\\|rss\\)\\+xml\" +" nil t)
+ (let ((url (save-excursion
+ (when (re-search-forward
+ "href=\"\\([^\n\"]+\\)\"" nil t)
+ (match-string-no-properties 1))))
+ (title (when (re-search-forward
+ "\\(?:title=\"\\([^\n\"]+\\)\" +\\)" nil t)
+ (match-string-no-properties 1))))
+ (cond ((derived-mode-p 'w3m-view-mode) (w3m-view-source))
+ ((string-match-p ".*\\*eww-source\\b.*" (buffer-name))
+ (View-quit)))
+ (when url (cons url (or title "")))))))
+
+(defun jao-r2e-subscribe (url &optional cat relist)
+ "Subscribe to a given RSS URL. If URL not given, look for it."
+ (interactive (list (or (jao-url-around-point)
+ (jao-r2e--find-url)
+ (read-string "Feed URL: "))))
+ (let* ((url+title (ensure-list url))
+ (url (car url+title))
+ (title (cdr url+title)))
+ (unless url (error "No feeds found"))
+ (let ((url (if (string-match "^feed:" url) (substring url 5) url)))
+ (when (y-or-n-p (format "Subscribe to <%s>? " url))
+ (let* ((name (read-string "Feed name: " title))
+ (cats (cons "prog" (jao-notmuch-subtags "feeds")))
+ (cat (completing-read "Category: " cats nil t cat))
+ (subs (format "r2e add %s '%s' feeds.%s@localhost"
+ name url cat)))
+ (with-temp-message "Subscribing..."
+ (shell-command-to-string subs))
+ (with-temp-message "Retrieving feed..."
+ (shell-command (format "r2e run %s" name)))
+ (when relist (jao-r2e-list)))))))
+
+(provide 'jao-r2e)
+;;; jao-r2e.el ends here
diff --git a/lib/jao-recoll.el b/lib/jao-recoll.el
new file mode 100644
index 0000000..364dfb5
--- /dev/null
+++ b/lib/jao-recoll.el
@@ -0,0 +1,76 @@
+;;; jao-recoll.el --- Utilities to use recoll -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2025 Jose Antonio Ortega Ruiz
+
+;; Author: Jose Antonio Ortega Ruiz <mail@jao.io>
+;; Keywords: mail, text
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Notably, a half-backed backend for Gnus
+
+;;; Code:
+
+(require 'gnus-search)
+
+(defclass gnus-search-recoll (gnus-search-indexed)
+ ((separator :type string :initform ".")
+ (program :initform "recoll")
+ (raw-queries-p :initform t)))
+
+(cl-defmethod gnus-search-indexed-extract ((_engine gnus-search-recoll))
+ (prog1 (and (looking-at "^file://\\(.+\\)$") (list (match-string 1) 100))
+ (forward-line 1)))
+
+(cl-defmethod gnus-search-transform-expression ((_engine gnus-search-recoll)
+ expr)
+ expr)
+
+(cl-defmethod gnus-search-indexed-search-command ((engine gnus-search-recoll)
+ (qstring string)
+ query
+ &optional groups)
+ (let* ((subdir (slot-value engine 'remove-prefix))
+ (sep (slot-value engine 'separator))
+ (gdirs (mapcar (lambda (g)
+ (let ((g (gnus-group-short-name g)))
+ (replace-regexp-in-string "\\." sep g)))
+ (or groups
+ (and (not (string= "" subdir)) (list subdir)))))
+ (dirsq (and gdirs
+ (concat "("
+ (mapconcat (lambda (d) (format "dir:%s" d))
+ gdirs " OR ")
+ ")")))
+ (qstring (if (string-prefix-p "id:" qstring)
+ (replace-regexp-in-string "<\\|>" "\"" qstring)
+ qstring))
+ (qstring (if (cdr (assoc 'thread query))
+ (concat qstring " OR "
+ (replace-regexp-in-string "id:\"" "ref:\""
+ qstring))
+ qstring))
+ (qstring (replace-regexp-in-string " or " " OR " qstring))
+ (qstring (replace-regexp-in-string " and " " AND " qstring))
+ (q (format "mime:message %s (%s)" dirsq qstring)))
+ ;; (message "query is: %s -- %S" q query)
+ `("-b" "-t" "-q" ,q)))
+
+(defun jao-recoll-gnus-search-engine (dir)
+ `(nnml "" (gnus-search-engine gnus-search-recoll (remove-prefix ,dir))))
+
+(provide 'jao-recoll)
+;;; jao-recoll.el ends here
diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el
index 4f5081c..5228787 100644
--- a/lib/media/jao-mpc.el
+++ b/lib/media/jao-mpc.el
@@ -1,6 +1,6 @@
;;; jao-mpc.el --- Using mpc to interact with mpd -*- lexical-binding: t; -*-
-;; Copyright (C) 2021, 2022, 2024 jao
+;; Copyright (C) 2021, 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: convenience
@@ -30,6 +30,7 @@
(require 'jao-themes)
(require 'jao-lyrics)
(require 'jao-random-album)
+(require 'jao-notify)
(defconst jao-mpc--albums "*MPC Albums*")
(defconst jao-mpc--playlist "*MPC Playlist*")
@@ -46,11 +47,12 @@
(mapconcat (lambda (f) (format "%s:::%%%s%%" f f)) fields "\n"))
(defconst jao-mpc--fields
- '(artist album composer originaldate genre title track position time name))
+ '(artist album composer originaldate genre title track position time name
+ file))
(defconst jao-mpc--stfmt
(jao-mpc--fformat
- '(artist album composer originaldate genre title track name)))
+ '(artist album composer originaldate genre title track name file)))
(defconst jao-mpc--stfmtt
(jao-mpc--fformat '(currenttime totaltime percenttime songpos length)))
@@ -106,7 +108,8 @@
(jao--put-face (or artist "") 'jao-themes-f01)
(jao--put-face (if composer (format " [%s]" composer) "")
'jao-themes-f01)
- (jao--put-face (if album (format " (%s)" album) "") 'jao-themes-f11)
+ (jao--put-face (if album (format " (%s)" album) "")
+ 'jao-themes-f11)
(jao--put-face tims (if times 'jao-themes-f00 'jao-themes-dimm))))
""))
@@ -131,9 +134,11 @@
(make-process :name (format "jao-mpc-idleloop (%s)" port)
:buffer nil
:noquery t
- :command `("mpc" "-p" ,(format "%s" (or port jao-mpc-port))
- "idleloop" "player")
- :filter (lambda (_p _s) (jao-mpc--set-current-str port)))))
+ :command
+ `("mpc" "-p" ,(format "%s" (or port jao-mpc-port))
+ "idleloop" "player")
+ :filter (lambda (_p _s)
+ (jao-mpc--set-current-str port)))))
(defvar jao-mpc--browser-port nil)
@@ -157,7 +162,8 @@
(let ((a (or album (string-trim (thing-at-point 'line))))
(p (or port jao-mpc--browser-port)))
(jao-mpc--cmd "clear" p)
- (jao-mpc--cmd (if idp (concat "add " a) (format "findadd album \"%s\"" a)) p)
+ (jao-mpc--cmd (if idp (concat "add " a) (format "findadd album \"%s\"" a))
+ p)
(jao-mpc--cmd "play" p)))
(define-key jao-mpc-albums-mode-map (kbd "n") #'next-line)
@@ -190,7 +196,8 @@
(define-key jao-mpc-playlist-mode-map (kbd "n") #'next-line)
(define-key jao-mpc-playlist-mode-map (kbd "p") #'previous-line)
(define-key jao-mpc-playlist-mode-map (kbd "q") #'bury-buffer)
-(define-key jao-mpc-playlist-mode-map (kbd ".") #'jao-mpc--playlist-goto-current)
+(define-key jao-mpc-playlist-mode-map (kbd ".")
+ #'jao-mpc--playlist-goto-current)
(define-key jao-mpc-playlist-mode-map (kbd "RET") #'jao-mpc--playlist-play)
(define-key jao-mpc-playlist-mode-map (kbd "C") #'jao-mpc-clear)
@@ -252,6 +259,23 @@
(message "Playing time: %s" (jao-mpc--current-timestr t)))
;;;###autoload
+(defun jao-mpc-notify (&optional port)
+ (interactive)
+ (when-let* ((current (jao-mpc--current)))
+ (let* ((artist (or (alist-get 'artist current) "Anonymous"))
+ (title (or (alist-get 'title current)
+ (when-let* ((tl (alist-get 'file current)))
+ (file-name-base tl))
+ ""))
+ (album (or (alist-get 'album current) ""))
+ (track (or (alist-get 'track current) ""))
+ (times (jao-mpc--current-timestr t current)))
+ (jao-notify (format "%s -- %s" artist times)
+ (format "%s %s" track title)
+ jao-notify-audio-icon
+ album))))
+
+;;;###autoload
(defun jao-mpc-add-url (url)
(interactive "sURL: ")
(jao-mpc--cmd (format "add %s" url)))
diff --git a/lib/media/jao-mpris.el b/lib/media/jao-mpris.el
index 3bb2636..80d0675 100644
--- a/lib/media/jao-mpris.el
+++ b/lib/media/jao-mpris.el
@@ -1,6 +1,6 @@
;;; jao-mpris.el --- mpris players control -*- lexical-binding: t; -*-
-;; Copyright (C) 2020, 2021, 2022, 2024 jao
+;; Copyright (C) 2020, 2021, 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: multimedia
@@ -158,25 +158,25 @@
(defun jao-mpris--handler (iname properties &rest _args)
(let ((inhibit-message t))
- (message "Received properties: %S from %s" properties iname))
- (when-let (md (caadr (assoc "Metadata" properties)))
- (let ((tno (caadr (assoc "xesam:trackNumber" md)))
- (tlt (caadr (assoc "xesam:title" md)))
- (art (caadr (assoc "xesam:artist" md)))
- (alb (caadr (assoc "xesam:album" md)))
- (len (caadr (assoc "mpris:length" md))))
- (if (string= (or tlt "") "TIDAL")
- (jao-mpris-reset)
+ (message "Received properties: %S from %s" properties iname)
+ (when-let (md (caadr (assoc "Metadata" properties)))
+ (let ((tno (caadr (assoc "xesam:trackNumber" md)))
+ (tlt (caadr (assoc "xesam:title" md)))
+ (art (caadr (assoc "xesam:artist" md)))
+ (alb (caadr (assoc "xesam:album" md)))
+ (len (caadr (assoc "mpris:length" md))))
(jao-mpris--set-current 'track tno)
(jao-mpris--set-current 'title tlt)
(jao-mpris--set-current 'artist art)
(jao-mpris--set-current 'album alb)
- (jao-mpris--set-current 'length len))))
- (when-let (st (caadr (assoc "PlaybackStatus" properties)))
- (jao-mpris--set-current 'status st)
- (when (string= st "Stopped")
- (dolist (k '(track title artist album length))
- (jao-mpris--del-current k))))
+ (jao-mpris--set-current 'length len)))
+ (when-let (st (caadr (assoc "PlaybackStatus" properties)))
+ (jao-mpris--set-current 'status st)
+ (when (string= st "Stopped")
+ (dolist (k '(track title artist album length))
+ (jao-mpris--del-current k))))
+ ;; (message "Current is: %S" jao-mpris--current)
+ )
(jao-mpris--track jao-mpris--current))
;;;###autoload
diff --git a/lib/net/jao-eww-session.el b/lib/net/jao-eww-session.el
index 4ac5447..da5bc8b 100644
--- a/lib/net/jao-eww-session.el
+++ b/lib/net/jao-eww-session.el
@@ -1,6 +1,6 @@
;;; jao-eww-session.el --- Persistent eww sessions -*- lexical-binding: t; -*-
-;; Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2012, 2021, 2022 Jose A Ortega Ruiz
+;; Copyright (C) 2003-2004, 2006-2009, 2012, 2021-2022, 2025 Jose A Ortega Ruiz
;; Author: Jose A Ortega Ruiz <jao@gnu.org>
;; Version: 0.4
@@ -168,15 +168,14 @@ the session is already displayed in a eww tab, jao-eww-session can:
(defun jao-eww-session--to--file (filename &optional skip)
(require 'pp)
- (when (jao-eww-session-not-empty)
- (let ((inhibit-message t)
- (session (jao-eww-session--update-current skip)))
- (with-temp-buffer
- (insert ";;;; File generated by jao-eww-session. DO NOT EDIT!\n")
- (pp session (current-buffer))
- (insert "\n" ";;;; End of "
- (file-name-nondirectory jao-eww-session-file) "\n")
- (write-region (point-min) (point-max) (expand-file-name filename))))))
+ (let ((inhibit-message t)
+ (session (jao-eww-session--update-current skip)))
+ (with-temp-buffer
+ (insert ";;;; File generated by jao-eww-session. DO NOT EDIT!\n")
+ (pp session (current-buffer))
+ (insert "\n" ";;;; End of "
+ (file-name-nondirectory jao-eww-session-file) "\n")
+ (write-region (point-min) (point-max) (expand-file-name filename)))))
(defun jao-eww-session--backup-name (fname)
(concat (expand-file-name fname) ".bak"))
diff --git a/lib/net/jao-notmuch-gnus.el b/lib/net/jao-notmuch-gnus.el
index f5cc3b2..3abfaee 100644
--- a/lib/net/jao-notmuch-gnus.el
+++ b/lib/net/jao-notmuch-gnus.el
@@ -1,6 +1,6 @@
;;; jao-notmuch-gnus.el --- notmuch-gnus interoperability -*- lexical-binding: t; -*-
-;; Copyright (C) 2022, 2024 jao
+;; Copyright (C) 2022, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: mail
@@ -52,7 +52,7 @@
"Interactively add or remove tags to the current message."
(interactive)
(let* ((id (or id (jao-notmuch-gnus-message-id)))
- (current (unless tags (jao-notmuch-gnus-message-tags id)))
+ (current (or tags (jao-notmuch-gnus-message-tags id)))
(prompt (format "Change tags %s" (string-join current "/")))
(tags (or tags (notmuch-read-tag-changes current prompt))))
(notmuch-tag (concat "id:" id) tags)
@@ -65,6 +65,11 @@
(when-let (id (jao-notmuch-gnus-message-id))
(message "%s" (string-join (jao-notmuch-gnus-message-tags id) " "))))
+(jao-transient-major-mode+ gnus-summary
+ ["Tags"
+ ("s" "show message tags" jao-notmuch-gnus-show-tags)
+ ("t" "tag message" jao-notmuch-gnus-tag-message)])
+
(defun jao-notmuch-gnus-toggle-tags (tags &optional id current)
"Toggle the given TAGS list for the current Gnus message."
(let* ((id (or id (jao-notmuch-gnus-message-id)))
@@ -76,9 +81,9 @@
(message "New tags: %s" (jao-notmuch-gnus-message-tags id))))
(defun jao-notmuch-gnus-tag-mark ()
- "Remove the new tag for an article when it's marked as seen by Gnus."
+ "Remove the new and unread tags for an article when it's marked as seen by Gnus."
(when-let (id (jao-notmuch-gnus-message-id t))
- (jao-notmuch-gnus-tag-message id '("-new") t)))
+ (jao-notmuch-gnus-tag-message id '("-new" "-unread") t)))
(add-hook 'gnus-mark-article-hook #'jao-notmuch-gnus-tag-mark)
@@ -171,7 +176,7 @@ Example:
(msg-id (when msg-id (replace-regexp-in-string "^id:" "" msg-id))))
(if (and group msg-id)
(org-gnus-follow-link group msg-id)
- (message "Couldn't get relevant infos for switching to Gnus."))))
+ (message "Couldn't get relevant info for switching to Gnus."))))
(defun jao-notmuch-gnus-engine (prefix config)
(let ((prefix (file-name-as-directory (expand-file-name prefix "~")))
@@ -223,6 +228,19 @@ Example:
(consult-customize jao-gnus-consult-notmuch :preview-key 'any))
+;;; tags and flags
+
+(defun jao-notmuch-gnus-flag-current (&rest _)
+ (jao-notmuch-gnus-tag-message nil '("+flagged") t))
+
+(defun jao-notmuch-gnus-unflag-current (&rest _)
+ (jao-notmuch-gnus-tag-message nil '("-flagged") t))
+
+(advice-add 'gnus-summary-tick-article-forward
+ :before #'jao-notmuch-gnus-flag-current)
+(advice-add 'gnus-summary-mark-as-read-forward
+ :before #'jao-notmuch-gnus-unflag-current)
+
;;; .
(provide 'jao-notmuch-gnus)
;;; jao-notmuch-gnus.el ends here
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index aef9757..75ee027 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -1,6 +1,6 @@
;;; jao-notmuch.el --- Extensions for notmuch -*- lexical-binding: t; -*-
-;; Copyright (C) 2021, 2022, 2023, 2024 jao
+;; Copyright (C) 2021, 2022, 2023, 2024, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: mail
@@ -339,6 +339,12 @@
(let ((tags (plist-get (notmuch-tree-get-message-properties) :orig-tags)))
(jao-notmuch-tree--tag tags nil)))
+(defun jao-notmuch-subtags (tag &rest excl)
+ (let* ((cmd (concat "notmuch search --output=tags tag:" tag))
+ (ts (split-string (shell-command-to-string cmd))))
+ (seq-difference ts (append jao-notmuch--shared-tags (cons tag excl)))))
+
+
;;; fcc
(defvar jao-notmuch-mua-reply-not-inherited
'("attachment" "sent" "new" "bigml" "jao" "trove"))
diff --git a/lib/net/jao-url.el b/lib/net/jao-url.el
new file mode 100644
index 0000000..9e58f99
--- /dev/null
+++ b/lib/net/jao-url.el
@@ -0,0 +1,36 @@
+;;; jao-url.el --- URL handling -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2025 Jose Antonio Ortega Ruiz
+
+;; Author: Jose Antonio Ortega Ruiz <mail@jao.io>
+;; Keywords: hypermedia
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+(require 'shr)
+(require 'ffap)
+(require 'thingatpt)
+
+(defun jao-url-around-point (&optional current-url)
+ (or (and (fboundp 'w3m-anchor) (w3m-anchor))
+ (shr-url-at-point nil)
+ (ffap-url-at-point)
+ (thing-at-point 'url)
+ (when current-url
+ (or (and (fboundp 'w3m-anchor) (w3m-anchor))
+ (and (derived-mode-p 'eww-mode) (plist-get eww-data :url))))))
+
+
+(provide 'jao-url)
+;;; jao-url.el ends here
diff --git a/lib/net/randomsig.el b/lib/net/randomsig.el
index cb37694..05b95ab 100644
--- a/lib/net/randomsig.el
+++ b/lib/net/randomsig.el
@@ -1,6 +1,6 @@
;;; randomsig.el --- insert a randomly selected signature
-;; Copyright (C) 2001, 2002, 2013, 2020, 2021 Hans-Jrgen Ficker
+;; Copyright (C) 2001, 2002, 2013, 2020, 2021, 2024 Hans-Jrgen Ficker
;; Emacs Lisp Archive Entry
;; Author: Hans-Juergen Ficker <hj@backmes.de>
@@ -277,8 +277,11 @@ You probably want to have a newline at the end of it."
(defun randomsig-prompt (&optional prompt)
;; Prompt for a signature file.
(let ((files (randomsig-files-to-list randomsig-files)))
- (completing-read (if prompt prompt "signature: ")
- (mapcar 'list files) nil t nil randomsig-history (car files))))
+ (if (cdr files)
+ (completing-read (if prompt prompt "signature: ")
+ (mapcar 'list files) nil t nil
+ randomsig-history (car files))
+ (car files))))
(defun randomsig-read-signatures-to-buffer (buffer-name &optional files)
;; read the signatures into the signature buffer
diff --git a/lib/prog/jao-clojure.el b/lib/prog/jao-clojure.el
new file mode 100644
index 0000000..796c35d
--- /dev/null
+++ b/lib/prog/jao-clojure.el
@@ -0,0 +1,186 @@
+;;; jao-clojure.el --- Clojure utilities -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2025 Jose Antonio Ortega Ruiz
+
+;; Author: Jose Antonio Ortega Ruiz <mail@jao.io>
+;; Keywords: languages
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Helpers for clojure coding
+
+;;; Code:
+
+(require 'clojure-mode)
+(require 'project)
+(require 'cider-test)
+(require 'jao-skel)
+
+;;;; Jumping between implementation and test files
+(defun jao-clojure--ext-dir (prefix)
+ (let* ((ext (file-name-extension buffer-file-name))
+ (ext-rx (format "/%s/" ext)))
+ (if (string-match-p ext-rx buffer-file-name)
+ (format "%s/%s" prefix ext)
+ prefix)))
+
+(defun jao-clojure-find-current-test ()
+ (save-excursion
+ (and (re-search-backward
+ "(deftest\\(?:\\W+^:\\w+\\)*\\W+\\b\\(.+\\)\\b" nil t)
+ (match-string-no-properties 1))))
+
+(defvar jao-clojure--src-candidates '("lib" "src" "srv" "app"))
+
+(defun jao-clojure--test-namespace-p (ns)
+ (or (string-suffix-p "-test" ns)
+ (string-match "\\(.+\\)\\.\\(test\\)\\(\\..+\\)" ns)))
+
+(defun jao-clojure-test-buffer-p ()
+ (jao-clojure--test-namespace-p (clojure-find-ns)))
+
+(defun jao-clojure--test-for (namespace sep)
+ (replace-regexp-in-string "\\." sep (cider-test-default-test-ns-fn namespace)))
+
+(defun jao-clojure--infer-test-ns (ns)
+ (if (jao-clojure--test-namespace-p ns)
+ ns
+ (jao-clojure--test-for ns ".")))
+
+(defun jao-clojure--root () (project-root (project-current)))
+
+(defun jao-clojure-jump-to-test ()
+ "Jump from implementation to test file."
+ (interactive)
+ (let* ((f (format "%s/%s/%s.%s"
+ (jao-clojure--root)
+ "test"
+ (jao-clojure--test-for (clojure-find-ns) "/")
+ (file-name-extension buffer-file-name)))
+ (f (replace-regexp-in-string "-" "_" f)))
+ (find-file f)))
+
+(defun jao-clojure--implementation-for (namespace)
+ (thread-last (replace-regexp-in-string "-test$" "" namespace)
+ (replace-regexp-in-string "\\.test\\." ".")
+ (replace-regexp-in-string "-" "_")
+ (replace-regexp-in-string "\\." "/")
+ (substring-no-properties)))
+
+(defun jao-clojure--find-implementation (src)
+ (let ((f (format "%s%s/%s.%s"
+ (jao-clojure--root)
+ src
+ (jao-clojure--implementation-for (clojure-find-ns))
+ (file-name-extension buffer-file-name))))
+ (and (file-exists-p f) f)))
+
+(defun jao-clojure-jump-to-implementation ()
+ "Jump from test file to implementation."
+ (interactive)
+ (let ((impl (car (seq-keep #'jao-clojure--find-implementation
+ jao-clojure--src-candidates))))
+ (if impl (find-file impl) (message "No implementation file found"))))
+
+(defun jao-clojure-other-file ()
+ "Toggle between implementation and test file"
+ (interactive)
+ (if (jao-clojure-test-buffer-p)
+ (jao-clojure-jump-to-implementation)
+ (jao-clojure-jump-to-test)))
+
+(defun jao-clojure--setup-compilation (&optional ns)
+ ;; (set (make-local-variable 'compile-command) (jao-clojure--test-str ns))
+ )
+
+;;;; Skeletons
+(defconst jao-clojure--ns-destruct-rx
+ (format "\\(?:%s\\|tests?\\)\\.\\(?:clj[cs]?\\.\\)?\\(.+\\)"
+ (regexp-opt jao-clojure--src-candidates)))
+
+(defun jao-clojure-buffer-namespace ()
+ (let* ((ddir (jao-compilation-root))
+ (mbase (and ddir
+ (concat (replace-regexp-in-string "/" "." ddir) ".")))
+ (mbase (and mbase
+ (string-match jao-clojure--ns-destruct-rx mbase)
+ (match-string 1 mbase))))
+ (concat (or mbase "")
+ (replace-regexp-in-string "_" "-" (jao-skel-basename)))))
+
+(defvar jao-clojure--test-check-lines
+ (concat "[clojure.test.check :as tc]\n "
+ "[clojure.test.check.generators :as gen]\n "
+ "[clojure.test.check.properties :as prop :include-macros true]\n"))
+
+(defun jao-clojure--cljs-test-reqs (prefix-cmp last-cmp test-check)
+ (concat " (:require [cljs.test :as t :refer-macros [is deftest async]]"
+ "\n [" prefix-cmp "." last-cmp " :as " last-cmp "])"))
+
+(defun jao-clojure--clj-test-reqs (prefix-cmp last-cmp test-check)
+ (format "(:use clojure.test)\n (:require %s(%s [%s :as %s]))"
+ (if test-check
+ (concat "(clojure.test.check [clojure-test :refer [defspec]])\n"
+ jao-clojure--test-check-lines)
+ "")
+ prefix-cmp last-cmp last-cmp))
+
+(defun jao-clojure--cljc-test-reqs (prefix-cmp last-cmp test-check)
+ (concat "(:require #?(:clj [clojure.test :as t :refer [is deftest]]\n"
+ " :cljs [cljs.test :as t :refer-macros [is deftest]])\n"
+ (when test-check
+ (concat " [clojure.test.check-clojure-test #?@("
+ ":cljs [:refer-macros [defspec]]\n"
+ ":clj [:refer [defspec]))]\n"
+ jao-clojure--test-check-lines))
+ " [" prefix-cmp "." last-cmp " :as " last-cmp "])"))
+
+(defun jao-clojure--skel-ns-contents (ns)
+ (if (jao-clojure--test-namespace-p ns)
+ (let ((test-check (y-or-n-p "Include test.check requires? "))
+ (ns (concat (match-string 1 ns) (match-string 3 ns))))
+ (let* ((cmps (split-string ns "\\."))
+ (last-cmp (car (last cmps)))
+ (prefix-cmp (mapconcat 'identity (butlast cmps) "."))
+ (ext (file-name-extension buffer-file-name)))
+ (cond ((string= "cljs" ext)
+ (jao-clojure--cljs-test-reqs prefix-cmp last-cmp test-check))
+ ((string= "cljc" ext)
+ (jao-clojure--cljc-test-reqs prefix-cmp last-cmp test-check))
+ ((string= "clj" ext)
+ (jao-clojure--clj-test-reqs prefix-cmp last-cmp test-check)))))
+ (format "%S" (read-string "Brief module description: "))))
+
+(define-skeleton jao-clojure-skeleton
+ "Standard Clojure module file skeleton"
+ ""
+ (jao-skel-copyright-line ";; ")
+ \n
+ (jao-skel-author-line ";; Author: ")
+ (jao-skel-date-line ";; Start date: ")
+ \n '(setq v1 (jao-clojure-buffer-namespace))
+ _ "(ns " v1
+ '(jao-clojure--setup-compilation v1)
+ \n (jao-clojure--skel-ns-contents v1) ")"
+ \n
+ '(ignore-errors (indent-region (region-beginning) (region-end)))
+ > -)
+
+(jao-skel-install "\\.clj[sc]?$" 'jao-clojure-skeleton)
+
+
+(provide 'jao-clojure)
+;;; jao-clojure.el ends here
diff --git a/lib/prog/jao-compilation.el b/lib/prog/jao-compilation.el
index c099701..e15c1e1 100644
--- a/lib/prog/jao-compilation.el
+++ b/lib/prog/jao-compilation.el
@@ -1,6 +1,6 @@
;;; jao-compilation.el --- utilities to lauch compilations -*- lexical-binding: t; -*-
-;; Copyright (C) 2020, 2021, 2022 jao
+;; Copyright (C) 2020, 2021, 2022, 2025 jao
;; Author: jao <mail@jao.io>
;; Keywords: convenience
@@ -109,7 +109,7 @@
(defun jao-compilation-setup ()
(jao-compilation-add-dominating
"Makefile" "makefile" "configure.ac" "bootstrap.sh" "aclocal.m4"
- "project.clj" "build.xml" "pom.xml" "setup.py" "stack.yaml")
+ "deps.edn" "project.clj" "build.xml" "pom.xml" "setup.py" "stack.yaml")
(with-eval-after-load "project"
(add-to-list 'project-find-functions #'jao-find-compilation-root t)))
diff --git a/lib/themes/jao-light-theme.el b/lib/themes/jao-light-theme.el
index 659b6bb..8d0f8ba 100644
--- a/lib/themes/jao-light-theme.el
+++ b/lib/themes/jao-light-theme.el
@@ -18,7 +18,7 @@
(jao-define-custom-theme jao-light
(:names (bg-lightest "gray98")
- (bg-light "gray95")
+ (bg-light "#efefef")
(light-gray "gray80")
@@ -36,9 +36,6 @@
(green "#005555")
(lightgreen "darkgreen")
(yellow "lightyellow"))
- (:face-size 9)
- ;; (:face-family "DejaVu Sans Mono")
- (:face-family "Hack")
(:bold-weight 'semibold)
(:palette (fg "black")
(bg "white")
@@ -93,6 +90,7 @@
(gnus-cite-2 (c "slate gray" nil))
(gnus-cite-3 (c "slate gray" nil))
(gnus-cite-4 (c "slate gray" nil))
+ (gnus-face-4 (p f11) :family "Triplicate C4c")
(gnus-header-name (c fg-light))
(gnus-summary-selected (c green) nbf)
(gnus-summary-cancelled (c "sienna3" nil) st)
@@ -101,13 +99,21 @@
(magit-diff-context-highlight (c nil yellow) ex)
(magit-diff-hunk-heading-highlight (c nil hl) it bf)
(message-header-subject (p warning) nbf)
- (mode-line (c "grey20") :box (:line-width 1 :color "grey80"))
+ (mode-line
+ (c "seashell3" nil)
+ :box (:line-width 1 :color "#dfdfdf" :style flat-button))
+ (mode-line-active
+ (c "#3f3f3f" "gray96")
+ :box (:line-width 1 :color "#dfdfdf" :style flat-button))
(mode-line-inactive
- (c "grey40" bg-light) :box (:line-width 1 :color "grey80"))
+ (c "#afafaf" nil)
+ :box (:line-width 1 :color "#efefdf" :style flat-button))
(mode-line-buffer-id (~ default) (c nil nil) nit)
(mode-line-emphasis (c green nil))
(mode-line-highlight (c green nil))
+ (org-agenda-calendar-event (p f02))
(org-link (p link) (ul "grey80"))
+ (org-time-grid (c "grey60" nil))
(tab-bar (~ header-line) :family "Source Code Pro")
(scroll-bar (c "grey80" nil))
(show-paren-match (c nil "grey85"))
@@ -115,9 +121,9 @@
(shr-link (~ link) (ul light-gray))
(shr-code (c blue nil))
(success (c green))
- (variable-pitch :family "Iosevka Etoile" :height 90)
- (vertical-border (c "grey70" nil))
+ (vertical-border (c "#dfdfdf" nil))
(vterm-color-yellow (c "darkgoldenrod4" yellow))
+ (window-divider (c "grey99" nil))
(widget-button (~ default) nit (ul "grey80"))))
;; (enable-theme 'jao-light)
diff --git a/lib/themes/jao-themes.el b/lib/themes/jao-themes.el
index 58d32a0..d34dc70 100644
--- a/lib/themes/jao-themes.el
+++ b/lib/themes/jao-themes.el
@@ -21,8 +21,14 @@
(require 'ansi-color)
;;; palette
-(defvar jao-themes-default-face "DejaVu Sans Mono-9")
-(defvar jao-themes--face-family "DejaVu Sans Mono")
+(defvar jao-themes-default-face nil)
+(defvar jao-themes-default-family "Hack")
+(defvar jao-themes-default-variable-pitch-size 9)
+(defvar jao-themes-default-variable-pitch-family "Hack")
+(defvar jao-themes-default-size 9)
+(defvar jao-themes--face-family jao-themes-default-face)
+(defvar jao-themes--variable-pitch-family nil)
+(defvar jao-themes--variable-pitch-height nil)
(defvar jao-themes--fg "black")
(defvar jao-themes--bg "white")
(defvar jao-themes--box "grey75")
@@ -318,9 +324,9 @@
(avy-lead-face-0 (~ avy-lead-face) bf)
(avy-lead-face-1 (~ avy-lead-face)))
`((bbdb-company)
- (bbdb-field-name bf)
+ (bbdb-field-name (p f00))
(bbdb-field-value (~ default))
- (bbdb-name ul)
+ (bbdb-name (p f01))
(bmk-mgr-bookmark-face (~ default))
(bmk-mgr-folder-face bf)
(bmk-mgr-sel-bookmark-face link)
@@ -597,7 +603,10 @@
(font-lock-type-face (p type))
(font-lock-variable-name-face (p variable-name))
(font-lock-warning-face (p warning))
+ (forge-pullreq-merged (p dimm))
(forge-pullreq-open (c nil nil))
+ (forge-pullreq-rejected (~ forge-pullreq-merged) st)
+ (forge-topic-pending (c nil nil))
(forge-topic-label bx)
(fringe (p dimm))
(fuel-font-lock-debug-error (p error) nul)
@@ -958,7 +967,7 @@
(org-table (p f01))
(org-tag (p dimm) nbf)
(org-target ul)
- (org-time-grid (c nil nil))
+ (org-time-grid (p dimm))
(org-todo nbf niv (p error))
(org-upcoming-deadline (p f02))
(org-verbatim (p hilite))
@@ -1106,7 +1115,7 @@
(twittering-uri-face (~ link))
(twittering-username-face (p f01)))
`((underline ul))
- `((variable-pitch :family ,jao-themes--face-family)
+ `((variable-pitch :family ,jao-themes--variable-pitch-family)
(variable-pitch-text (~ variable-pitch))
(vertical-border (c ,jao-themes--box nil) :inherit default)
(vertico-current (p hilite))
@@ -1225,21 +1234,32 @@
(let ((palette (cdr (assoc :palette args)))
(x-faces (cdr (assoc :x-faces args)))
(x-colors (cdr (assoc :x-colors args)))
- (family (cadr (assoc :face-family args)))
- (size (or (cadr (assoc :face-size args)) 9))
+ (family (or (cadr (assoc :face-family args))
+ jao-themes-default-family))
+ (size (or (cadr (assoc :face-size args))
+ jao-themes-default-size))
+ (vpitch (or (cadr (assoc :variable-pitch-family args))
+ jao-themes-default-variable-pitch-family))
+ (vsize (or (cadr (assoc :variable-pitch-size args))
+ jao-themes-default-variable-pitch-size))
(bw (or (cadr (assoc :bold-weight args)) jao-themes--bold-weight)))
`(progn
(custom-make-theme-feature ',name)
(deftheme ,name)
(custom-theme-set-variables ',name
'(jao-themes-default-face
- (format "%s-%s" ,family ,size))
+ ,(format "%s-%s" family size))
'(jao-themes--face-family ,family)
+ '(jao-themes--variable-pitch-family
+ ,vpitch)
+ '(jao-themes--variable-pitch-height
+ ,(* 10 vsize))
'(jao-themes--bold-weight ,bw))
(let ((*jao-themes--color-names* ',(cdr (assoc :names args)))
(jao-themes--face-family ,family))
(let* ,(jao-themes--let-palette palette)
(jao-themes--set-fbg 'x)
+ (jao-themes--set-fbg 'ns)
(jao-themes--set-fbg 'pgtk)
(let* ((xfaces (jao-themes--make-faces ',x-faces ',x-colors))
(tx-faces (jao-themes--extract-faces xfaces xfaces)))