Gnus development mailing list
 help / color / mirror / Atom feed
From: jbw@cs.bu.edu (Joe Wells)
Subject: Re: setting marks for imported mailboxes, adding new mark types
Date: Thu, 13 Jun 1996 21:45:26 -0400	[thread overview]
Message-ID: <199606140145.VAA08072@csb.bu.edu> (raw)
In-Reply-To: jbw@cs.bu.edu's message of Tue, 11 Jun 1996 23:53:34 -0400

Enclosed below is a piece of code that sets the "answered" marks correctly
for mail imported from VM 5.32 mailboxes.

Instructions for use:

  0. Only tried with these versions: VM 5.32; Gnus v5.1; nnml
     1.0.  I have no idea if it will work with any others.

  1. Set up mail reading with some Gnus backend.  If you are not using
     nnml, you must hack the code by replacing (nnml "") with the
     appropriate method specification.

  2. Snarf the VM mailbox.  I did this by setting nnmail-spool-file to
     point to a copy of the mailbox and then starting Gnus.

  3. Invoke the command "M-x gnus-notice-vm-replied-marks".  Do this
     before answering any of the imported messages.  Your computer will
     explode if any of the messages are already marked as being answered
     in Gnus.

  4. Check if it worked.  If it didn't, fix the code and share the fixed
     version.

-- 
Enjoy,

Joe Wells <jbw@cs.bu.edu>

----------------------------------------------------------------------
;; Created by: Joe Wells, jbw@csb.bu.edu
;; Created on: Thu Jun 13 21:38:36 1996
;; Last modified by: Joe Wells, jbw@csb.bu.edu
;; Last modified on: Thu Jun 13 21:39:38 1996
;; Filename: fixup-mail-reply-marks.el
;; Purpose: import VM replied marks into Gnus

;; Hacked together from various pieces of Gnus.

(defun gnus-notice-vm-replied-marks ()
  (interactive)
  (save-excursion
    (set-buffer nntp-server-buffer)
    
    (let ((newsrc (cdr gnus-newsrc-alist))
          (method '(nnml ""))
          groups)

      ;; Get list of mail groups.
      (while newsrc
        (and (gnus-server-equal 
              (gnus-find-method-for-group 
               (car (car newsrc)) (car newsrc))
              method)
             (setq groups (cons (car (car newsrc)) groups)))
        (setq newsrc (cdr newsrc)))
      
      (while groups
        (let ((group (car groups))
              articles article replied headers)
          (setq groups (cdr groups))

          ;; Find articles in group.
          ;; Raw range possibly including expired articles.
          (setq articles
                (gnus-uncompress-sequence
                 (gnus-gethash group gnus-active-hashtb)))
          ;; Get headers for actual existing articles.
          (or (eq 'nov (gnus-retrieve-headers articles group))
              (error "oops .. not implemented"))
          ;; Bullshit so next step does not go awry.
          (setq gnus-newsgroup-dependencies 
                (gnus-make-hashtable (length articles)))
          ;; Parse the *nntpd* buffer to get article numbers.
          (setq headers (gnus-get-newsgroup-headers-xover articles))
          (setq articles
                (mapcar
                 (function (lambda (header) (mail-header-number header)))
                 headers))
          
          ;; Find sequence of answered messages in group.
          (while articles
            (let ((article (car articles)))
              (setq articles (cdr articles))

              ;; Load article's data.
              (gnus-request-article article group) ; buffer
              
              ;; Determine if article had been replied to in VM.
              ;; X-VM-v5-Data: ([nil nil nil nil t nil nil nil nil] ...
              (goto-char (point-min))
              (narrow-to-region (point-min)
                                (progn (search-forward "\n\n") (point)))
              (let* ((vm-data (read (mail-fetch-field "X-VM-v5-Data")))
                     (vm-flags (if (consp vm-data) (car vm-data)))
                     (replied-flag (if (vectorp vm-flags) (aref vm-flags 4))))
                (if replied-flag
                    (setq replied (cons article replied))))))
        
          ;; Mark sequence as answered.
          ;; The 'reply marks are kept uncompressed (Why!?!?). 
          (setq replied (nreverse replied))
          (gnus-add-marked-articles group 'reply replied))))))


      parent reply	other threads:[~1996-06-14  1:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-07 23:16 various nnml questions, many about cross-posted mail messages Joe Wells
1996-06-09  4:06 ` Lars Magne Ingebrigtsen
1996-06-09 10:09   ` Darren/Torin/Who Ever...
1996-06-09 17:02     ` Lars Magne Ingebrigtsen
1996-06-10  2:42       ` Mark Eichin
1996-06-10 20:30         ` Sten Drescher
1996-06-09 19:57     ` Hallvard B Furuseth
1996-06-10  3:39   ` Joe Wells
1996-06-20  8:32     ` Lars Magne Ingebrigtsen
1996-06-10  9:16 ` Per Abrahamsen
1996-06-10 19:46   ` Lars Magne Ingebrigtsen
1996-06-12  3:53 ` setting marks for imported mailboxes, adding new mark types Joe Wells
1996-06-12 18:03   ` Lars Magne Ingebrigtsen
1996-06-14  1:45   ` Joe Wells [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199606140145.VAA08072@csb.bu.edu \
    --to=jbw@cs.bu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).