🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #9406

Re: Interesting & helpful vm-auto-folder-alist settings?

#9406
From: Noah Friedman
Date: Wed, 25 Sep 1991 18:35
74 lines
3961 bytes
In article <KERCE.91Sep23222437@xi.cs.fsu.edu> kerce@xi.cs.fsu.edu (Kingsley F. Kerce) writes:
>If I understand the VM info docs correctly then vm-auto-folder-alist
>will allow a folder name to be automatically constructed from the
>header fields of a message.  Does anyone have a setting for this
>variable that creates a folder name as the sender's 1st and last names
>appended (like JoeFoo) or just simply the sender's email address sans
>the @foo.bar.baz trailer i.e. the sender's user name?  How about
>helpful settings for this variable in general?

   You can use the buffer-substring function to construct filenames.  

   Myself, I found such expressions made the form setting my
auto-folder-alist unreadable.  So I wrote the following function:

(defun vm-afa-match-format (format-str &rest match-values) 
  "Creates a string of the format FORMAT-STR by getting
buffer-substrings determined by the &rest values MATCH-VALUES.  This
function is meant to be used when setting vm-auto-folder-alist.  It
allows you to construct filenames from saved regexp patterns.

Example: 
   (setq vm-auto-folder-alist
         '(\"To\"
           (\"fsf-\\\\([^@%]*\\\\)\" . (vm-afa-match-format-format \"fsf-%s\" 1))
           (\"foo-\\\\(bar\\\\)@\\\\(baz\\\\)\" . (vm-afa-match-format \"foo%s@%s\" 1 2))))

Thus, a To: line addressed to fsf-staff@gnu.ai.mit.edu would be saved by
default in a folder called \"fsf-staff\", and mail addressed to
foo-bar@baz would go in a folder called \"foobar@baz\"."
  (apply 'format format-str
         (mapcar
          (function
           (lambda (match-value)
             (buffer-substring (match-beginning match-value) 
                               (match-end match-value))))
          match-values)))


   And I define my auto-folder-alist as follows:

;; The HEADER string (e.g. Subject, Cc, To, etc.) should also be a regexp
;; to avoid duplicating lists... Hopefully I or Kyle will fix this someday.
(setq vm-auto-folder-alist
      '(("Subject" 
	 ("New account: .*" 		. "request")
         ("account" 			. "request"))
        ("From"
         ("EDB134TBP2@vx24\\.cc\\.monash\\.edu\\.au" . "tcwf"))
        ("To"
         ("fsf-\\([^@%]*\\)" 		. (vm-afa-match-format "fsf-%s" 1))
         ("system-hackers"		. "system-hackers")
         ("elisp-hackers"               . "elisp-hackers")
         ("league.*" 			. "league")
         ("request"			. "request")
         ("hurd-folks"			. "hurd-folks")
         ("ange-ftp-lovers"		. "ange-ftp-lovers"))
        ("Cc"
         ("fsf-\\([^@%]*\\)" 		. (vm-afa-match-format "fsf-%s" 1))
         ("system-hackers"		. "system-hackers")
         ("elisp-hackes"                . "elisp-hackers")
         ("league.*" 			. "league")
         ("request"			. "request")
         ("hurd-folks"			. "hurd-folks")
         ("ange-ftp-lovers"		. "ange-ftp-lovers")
         ("\\([^%@]*\\)"		. (vm-afa-match-format "%s" 1)))))

   I think one of the regexps you want (the one with the user's name with
the internet address stripped off) is the last one in the Cc part.

   Enjoy.

---
Noah Friedman
friedman@ai.mit.edu
Technical Details
Message-ID: <FRIEDMAN.91Sep25143507@nutrimat.gnu.ai.mit.edu>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!mips!think.com!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!friedman
References: <KERCE.91Sep23222437@xi.cs.fsu.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6829,3e5cfbae3b180cc7
X-Google-Attributes: gidf6829,public
X-Google-ArrivalTime: 1991-10-04 05:58:20 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!spool.mu.edu!mips!think.com!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!friedman
From: friedman@nutrimat.gnu.ai.mit.edu (Noah Friedman)
Newsgroups: gnu.emacs.vm.bug
Subject: Re: Interesting & helpful vm-auto-folder-alist settings?
Message-ID: <FRIEDMAN.91Sep25143507@nutrimat.gnu.ai.mit.edu>
Date: 25 Sep 91 18:35:07 GMT
References: <KERCE.91Sep23222437@xi.cs.fsu.edu>
Sender: news@ai.mit.edu
Distribution: gnu.emacs.vm.bug
Organization: Free Software Foundation, 675 Mass Ave. Cambridge, MA 02139
Lines: 74
In-reply-to: kerce@xi.cs.fsu.edu's message of 24 Sep 91 02:24:37 GMT