* many-to boring header (was Re: long-to boring header)
1997-10-12 21:53 ` Lars Magne Ingebrigtsen
@ 1997-10-13 16:46 ` David S. Goldberg
1997-10-24 22:20 ` Lars Magne Ingebrigtsen
0 siblings, 1 reply; 4+ messages in thread
From: David S. Goldberg @ 1997-10-13 16:46 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]
> dsg@linus.mitre.org (David S. Goldberg) writes:
>> Unfortunately, the system that generates these damn To lines splits
>> it into several To headers, most of which are to long and the
>> long-to element only gets rid of the first one.
> If you want to get rid of these, you should add a `many-to' boring
> header hiding type instead.
Sounds reasonable. Here's one such implementation. I've also patched
gnus.texi to document it. One thing that I found kind of weird while
working on this: My first thought was to simply re-search-forward to
the first `to' header and call (gnus-article-hide-header "to"). Go
back to the beginning and try again. Repeat until none left. This
didn't work because re-search-forward would end up finding the hidden
text and so even though I'd call gnus-article-hide-header multiple
times, it only affected the first instance of the header (I verified
this behavior with the debugger, the return value from
re-search-forward in gnus-article-hide-header was always the same
thing). But... if I selected the *Article* buffer (after reading it),
turned off read-only and explicitly called (gnus-article-hide-header
"to") via eval-expression, it did the "right" thing and got rid of
each instance of the header in succession. I'm curious as to why this
happens. Anyway as you can see, my workaround was to go to the last
occurrence, narrow the region, hide and then back up. This seems
awfully inefficient, but it works.
--
Dave Goldberg
Post: The Mitre Corporation\MS B305\202 Burlington Rd.\Bedford, MA 01730
Phone: 781-271-3887
Email: dsg@mitre.org
[-- Attachment #2: gnus.diff --]
[-- Type: application/octet-stream, Size: 3016 bytes --]
*** lisp/gnus-art.el.orig Tue Oct 7 12:16:48 1997
--- lisp/gnus-art.el Mon Oct 13 12:15:03 1997
***************
*** 129,141 ****
(defcustom gnus-boring-article-headers '(empty followup-to reply-to)
"Headers that are only to be displayed if they have interesting data.
Possible values in this list are `empty', `newsgroups', `followup-to',
! `reply-to', and `date'."
:type '(set (const :tag "Headers with no content." empty)
(const :tag "Newsgroups with only one group." newsgroups)
(const :tag "Followup-to identical to newsgroups." followup-to)
(const :tag "Reply-to identical to from." reply-to)
(const :tag "Date less than four days old." date)
! (const :tag "Very long To header." long-to))
:group 'gnus-article-hiding)
(defcustom gnus-signature-separator '("^-- $" "^-- *$")
--- 129,142 ----
(defcustom gnus-boring-article-headers '(empty followup-to reply-to)
"Headers that are only to be displayed if they have interesting data.
Possible values in this list are `empty', `newsgroups', `followup-to',
! `reply-to', `date', `long-to', and `many-to'."
:type '(set (const :tag "Headers with no content." empty)
(const :tag "Newsgroups with only one group." newsgroups)
(const :tag "Followup-to identical to newsgroups." followup-to)
(const :tag "Reply-to identical to from." reply-to)
(const :tag "Date less than four days old." date)
! (const :tag "Very long To header." long-to)
! (const :tag "Multiple To headers." many-to))
:group 'gnus-article-hiding)
(defcustom gnus-signature-separator '("^-- $" "^-- *$")
***************
*** 747,753 ****
((eq elem 'long-to)
(let ((to (message-fetch-field "to")))
(when (> (length to) 1024)
! (gnus-article-hide-header "to")))))))))))
(defun gnus-article-hide-header (header)
(save-excursion
--- 748,768 ----
((eq elem 'long-to)
(let ((to (message-fetch-field "to")))
(when (> (length to) 1024)
! (gnus-article-hide-header "to"))))
! ((eq elem 'many-to)
! (let ((to-count 0))
! (goto-char (point-min))
! (while (re-search-forward "^to:" nil t)
! (setq to-count (1+ to-count)))
! (when (> to-count 1)
! (while (> to-count 0)
! (goto-char (point-min))
! (save-restriction
! (re-search-forward "^to:" nil nil to-count)
! (forward-line -1)
! (narrow-to-region (point) (point-max))
! (gnus-article-hide-header "to"))
! (setq to-count (1- to-count)))))))))))))
(defun gnus-article-hide-header (header)
(save-excursion
*** texi/gnus.texi.orig Fri Oct 3 19:03:42 1997
--- texi/gnus.texi Mon Oct 13 12:28:17 1997
***************
*** 7674,7679 ****
--- 7674,7681 ----
old.
@item long-to
Remove the @code{To} header if it is very long.
+ @item many-to
+ Remove all @code{To} headers if there are more than one.
@end table
To include the four first elements, you could say something like;
^ permalink raw reply [flat|nested] 4+ messages in thread