summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2026-11-27 22:59:47 +0000
committerjao <jao@gnu.org>2026-11-27 22:59:47 +0000
commitbca51e1655d5a305745b7826cf5134f37f6a960a (patch)
tree47fa78d6fa69e004f412087722583b2efac1e95d
parent307f2adf232ab89325549346aadab69ed1702b8d (diff)
downloadelibs-bca51e1655d5a305745b7826cf5134f37f6a960a.tar.gz
elibs-bca51e1655d5a305745b7826cf5134f37f6a960a.tar.bz2
afio refactorings
-rw-r--r--custom/jao-custom-chats.el16
-rw-r--r--custom/jao-custom-email.el2
-rw-r--r--custom/jao-custom-eww.el21
-rw-r--r--custom/jao-custom-pdf.el17
-rw-r--r--lib/doc/jao-pdf.el10
-rw-r--r--lib/eos/jao-afio.el92
6 files changed, 81 insertions, 77 deletions
diff --git a/custom/jao-custom-chats.el b/custom/jao-custom-chats.el
index d110a24..57af82f 100644
--- a/custom/jao-custom-chats.el
+++ b/custom/jao-custom-chats.el
@@ -125,8 +125,8 @@
(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 (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))))
@@ -139,6 +139,18 @@
(delete-other-windows))
(jao-chats t))
+(defun jao-chats-open-afio ()
+ (jao-afio-trisect)
+ (when (y-or-n-p "telegram? ")
+ (telega)
+ (other-buffer))
+ (when (y-or-n-p "mastodon? ")
+ (mastodon)
+ (other-buffer))
+ (when (y-or-n-p "irc? ") (circe "Libera Chat")))
+
+(setq jao-afio-open-chats #'jao-chats-open-afio)
+
(defun jao-chats-telega ()
(interactive)
(jao-buffer-same-mode '(telega-root-mode telega-chat-mode)))
diff --git a/custom/jao-custom-email.el b/custom/jao-custom-email.el
index e92a17b..ff84bd2 100644
--- a/custom/jao-custom-email.el
+++ b/custom/jao-custom-email.el
@@ -2,7 +2,7 @@
;;; main email system
(require 'jao-afio)
-(setq jao-afio-mail-function (jao-d-l 'notmuch 'notmuch))
+(setq jao-afio-mail-function 'notmuch)
(defvar jao-notmuch-enabled (eq jao-afio-mail-function 'notmuch))
diff --git a/custom/jao-custom-eww.el b/custom/jao-custom-eww.el
index 3cc10cb..5b39c18 100644
--- a/custom/jao-custom-eww.el
+++ b/custom/jao-custom-eww.el
@@ -118,6 +118,27 @@
;;; sessions
(use-package jao-eww-session :demand t)
+(defun jao-afio--open-eww-session ()
+ (if-let* ((b (jao-eww-session-eww-buffers)))
+ (switch-to-buffer (car b))
+ (jao-eww-session-load)))
+
+(defun jao-afio-open-eww ()
+ (interactive)
+ (require 'jao-eww-session)
+ (if (< (frame-width) 160)
+ (jao-afio--open-eww-session)
+ (jao-afio-trisect)
+ (jao-afio--open-eww-session)
+ (let ((b (current-buffer)))
+ (other-window 1)
+ (switch-to-buffer (car (jao-eww-session-eww-buffers b)))
+ (other-window 1)
+ (switch-to-buffer (car (jao-eww-session-eww-buffers b)))
+ (other-window 1))))
+
+(setq jao-afio-open-www #'jao-afio-open-eww)
+
;;; eww to org
(defun jao-eww-to-org (&optional dest)
(interactive "P")
diff --git a/custom/jao-custom-pdf.el b/custom/jao-custom-pdf.el
index cbe74ef..f42546b 100644
--- a/custom/jao-custom-pdf.el
+++ b/custom/jao-custom-pdf.el
@@ -78,6 +78,23 @@
("S" . jao-doc-session-save)
("u" . jao-doc-view-visit-url)))
+;;;; afio
+(defvar jao-pdf-afio-left-width nil)
+
+(defun jao-afio-open-doc ()
+ (interactive)
+ (delete-other-windows)
+ (split-window-right jao-pdf-afio-left-width)
+ (let ((docs (cl-remove-if-not 'jao-doc-session-is-doc (buffer-list))))
+ (if (car docs)
+ (progn (switch-to-buffer (car docs))
+ (switch-to-buffer-other-window (or (cadr docs) (car docs))))
+ (when-let* ((docs (jao-doc-session)))
+ (when (y-or-n-p (format "Load saved session? (%d docs)" (length docs)))
+ (jao-pdf-open-session docs))))))
+
+(setq jao-afio-open-doc #'jao-afio-open-doc)
+
;;;; transient
(defun jao-org-pdf-goto-org-linking ()
(interactive)
diff --git a/lib/doc/jao-pdf.el b/lib/doc/jao-pdf.el
index 01334b1..0347dc8 100644
--- a/lib/doc/jao-pdf.el
+++ b/lib/doc/jao-pdf.el
@@ -124,6 +124,16 @@
(add-to-list 'browse-url-handlers (cons "^doc://.+" 'jao-open-doc-url))
+;;; afio
+;;;###autoload
+(defun jao-pdf-open-session (&optional docs)
+ (interactive)
+ (dolist (doc (or docs (jao-doc-session)))
+ (when (and (stringp doc) (file-exists-p doc))
+ (if (jao-pdf-is-pdf-file doc) (funcall jao-open-doc-fun doc) (find-file doc))
+ (other-window 1)))
+ (other-window 1))
(provide 'jao-pdf)
+
;;; jao-pdf.el ends here
diff --git a/lib/eos/jao-afio.el b/lib/eos/jao-afio.el
index b23e6af..b4a4478 100644
--- a/lib/eos/jao-afio.el
+++ b/lib/eos/jao-afio.el
@@ -29,7 +29,6 @@
(defvar jao-afio-persist-configurations nil)
(defvar jao-open-doc-fun 'find-file)
-(defvar jao-afio-mail-function 'gnus)
(defvar jao-afio-use-w3m nil)
(defvar jao-afio-auto-toggle nil)
(defvar jao-afio-switch-hook nil)
@@ -111,38 +110,13 @@
(switch-to-buffer (other-buffer))))))
;;; session openers
-;;;###autoload
-(defun jao-afio-open-pdf-session (&optional docs)
- (interactive)
- (dolist (doc (or docs (jao-doc-session)))
- (when (and (stringp doc) (file-exists-p doc))
- (if (jao-pdf-is-pdf-file doc) (funcall jao-open-doc-fun doc) (find-file doc))
- (other-window 1)))
- (other-window 1))
-
-(defvar jao-afio-left-width nil)
-
-(defun jao-afio-open-doc ()
- (interactive)
- (delete-other-windows)
- (split-window-right jao-afio-left-width)
- (let ((docs (cl-remove-if-not 'jao-doc-session-is-doc (buffer-list))))
- (if (car docs)
- (progn (switch-to-buffer (car docs))
- (switch-to-buffer-other-window (or (cadr docs) (car docs))))
- (when-let* ((docs (jao-doc-session)))
- (when (y-or-n-p (format "Load saved session? (%d docs)" (length docs)))
- (jao-afio-open-pdf-session docs))))))
-
-(declare-function w3m "w3m")
-(declare-function notmuch "notmuch")
-(declare-function jao-eww-session-eww-buffers "jao-eww-session")
-(declare-function jao-eww-session-load "jao-eww-session")
-
-(defun jao-afio--open-eww-session ()
- (if-let* ((b (jao-eww-session-eww-buffers)))
- (switch-to-buffer (car b))
- (jao-eww-session-load)))
+(defvar jao-afio-open-doc nil)
+(defvar jao-afio-open-www nil)
+(defvar jao-afio-open-chats nil)
+(defvar jao-afio-mail-function nil)
+(defvar jao-afio-open-mail #'jao-afio-open-mail)
+(defvar jao-afio-mail-sidebar-width 60)
+(defvar jao-afio-mail-sidebar-right nil)
;;;###autoload
(defun jao-afio-org-agenda ()
@@ -154,36 +128,6 @@
(setq-local cursor-in-non-selected-windows nil
line-spacing 0.2))))
-;;;###autoload
-(defun jao-afio-open-www ()
- (interactive)
- (require 'jao-eww-session)
- (if (< (frame-width) 160)
- (if jao-afio-use-w3m (w3m) (jao-afio--open-eww-session))
- (if jao-afio-use-w3m
- (progn (delete-other-windows)
- (split-window-right)
- (w3m))
- (jao-afio-trisect)
- (jao-afio--open-eww-session)
- (let ((b (current-buffer)))
- (other-window 1)
- (switch-to-buffer (car (jao-eww-session-eww-buffers b)))
- (other-window 1)
- (switch-to-buffer (car (jao-eww-session-eww-buffers b)))
- (other-window 1)))))
-
-;;;###autoload
-(defun jao-afio-open-gnus ()
- (interactive)
- (jao-afio-org-agenda)
- (calendar)
- (find-file (expand-file-name "inbox.org" org-directory))
- (delete-other-windows)
- (gnus)
- ;; (jao-gnus--set-summary-line)
- )
-
(defun jao-afio--mail-sidebar ()
(other-window 1)
(delete-other-windows-vertically)
@@ -199,9 +143,6 @@
(set-window-dedicated-p nil t)
(other-window 1))
-(defvar jao-afio-mail-sidebar-width 60)
-(defvar jao-afio-mail-sidebar-right nil)
-
(defun jao-afio--open-mail (fun)
(unless (get-buffer "*Calendar*") (calendar))
(delete-other-windows)
@@ -219,9 +160,9 @@
;;;###autoload
(defun jao-afio-open-mail ()
(interactive)
- (cond ((eq 'gnus jao-afio-mail-function) (jao-afio-open-gnus))
- ((eq 'notmuch jao-afio-mail-function) (jao-afio--open-mail 'notmuch))
- (t (jao-afio-trisect))))
+ (if (functionp jao-afio-mail-function)
+ (jao-afio--open-mail jao-afio-mail-function)
+ (jao-afio-trisect)))
;;;###autoload
(defun jao-afio-toggle-mail-sidebar ()
@@ -235,11 +176,14 @@
(let ((c (jao-afio--current-config)))
(unless (jao-afio-restore-configuration c)
(delete-other-windows)
- (cl-case c
- (?w (jao-afio-open-www))
- (?g (jao-afio-open-mail))
- (?p (jao-afio-open-doc))
- (t (jao-afio-trisect)))
+ (let ((f (cl-case c
+ (?w jao-afio-open-www)
+ (?g jao-afio-open-mail)
+ (?p jao-afio-open-doc)
+ (?t jao-afio-open-chats))))
+ (if (functionp f)
+ (funcall f)
+ (jao-afio-trisect)))
(when jao-afio-persist-configurations (jao-afio-save-configuration)))))
;;; go to frame