mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-02-17 15:43:11 +01:00
Integrate notmuch-maildir-fcc into notmuch
Require notmuch-maildir-fcc and also install it. Rename all jkr/* functions to notmuch-maildir-fcc-* Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
1775893720
commit
36245db69d
3 changed files with 24 additions and 20 deletions
|
@ -10,6 +10,7 @@ emacs_sources := \
|
||||||
$(dir)/notmuch-hello.el \
|
$(dir)/notmuch-hello.el \
|
||||||
$(dir)/notmuch-mua.el \
|
$(dir)/notmuch-mua.el \
|
||||||
$(dir)/notmuch-address.el \
|
$(dir)/notmuch-address.el \
|
||||||
|
$(dir)/notmuch-maildir-fcc.el \
|
||||||
$(dir)/coolj.el
|
$(dir)/coolj.el
|
||||||
|
|
||||||
emacs_images := \
|
emacs_images := \
|
||||||
|
|
|
@ -28,18 +28,18 @@
|
||||||
;;
|
;;
|
||||||
;; (setq message-fcc-handler-function
|
;; (setq message-fcc-handler-function
|
||||||
;; '(lambda (destdir)
|
;; '(lambda (destdir)
|
||||||
;; (jkr/maildir-write-buffer-to-maildir destdir t)))
|
;; (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))
|
||||||
;;
|
;;
|
||||||
;; if you want Fcc'd messages to be marked as new:
|
;; if you want Fcc'd messages to be marked as new:
|
||||||
;;
|
;;
|
||||||
;; (setq message-fcc-handler-function
|
;; (setq message-fcc-handler-function
|
||||||
;; '(lambda (destdir)
|
;; '(lambda (destdir)
|
||||||
;; (jkr/maildir-write-buffer-to-maildir destdir nil)))
|
;; (notmuch-maildir-fcc-write-buffer-to-maildir destdir nil)))
|
||||||
|
|
||||||
|
|
||||||
(defvar jkr/maildir-count 0)
|
(defvar notmuch-maildir-fcc-count 0)
|
||||||
|
|
||||||
(defun jkr/maildir-host-fixer (hostname)
|
(defun notmuch-maildir-fcc-host-fixer (hostname)
|
||||||
(replace-regexp-in-string "/\\|:"
|
(replace-regexp-in-string "/\\|:"
|
||||||
'(lambda (s)
|
'(lambda (s)
|
||||||
(cond ((string-equal s "/") "\\057")
|
(cond ((string-equal s "/") "\\057")
|
||||||
|
@ -49,31 +49,31 @@
|
||||||
t
|
t
|
||||||
t))
|
t))
|
||||||
|
|
||||||
(defun jkr/maildir-make-uniq-maildir-id ()
|
(defun notmuch-maildir-fcc-make-uniq-maildir-id ()
|
||||||
(let* ((ct (current-time))
|
(let* ((ct (current-time))
|
||||||
(timeid (+ (* (car ct) 65536) (cadr ct)))
|
(timeid (+ (* (car ct) 65536) (cadr ct)))
|
||||||
(microseconds (caddr ct))
|
(microseconds (caddr ct))
|
||||||
(hostname (jkr/maildir-host-fixer system-name)))
|
(hostname (notmuch-maildir-fcc-host-fixer system-name)))
|
||||||
(setq jkr/maildir-count (+ jkr/maildir-count 1))
|
(setq notmuch-maildir-fcc-count (+ notmuch-maildir-fcc-count 1))
|
||||||
(format "%d.%d_%d_%d.%s"
|
(format "%d.%d_%d_%d.%s"
|
||||||
timeid
|
timeid
|
||||||
(emacs-pid)
|
(emacs-pid)
|
||||||
microseconds
|
microseconds
|
||||||
jkr/maildir-count
|
notmuch-maildir-fcc-count
|
||||||
hostname)))
|
hostname)))
|
||||||
|
|
||||||
(defun jkr/maildir-dir-is-maildir-p (dir)
|
(defun notmuch-maildir-fcc-dir-is-maildir-p (dir)
|
||||||
(and (file-exists-p (concat dir "/cur/"))
|
(and (file-exists-p (concat dir "/cur/"))
|
||||||
(file-exists-p (concat dir "/new/"))
|
(file-exists-p (concat dir "/new/"))
|
||||||
(file-exists-p (concat dir "/tmp/"))))
|
(file-exists-p (concat dir "/tmp/"))))
|
||||||
|
|
||||||
(defun jkr/maildir-save-buffer-to-tmp (destdir)
|
(defun notmuch-maildir-fcc-save-buffer-to-tmp (destdir)
|
||||||
"Returns the msg id of the message written to the temp directory
|
"Returns the msg id of the message written to the temp directory
|
||||||
if successful, nil if not."
|
if successful, nil if not."
|
||||||
(let ((msg-id (jkr/maildir-make-uniq-maildir-id)))
|
(let ((msg-id (notmuch-maildir-fcc-make-uniq-maildir-id)))
|
||||||
(while (file-exists-p (concat destdir "/tmp/" msg-id))
|
(while (file-exists-p (concat destdir "/tmp/" msg-id))
|
||||||
(setq msg-id (jkr/maildir-make-uniq-maildir-id)))
|
(setq msg-id (notmuch-maildir-fcc-make-uniq-maildir-id)))
|
||||||
(cond ((jkr/maildir-dir-is-maildir-p destdir)
|
(cond ((notmuch-maildir-fcc-dir-is-maildir-p destdir)
|
||||||
(write-file (concat destdir "/tmp/" msg-id))
|
(write-file (concat destdir "/tmp/" msg-id))
|
||||||
msg-id)
|
msg-id)
|
||||||
(t
|
(t
|
||||||
|
@ -81,17 +81,17 @@ if successful, nil if not."
|
||||||
destdir))
|
destdir))
|
||||||
nil))))
|
nil))))
|
||||||
|
|
||||||
(defun jkr/maildir-move-tmp-to-new (destdir msg-id)
|
(defun notmuch-maildir-fcc-move-tmp-to-new (destdir msg-id)
|
||||||
(add-name-to-file
|
(add-name-to-file
|
||||||
(concat destdir "/tmp/" msg-id)
|
(concat destdir "/tmp/" msg-id)
|
||||||
(concat destdir "/new/" msg-id ":2,")))
|
(concat destdir "/new/" msg-id ":2,")))
|
||||||
|
|
||||||
(defun jkr/maildir-move-tmp-to-cur (destdir msg-id &optional mark-seen)
|
(defun notmuch-maildir-fcc-move-tmp-to-cur (destdir msg-id &optional mark-seen)
|
||||||
(add-name-to-file
|
(add-name-to-file
|
||||||
(concat destdir "/tmp/" msg-id)
|
(concat destdir "/tmp/" msg-id)
|
||||||
(concat destdir "/cur/" msg-id ":2," (when mark-seen "S"))))
|
(concat destdir "/cur/" msg-id ":2," (when mark-seen "S"))))
|
||||||
|
|
||||||
(defun jkr/maildir-write-buffer-to-maildir (destdir &optional mark-seen)
|
(defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir &optional mark-seen)
|
||||||
"Writes the current buffer to maildir destdir. If mark-seen is
|
"Writes the current buffer to maildir destdir. If mark-seen is
|
||||||
non-nil, it will write it to cur/, and mark it as read. It should
|
non-nil, it will write it to cur/, and mark it as read. It should
|
||||||
return t if successful, and nil otherwise."
|
return t if successful, and nil otherwise."
|
||||||
|
@ -99,17 +99,19 @@ return t if successful, and nil otherwise."
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-buffer orig-buffer)
|
(insert-buffer orig-buffer)
|
||||||
(catch 'link-error
|
(catch 'link-error
|
||||||
(let ((msg-id (jkr/maildir-save-buffer-to-tmp destdir)))
|
(let ((msg-id (notmuch-maildir-fcc-save-buffer-to-tmp destdir)))
|
||||||
(when msg-id
|
(when msg-id
|
||||||
(cond (mark-seen
|
(cond (mark-seen
|
||||||
(condition-case err
|
(condition-case err
|
||||||
(jkr/maildir-move-tmp-to-cur destdir msg-id t)
|
(notmuch-maildir-fcc-move-tmp-to-cur destdir msg-id t)
|
||||||
(file-already-exists
|
(file-already-exists
|
||||||
(throw 'link-error nil))))
|
(throw 'link-error nil))))
|
||||||
(t
|
(t
|
||||||
(condition-case err
|
(condition-case err
|
||||||
(jkr/maildir-move-tmp-to-new destdir msg-id)
|
(notmuch-maildir-fcc-move-tmp-to-new destdir msg-id)
|
||||||
(file-already-exists
|
(file-already-exists
|
||||||
(throw 'link-error nil))))))
|
(throw 'link-error nil))))))
|
||||||
(delete-file (concat destdir "/tmp/" msg-id))))
|
(delete-file (concat destdir "/tmp/" msg-id))))
|
||||||
t)))
|
t)))
|
||||||
|
|
||||||
|
(provide 'notmuch-maildir-fcc)
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
(require 'notmuch-show)
|
(require 'notmuch-show)
|
||||||
(require 'notmuch-mua)
|
(require 'notmuch-mua)
|
||||||
(require 'notmuch-hello)
|
(require 'notmuch-hello)
|
||||||
|
(require 'notmuch-maildir-fcc)
|
||||||
|
|
||||||
(defcustom notmuch-search-result-format
|
(defcustom notmuch-search-result-format
|
||||||
`(("date" . "%s ")
|
`(("date" . "%s ")
|
||||||
|
|
Loading…
Add table
Reference in a new issue