summaryrefslogtreecommitdiffhomepage
path: root/custom
diff options
context:
space:
mode:
Diffstat (limited to 'custom')
-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.el9
-rw-r--r--custom/jao-custom-email.el30
-rw-r--r--custom/jao-custom-eww.el90
-rw-r--r--custom/jao-custom-exwm.el11
-rw-r--r--custom/jao-custom-gnus.el304
-rw-r--r--custom/jao-custom-mac.el22
-rw-r--r--custom/jao-custom-multimedia.el119
-rw-r--r--custom/jao-custom-notmuch.el147
-rw-r--r--custom/jao-custom-org.el58
-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
17 files changed, 1827 insertions, 284 deletions
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..ba47df7
--- /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 b44f9b6..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
@@ -107,7 +109,7 @@
:ensure t
:bind (("C-x M-:" . consult-complex-command)
("C-x b" . consult-buffer)
- ("C-x C-b" . consult-buffer)
+ ("C-x C-b" . switch-to-buffer)
("C-x 4 b" . consult-buffer-other-window)
("C-c b" . project-find-file)
("C-c h" . nil)
@@ -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..262b312 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)
@@ -219,12 +218,14 @@
(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))
-(jao-sendmail-local)
+(jao-d-l
+ (jao-sendmail-msmtp)
+ (jao-sendmail-local))
;;; bbdb
;; (jao-load-path "bbdb/lisp")
@@ -232,6 +233,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 +264,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 a3f4df9..a6fb342 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)
@@ -116,16 +119,17 @@
;;; eww to org
(defun jao-eww-to-org (&optional dest)
- (interactive)
- (unless (org-region-active-p)
+ (interactive "P")
+ (unless (or (and (interactive-p) dest) (org-region-active-p))
(let ((shr-width 80)) (eww-readable)))
- (let* ((start (if (org-region-active-p) (region-beginning) (point-min)))
+ (let* ((dest (unless (interactive-p) dest))
+ (start (if (org-region-active-p) (region-beginning) (point-min)))
(end (if (org-region-active-p) (region-end) (point-max)))
- (buff (or dest (generate-new-buffer "*eww-to-org*")))
(link (eww-current-url))
- (title (or (plist-get eww-data :title) "")))
+ (title (plist-get eww-data :title))
+ (buff (save-current-buffer (or dest (jao-org-notes-create title)))))
(with-current-buffer buff
- (insert "#+title: " title "\n#+link: " link "\n\n")
+ (insert "#+link: " link "\n\n")
(org-mode))
(save-excursion
(goto-char start)
@@ -156,33 +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))
+;;; auto-readable
+(defvar jao-eww-auto-readable-urls
+ (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)
-(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))
;;; package
(use-package shr
:custom ((shr-width nil)
@@ -200,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))
@@ -216,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)
@@ -232,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)
@@ -240,22 +219,12 @@ 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)
("M-i" . eww-toggle-images))))
-;;; auto-readable
-(defvar jao-eww-auto-readable-urls
- (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)
-
;;; fixes for shr image rendering
(require 'shr)
@@ -279,5 +248,8 @@ It should be the title of the web page as returned by `rdrview'"
(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)
+
;;; .
(provide 'jao-custom-eww)
diff --git a/custom/jao-custom-exwm.el b/custom/jao-custom-exwm.el
index dbad1da..ac88ec1 100644
--- a/custom/jao-custom-exwm.el
+++ b/custom/jao-custom-exwm.el
@@ -151,13 +151,13 @@
(add-hook 'exwm-workspace-switch-hook #'jao-minibuffer-refresh)
(require 'exwm-systemtray)
-(exwm-systemtray-enable)
+(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 e5a1762..dc729ce 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,49 +86,61 @@
(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)))
+ (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*" 0.5)
+ ("inbox.org" 1.0)
+ ;; ("*notmuch-hello*" 1.0)
+ ))))
+
+ (gnus-add-configuration
+ `(message (horizontal 1.0 (message 1.0 point))))
+
+ (gnus-add-configuration
+ `(reply-yank (horizontal 1.0 (message 1.0 point))))
+
+ (gnus-add-configuration
+ `(summary
+ (horizontal 1.0
+ (vertical ,groups-len (group 1.0))
+ (vertical 1.0 (summary 1.0 point)))))
+
+ (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 ")
- ")")))
- (q (concat "mime:message " dirsq " (" qstring ")")))
- ;; (message "query is: %s" q)
- `("-b" "-t" "-q" ,q))))
+(use-package jao-recoll
+ :if (jao-is-linux))
;; (add-to-list 'gnus-parameters '("^nnselect:.*" (nnselect-rescan . t)))
@@ -184,26 +194,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)
@@ -308,12 +334,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)
@@ -437,20 +465,49 @@
(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 %i" :immediate-finish t)
+ "* %(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 ")
+ (goto-char 0)
+ (fill-paragraph)
+ (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-gnus-subject (gnus-summary-article-subject))
(gnus-summary-select-article-buffer)
(gnus-article-goto-part 0)
- (forward-paragraph)
- (setq-local transient-mark-mode 'lambda)
- (set-mark (point))
- (goto-char (point-max))
- (org-capture nil "X"))
+ (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
;;;; config, headers
@@ -530,12 +587,21 @@
(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))))
- (if external
- (jao-browse-with-external-browser)
- (browse-url (jao-url-around-point))))))
+ (cond (external (jao-browse-with-external-browser))
+ ((featurep 'jao-custom-eww) (eww (jao-url-around-point)))
+ (t (browse-url (jao-url-around-point)))))))
+
+(defun jao-gnus-from-eww (keep-eww-buffer)
+ (interactive "P")
+ (unless keep-eww-buffer (jao-eww-close))
+ (jao-afio-goto-mail)
+ (gnus-article-show-summary))
+
+(with-eval-after-load 'eww
+ (define-key eww-mode-map (kbd "h") #'jao-gnus-from-eww))
(defun jao-gnus-open-enclosure ()
(interactive)
@@ -543,7 +609,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)))
@@ -574,9 +640,30 @@
(defun jao-gnus--scan ()
(let ((inhibit-message t))
(gnus-demon-scan-news)
+ (jao-shell-exec "notmuch-gnus-tags.sh")
+ (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)))
-(gnus-demon-add-handler 'jao-gnus--scan 5 1)
+(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
+(jao-when-linux (add-to-list 'jao-sleep-awake-functions #'jao-gnus-add-demon))
;;; add-ons
;;;; notifications
@@ -584,18 +671,23 @@
(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:bigml\\.inbox" "B" jao-themes-f00)
+ ;; ("nnml:bigml\\.alba" "A" jao-themes-f00)
+ ;; ("nnml:bigml\\.ryou" "R" jao-themes-f00)
+ ;; ("nnml:bigml\\.bugs" "b" jao-themes-error)
+ ;; ("nnml:bigml\\.support" "S" default)
+ ;; ("nnml:bigml\\.[^aibsr]" "W" jao-themes-dimm)
+ ("nnml:jao\\.bigml" "B" jao-themes-f00)
("nnml:jao\\.\\(inbox\\|trove\\)" "I" jao-themes-f01)
- ("nnml:bigml\\.[^ibs]" "W" jao-themes-dimm)
- ("nnml:jao.hacking" "H" jao-themes-dimm)
- ("nnml:jao.write" "W" jao-themes-error)
- ("nnml:jao.[^isthw]" "J" jao-themes-dimm)
+ ("nnml:jao.hunting" "H" jao-themes-f02)
+ ("nnml:jao.write" "W" jao-themes-warning)
+ ("nnml:jao.[^ithwb]" "J" jao-themes-dimm)
+ ("nnml:jao.hacking" "J" jao-themes-dimm)
(,(format "^nnml:%s" (regexp-opt feeds)) "F" jao-themes-dimm)
- ("feeds\\.e" "E" jao-themes-dimm)
+ ("feeds\\.emacs" "E" jao-themes-dimm)
("nnml:local" "l" jao-themes-dimm)
("nnrss:.*" "R" jao-themes-dimm)
("^\\(gwene\\|gmane\\)\\." "N" jao-themes-dimm))))
@@ -607,6 +699,11 @@
gnus-newsrc-alist
()))
+(defun jao-gnus-unread-count ()
+ (seq-reduce (lambda (c g) (+ c (or (gnus-group-unread (car g)) 0)))
+ gnus-newsrc-alist
+ 0))
+
(defun jao-gnus--unread-label (counts rx label face)
(let ((n (seq-reduce (lambda (n c)
(if (string-match-p rx (car c)) (+ n (cdr c)) n))
@@ -616,12 +713,24 @@
(defvar jao-gnus--notify-strs ())
+(defun jao-gnus--nnw-count ()
+ (jao-when-darwin
+ (when-let* ((n (jao-nnw-unread-count)))
+ (when (> n 0) (list (format "(%s)" n))))))
+
+(defun jao-gnus-xbar ()
+ (let ((n (jao-gnus-unread-count)))
+ (concat (if (> n 0) (format "%s " n) "")
+ (or (car (jao-gnus--nnw-count)) ""))))
+
(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))))
+ (append
+ (seq-filter #'identity
+ (seq-map (lambda (args)
+ (apply 'jao-gnus--unread-label counts args))
+ jao-gnus-tracked-groups))
+ (jao-gnus--nnw-count))))
(defun jao-gnus--notify ()
(setq jao-gnus--notify-strs (jao-gnus--notify-strs))
@@ -643,6 +752,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)
@@ -679,6 +789,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)))))
@@ -717,6 +828,20 @@
(with-eval-after-load "consult-recoll"
(add-to-list 'consult-recoll-open-fns
'("message/rfc822" . jao-gnus-goto-file))))
+;;;; notmuch
+(use-package jao-notmuch-gnus
+ :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
+ :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)
(define-key gnus-summary-mode-map "i" 'jao-gnus-show-images)
@@ -728,3 +853,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 3919897..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)
@@ -588,12 +592,13 @@
;;; arXiv
(use-package org-capture
:config
- (add-to-list 'org-capture-templates
- '("X" "arXiv" entry (file "notes/physics/arxiv.org")
- "* %(jao-org-notmuch-last-subject)\n %i"
- :immediate-finish t)
- t)
- (org-capture-upgrade-templates org-capture-templates))
+ (when jao-notmuch-enabled
+ (add-to-list 'org-capture-templates
+ '("X" "arXiv" entry (file "notes/physics/arxiv.org")
+ "* %(jao-org-notmuch-last-subject)\n %i"
+ :immediate-finish t)
+ t)
+ (org-capture-upgrade-templates org-capture-templates)))
(defun jao-notmuch-arXiv-capture ()
(interactive)
@@ -612,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 02e7a03..01f324e 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))
@@ -99,7 +100,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 +141,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 +160,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 +170,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 +191,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 +277,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 +297,30 @@
(org-show-subtree))))
(add-hook 'org-mode-hook 'jao-org--show-if-hidden t)
+;;; 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))
+
+ :hook ((org-agenda-finalize . org-modern-agenda)))
+
+;;; 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)