From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/9603 Path: news.gmane.org!not-for-mail From: Reiner Steib Newsgroups: gmane.emacs.gnus.user Subject: Re: Changing the "Sender" for the summary buffer Date: Thu, 30 Aug 2007 20:13:54 +0200 Organization: T-Online Message-ID: References: <87abs9fll5.fsf@workstation001.office.ice-sf.at> Reply-To: Reiner Steib NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1188499294 32194 80.91.229.12 (30 Aug 2007 18:41:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 30 Aug 2007 18:41:34 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Thu Aug 30 20:41:33 2007 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IQoxG-0008KW-2p for gegu-info-gnus-english@m.gmane.org; Thu, 30 Aug 2007 20:41:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IQoxF-0003x5-Mw for gegu-info-gnus-english@m.gmane.org; Thu, 30 Aug 2007 14:41:21 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsinpeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-Lines: 102 Original-X-Trace: news.t-online.com 1188497645 02 5133 d2ab1Xtl2aperig 070830 18:14:05 Original-X-Complaints-To: usenet-abuse@t-online.de X-ID: Vx4CPEZlQer9qAOQOakkcpyfTbt0gAEETBdXvWwLBkSjDxvCyeuUkv X-Face: P05mdcZT&lL[-s2=mw~RsllZ0zZAb?vdE}.s List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.gnus.user:9603 Archived-At: On Thu, Aug 30 2007, Bernhard Gschaider wrote: > Hi! > > I have the following thing I want my Gnus to do, but before I set out > to try it I want to know whether it can be done with juistifyable > effort (my lisp is a bit rusty ....): > > I'm receiving mails from a message board software (and a filter sorts > them into a separate folder). Obviously the sender address is that of > the MessageBoard-software. Each mail starts with the message > "This was posted by Isidor Pepranek on Tuesday..." > (the name variies obviously) > > Now what I would like to achive is that in the summary-buffer of the > folder for the Sender-Name instead of the MessageBoard-name the name > of the poster is displayed. [...] > Can somebody give me a hint how this could be done? Just something > like "look at variable foo, implement hook bar for the buffer". > > One of the key questions for me is: Can it only be done by generating > a new mail-header when filtering the mail (thus changing the messages > on disk) or can it be done during the displaying of the summary > buffer? Using `nnmail-prepare-incoming-message-hook' should work, I think. ,----[ (info "(gnus)Washing Mail") ] | `nnmail-prepare-incoming-message-hook' | This hook is called narrowed to each message. `---- Untested (and a little ugly): (defun rs-nnmail-fetch-sender-from-body () "Fetch sender's name from body and isert it into the From: header." (save-excursion (let ((case-fold-search t) endofheaders name) (goto-char (point-min)) (search-forward "\n\n" nil t) (setq endofheaders (1- (point))) (re-search-forward "^This was posted by \\(.*\\) on [MTWFS]" nil t) (setq name (match-string 1)) (goto-char endofheaders) (beginning-of-line) (insert (format "From: %s \n" name)) (goto-char (point-min)) (re-search-forward "^From: ") (beginning-of-line) (insert "Old-")))) (add-hook 'nnmail-prepare-incoming-message-hook 'rs-nnmail-fetch-sender-from-body) You could also do it with procmail. The following procmail recipe extracts a line from the body and puts it in the Subject. You need to modify From instead. The original header is renamed to "Old-Subject", see procmailrc(5) or procmailex(5) for details. ,----[ Original ] | Subject: CNN Breaking News | | -- Some relevant stuff | ads, ads, ... | more ads. `---- ,----[ Modified ] | Subject: Some relevant stuff | | -- Some relevant stuff | ads, ads, ... | more ads. `---- --8<---------------cut here---------------start------------->8--- :0 * ^From: .*@(|.*\.)CNN.COM * < 5000 { # Add a Subject to CNN Breaking News :0 BHf * ^From:.*BreakingNews * ^Subject:.*CNN Breaking News * ^-- \/.* | formail -i "Subject: $MATCH" } # :0 * ^From: .*@(|.*\.)CNN.COM $NEWS_SPOOL_IN/local.newsletters.cnn.breakingnews --8<---------------cut here---------------end--------------->8--- Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/