annotate lisp/gnus/gnus-logic.el @ 164:4e0740e5aab2

Added tag r20-3b8 for changeset 0132846995bd
author cvs
date Mon, 13 Aug 2007 09:43:39 +0200
parents ec9a17fef872
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1 ;;; gnus-logic.el --- advanced scoring code for Gnus
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
3
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
5 ;; Keywords: news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
6
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
8
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
12 ;; any later version.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
13
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
18
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
23
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
24 ;;; Commentary:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
25
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
26 ;;; Code:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
27
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
28 (require 'gnus)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
29 (require 'gnus-score)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
30 (require 'gnus-util)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
31
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
32 ;;; Internal variables.
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
33
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
34 (defvar gnus-advanced-headers nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
35
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
36 ;; To avoid having 8-bit characters in the source file.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
37 (defvar gnus-advanced-not (intern (format "%c" 172)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
38
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
39 (defconst gnus-advanced-index
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
40 ;; Name to index alist.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
41 '(("number" 0 gnus-advanced-integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
42 ("subject" 1 gnus-advanced-string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
43 ("from" 2 gnus-advanced-string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
44 ("date" 3 gnus-advanced-date)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
45 ("message-id" 4 gnus-advanced-string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
46 ("references" 5 gnus-advanced-string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
47 ("chars" 6 gnus-advanced-integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
48 ("lines" 7 gnus-advanced-integer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
49 ("xref" 8 gnus-advanced-string)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
50 ("head" nil gnus-advanced-body)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
51 ("body" nil gnus-advanced-body)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
52 ("all" nil gnus-advanced-body)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
53
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
54 (eval-and-compile
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
55 (autoload 'parse-time-string "parse-time"))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
56
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
57 (defun gnus-score-advanced (rule &optional trace)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
58 "Apply advanced scoring RULE to all the articles in the current group."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
59 (let ((headers gnus-newsgroup-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
60 gnus-advanced-headers score)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
61 (while (setq gnus-advanced-headers (pop headers))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
62 (when (gnus-advanced-score-rule (car rule))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
63 ;; This rule was successful, so we add the score to
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
64 ;; this article.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
65 (if (setq score (assq (mail-header-number gnus-advanced-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
66 gnus-newsgroup-scored))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
67 (setcdr score
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
68 (+ (cdr score)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
69 (or (nth 1 rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
70 gnus-score-interactive-default-score)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
71 (push (cons (mail-header-number gnus-advanced-headers)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
72 (or (nth 1 rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
73 gnus-score-interactive-default-score))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
74 gnus-newsgroup-scored)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
75 (when trace
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
76 (push (cons "A file" rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
77 gnus-score-trace)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
78
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
79 (defun gnus-advanced-score-rule (rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
80 "Apply RULE to `gnus-advanced-headers'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
81 (let ((type (car rule)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
82 (cond
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
83 ;; "And" rule.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
84 ((or (eq type '&) (eq type 'and))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
85 (pop rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
86 (if (not rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
87 t ; Empty rule is true.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
88 (while (and rule
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
89 (gnus-advanced-score-rule (car rule)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
90 (pop rule))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
91 ;; If all the rules were true, then `rule' should be nil.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
92 (not rule)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
93 ;; "Or" rule.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
94 ((or (eq type '|) (eq type 'or))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
95 (pop rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
96 (if (not rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
97 nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
98 (while (and rule
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
99 (not (gnus-advanced-score-rule (car rule))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
100 (pop rule))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
101 ;; If one of the rules returned true, then `rule' should be non-nil.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
102 rule))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
103 ;; "Not" rule.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
104 ((or (eq type '!) (eq type 'not) (eq type gnus-advanced-not))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
105 (not (gnus-advanced-score-rule (nth 1 rule))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
106 ;; This is a `1-'-type redirection rule.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
107 ((and (symbolp type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
108 (string-match "^[0-9]+-$\\|^\\^+$" (symbol-name type)))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
109 (let ((gnus-advanced-headers
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
110 (gnus-parent-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
111 gnus-advanced-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
112 (if (string-match "^\\([0-9]+\\)-$" (symbol-name type))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
113 ;; 1- type redirection.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
114 (string-to-number
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
115 (substring (symbol-name type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
116 (match-beginning 0) (match-end 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
117 ;; ^^^ type redirection.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
118 (length (symbol-name type))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
119 (when gnus-advanced-headers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
120 (gnus-advanced-score-rule (nth 1 rule)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
121 ;; Plain scoring rule.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
122 ((stringp type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
123 (gnus-advanced-score-article rule))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
124 ;; Bug-out time!
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
125 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
126 (error "Unknown advanced score type: %s" rule)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
127
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
128 (defun gnus-advanced-score-article (rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
129 ;; `rule' is a semi-normal score rule, so we find out
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
130 ;; what function that's supposed to do the actual
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
131 ;; processing.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
132 (let* ((header (car rule))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
133 (func (assoc (downcase header) gnus-advanced-index)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
134 (if (not func)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
135 (error "No such header: %s" rule)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
136 ;; Call the score function.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
137 (funcall (caddr func) (or (cadr func) header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
138 (cadr rule) (caddr rule)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
139
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
140 (defun gnus-advanced-string (index match type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
141 "See whether string MATCH of TYPE matches `gnus-advanced-headers' in INDEX."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
142 (let* ((type (or type 's))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
143 (case-fold-search (not (eq (downcase (symbol-name type))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
144 (symbol-name type))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
145 (header (aref gnus-advanced-headers index)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
146 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
147 ((memq type '(r R regexp Regexp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
148 (string-match match header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
149 ((memq type '(s S string String))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
150 (string-match (regexp-quote match) header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
151 ((memq type '(e E exact Exact))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
152 (string= match header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
153 ((memq type '(f F fuzzy Fuzzy))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
154 (string-match (regexp-quote (gnus-simplify-subject-fuzzy match))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
155 header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
156 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
157 (error "No such string match type: %s" type)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
158
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
159 (defun gnus-advanced-integer (index match type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
160 (if (not (memq type '(< > <= >= =)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
161 (error "No such integer score type: %s" type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
162 (funcall type match (or (aref gnus-advanced-headers index) 0))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
163
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
164 (defun gnus-advanced-date (index match type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
165 (let ((date (encode-time (parse-time-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
166 (aref gnus-advanced-headers index))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
167 (match (encode-time (parse-time-string match))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
168 (cond
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
169 ((eq type 'at)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
170 (equal date match))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
171 ((eq type 'before)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
172 (gnus-time-less match date))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
173 ((eq type 'after)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
174 (gnus-time-less date match))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
175 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
176 (error "No such date score type: %s" type)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
177
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
178 (defun gnus-advanced-body (header match type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
179 (when (string= header "all")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
180 (setq header "article"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
181 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
182 (set-buffer nntp-server-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
183 (let* ((request-func (cond ((string= "head" header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
184 'gnus-request-head)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
185 ((string= "body" header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
186 'gnus-request-body)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
187 (t 'gnus-request-article)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
188 ofunc article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
189 ;; Not all backends support partial fetching. In that case,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
190 ;; we just fetch the entire article.
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
191 (unless (gnus-check-backend-function
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
192 (intern (concat "request-" header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
193 gnus-newsgroup-name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
194 (setq ofunc request-func)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
195 (setq request-func 'gnus-request-article))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
196 (setq article (mail-header-number gnus-advanced-headers))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
197 (gnus-message 7 "Scoring article %s..." article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
198 (when (funcall request-func article gnus-newsgroup-name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
199 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
200 ;; If just parts of the article is to be searched and the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
201 ;; backend didn't support partial fetching, we just narrow
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
202 ;; to the relevant parts.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
203 (when ofunc
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
204 (if (eq ofunc 'gnus-request-head)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
205 (narrow-to-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
206 (point)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
207 (or (search-forward "\n\n" nil t) (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
208 (narrow-to-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
209 (or (search-forward "\n\n" nil t) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
210 (point-max))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
211 (let* ((case-fold-search (not (eq (downcase (symbol-name type))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
212 (symbol-name type))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 16
diff changeset
213 (search-func
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
214 (cond ((memq type '(r R regexp Regexp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
215 're-search-forward)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
216 ((memq type '(s S string String))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
217 'search-forward)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
218 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
219 (error "Illegal match type: %s" type)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
220 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
221 (prog1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
222 (funcall search-func match nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
223 (widen)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
224
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
225 (provide 'gnus-logic)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
226
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
227 ;;; gnus-logic.el ends here.