aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Cohen2010-12-03 14:53:52 +0000
committerKatsumi Yamaoka2010-12-03 14:53:52 +0000
commit62cd2a73b8d2e33fcfb7bcaa1e973fb0822472f7 (patch)
treef42956997d4bb109c4f3578f6de6885e53963809
parent067d23c97ab3a4135388d8dd87f1dd04c6248572 (diff)
downloademacs-62cd2a73b8d2e33fcfb7bcaa1e973fb0822472f7.tar.gz
emacs-62cd2a73b8d2e33fcfb7bcaa1e973fb0822472f7.zip
nnir.el: Rearrange code to allow macros to be autoloaded by gnus-sum.el.
(nnir-retrieve-headers-override-function): Make this variable customizable. (nnir-retrieve-headers): Remove obsolete subject-mangling code. gnus-sum.el (nnir-article-group,nnir-article-rsv): Autoload macros from nnir.el.
-rw-r--r--lisp/gnus/ChangeLog11
-rw-r--r--lisp/gnus/gnus-demon.el2
-rw-r--r--lisp/gnus/gnus-sum.el2
-rw-r--r--lisp/gnus/nnir.el240
4 files changed, 134 insertions, 121 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 068ca8d0e08..7d8e954debd 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,14 @@
12010-12-03 Andrew Cohen <cohen@andy.bu.edu>
2
3 * nnir.el: Rearrange code to allow macros to be autoloaded by
4 gnus-sum.el.
5 (nnir-retrieve-headers-override-function): Make this variable
6 customizable.
7 (nnir-retrieve-headers): Remove obsolete subject-mangling code.
8
9 * gnus-sum.el (nnir-article-group,nnir-article-rsv): Autoload macros
10 from nnir.el.
11
12010-12-03 Julien Danjou <julien@danjou.info> 122010-12-03 Julien Danjou <julien@danjou.info>
2 13
3 * gnus-demon.el (gnus-demon-init): Fix time computing when time is nil. 14 * gnus-demon.el (gnus-demon-init): Fix time computing when time is nil.
diff --git a/lisp/gnus/gnus-demon.el b/lisp/gnus/gnus-demon.el
index 94a49525847..b33a673c354 100644
--- a/lisp/gnus/gnus-demon.el
+++ b/lisp/gnus/gnus-demon.el
@@ -121,7 +121,7 @@ Emacs has been idle for IDLE `gnus-demon-timestep's."
121 ;; If t, replace by 1 121 ;; If t, replace by 1
122 (time (cond ((eq time t) 122 (time (cond ((eq time t)
123 gnus-demon-timestep) 123 gnus-demon-timestep)
124 ((null time)) 124 ((null time) nil)
125 (t (* time gnus-demon-timestep)))) 125 (t (* time gnus-demon-timestep))))
126 (timer 126 (timer
127 (cond 127 (cond
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index bb8947b5c86..ba124d5115d 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -60,6 +60,8 @@
60(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t) 60(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
61(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t) 61(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
62(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t) 62(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
63(autoload 'nnir-article-rsv "nnir" nil nil 'macro)
64(autoload 'nnir-article-group "nnir" nil nil 'macro)
63 65
64(defcustom gnus-kill-summary-on-exit t 66(defcustom gnus-kill-summary-on-exit t
65 "*If non-nil, kill the summary buffer when you exit from it. 67 "*If non-nil, kill the summary buffer when you exit from it.
diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el
index 889d6ff7da5..7e1bd309c9d 100644
--- a/lisp/gnus/nnir.el
+++ b/lisp/gnus/nnir.el
@@ -163,7 +163,9 @@
163;; `nnir-engines'. Then, users can choose the backend by setting 163;; `nnir-engines'. Then, users can choose the backend by setting
164;; `nnir-search-engine' as a server variable. 164;; `nnir-search-engine' as a server variable.
165 165
166;;; Setup Code: 166;;; Code:
167
168;;; Setup:
167 169
168;; For Emacs <22.2 and XEmacs. 170;; For Emacs <22.2 and XEmacs.
169(eval-and-compile 171(eval-and-compile
@@ -171,12 +173,117 @@
171 173
172(require 'nnoo) 174(require 'nnoo)
173(require 'gnus-group) 175(require 'gnus-group)
174(require 'gnus-sum)
175(require 'message) 176(require 'message)
176(require 'gnus-util) 177(require 'gnus-util)
177(eval-when-compile 178(eval-when-compile
178 (require 'cl)) 179 (require 'cl))
179 180
181;;; Internal Variables:
182
183(defvar nnir-current-query nil
184 "Internal: stores current query (= group name).")
185
186(defvar nnir-current-server nil
187 "Internal: stores current server (does it ever change?).")
188
189(defvar nnir-current-group-marked nil
190 "Internal: stores current list of process-marked groups.")
191
192(defvar nnir-artlist nil
193 "Internal: stores search result.")
194
195(defvar nnir-tmp-buffer " *nnir*"
196 "Internal: temporary buffer.")
197
198(defvar nnir-search-history ()
199 "Internal: the history for querying search options in nnir")
200
201(defvar nnir-extra-parms nil
202 "Internal: stores request for extra search parms")
203
204;; Imap variables
205
206(defvar nnir-imap-search-arguments
207 '(("Whole message" . "TEXT")
208 ("Subject" . "SUBJECT")
209 ("To" . "TO")
210 ("From" . "FROM")
211 ("Imap" . ""))
212 "Mapping from user readable keys to IMAP search items for use in nnir")
213
214(defvar nnir-imap-search-other "HEADER %S"
215 "The IMAP search item to use for anything other than
216 `nnir-imap-search-arguments'. By default this is the name of an
217 email header field")
218
219(defvar nnir-imap-search-argument-history ()
220 "The history for querying search options in nnir")
221
222;;; Helper macros
223
224;; Data type article list.
225
226(defmacro nnir-artlist-length (artlist)
227 "Returns number of articles in artlist."
228 `(length ,artlist))
229
230(defmacro nnir-artlist-article (artlist n)
231 "Returns from ARTLIST the Nth artitem (counting starting at 1)."
232 `(when (> ,n 0)
233 (elt ,artlist (1- ,n))))
234
235(defmacro nnir-artitem-group (artitem)
236 "Returns the group from the ARTITEM."
237 `(elt ,artitem 0))
238
239(defmacro nnir-artitem-number (artitem)
240 "Returns the number from the ARTITEM."
241 `(elt ,artitem 1))
242
243(defmacro nnir-artitem-rsv (artitem)
244 "Returns the Retrieval Status Value (RSV, score) from the ARTITEM."
245 `(elt ,artitem 2))
246
247(defmacro nnir-article-group (article)
248 "Returns the group for ARTICLE"
249 `(nnir-artitem-group (nnir-artlist-article nnir-artlist ,article)))
250
251(defmacro nnir-article-number (article)
252 "Returns the number for ARTICLE"
253 `(nnir-artitem-number (nnir-artlist-article nnir-artlist ,article)))
254
255(defmacro nnir-article-rsv (article)
256 "Returns the rsv for ARTICLE"
257 `(nnir-artitem-rsv (nnir-artlist-article nnir-artlist ,article)))
258
259(defsubst nnir-article-ids (article)
260 "Returns the pair `(nnir id . real id)' of ARTICLE"
261 (cons article (nnir-article-number article)))
262
263(defmacro nnir-categorize (sequence keyfunc &optional valuefunc)
264 "Sorts a sequence into categories and returns a list of the form
265`((key1 (element11 element12)) (key2 (element21 element22))'.
266The category key for a member of the sequence is obtained
267as `(keyfunc member)' and the corresponding element is just
268`member'. If `valuefunc' is non-nil, the element of the list
269is `(valuefunc member)'."
270 `(unless (null ,sequence)
271 (let (value)
272 (mapcar
273 (lambda (member)
274 (let ((y (,keyfunc member))
275 (x ,(if valuefunc
276 `(,valuefunc member)
277 'member)))
278 (if (assoc y value)
279 (push x (cadr (assoc y value)))
280 (push (list y (list x)) value))))
281 ,sequence)
282 value)))
283
284;;; Finish setup:
285
286(require 'gnus-sum)
180 287
181(eval-when-compile 288(eval-when-compile
182 (autoload 'nnimap-buffer "nnimap") 289 (autoload 'nnimap-buffer "nnimap")
@@ -223,6 +330,17 @@ If nil this will use `gnus-summary-line-format'."
223 :type '(regexp) 330 :type '(regexp)
224 :group 'nnir) 331 :group 'nnir)
225 332
333(defcustom nnir-retrieve-headers-override-function nil
334 "*If non-nil, a function that accepts an article list and group
335and populates the `nntp-server-buffer' with the retrieved
336headers. Must return either 'nov or 'headers indicating the
337retrieved header format.
338
339If this variable is nil, or if the provided function returns nil for a search
340result, `gnus-retrieve-headers' will be called instead."
341 :type '(function)
342 :group 'nnir)
343
226(defcustom nnir-imap-default-search-key "Whole message" 344(defcustom nnir-imap-default-search-key "Whole message"
227 "*The default IMAP search key for an nnir search. Must be one of 345 "*The default IMAP search key for an nnir search. Must be one of
228 the keys in `nnir-imap-search-arguments'. To use raw imap queries 346 the keys in `nnir-imap-search-arguments'. To use raw imap queries
@@ -385,24 +503,6 @@ arrive at the correct group name, \"mail.misc\"."
385 :type '(directory) 503 :type '(directory)
386 :group 'nnir) 504 :group 'nnir)
387 505
388;; Imap variables
389
390(defvar nnir-imap-search-arguments
391 '(("Whole message" . "TEXT")
392 ("Subject" . "SUBJECT")
393 ("To" . "TO")
394 ("From" . "FROM")
395 ("Imap" . ""))
396 "Mapping from user readable keys to IMAP search items for use in nnir")
397
398(defvar nnir-imap-search-other "HEADER %S"
399 "The IMAP search item to use for anything other than
400 `nnir-imap-search-arguments'. By default this is the name of an
401 email header field")
402
403(defvar nnir-imap-search-argument-history ()
404 "The history for querying search options in nnir")
405
406;;; Developer Extension Variable: 506;;; Developer Extension Variable:
407 507
408(defvar nnir-engines 508(defvar nnir-engines
@@ -444,101 +544,6 @@ needs the variables `nnir-namazu-program',
444 544
445Add an entry here when adding a new search engine.") 545Add an entry here when adding a new search engine.")
446 546
447(defvar nnir-retrieve-headers-override-function nil
448 "If non-nil, a function that accepts an article list and group
449and populates the `nntp-server-buffer' with the retrieved
450headers. Must return either 'nov or 'headers indicating the
451retrieved header format.
452
453If this variable is nil, or if the provided function returns nil for a search
454result, `gnus-retrieve-headers' will be called instead.")
455
456;;; Internal Variables:
457
458(defvar nnir-current-query nil
459 "Internal: stores current query (= group name).")
460
461(defvar nnir-current-server nil
462 "Internal: stores current server (does it ever change?).")
463
464(defvar nnir-current-group-marked nil
465 "Internal: stores current list of process-marked groups.")
466
467(defvar nnir-artlist nil
468 "Internal: stores search result.")
469
470(defvar nnir-tmp-buffer " *nnir*"
471 "Internal: temporary buffer.")
472
473(defvar nnir-search-history ()
474 "Internal: the history for querying search options in nnir")
475
476(defvar nnir-extra-parms nil
477 "Internal: stores request for extra search parms")
478
479;;; Code:
480
481;;; Helper macros
482
483;; Data type article list.
484
485(defmacro nnir-artlist-length (artlist)
486 "Returns number of articles in artlist."
487 `(length ,artlist))
488
489(defmacro nnir-artlist-article (artlist n)
490 "Returns from ARTLIST the Nth artitem (counting starting at 1)."
491 `(when (> ,n 0)
492 (elt ,artlist (1- ,n))))
493
494(defmacro nnir-artitem-group (artitem)
495 "Returns the group from the ARTITEM."
496 `(elt ,artitem 0))
497
498(defmacro nnir-artitem-number (artitem)
499 "Returns the number from the ARTITEM."
500 `(elt ,artitem 1))
501
502(defmacro nnir-artitem-rsv (artitem)
503 "Returns the Retrieval Status Value (RSV, score) from the ARTITEM."
504 `(elt ,artitem 2))
505
506(defmacro nnir-article-group (article)
507 "Returns the group for ARTICLE"
508 `(nnir-artitem-group (nnir-artlist-article nnir-artlist ,article)))
509
510(defmacro nnir-article-number (article)
511 "Returns the number for ARTICLE"
512 `(nnir-artitem-number (nnir-artlist-article nnir-artlist ,article)))
513
514(defmacro nnir-article-rsv (article)
515 "Returns the rsv for ARTICLE"
516 `(nnir-artitem-rsv (nnir-artlist-article nnir-artlist ,article)))
517
518(defsubst nnir-article-ids (article)
519 "Returns the pair `(nnir id . real id)' of ARTICLE"
520 (cons article (nnir-article-number article)))
521
522(defmacro nnir-categorize (sequence keyfunc &optional valuefunc)
523 "Sorts a sequence into categories and returns a list of the form
524`((key1 (element11 element12)) (key2 (element21 element22))'.
525The category key for a member of the sequence is obtained
526as `(keyfunc member)' and the corresponding element is just
527`member'. If `valuefunc' is non-nil, the element of the list
528is `(valuefunc member)'."
529 `(unless (null ,sequence)
530 (let (value)
531 (mapcar
532 (lambda (member)
533 (let ((y (,keyfunc member))
534 (x ,(if valuefunc
535 `(,valuefunc member)
536 'member)))
537 (if (assoc y value)
538 (push x (cadr (assoc y value)))
539 (push (list y (list x)) value))))
540 ,sequence)
541 value)))
542 547
543;; Gnus glue. 548;; Gnus glue.
544 549
@@ -633,11 +638,6 @@ is `(valuefunc member)'."
633 (art (car (rassoc artno articleids)))) 638 (art (car (rassoc artno articleids))))
634 (when art 639 (when art
635 (mail-header-set-number novitem art) 640 (mail-header-set-number novitem art)
636 ;; (mail-header-set-subject
637 ;; novitem
638 ;; (format "[%d: %s/%d] %s"
639 ;; (nnir-article-rsv art) artgroup artno
640 ;; (mail-header-subject novitem)))
641 (push novitem headers)) 641 (push novitem headers))
642 (forward-line 1))))) 642 (forward-line 1)))))
643 (setq headers 643 (setq headers