Gnus development mailing list
 help / color / mirror / Atom feed
* long-to boring header
@ 1997-10-07 17:39 David S. Goldberg
  1997-10-12 21:53 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: David S. Goldberg @ 1997-10-07 17:39 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 556 bytes --]

Well, I asked for it and I got it.  Thanks Lars!

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.  The attached kludge to
gnus-article-hide-header (gnus-art.el) fixes it, but given the recent
discussion about garbage generation and loops in washing, I'm not sure
it's the best way to do this.

--
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-art.diff --]
[-- Type: application/octet-stream, Size: 1148 bytes --]

*** gnus-art.el.orig	Tue Oct  7 12:16:48 1997
--- gnus-art.el	Tue Oct  7 13:16:04 1997
***************
*** 752,758 ****
  (defun gnus-article-hide-header (header)
    (save-excursion
      (goto-char (point-min))
!     (when (re-search-forward (concat "^" header ":") nil t)
        (gnus-article-hide-text-type
         (progn (beginning-of-line) (point))
         (progn
--- 752,758 ----
  (defun gnus-article-hide-header (header)
    (save-excursion
      (goto-char (point-min))
!     (while (re-search-forward (concat "^" header ":") nil t)
        (gnus-article-hide-text-type
         (progn (beginning-of-line) (point))
         (progn
***************
*** 760,766 ****
  	 (if (re-search-forward "^[^ \t]" nil t)
  	     (match-beginning 0)
  	   (point-max)))
!        'boring-headers))))
  
  ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
  (defun article-treat-overstrike ()
--- 760,767 ----
  	 (if (re-search-forward "^[^ \t]" nil t)
  	     (match-beginning 0)
  	   (point-max)))
!        'boring-headers)
!       (forward-char -1))))
  
  ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
  (defun article-treat-overstrike ()

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: long-to boring header
  1997-10-07 17:39 long-to boring header David S. Goldberg
@ 1997-10-12 21:53 ` Lars Magne Ingebrigtsen
  1997-10-13 16:46   ` many-to boring header (was Re: long-to boring header) David S. Goldberg
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 1997-10-12 21:53 UTC (permalink / raw)


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.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 4+ messages in thread

* 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

* Re: many-to boring header (was Re: long-to boring header)
  1997-10-13 16:46   ` many-to boring header (was Re: long-to boring header) David S. Goldberg
@ 1997-10-24 22:20     ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Magne Ingebrigtsen @ 1997-10-24 22:20 UTC (permalink / raw)


dsg@linus.mitre.org (David S. Goldberg) writes:

> Sounds reasonable.  Here's one such implementation.  I've also patched
> gnus.texi to document it.

Thanks for the patch; I've applied it to Quassia Gnus v0.13.

> 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.  

[...]

> 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.

Because the Gnus function binds `inhibit-point-motion-hooks', which
means that it treats intangible text as tangible.

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-10-24 22:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-07 17:39 long-to boring header David S. Goldberg
1997-10-12 21:53 ` Lars Magne Ingebrigtsen
1997-10-13 16:46   ` many-to boring header (was Re: long-to boring header) David S. Goldberg
1997-10-24 22:20     ` Lars Magne Ingebrigtsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).