Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: Re: mail-slip numbers




This message is for those of you who would rather not see the way
the TLUG majordomo server messes with Subject: lines of messages. 
This was inspired by Steve Turnbull's Emacs code that was posted on
tlug-admin, which I've included at the end for anyone interested
who's not on tlug-admin.  First though, I've included the changes I
made to my .procmailrc file to do the same thing, for those of us
who don't use Emacs.  It seems to work, and hopefully won't destroy
any e-mail.  :)   If you know of any way to improve it, let me
know!

----------- from my .procmailrc --------------------------------

# Used in most of my procmail stuff, and needed below
FORMAIL=/usr/bin/formail 

# Tokyo Linux Users Group (TLUG) mailing list
#     This one gets so much traffic, route it to it's own mailbox.
#   Since it's in its own mailbox, don't need the tlug... in the Subject line.
#   and since mutt threads messages, the number can be cut too.

# Inspiration, and a starting regular expression from Yaseppochi-Gumi, 
#  so I'll guess I'll GPL this as he did his.  ( GPL is our friend.)
#; You may copy, use and modify this code as provided under the GNU
#; Public License, version 2, or any more recent version at your
#; option.  The GPL should be available via M-X describe-copying in
#; any handy GNU Emacs variant (specifically including XEmacs).

#; This code comes with NO WARRANTIES.  If it RPMs everything in
#; /usr/local/bin, such is life.  Every attempt has been made to
#; insure that it can't RPM anything, but this is LISP, [err procmail & sh]
#  Suggestions / bug fixes desired (and needed).  
#	For instance, proper Japanese & non-ascii handling.

# Get the subject line for later use
SUBJECT=`$FORMAIL -xSubject:`
# For tlug-advocacy and tlug-admin
:0
*  ^(To:|Cc:).*(tlug-advocacy@example.com)|\
   ^From.*(owner-tlug-advocacy@example.com)|\
  ^(To:|Cc:).*(tlug-admin@example.com)|\
   ^From.*(owner-tlug-admin@example.com)
{
   #   Cut out the [tlug-ETC: ####]'s from Subject line
   #   and also any 'Re: Re:'s that result
   NEWSUBJECT=`echo $SUBJECT|sed -e"s/\[tlug-\(admin: \|advocacy:\)[0-9]\+\] *//g" -e"s/^Re: Re:/Re:/g"`
   #
   #  Get the sequence number.  
   #   I wouldn't have bothered, because this was a ROYAL pain, 
   #	but it was done in the LISP emacs code I started with, so...
   #       if anyone can clean up this UGLY mess, it would be appreciated
   # After eliminating extra tlug-ad...'s, this eliminates every 
   # non-numerical, non-space printable ASCII character.  I can't get rid 
   # of trailing numbers, therefore I left spaces to separate them.
   # Can eliminate tlug generated seqence numbers from replies.
   # So the only extra numbers left are ones that were in the original subject
   MSGNO=`echo $SUBJECT | sed -e"s/^\[tlug-\(admin\): //" -e"s/^\[tlug-\(advocacy\)://" -e"s/\] //" -e"s/\[tlug-\(admin: \|advocacy:\)[0-9]\+\] //g" -e"s/[!-/]\+//g" -e"s/[:-}]\+//g"`
   #  Put the message number from above in a new header called X-TLUG-serial:,
   #  save the old Subject as Old-Subject, and put in the new cleaner Subject:
   :0
   | $FORMAIL -A"X-Sorted: Bulk" -i"Subject: $NEWSUBJECT" -A"X-TLUG-serial: $MSGNO" >>$MAILDIR/incoming.computer.eml
}
:0
* ^(To:|Cc:).*(tlug@example.com)|\
   ^From.*(owner-tlug@example.com)
{
   # For mail to tlug, just cut 'tlug:' from Subject line
   #   and also any 'Re: Re:'s that result
   NEWSUBJECT=`echo $SUBJECT|sed -e"s/tlug: *//g" -e"s/^Re: Re:/Re:/g"`
   :0
   | $FORMAIL -A"X-Sorted: Bulk" -i"Subject: $NEWSUBJECT" >>$MAILDIR/incoming.computer.eml
}

-------------------------------------------
In mail Re: mail-slip numbers, Stephen J. Turnbull wrote:
> ;; Copyright 1998 Yaseppochi-Gumi
> ;; You may copy, use and modify this code as provided under the GNU
> ;; Public License, version 2, or any more recent version at your
> ;; option.  The GPL should be available via M-X describe-copying in
> ;; any handy GNU Emacs variant (specifically including XEmacs).
> 
> ;; This code comes with NO WARRANTIES.  If it RPMs everything in
> ;; /usr/local/bin, such is life.  Every attempt has been made to
> ;; insure that it can't RPM anything, but this is LISP....
> 
> ;; Since this is called via vm-select-message-hook, buffer is already
> ;; narrowed to message boundaries.
> 
> (defun sjt-vm-clean-tlug-subjects-function ()
>   "Restore Subject header to pristine state intended by God and author."
>   ;; be polite
>   (save-excursion
>     ;; narrow to headers
>     (goto-char (point-min))
>     (search-forward "\n\n")
>     (backward-char 2)
>     (narrow-to-region (point-min) (point))
>     (goto-char (point-min))
>     ;; re-narrow to subject header, ok, this is yuguly
>     (if (not (re-search-forward "^Subject:" (point-max) t))
>         nil
>       (let ((start (point))
>             (data nil))
>         (forward-line 1)
>         ;; don't forget that headers can be continued!
>         (while (looking-at "[ \\t]") (forward-line 1))
>         (narrow-to-region start (point))
>         ;; search out the most recent sequence number ...
>         (goto-char (point-min))
>         (if (re-search-forward
>               "\\[tlug\\(-admin\\|-advocacy\\):[ \t][0-9]+\\][ \t]*" nil t)
> 	    (progn
> 	      ;; ... save it ...
> 	      (setq data (match-string 0))
> 	      (toggle-read-only)
> 	      ;; ... and "Hasta la vista, baby!"
> 	      (replace-match "" nil nil)
> 	      ;; now, snuff any others
> 	      (while (re-search-forward
>                       ;; this regexp should be a buffer-local variable
> 		      "\\[tlug\\(-admin\\|-advocacy\\):[ \t][0-9]+\\][ \t]*"
> 		      nil t)
> 		(replace-match "" nil nil))
> 	      ;; after three days...
> 	      (goto-char (point-max))
> 	      (insert (concat "X-TLUG-serial: " data "\n"))
> 	      (toggle-read-only)
>               ;; clean out summary, too
> 	      (vm-discard-cached-data)))))))
> 
> ;; Next I should make this buffer-local so that only TLUG folders
> ;; incur this barbarous overhead
> (add-hook vm-select-message-hook 'sjt-vm-clean-tlug-subjects-function)
> 
		later,

                        Howard Abbey
-- 
__(O_O)____(._.)____(\@example.com@/)____(o_o)____(^_^;)____(-.-)____(^o^)/~~___
I From: Howard Measurement System site 1; Current Readings: 1 howard I
I E-mail: hrabbey@example.com  Web: http://www.bitsmart.com/hrabbey I
I  "Do not rejoice that the spirits submit to you, but rejoice that  I
I       your names are written in heaven." - Jesus - Luke 10:20.     I
`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
----------------------------------------------------------------
Next Technical Meeting: 12 December, 12:30 HSBC Securities Office
Next Nomikai: 15 January 1999, 19:30 Tengu TokyoEkiMae 03-3275-3691
----------------------------------------------------------------
more info: http://tlug.linux.or.jp Sponsors: PHT, HSBC Securities


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links