aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/.emacs.d/init/ycp-gnus.el1
-rw-r--r--emacs/.emacs.d/init/ycp-web.el2
-rw-r--r--emacs/.emacs.d/lisp/my/iarc.el84
-rw-r--r--emacs/.emacs.d/lisp/my/my-gnus.el14
4 files changed, 93 insertions, 8 deletions
diff --git a/emacs/.emacs.d/init/ycp-gnus.el b/emacs/.emacs.d/init/ycp-gnus.el
index f95b03b..7275363 100644
--- a/emacs/.emacs.d/init/ycp-gnus.el
+++ b/emacs/.emacs.d/init/ycp-gnus.el
@@ -148,6 +148,7 @@
(require 'my-gnus)
(my-keybind gnus-group-mode-map
"g" #'my-gnus-group-refresh
+ "i" #'my-gnus-open-inbox
"n" #'next-line
"p" #'previous-line
"m" #'my-gnus-group-compose
diff --git a/emacs/.emacs.d/init/ycp-web.el b/emacs/.emacs.d/init/ycp-web.el
index 8e93c17..d309686 100644
--- a/emacs/.emacs.d/init/ycp-web.el
+++ b/emacs/.emacs.d/init/ycp-web.el
@@ -391,7 +391,7 @@
(setq exitter-debug nil)
(add-to-list 'browse-url-handlers
`(exitter-post-url-p
- . ,(lambda (url &rest _) (exitter-open-post url))))
+ . ,(lambda (url arg) (exitter-open-post url arg))))
)
diff --git a/emacs/.emacs.d/lisp/my/iarc.el b/emacs/.emacs.d/lisp/my/iarc.el
index a412aa3..d29d525 100644
--- a/emacs/.emacs.d/lisp/my/iarc.el
+++ b/emacs/.emacs.d/lisp/my/iarc.el
@@ -26,6 +26,17 @@
;;; Code:
+(require 'infobox)
+
+(defvar-keymap iarc-mode-map
+ :parent tabulated-list-mode-map
+ "F" #'iarc-toggle-follow-mode
+ "i" #'iarc-infobox
+ "n" #'iarc-next-line
+ "p" #'iarc-previous-line
+ "RET" #'iarc-item-at-point
+ )
+
(define-derived-mode iarc-mode tabulated-list-mode "IArc"
(hl-line-mode 1)
(setq tabulated-list-format
@@ -37,6 +48,24 @@
(defvar iarc-search-dataset nil)
+(defvar iarc-follow-mode nil "Whether follow mode is on.")
+
+(defun iarc-toggle-follow-mode ()
+ (interactive)
+ (setq iarc-follow-mode (not iarc-follow-mode)))
+
+(defun iarc-previous-line ()
+ (interactive)
+ (previous-line)
+ (when iarc-follow-mode
+ (iarc-infobox)))
+
+(defun iarc-next-line ()
+ (interactive)
+ (next-line)
+ (when iarc-follow-mode
+ (iarc-infobox)))
+
(defun iarc-compare-favourites (x y)
(> (let-alist (car x) (or .fields.num_favorites 0))
(let-alist (car y) (or .fields.num_favorites 0))))
@@ -67,9 +96,64 @@
iarc-host query)))
(defun iarc-search (query)
+ (interactive "sIArc Query: ")
(setq iarc-search-dataset (let-alist (iarc-api-search query)
.response.body.hits.hits))
(iarc))
+(defun iarc-infobox ()
+ (interactive)
+ (let ((help-window-select (not iarc-follow-mode)))
+ (iarc-render-info (alist-get 'fields (tabulated-list-get-id)))))
+
+(defun iarc-render-info (info)
+ (infobox-render
+ (infobox-translate info (infobox-default-specs info))
+ `(iarc-render-infobox ,info)
+ (called-interactively-p 'interactive)))
+
+(defun iarc-item-at-point ()
+ (interactive)
+ (iarc-item (alist-get 'identifier (alist-get 'fields
+ (tabulated-list-get-id)))))
+
+(define-derived-mode iarc-item-mode tabulated-list-mode "IArc Item"
+ (hl-line-mode 1)
+ (setq revert-buffer-function #'iarc-list-refresh))
+
+(defvar-local iarc-item-id nil "The item identifier for the iarc-item mode")
+(defvar-local iarc-item-data nil "The content of the iarc-item mode")
+
+(defun iarc-item (id)
+ "List content of item with ID"
+ (let* ((buf (get-buffer-create (format "*IArc %s*" id)))
+ (out
+ (seq-map
+ (lambda (s) (split-string s "\t"))
+ (string-lines
+ (with-temp-buffer
+ (call-process "ia" nil t nil "ls" "-v" "-c" "name,mtime,size" id)
+ (buffer-string))))))
+ (with-current-buffer buf
+ (setq tabulated-list-format
+ (vconcat
+ (seq-map
+ (lambda (c) (list c 20))
+ (car out))))
+ (setq tabulated-list-padding 2)
+ (iarc-item-mode)
+ (tabulated-list-init-header)
+ (setq iarc-item-data (cdr out))
+ (iarc-item-list-refresh))
+ (pop-to-buffer-same-window buf)))
+
+(defun iarc-item-list-refresh ()
+ (setq tabulated-list-entries
+ (seq-map 'iarc-item-list-print-entry iarc-item-data))
+ (tabulated-list-print))
+
+(defun iarc-item-list-print-entry (info)
+ (list info (vconcat info)))
+
(provide 'iarc)
;;; iarc.el ends here
diff --git a/emacs/.emacs.d/lisp/my/my-gnus.el b/emacs/.emacs.d/lisp/my/my-gnus.el
index d61efc8..7623548 100644
--- a/emacs/.emacs.d/lisp/my/my-gnus.el
+++ b/emacs/.emacs.d/lisp/my/my-gnus.el
@@ -427,13 +427,13 @@ The archiving target comes from `my-gnus-group-alist'."
(start-process "isync" "*isync*" "mbsync" "-a")
(lambda (proc event)
(let ((status (process-exit-status proc)))
- (when (eq status 0)
- (message "isync in progress...done: %s"
- (with-current-buffer (process-buffer proc)
- (goto-char (point-max))
- (re-search-backward " ")
- (buffer-substring (1+ (point)) (point-max))))
- (gnus-group-get-new-news))))))
+ (message "isync in progress...%s: %s"
+ (if (eq status 0) "done" "failed")
+ (with-current-buffer (process-buffer proc)
+ (goto-char (point-max))
+ (re-search-backward " ")
+ (buffer-substring (1+ (point)) (point-max))))
+ (gnus-group-get-new-news)))))
(defun my-gnus-group-refresh (arg)
"Call `gnus-group-get-new-news' or, with a prefix arg, `my-isync-sync-mail'"