From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/32581 Path: main.gmane.org!not-for-mail From: Matt Pharr Newsgroups: gmane.emacs.gnus.general Subject: Re: [Q] stripping banners at the start of messages Date: 25 Sep 2000 13:03:25 -0700 Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035168844 20647 80.91.224.250 (21 Oct 2002 02:54:04 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 02:54:04 +0000 (UTC) Return-Path: Original-Received: from fisher.math.uh.edu (fisher.math.uh.edu [129.7.128.35]) by mailhost.sclp.com (Postfix) with ESMTP id 11F13D051E for ; Mon, 25 Sep 2000 16:05:08 -0400 (EDT) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by fisher.math.uh.edu (8.9.1/8.9.1) with ESMTP id PAC03505; Mon, 25 Sep 2000 15:04:14 -0500 (CDT) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Mon, 25 Sep 2000 15:03:19 -0500 (CDT) Original-Received: from mailhost.sclp.com (postfix@66-209.196.61.interliant.com [209.196.61.66] (may be forged)) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id PAA19410 for ; Mon, 25 Sep 2000 15:03:04 -0500 (CDT) Original-Received: from abuffer.stanford.edu (abuffer.Stanford.EDU [171.64.77.42]) by mailhost.sclp.com (Postfix) with ESMTP id 984F9D051E for ; Mon, 25 Sep 2000 16:03:26 -0400 (EDT) Original-Received: (from mmp@localhost) by abuffer.stanford.edu (8.9.3/8.9.3) id NAA19500; Mon, 25 Sep 2000 13:03:25 -0700 X-Authentication-Warning: abuffer.stanford.edu: mmp set sender to mmp@Exluna.com using -f Original-To: ding@gnus.org X-Face: C!.oGaE]n@p)VF9Ss3]f'|<)kRrtpG)^^b^X-3_zhUHp\jBj29jaoTItqWR>mHa+v-{/!jx7OA@!cV0>Fm-b:zEL<`oOXG[BFQ\ writes: > My regexp which works well (for the time being...) is > > (banner . "^[ ,-,_,-]+eGroups Sponsor\\(.*\n\\)\\(.*\n\\)\\(.*\n\\)\\(.*\n\\)\\(.*\n\\)?\\(.*\n\\)?[ ,-,_,-][ ,-,_,-][ ,-,_,-][ ,-,_,-][ ,-,_,-][ ,-,_,-][ ,-,_,-][ ,-,_,-][ ,-,_,-][ ,-,_,-].*\n") Since there's a lot of arcane magic in figuring out these multi-line regexps (I'd never be able to put together magic like the above, much as I hate the egroups banners), I've got a suggested patch that I just cooked up. The basic idea is that in addition to the old "banner" group parameter, there are now new banner-start and banner-end parameters. A new article-treat-banner function (see below) also looks for these two new parameters; if both are present, it will nuke all text between the start of the first regexp and the end of the second one. This makes for much easier configurability. For example, for eGroups lists, I've got these set like this: ((banner-start . "^----.*eGroups") (banner-end . "^----.*>")) That's all it takes. What do people think about this? I'm also no major elisp hacker, so if I coded it up poorly, I'm happy to hear about it. If this seems to be a generally useful thing, I'll write up some documentation for the manual and commit it all to the CVS repository. -matt *** gnus-art.el.orig Mon Sep 25 12:47:09 2000 --- gnus-art.el Mon Sep 25 12:56:57 2000 *************** *** 769,775 **** (defcustom gnus-treat-strip-banner t "Strip banners from articles. ! The banner to be stripped is specified in the `banner' group parameter. Valid values are nil, t, `head', `last', an integer or a predicate. See the manual for details." :group 'gnus-article-treat --- 769,776 ---- (defcustom gnus-treat-strip-banner t "Strip banners from articles. ! The banner to be stripped is specified in the `banner', and/or `banner-start' ! and `banner-end' group parameters. Valid values are nil, t, `head', `last', an integer or a predicate. See the manual for details." :group 'gnus-article-treat *************** *** 1649,1673 **** (match-beginning 0) (match-end 0) 'pem))))))) (defun article-strip-banner () ! "Strip the banner specified by the `banner' group parameter." (interactive) (save-excursion (save-restriction (let ((inhibit-point-motion-hooks t) (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner)) (gnus-signature-limit nil) ! buffer-read-only beg end) ! (when banner ! (article-goto-body) ! (cond ! ((eq banner 'signature) ! (when (gnus-article-narrow-to-signature) ! (widen) ! (forward-line -1) ! (delete-region (point) (point-max)))) ! ((stringp banner) ! (while (re-search-forward banner nil t) ! (delete-region (match-beginning 0) (match-end 0)))))))))) (defun article-babel () "Translate article using an online translation service." --- 1650,1683 ---- (match-beginning 0) (match-end 0) 'pem))))))) (defun article-strip-banner () ! "Strip the banner specified by the `banner', and/or `banner-start' and `banner-end' group parameters." (interactive) (save-excursion (save-restriction (let ((inhibit-point-motion-hooks t) (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner)) + (banner-start (gnus-group-get-parameter gnus-newsgroup-name 'banner-start)) + (banner-end (gnus-group-get-parameter gnus-newsgroup-name 'banner-end)) (gnus-signature-limit nil) ! buffer-read-only beg) ! (when banner ! (article-goto-body) ! (cond ! ((eq banner 'signature) ! (when (gnus-article-narrow-to-signature) ! (widen) ! (forward-line -1) ! (delete-region (point) (point-max)))) ! ((stringp banner) ! (while (re-search-forward banner nil t) ! (delete-region (match-beginning 0) (match-end 0)))))) ! (when (and banner-start banner-end (stringp banner-start) ! (stringp banner-end)) ! (article-goto-body) ! (while (re-search-forward banner-start nil t) ! (setq beg (match-beginning 0)) ! (if (re-search-forward banner-end nil t) ! (delete-region beg (match-end 0))))))))) (defun article-babel () "Translate article using an online translation service." -- Matt Pharr =============================================================================== In a cruel and evil world, being cynical can allow you to get some entertainment out of it. --Daniel Waters