Gnus development mailing list
 help / color / mirror / Atom feed
* Maildir support (patch included)
@ 1999-02-02 20:26 Carsten Leonhardt
  1999-02-03  9:12 ` Hans de Graaff
  0 siblings, 1 reply; 3+ messages in thread
From: Carsten Leonhardt @ 1999-02-02 20:26 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

Hi!

Here's my shot at maildir support.

The main problem with supporting the maildir format is that the
nnmail-process-*-mail-format functions can't handle the mails, so a
new function nnmail-process-maildir-mail-format is needed.

The patch to nnmail.el has already served me for a very long time
(might be years by now). 

Please note that I am not a lisp-wizard, so please review the patch
first.

leo


[-- Attachment #2: Type: text/plain, Size: 392 bytes --]


ChangeLog entry:

1999-02-02 18:12:00  Carsten Leonhardt  <leo@arioch.oche.de>

	* nnmail.el (nnmail-split-incoming): Added detection of maildir
 	format.
	(nnmail-process-maildir-mail-format): New function.

	* mail-source.el (mail-source-fetch-maildir): New function.
	(mail-source-keyword-map): Add default for maildir method.
	(mail-source-fetcher-alist): Changed "qmail" to "maildir".


[-- Attachment #3: Type: text/plain, Size: 3790 bytes --]


*** pgnus-0.75/lisp/mail-source.el	1999/02/02 14:45:13	1.0
--- pgnus-0.75/lisp/mail-source.el	1999/02/02 18:07:27
***************
*** 75,81 ****
         (:function)
         (:password))
        (maildir
!        (:path)))
      "Mapping from keywords to default values.
  All keywords that can be used must be listed here."))
  
--- 75,81 ----
         (:function)
         (:password))
        (maildir
!        (:path "~/Maildir/new/")))
      "Mapping from keywords to default values.
  All keywords that can be used must be listed here."))
  
***************
*** 83,89 ****
    '((file mail-source-fetch-file)
      (directory mail-source-fetch-directory)
      (pop mail-source-fetch-pop)
!     (qmail mail-source-fetch-qmail))
    "A mapping from source type to fetcher function.")
  
  (defvar mail-source-password-cache nil)
--- 83,89 ----
    '((file mail-source-fetch-file)
      (directory mail-source-fetch-directory)
      (pop mail-source-fetch-pop)
!     (maildir mail-source-fetch-maildir))
    "A mapping from source type to fetcher function.")
  
  (defvar mail-source-password-cache nil)
***************
*** 341,346 ****
--- 341,357 ----
  	      (delq (assoc from mail-source-password-cache)
  		    mail-source-password-cache))
  	0))))
+ 
+ (defun mail-source-fetch-maildir (source callback)
+   "Fetcher for maildir sources."
+   (mail-source-bind (maildir source)
+     (let ((found 0)
+ 	  (mail-source-string (format "maildir:%s" path)))
+       (dolist (file (directory-files path t))
+ 	(when (and (file-regular-p file)
+ 		   (not (rename-file file mail-source-crash-box)))
+ 	  (incf found (mail-source-callback callback file))))
+       found)))
  
  (provide 'mail-source)
  
*** pgnus-0.75/lisp/nnmail.el	1999/02/02 16:42:15	1.0
--- pgnus-0.75/lisp/nnmail.el	1999/02/02 16:38:11
***************
*** 786,791 ****
--- 786,825 ----
  	(goto-char end)
  	(forward-line 2)))))
  
+ (defun nnmail-process-maildir-mail-format (func artnum-func)
+ ; In a maildir, every file contains exactly one mail
+   (let ((case-fold-search t)
+ 	message-id)
+     (goto-char (point-min))
+     ;; Find the end of the head.
+     (narrow-to-region
+      (point-min) 
+      (if (search-forward "\n\n" nil t)
+ 	 (1- (point))
+        ;; This will never happen, but just to be on the safe side --
+        ;; if there is no head-body delimiter, we search a bit manually.
+        (while (and (looking-at "From \\|[^ \t]+:")
+ 		   (not (eobp)))
+ 	 (forward-line 1)
+ 	 (point))))
+     ;; Find the Message-ID header.
+     (goto-char (point-min))
+     (if (re-search-forward "^Message-ID:[ \t]*\\(<[^>]+>\\)" nil t)
+ 	(setq message-id (match-string 1))
+       ;; There is no Message-ID here, so we create one.
+       (save-excursion
+ 	    (when (re-search-backward "^Message-ID[ \t]*:" nil t)
+ 	  (beginning-of-line)
+ 	  (insert "Original-")))
+       (forward-line 1)
+       (insert "Message-ID: " (setq message-id (nnmail-message-id)) "\n"))
+     (run-hooks 'nnmail-prepare-incoming-header-hook)
+     ;; Allow the backend to save the article.
+     (widen)
+     (save-excursion
+ 	(goto-char (point-min))
+ 	(nnmail-check-duplication message-id func artnum-func))))
+ 
  (defun nnmail-split-incoming (incoming func &optional exit-func
  				       group artnum-func)
    "Go through the entire INCOMING file and pick out each individual mail.
***************
*** 813,818 ****
--- 847,854 ----
  	       (nnmail-process-babyl-mail-format func artnum-func))
  	      ((looking-at "\^A\^A\^A\^A")
  	       (nnmail-process-mmdf-mail-format func artnum-func))
+ 	      ((looking-at "Return-Path:")
+ 	       (nnmail-process-maildir-mail-format func artnum-func))
  	      (t
  	       (nnmail-process-unix-mail-format func artnum-func))))
        (when exit-func


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Maildir support (patch included)
  1999-02-02 20:26 Maildir support (patch included) Carsten Leonhardt
@ 1999-02-03  9:12 ` Hans de Graaff
  1999-02-03 20:38   ` Carsten Leonhardt
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Graaff @ 1999-02-03  9:12 UTC (permalink / raw)


Carsten Leonhardt <leo@arioch.oche.de> writes:

> Here's my shot at maildir support.

I would like to see this supported in Gnus as well. Thanks for sending 
in the patch.

One question I have: With the current system with a single mailbox
file, a copy is left in mail-source-dir named Incomingxxxxx. I do like 
this feature with the alpha versions of Gnus.

>From quickly glancing through the patch (and by not being a lisp
person), I couldn't find whether this will also be done for maildir,
and if so in what way (e.g. many, many Incoming files?) I would like
to see a safetynet like that wit maildir support as well, though.

Hans


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Maildir support (patch included)
  1999-02-03  9:12 ` Hans de Graaff
@ 1999-02-03 20:38   ` Carsten Leonhardt
  0 siblings, 0 replies; 3+ messages in thread
From: Carsten Leonhardt @ 1999-02-03 20:38 UTC (permalink / raw)


Hans> One question I have: With the current system with a single mailbox
Hans> file, a copy is left in mail-source-dir named Incomingxxxxx. I do like 
Hans> this feature with the alpha versions of Gnus.

Hans> From quickly glancing through the patch (and by not being a lisp
Hans> person), I couldn't find whether this will also be done for maildir,
Hans> and if so in what way (e.g. many, many Incoming files?) I would like
Hans> to see a safetynet like that wit maildir support as well, though.

This feature is independent of the mail-source-fetch-method, so
indeed, with maildir you get loads of Incoming* files (and then some).
(see mail-source-fetch-* and mail-source-callback functions)

leo


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-02-03 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-02 20:26 Maildir support (patch included) Carsten Leonhardt
1999-02-03  9:12 ` Hans de Graaff
1999-02-03 20:38   ` Carsten Leonhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).