diff options
| author | jao <jao@gnu.org> | 2021-06-12 22:15:15 +0100 | 
|---|---|---|
| committer | jao <jao@gnu.org> | 2021-06-12 22:15:27 +0100 | 
| commit | 7da7f5f627b9ba657f3fb08c8eacf2de9300d770 (patch) | |
| tree | 6a370c5b94d1b1532678145e10134a9b188ca5d9 /lib/net | |
| parent | cf759f6b46a23732ad151abac466740ccc9fc7aa (diff) | |
| download | elibs-7da7f5f627b9ba657f3fb08c8eacf2de9300d770.tar.gz elibs-7da7f5f627b9ba657f3fb08c8eacf2de9300d770.tar.bz2  | |
jao-notmuch clean-ups
Diffstat (limited to 'lib/net')
| -rw-r--r-- | lib/net/jao-notmuch.el | 50 | 
1 files changed, 28 insertions, 22 deletions
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index 5916840..fd2694f 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -24,6 +24,8 @@  ;;; Code: +(require 'eww) +  (require 'notmuch)  (require 'notmuch-tree)  (require 'notmuch-show) @@ -41,7 +43,7 @@        (match-string 0 full-path)      (user-error "Message not in any mailbox!"))) -(defun jao-notmuch-msg-props () +(defun jao-notmuch--msg-props ()    (if-let ((p (save-excursion                  (text-property-search-forward :notmuch-message-properties))))        (prop-match-value p) @@ -50,32 +52,30 @@  (defun jao-notmuch--move (full-path &optional d)    (let* ((ff (jao-notmuch--path-to-mailbox full-path))           (d (or d (completing-read (format "From %s to: " ff) -                                   (remove ff jao-notmuch-mailboxes) -                                   nil -                                   t))) +                                   (remove ff jao-notmuch-mailboxes) nil t)))           (dest (string-replace ff d full-path))           (dest (replace-regexp-in-string ",U=.+$" "" dest))           (fnd (file-name-nondirectory full-path)) -         (dnd (file-name-nondirectory dest)) -         (prompt (format "%s/%s -> %s/%s? " ff fnd d dnd))) -    (when (y-or-n-p prompt) -      (let ((c (notmuch-tag-change-list (split-string ff "/") t)) -            (cc (notmuch-tag-change-list (split-string d "/")))) -        (notmuch-tree-tag (append c cc))) +         (dnd (file-name-nondirectory dest))) +    (when (y-or-n-p (format "%s/%s -> %s/%s? " ff fnd d dnd)) +      (notmuch-tree-tag (append (notmuch-tag-change-list (split-string ff "/") t) +                                (split-string d "/")))        (notmuch-tree-close-message-window)        (rename-file full-path dest)        (shell-command-to-string "notmuch new")        (notmuch-refresh-this-buffer))))  (defun jao-notmuch-move-message () +  "Move message at point to another folder."    (interactive) -  (let* ((p (jao-notmuch-msg-props)) +  (let* ((p (jao-notmuch--msg-props))           (f (car (plist-get p :filename))))      (jao-notmuch--move (or f ""))))  (defun jao-notmuch-tree-spam () -  (interactive) -  (let* ((p (jao-notmuch-msg-props)) +  "Move message at point to the spam folder." +    (interactive) +  (let* ((p (jao-notmuch--msg-props))           (f (car (plist-get p :filename)))           (mbox (car (split-string (jao-notmuch--path-to-mailbox f) "/"))))      (notmuch-tree-tag '("-new" "-unread")) @@ -102,11 +102,11 @@      (unless (eq 'url (jao-notmuch-goto-message-buffer t))        (pop-to-buffer b)))) -(defun jao-notmuch-goto-index-buffer () +(defun jao-notmuch-goto-tree-buffer ()    (interactive)    (if (buffer-live-p jao-notmuch--tree-buffer)        (pop-to-buffer jao-notmuch--tree-buffer) -    (user-error "No index for this buffer"))) +    (user-error "No tree view for this buffer")))  (defun jao-notmuch-browse-urls ()    (interactive) @@ -125,7 +125,7 @@          (when (re-search-forward "\\[ multipart/alternative \\]" nil t)            (while (forward-button 1 nil nil t)              (notmuch-show-toggle-part-invisibility))))) -    (jao-notmuch-goto-index-buffer))) +    (jao-notmuch-goto-tree-buffer)))  (defun jao-notmuch-toggle-images ()    (interactive) @@ -144,21 +144,27 @@    (save-excursion      (goto-char (point-min))      (let ((p) (cnt)) -      (while (setq p (text-property-search-forward -                      :notmuch-message-properties)) +      (while (setq p (text-property-search-forward :notmuch-message-properties))          (unless cnt (setq cnt 0))          (let ((tags (plist-get (prop-match-value p) :tags)))            (when (or (member "unread" tags) (member "new" tags))              (setq cnt (1+ cnt)))))        cnt))) -(defun jao-notmuch-tree-update-buffer-name (&optional n) +(defun jao-notmuch--tree-update-buffer-name (&optional n)    (when-let ((n (or n (jao-notmuch--unread-count))))      (rename-buffer (format "*%s - {%s messages left}*"                             notmuch-tree-basic-query                             n))      (jao-minibuffer-refresh))) +(defun jao-notmuch-echo-count () +  "Show the number of unread messages left in this tree view." +  (interactive) +  (when-let ((n (jao-notmuch--unread-count))) +    (jao-notmuch--tree-update-buffer-name n) +    (message "%s messages left" n))) +  (defun jao-notmuch-tree-next (thread &optional no-exit)    "Next message or thread in forest or exit if none."    (interactive "P") @@ -166,7 +172,7 @@        (progn (notmuch-tree-next-thread)               (notmuch-tree-show-message nil))      (notmuch-tree-next-matching-message (not no-exit))) -  (jao-notmuch-tree-update-buffer-name)) +  (jao-notmuch--tree-update-buffer-name))  ;; Tagging @@ -201,7 +207,7 @@        (notmuch-tree-next-matching-message t)      (when (not (window-live-p notmuch-tree-message-window))        (notmuch-tree-show-message nil))) -  (jao-notmuch-tree-update-buffer-name)) +  (jao-notmuch--tree-update-buffer-name))  (defun jao-notmuch-tree-show-or-scroll ()    "Show current message, or scroll it if visible." @@ -209,7 +215,7 @@    (if (window-live-p notmuch-tree-message-window)        (scroll-other-window 1)      (notmuch-tree-show-message nil) -    (jao-notmuch-tree-update-buffer-name))) +    (jao-notmuch--tree-update-buffer-name)))  (provide 'jao-notmuch)  | 
