[gnu.emacs.gnus] Kill-permanent command; Faster kill hooks

ashwin@gatech.edu (Ashwin Ram) (12/08/89)

Does anyone have a 'kill-permanent' command for gnus (like the 'K' command
in rn)?

Also, does anyone have faster code for applying kill hooks?  I find that
using kill files is very slow if I have more than 4 or 5 gnus-kill commands
in the kill file and there are 20-30 messages in the newsgroup.  With 10 kill
commands and 50 messages it's pretty much unusable.  I think it is the
gnus-kill function that is the bottleneck, but I could be wrong.

Thanks in advance,

-- Ashwin (ashwin@gatech.edu)
--
Ashwin Ram
Georgia Institute of Technology, Atlanta, Georgia 30332-0280
UUCP:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!ar17
Internet: ashwin@gatech.edu, ashwin@pravda.gatech.edu, ar17@prism.gatech.edu

rgs@CS.CMU.EDU (Robert Stockton) (12/09/89)

In article <ASHWIN.89Dec8104122@pravda.gatech.edu> ashwin@gatech.edu (Ashwin Ram) writes:

   Does anyone have a 'kill-permanent' command for gnus (like the 'K' command
   in rn)?

   Also, does anyone have faster code for applying kill hooks?  I find that
   using kill files is very slow if I have more than 4 or 5 gnus-kill commands
   in the kill file and there are 20-30 messages in the newsgroup.  With 10
   kill commands and 50 messages it's pretty much unusable.  I think it is the
   gnus-kill function that is the bottleneck, but I could be wrong.

I would tend to agree that the gnus-kill function is entirely too slow.  I've
seen it take upwards of half an hour on some of the larger newsgroups (which
are the ones that really need kill files.)  I have worked around this problem
by writing my own version of 'gnus-kill which is nearly compatible with the
old one, but which runs vastly faster (i.e. I have no problem running it on
1000 messages at a time).  It's not incredibly clean code at the moment, but I
think you will find it worthwhile anyway.  If anyone out there wants to clean
it up and include it in the distribution that is fine with me.

------------------------------ >8 Cut here 8< ------------------------------
(defun new-gnus-kill (field regexp &optional command)
  (save-excursion
    (save-window-excursion
      (switch-to-buffer gnus-Subject-buffer)
      (let ((fun (intern-soft (concat "gnus-header-" (downcase field))))
	    (headers gnus-newsgroup-headers)
	    (value nil))
      (while headers
	(setq value (funcall fun (car headers)))
	;; Number (Lines:) or symbol must be converted to string.
	(or (stringp value)
	    (setq value (prin1-to-string value)))
	(if (string-match regexp value)
	    (progn (goto-char (point-min))
		   (while (and (re-search-forward (int-to-string (gnus-header-number (car headers))) nil t)
		     (not (looking-at ":.\\["))))
		   (cond ((not (looking-at ": \\[")) nil)
			 ((null command) (gnus-Subject-mark-as-read nil "X"))
			 ((stringp command)	;Keyboard macro.
			  (execute-kbd-macro command))
			 (t (eval command)))))
	(setq headers (cdr headers)))))))
--
Robert Stockton
ARPA: rgs@k.cs.cmu.edu
UUCP: ...!seismo!cmu-cs-k!rgs
      ...!seismo!rgs@k.cs.cmu.edu