Article View: comp.mail.mh
Article #2090Re: Emacs MH -- kill Subject thread?
From: John Heidemann
Date: Mon, 27 Mar 1995 21:15
Date: Mon, 27 Mar 1995 21:15
70 lines
3276 bytes
3276 bytes
cshenton@wirehead.hq.nasa.gov (Chris Shenton) writes:
>I want to be able to kill a lame thread based on Subject, perhaps
>something like ``Subject: Make more money''. I'm fairly new to MH,
>and am using the Emacs interface to it.
Try the attached code on for size.
-John Heidemann
UCLA Ficus Project
----------------------------------------------------------------------
;;;
;;; mh-kill-subject
;;; John Heidemann/27-Mar-95
;;;
(defun mh-kill-subject ()
"Mark for removal the current message and any subsequent messages
with the same subject.
Bugs: should use reference headers if they're available.
To use, put something like
(define-key mh-folder-mode-map \"K\" 'mh-kill-subject)
in your mh-folder-mode-hook."
(interactive)
(let ((cur-subject-regexp (regexp-quote (mh-get-subject)))
new-msg full-regexp)
(save-excursion
(beginning-of-line)
(setq full-regexp (concat "^\\(....\\).*"
(make-string 23 ?.)
".*"
cur-subject-regexp))
(while (re-search-forward full-regexp nil t)
(setq new-msg (buffer-substring (match-beginning 1) (match-end 1)))
;; remove any leading whitespace
(setq new-msg (substring new-msg (string-match "[0-9]" new-msg) nil))
;; convert to an int
(setq new-msg (string-to-int new-msg))
(mh-delete-a-msg new-msg)))
(mh-next-msg)))
(defun mh-get-subject ()
"Extract the subject from the current line. Assumes the cursor is currently
on the line (somewhere).
Bugs: can be confused by << in the message header."
(interactive)
(let (subject-start subject-end raw-subject)
(save-excursion
;; extract the raw subject
(beginning-of-line)
(forward-char 37)
;; skip over "Re: "
(while (looking-at "\\([Rr][Ee]:[ \t]+\\)")
(forward-char (- (match-end 1) (match-beginning 1))))
(setq subject-start (point))
;; estimate the end as the end of line
(end-of-line)
(setq subject-end (point))
;; see if the body text intrudes
(goto-char subject-start)
(if (search-forward "<<" subject-end t)
(setq subject-end (- (point) 2)))
(setq raw-subject (buffer-substring subject-start subject-end)))))
Technical Details
Message-ID:
<3l79td$7vl@saba.info.ucla.edu>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!dearn!blekul11!ccsdec1.ufsia.ac.be!reks.uia.ac.be!idefix.CS.kuleuven.ac.be! Belgium.EU.net!EU.net!howland.reston.ans.net!gatech!udel!news.mathworks.com!solaris.cc.vt.edu!swiss.ans.net!meaddata!ddsw1!rahul.net!a2i!olivea!charnel.ecst.csuchico.edu!csusac!csus.edu!news.ucdavis.edu!library.ucla.edu!nnrp.info.ucla.edu!johnhReferences:
<CSHENTON.95Mar21152332@wirehead.hq.nasa.gov>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,2a73ce3397b2a68d X-Google-Attributes: gid103b8b,public X-Google-Thread: fe14c,2a73ce3397b2a68d X-Google-Attributes: gidfe14c,public X-Google-ArrivalTime: 1995-03-27 16:24:58 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!dearn!blekul11!ccsdec1.ufsia.ac.be!reks.uia.ac.be!idefix.CS.kuleuven.ac.be! Belgium.EU.net!EU.net!howland.reston.ans.net!gatech!udel!news.mathworks.com!solaris.cc.vt.edu!swiss.ans.net!meaddata!ddsw1!rahul.net!a2i!olivea!charnel.ecst.csuchico.edu!csusac!csus.edu!news.ucdavis.edu!library.ucla.edu!nnrp.info.ucla.edu!johnh From: johnh@ficus.cs.ucla.edu (John Heidemann) Newsgroups: comp.mail.mh,gnu.emacs.help Subject: Re: Emacs MH -- kill Subject thread? Date: 27 Mar 1995 21:15:25 GMT Organization: University of California, Los Angeles Lines: 72 Message-ID: <3l79td$7vl@saba.info.ucla.edu> References: <CSHENTON.95Mar21152332@wirehead.hq.nasa.gov> NNTP-Posting-Host: ipswich.cs.ucla.edu X-Newsreader: NN version 6.5.0.b3.0 #11 (NOV)