*** empty log message ***
[gnus] / lisp / gnus-vis.el
1 ;;; gnus-vis.el --- display-oriented parts of Gnus
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;;      Per Abrahamsen <abraham@iesd.auc.dk>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (require 'gnus)
30 (require 'gnus-ems)
31 (require 'easymenu)
32 (require 'custom)
33 (require 'browse-url)
34 (require 'gnus-score)
35 (eval-when-compile (require 'cl))
36
37 (defvar gnus-group-menu-hook nil
38   "*Hook run after the creation of the group mode menu.")
39
40 (defvar gnus-summary-menu-hook nil
41   "*Hook run after the creation of the summary mode menu.")
42
43 (defvar gnus-article-menu-hook nil
44   "*Hook run after the creation of the article mode menu.")
45
46 ;;; Summary highlights.
47
48 ;(defvar gnus-summary-highlight-properties
49 ;  '((unread "ForestGreen" "green")
50 ;    (ticked "Firebrick" "pink")
51 ;    (read "black" "white")
52 ;    (low italic italic)
53 ;    (high bold bold)
54 ;    (canceled "yellow/black" "black/yellow")))
55
56 ;(defvar gnus-summary-highlight-translation
57 ;  '(((unread (= mark gnus-unread-mark))
58 ;     (ticked (or (= mark gnus-ticked-mark) (= mark gnus-dormant-mark)))
59 ;     (read (not (or (= mark gnus-unread-mark) (= mark gnus-dormant-mark)
60 ;                   (= mark gnus-ticked-mark) (= mark gnus-canceled-mark))))
61 ;     (canceled (= mark gnus-canceled-mark)))
62 ;    ((low (< score gnus-summary-default-score))
63 ;     (high (> score gnus-summary-default-score)))))
64
65 ;(defun gnus-visual-map-face-translation ()
66 ;  (let ((props gnus-summary-highlight-properties)
67 ;       (trans gnus-summary-highlight-translation)
68 ;       map)
69 ;    (while props)))
70       
71 ;see gnus-cus.el
72 ;(defvar gnus-summary-selected-face 'underline
73 ;  "*Face used for highlighting the current article in the summary buffer.")
74  
75 ;see gnus-cus.el
76 ;(defvar gnus-summary-highlight
77 ;  (cond ((not (eq gnus-display-type 'color))
78 ;        '(((> score default) . bold)
79 ;          ((< score default) . italic)))
80 ;       ((eq gnus-background-mode 'dark)
81 ;        (list (cons '(= mark gnus-canceled-mark)
82 ;                    (custom-face-lookup "yellow" "black" nil nil nil nil))
83 ;              (cons '(and (> score default) 
84 ;                          (or (= mark gnus-dormant-mark)
85 ;                              (= mark gnus-ticked-mark)))
86 ;                    (custom-face-lookup "pink" nil nil t nil nil))
87 ;              (cons '(and (< score default) 
88 ;                          (or (= mark gnus-dormant-mark)
89 ;                              (= mark gnus-ticked-mark)))
90 ;                    (custom-face-lookup "pink" nil nil nil t nil))
91 ;              (cons '(or (= mark gnus-dormant-mark)
92 ;                         (= mark gnus-ticked-mark))
93 ;                    (custom-face-lookup "pink" nil nil nil nil nil))
94
95 ;              (cons '(and (> score default) (= mark gnus-ancient-mark))
96 ;                    (custom-face-lookup "SkyBlue" nil nil t nil nil))
97 ;              (cons '(and (< score default) (= mark gnus-ancient-mark))
98 ;                    (custom-face-lookup "SkyBlue" nil nil nil t nil))
99 ;              (cons '(= mark gnus-ancient-mark)
100 ;                    (custom-face-lookup "SkyBlue" nil nil nil nil nil))
101
102 ;              (cons '(and (> score default) (= mark gnus-unread-mark))
103 ;                    (custom-face-lookup "white" nil nil t nil nil))
104 ;              (cons '(and (< score default) (= mark gnus-unread-mark))
105 ;                    (custom-face-lookup "white" nil nil nil t nil))
106 ;              (cons '(= mark gnus-unread-mark)
107 ;                    (custom-face-lookup "white" nil nil nil nil nil))
108
109 ;              (cons '(> score default) 'bold)
110 ;              (cons '(< score default) 'italic)))
111 ;       (t
112 ;        (list (cons '(= mark gnus-canceled-mark)
113 ;                    (custom-face-lookup "yellow" "black" nil nil nil nil))
114 ;              (cons '(and (> score default) 
115 ;                          (or (= mark gnus-dormant-mark)
116 ;                              (= mark gnus-ticked-mark)))
117 ;                    (custom-face-lookup "firebrick" nil nil t nil nil))
118 ;              (cons '(and (< score default) 
119 ;                          (or (= mark gnus-dormant-mark)
120 ;                              (= mark gnus-ticked-mark)))
121 ;                    (custom-face-lookup "firebrick" nil nil nil t nil))
122 ;              (cons '(or (= mark gnus-dormant-mark)
123 ;                         (= mark gnus-ticked-mark))
124 ;                    (custom-face-lookup "firebrick" nil nil nil nil nil))
125
126 ;              (cons '(and (> score default) (= mark gnus-ancient-mark))
127 ;                    (custom-face-lookup "RoyalBlue" nil nil t nil nil))
128 ;              (cons '(and (< score default) (= mark gnus-ancient-mark))
129 ;                    (custom-face-lookup "RoyalBlue" nil nil nil t nil))
130 ;              (cons '(= mark gnus-ancient-mark)
131 ;                    (custom-face-lookup "RoyalBlue" nil nil nil nil nil))
132
133 ;              (cons '(and (> score default) (/= mark gnus-unread-mark))
134 ;                    (custom-face-lookup "DarkGreen" nil nil t nil nil))
135 ;              (cons '(and (< score default) (/= mark gnus-unread-mark))
136 ;                    (custom-face-lookup "DarkGreen" nil nil nil t nil))
137 ;              (cons '(/= mark gnus-unread-mark)
138 ;                    (custom-face-lookup "DarkGreen" nil nil nil nil nil))
139
140 ;              (cons '(> score default) 'bold)
141 ;              (cons '(< score default) 'italic))))
142 ;  "*Alist of `(FORM . FACE)'.
143 ;Summary lines are highlighted with the FACE for the first FORM which
144 ;evaluate to a non-nil value.  
145
146 ;Point will be at the beginning of the line when FORM is evaluated.
147 ;The following can be used for convenience:
148
149 ;score:   (gnus-summary-article-score)
150 ;default: gnus-summary-default-score
151 ;below:   gnus-summary-mark-below
152 ;mark:    (gnus-summary-article-mark)
153
154 ;The latter can be used like this:
155 ;   ((= mark gnus-replied-mark) . underline)")
156
157 ;;; article highlights
158
159 ;see gnus-cus.el
160 ;(defvar gnus-header-face-alist 
161 ;  (cond ((not (eq gnus-display-type 'color))
162 ;        '(("" bold italic)))
163 ;       ((eq gnus-background-mode 'dark)
164 ;        (list (list "From" nil 
165 ;                    (custom-face-lookup "SkyBlue" nil nil t t nil))
166 ;              (list "Subject" nil 
167 ;                    (custom-face-lookup "pink" nil nil t t nil))
168 ;              (list "Newsgroups:.*," nil
169 ;                    (custom-face-lookup "yellow" nil nil t t nil))
170 ;              (list "" 
171 ;                    (custom-face-lookup "cyan" nil nil t nil nil)
172 ;                    (custom-face-lookup "green" nil nil nil t nil))))
173 ;       (t
174 ;        (list (list "From" nil 
175 ;                    (custom-face-lookup "RoyalBlue" nil nil t t nil))
176 ;              (list "Subject" nil 
177 ;                    (custom-face-lookup "firebrick" nil nil t t nil))
178 ;              (list "Newsgroups:.*," nil
179 ;                    (custom-face-lookup "red" nil nil t t nil))
180 ;              (list ""
181 ;                    (custom-face-lookup "DarkGreen" nil nil t nil nil)
182 ;                    (custom-face-lookup "DarkGreen" nil nil nil t nil)))))
183 ;  "Alist of headers and faces used for highlighting them.
184 ;The entries in the list has the form `(REGEXP NAME CONTENT)', where
185 ;REGEXP is a regular expression matching the beginning of the header,
186 ;NAME is the face used for highlighting the header name and CONTENT is
187 ;the face used for highlighting the header content. 
188
189 ;The first non-nil NAME or CONTENT with a matching REGEXP in the list
190 ;will be used.")
191
192
193 ;see gnus-cus.el
194 ;(defvar gnus-make-foreground t
195 ;  "Non nil means foreground color to highlight citations.")
196
197 ;see gnus-cus.el
198 ;(defvar gnus-article-button-face 'bold
199 ;  "Face used for text buttons.")
200
201 ;see gnus-cus.el
202 ;(defvar gnus-article-mouse-face (if (boundp 'gnus-mouse-face)
203 ;                                   gnus-mouse-face
204 ;                                 'highlight)
205 ;  "Face used when the mouse is over the button.")
206
207 ;see gnus-cus.el
208 ;(defvar gnus-signature-face 'italic
209 ;  "Face used for signature.")
210
211 (defvar gnus-button-url-regexp "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-\\wa-zA-Z0-9_=!?#$@~`%&*+|\\/.,]*[-\\wa-zA-Z0-9_=#$@~`%&*+|\\/]"
212   "*Regular expression that matches URLs.")
213
214 (defvar gnus-button-alist 
215   `(("\\bin\\( +article\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2 
216      t gnus-button-message-id 3)
217     ;; This is how URLs _should_ be embedded in text...
218     ("<URL: *\\([^\n\r>]*\\)>" 0 t gnus-button-url 1)
219     ;; Next regexp stolen from highlight-headers.el.
220     ;; Modified by Vladimir Alexiev.
221     (,gnus-button-url-regexp 0 t gnus-button-url 0)
222     ("\\(<?\\(url: \\)?news:\\([^>\n\t ]*\\)>?\\)" 1 t
223      gnus-button-message-id 3)
224     ("\\(<URL: *\\)?mailto: *\\([^ \n\t]+\\)>?" 0 t gnus-button-reply 2))
225   "Alist of regexps matching buttons in article bodies.
226
227 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
228 REGEXP: is the string matching text around the button,
229 BUTTON: is the number of the regexp grouping actually matching the button,
230 FORM: is a lisp expression which must eval to true for the button to
231 be added, 
232 CALLBACK: is the function to call when the user push this button, and each
233 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
234
235 CALLBACK can also be a variable, in that case the value of that
236 variable it the real callback function.")
237
238 (defvar gnus-header-button-alist 
239   `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
240      0 t gnus-button-message-id 0)
241     ("^\\(From\\|Reply-To\\): " ": *\\(.+\\)$" 1 t gnus-button-reply 0)
242     ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" 
243      0 t gnus-button-mailto 0)
244     ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
245     ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
246     ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
247      gnus-button-message-id 3))
248   "Alist of headers and regexps to match buttons in article heads.
249
250 This alist is very similar to `gnus-button-alist', except that each
251 alist has an additional HEADER element first in each entry:
252
253 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
254
255 HEADER is a regexp to match a header.  For a fuller explanation, see
256 `gnus-button-alist'.")
257
258 ;see gnus-cus.el
259 ;(eval-when-compile
260 ;  (defvar browse-url-browser-function))
261
262 ;;; Group mode highlighting.
263
264 ;see gnus-cus.el
265 (defvar gnus-group-highlight nil
266   "Group lines are highlighted with the FACE for the first FORM which
267 evaluate to a non-nil value.  
268
269 Point will be at the beginning of the line when FORM is evaluated.
270 Variables bound when these forms are evaluated include:
271
272 group: The group name.
273 unread: The number of unread articles.
274 method: The select method.
275 mailp: Whether the select method is a mail method.
276 level: The level of the group.
277 score: The score of the group.
278 ticked: The number of ticked articles in the group.
279 ")
280
281
282 ;;; Internal variables.
283
284 (defvar gnus-button-marker-list nil)
285
286 \f
287
288 (eval-and-compile
289   (autoload 'nnkiboze-generate-groups "nnkiboze")
290   (autoload 'gnus-cite-parse-maybe "gnus-cite" nil t))
291
292 ;;;
293 ;;; gnus-menu
294 ;;;
295
296 (defun gnus-visual-turn-off-edit-menu (type)
297   (define-key (symbol-value (intern (format "gnus-%s-mode-map" type)))
298     [menu-bar edit] 'undefined))
299
300 ;; Newsgroup buffer
301
302 (defun gnus-group-make-menu-bar ()
303   (gnus-visual-turn-off-edit-menu 'group)
304   (or 
305    (boundp 'gnus-group-reading-menu)
306    (progn
307      (easy-menu-define
308       gnus-group-reading-menu gnus-group-mode-map ""
309       '("Group"
310         ["Read" gnus-group-read-group (gnus-group-group-name)]
311         ["Select" gnus-group-select-group (gnus-group-group-name)]
312         ["See old articles" (gnus-group-select-group 'all)
313          :keys "C-u SPC" :active (gnus-group-group-name)]
314         ["Catch up" gnus-group-catchup-current (gnus-group-group-name)]
315         ["Catch up all articles" gnus-group-catchup-current-all
316          (gnus-group-group-name)]
317         ["Check for new articles" gnus-group-get-new-news-this-group
318          (gnus-group-group-name)]
319         ["Toggle subscription" gnus-group-unsubscribe-current-group
320          (gnus-group-group-name)]
321         ["Kill" gnus-group-kill-group (gnus-group-group-name)]
322         ["Yank" gnus-group-yank-group gnus-list-of-killed-groups]
323         ["Describe" gnus-group-describe-group (gnus-group-group-name)]
324         ["Fetch FAQ" gnus-group-fetch-faq (gnus-group-group-name)]
325         ["Edit kill file" gnus-group-edit-local-kill
326          (gnus-group-group-name)]
327         ;; Actually one should check, if any of the marked groups gives t for
328         ;; (gnus-check-backend-function 'request-expire-articles ...)
329         ["Expire articles" gnus-group-expire-articles
330          (or (and (gnus-group-group-name)
331                   (gnus-check-backend-function
332                    'request-expire-articles
333                    (gnus-group-group-name))) gnus-group-marked)]
334         ["Set group level" gnus-group-set-current-level
335          (gnus-group-group-name)]
336         ["Select quick" gnus-group-quick-select-group (gnus-group-group-name)]
337         ))
338   
339      (easy-menu-define
340       gnus-group-group-menu gnus-group-mode-map ""
341       '("Groups"
342         ("Listing"
343          ["List subscribed groups" gnus-group-list-groups t]
344          ["List all groups" gnus-group-list-all-groups t]
345          ["List killed groups" gnus-group-list-killed gnus-killed-list]
346          ["List zombie groups" gnus-group-list-zombies gnus-zombie-list]
347          ["List level..." gnus-group-list-level t]
348          ["Describe all groups" gnus-group-describe-all-groups t]
349          ["Group apropos..." gnus-group-apropos t]
350          ["Group and description apropos..." gnus-group-description-apropos t]
351          ["List groups matching..." gnus-group-list-matching t]
352          ["List all groups matching..." gnus-group-list-all-matching t]
353          ["List active file" gnus-group-list-active t])
354         ("Sort"
355          ["Default sort" gnus-group-sort-groups
356           (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
357          ["Sort by method" gnus-group-sort-groups-by-method
358           (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
359          ["Sort by rank" gnus-group-sort-groups-by-rank
360           (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
361          ["Sort by score" gnus-group-sort-groups-by-score
362           (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
363          ["Sort by level" gnus-group-sort-groups-by-level
364           (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
365          ["Sort by unread" gnus-group-sort-groups-by-unread
366           (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))]
367          ["Sort by name" gnus-group-sort-groups-by-alphabet
368           (or (not (boundp 'gnus-topic-mode)) (not gnus-topic-mode))])
369         ("Mark"
370          ["Mark group" gnus-group-mark-group
371           (and (gnus-group-group-name)
372                (not (memq (gnus-group-group-name) gnus-group-marked)))]
373          ["Unmark group" gnus-group-unmark-group
374           (and (gnus-group-group-name)
375                (memq (gnus-group-group-name) gnus-group-marked))]
376          ["Unmark all" gnus-group-unmark-all-groups gnus-group-marked]
377          ["Mark regexp..." gnus-group-mark-regexp t]
378          ["Mark region" gnus-group-mark-region t]
379          ["Mark buffer" gnus-group-mark-buffer t]
380          ["Execute command" gnus-group-universal-argument
381           (or gnus-group-marked (gnus-group-group-name))])
382         ("Subscribe"
383          ["Subscribe to random group" gnus-group-unsubscribe-group t]
384          ["Kill all newsgroups in region" gnus-group-kill-region t]
385          ["Kill all zombie groups" gnus-group-kill-all-zombies
386           gnus-zombie-list]
387          ["Kill all groups on level..." gnus-group-kill-level t])
388         ("Foreign groups"
389          ["Make a foreign group" gnus-group-make-group t]
390          ["Add a directory group" gnus-group-make-directory-group t]
391          ["Add the help group" gnus-group-make-help-group t]
392          ["Add the archive group" gnus-group-make-archive-group t]
393          ["Make a doc group" gnus-group-make-doc-group t]
394          ["Make a kiboze group" gnus-group-make-kiboze-group t]
395          ["Make a virtual group" gnus-group-make-empty-virtual t]
396          ["Add a group to a virtual" gnus-group-add-to-virtual t]
397          ["Rename group" gnus-group-rename-group
398           (gnus-check-backend-function
399            'request-rename-group (gnus-group-group-name))]
400          ["Delete group" gnus-group-delete-group
401           (gnus-check-backend-function
402            'request-delete-group (gnus-group-group-name))])
403         ("Editing groups"
404          ["Parameters" gnus-group-edit-group-parameters
405           (gnus-group-group-name)]
406          ["Select method" gnus-group-edit-group-method
407           (gnus-group-group-name)]
408          ["Info" gnus-group-edit-group (gnus-group-group-name)])
409         ("Score file"
410          ["Flush cache" gnus-score-flush-cache
411           (or gnus-score-cache gnus-short-name-score-file-cache)])
412         ("Move"
413          ["Next" gnus-group-next-group t]
414          ["Previous" gnus-group-prev-group t]
415          ["Next unread" gnus-group-next-unread-group t]
416          ["Previous unread" gnus-group-prev-unread-group t]
417          ["Next unread same level" gnus-group-next-unread-group-same-level t]
418          ["Previous unread same level"
419           gnus-group-previous-unread-group-same-level t]
420          ["Jump to group" gnus-group-jump-to-group t]
421          ["First unread group" gnus-group-first-unread-group t]
422          ["Best unread group" gnus-group-best-unread-group t])
423         ["Transpose" gnus-group-transpose-groups
424          (gnus-group-group-name)]
425         ["Read a directory as a group..." gnus-group-enter-directory t]
426         ))
427
428      (easy-menu-define
429       gnus-group-misc-menu gnus-group-mode-map ""
430       '("Misc"
431         ["Send a bug report" gnus-bug t]
432         ["Send a mail" gnus-group-mail t]
433         ["Post an article..." gnus-group-post-news t]
434         ["Customize score file" gnus-score-customize 
435          (not (string-match "XEmacs" emacs-version))]
436         ["Check for new news" gnus-group-get-new-news t]     
437         ["Activate all groups" gnus-activate-all-groups t]
438         ["Delete bogus groups" gnus-group-check-bogus-groups t]
439         ["Find new newsgroups" gnus-find-new-newsgroups t]
440         ["Restart Gnus" gnus-group-restart t]
441         ["Read init file" gnus-group-read-init-file t]
442         ["Browse foreign server" gnus-group-browse-foreign-server t]
443         ["Enter server buffer" gnus-group-enter-server-mode t]
444         ["Expire all expirable articles" gnus-group-expire-all-groups t]
445         ["Generate any kiboze groups" nnkiboze-generate-groups t]
446         ["Gnus version" gnus-version t]
447         ["Save .newsrc files" gnus-group-save-newsrc t]
448         ["Suspend Gnus" gnus-group-suspend t]
449         ["Clear dribble buffer" gnus-group-clear-dribble t]
450         ["Exit from Gnus" gnus-group-exit t]
451         ["Exit without saving" gnus-group-quit t]
452         ["Edit global kill file" gnus-group-edit-global-kill t]
453         ["Read manual" gnus-info-find-node t]
454         ["Toggle topics" gnus-topic-mode t]
455         ("SOUP"
456          ["Pack replies" nnsoup-pack-replies (fboundp 'nnsoup-request-group)]
457          ["Send replies" gnus-soup-send-replies
458           (fboundp 'gnus-soup-pack-packet)]
459          ["Pack packet" gnus-soup-pack-packet (fboundp 'gnus-soup-pack-packet)]
460          ["Save areas" gnus-soup-save-areas (fboundp 'gnus-soup-pack-packet)]
461          ["Brew SOUP" gnus-soup-brew-soup (fboundp 'gnus-soup-pack-packet)])
462         ))
463      (run-hooks 'gnus-group-menu-hook)
464      )))
465
466 ;; Summary buffer
467 (defun gnus-summary-make-menu-bar ()
468   (gnus-visual-turn-off-edit-menu 'summary)
469
470   (unless (boundp 'gnus-summary-misc-menu)
471
472     (easy-menu-define
473      gnus-summary-misc-menu gnus-summary-mode-map ""
474      '("Misc"
475        ("Mark"
476         ("Read"
477          ["Mark as read" gnus-summary-mark-as-read-forward t]
478          ["Mark same subject and select"
479           gnus-summary-kill-same-subject-and-select t]
480          ["Mark same subject" gnus-summary-kill-same-subject t]
481          ["Catchup" gnus-summary-catchup t]
482          ["Catchup all" gnus-summary-catchup-all t]
483          ["Catchup to here" gnus-summary-catchup-to-here t]
484          ["Catchup region" gnus-summary-mark-region-as-read t]
485          ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
486         ("Various"
487          ["Tick" gnus-summary-tick-article-forward t]
488          ["Mark as dormant" gnus-summary-mark-as-dormant t]
489          ["Remove marks" gnus-summary-clear-mark-forward t]
490          ["Set expirable mark" gnus-summary-mark-as-expirable t]
491          ["Set bookmark" gnus-summary-set-bookmark t]
492          ["Remove bookmark" gnus-summary-remove-bookmark t])
493         ("Limit"
494          ["Marks..." gnus-summary-limit-to-marks t]
495          ["Subject..." gnus-summary-limit-to-subject t]
496          ["Author..." gnus-summary-limit-to-author t]
497          ["Score" gnus-summary-limit-to-score t]
498          ["Unread" gnus-summary-limit-to-unread t]
499          ["Non-dormant" gnus-summary-limit-exclude-dormant t]
500          ["Articles" gnus-summary-limit-to-articles t]
501          ["Pop limit" gnus-summary-pop-limit t]
502          ["Show dormant" gnus-summary-limit-include-dormant t]
503          ["Hide childless dormant" 
504           gnus-summary-limit-exclude-childless-dormant t]
505          ;;["Hide thread" gnus-summary-limit-exclude-thread t]
506          ["Show expunged" gnus-summary-show-all-expunged t])
507         ("Process mark"
508          ["Set mark" gnus-summary-mark-as-processable t]
509          ["Remove mark" gnus-summary-unmark-as-processable t]
510          ["Remove all marks" gnus-summary-unmark-all-processable t]
511          ["Mark above" gnus-uu-mark-over t]
512          ["Mark series" gnus-uu-mark-series t]
513          ["Mark region" gnus-uu-mark-region t]
514          ["Mark by regexp..." gnus-uu-mark-by-regexp t]
515          ["Mark all" gnus-uu-mark-all t]
516          ["Mark buffer" gnus-uu-mark-buffer t]
517          ["Mark sparse" gnus-uu-mark-sparse t]
518          ["Mark thread" gnus-uu-mark-thread t]
519          ["Unmark thread" gnus-uu-unmark-thread t]))
520        ("Scroll article"
521         ["Page forward" gnus-summary-next-page t]
522         ["Page backward" gnus-summary-prev-page t]
523         ["Line forward" gnus-summary-scroll-up t])
524        ("Move"
525         ["Next unread article" gnus-summary-next-unread-article t]
526         ["Previous unread article" gnus-summary-prev-unread-article t]
527         ["Next article" gnus-summary-next-article t]
528         ["Previous article" gnus-summary-prev-article t]
529         ["Next unread subject" gnus-summary-next-unread-subject t]
530         ["Previous unread subject" gnus-summary-prev-unread-subject t]
531         ["Next article same subject" gnus-summary-next-same-subject t]
532         ["Previous article same subject" gnus-summary-prev-same-subject t]
533         ["First unread article" gnus-summary-first-unread-article t]
534         ["Best unread article" gnus-summary-best-unread-article t]
535         ["Go to subject number..." gnus-summary-goto-subject t]
536         ["Go to article number..." gnus-summary-goto-article t]
537         ["Go to the last article" gnus-summary-goto-last-article t]
538         ["Pop article off history" gnus-summary-pop-article t]) 
539        ("Sort"
540         ["Sort by number" gnus-summary-sort-by-number t]
541         ["Sort by author" gnus-summary-sort-by-author t]
542         ["Sort by subject" gnus-summary-sort-by-subject t]
543         ["Sort by date" gnus-summary-sort-by-date t]
544         ["Sort by score" gnus-summary-sort-by-score t])
545        ("Exit"
546         ["Catchup and exit" gnus-summary-catchup-and-exit t]
547         ["Catchup all and exit" gnus-summary-catchup-and-exit t]
548         ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
549         ["Exit group" gnus-summary-exit t]
550         ["Exit group without updating" gnus-summary-exit-no-update t]
551         ["Exit and goto next group" gnus-summary-next-group t]
552         ["Exit and goto prev group" gnus-summary-prev-group t]
553         ["Reselect group" gnus-summary-reselect-current-group t]
554         ["Rescan group" gnus-summary-rescan-group t])
555        ("Help"
556         ["Fetch group FAQ" gnus-summary-fetch-faq t]
557         ["Describe group" gnus-summary-describe-group t]
558         ["Read manual" gnus-info-find-node t])
559        ("Cache"
560         ["Enter article" gnus-cache-enter-article t]
561         ["Remove article" gnus-cache-remove-article t])
562        ("Modes"
563         ["Pick and read" gnus-pick-mode t]
564         ["Binary" gnus-binary-mode t])
565        ["Filter articles..." gnus-summary-execute-command t]
566        ["Run command on subjects..." gnus-summary-universal-argument t]
567        ["Toggle line truncation" gnus-summary-toggle-truncation t]
568        ["Expand window" gnus-summary-expand-window t]
569        ["Expire expirable articles" gnus-summary-expire-articles
570         (gnus-check-backend-function
571          'request-expire-articles gnus-newsgroup-name)]
572        ["Edit local kill file" gnus-summary-edit-local-kill t]
573        ["Edit main kill file" gnus-summary-edit-global-kill t]
574        ))
575
576     (easy-menu-define
577      gnus-summary-kill-menu gnus-summary-mode-map ""
578      (cons
579       "Score"
580       (nconc
581        (list
582         ["Enter score..." gnus-summary-score-entry t])
583        (gnus-visual-score-map 'increase)
584        (gnus-visual-score-map 'lower)
585        '(("Mark"
586           ["Kill below" gnus-summary-kill-below t]
587           ["Mark above" gnus-summary-mark-above t]
588           ["Tick above" gnus-summary-tick-above t]
589           ["Clear above" gnus-summary-clear-above t])
590          ["Current score" gnus-summary-current-score t]
591          ["Set score" gnus-summary-set-score t]
592          ["Customize score file" gnus-score-customize t]
593          ["Switch current score file..." gnus-score-change-score-file t]
594          ["Set mark below..." gnus-score-set-mark-below t]
595          ["Set expunge below..." gnus-score-set-expunge-below t]
596          ["Edit current score file" gnus-score-edit-current-scores t]
597          ["Edit score file" gnus-score-edit-file t]
598          ["Trace score" gnus-score-find-trace t]
599          ["Rescore buffer" gnus-summary-rescore t]
600          ["Increase score..." gnus-summary-increase-score t]
601          ["Lower score..." gnus-summary-lower-score t]))))
602
603     '(("Default header"
604        ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
605         :style radio 
606         :selected (null gnus-score-default-header)]
607        ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
608         :style radio 
609         :selected (eq gnus-score-default-header 'a)]
610        ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
611         :style radio 
612         :selected (eq gnus-score-default-header 's)]
613        ["Article body"
614         (gnus-score-set-default 'gnus-score-default-header 'b)
615         :style radio 
616         :selected (eq gnus-score-default-header 'b )]
617        ["All headers"
618         (gnus-score-set-default 'gnus-score-default-header 'h)
619         :style radio 
620         :selected (eq gnus-score-default-header 'h )]
621        ["Message-Id" (gnus-score-set-default 'gnus-score-default-header 'i)
622         :style radio 
623         :selected (eq gnus-score-default-header 'i )]
624        ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
625         :style radio 
626         :selected (eq gnus-score-default-header 't )]
627        ["Crossposting"
628         (gnus-score-set-default 'gnus-score-default-header 'x)
629         :style radio 
630         :selected (eq gnus-score-default-header 'x )]
631        ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
632         :style radio 
633         :selected (eq gnus-score-default-header 'l )]
634        ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
635         :style radio 
636         :selected (eq gnus-score-default-header 'd )]
637        ["Followups to author"
638         (gnus-score-set-default 'gnus-score-default-header 'f)
639         :style radio 
640         :selected (eq gnus-score-default-header 'f )])
641       ("Default type"
642        ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
643         :style radio 
644         :selected (null gnus-score-default-type)]
645        ;; The `:active' key is commented out in the following,
646        ;; because the GNU Emacs hack to support radio buttons use
647        ;; active to indicate which button is selected.  
648        ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
649         :style radio 
650         ;; :active (not (memq gnus-score-default-header '(l d)))
651         :selected (eq gnus-score-default-type 's)]
652        ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
653         :style radio
654         ;; :active (not (memq gnus-score-default-header '(l d)))
655         :selected (eq gnus-score-default-type 'r)]
656        ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
657         :style radio
658         ;; :active (not (memq gnus-score-default-header '(l d)))
659         :selected (eq gnus-score-default-type 'e)]
660        ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
661         :style radio 
662         ;; :active (not (memq gnus-score-default-header '(l d)))
663         :selected (eq gnus-score-default-type 'f)]
664        ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
665         :style radio 
666         ;; :active (eq (gnus-score-default-header 'd))
667         :selected (eq gnus-score-default-type 'b)]
668        ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
669         :style radio 
670         ;; :active (eq (gnus-score-default-header 'd))
671         :selected (eq gnus-score-default-type 'n)]
672        ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
673         :style radio 
674         ;; :active (eq (gnus-score-default-header 'd))
675         :selected (eq gnus-score-default-type 'a)]
676        ["Less than number"
677         (gnus-score-set-default 'gnus-score-default-type '<)
678         :style radio 
679         ;; :active (eq (gnus-score-default-header 'l))
680         :selected (eq gnus-score-default-type '<)]
681        ["Equal to number"
682         (gnus-score-set-default 'gnus-score-default-type '=)
683         :style radio 
684         ;; :active (eq (gnus-score-default-header 'l))
685         :selected (eq gnus-score-default-type '=)]
686        ["Greater than number" 
687         (gnus-score-set-default 'gnus-score-default-type '>)
688         :style radio 
689         ;; :active (eq (gnus-score-default-header 'l))
690         :selected (eq gnus-score-default-type '>)])
691       ["Default fold" gnus-score-default-fold-toggle
692        :style toggle
693        :selected gnus-score-default-fold]
694       ("Default duration"
695        ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
696         :style radio
697         :selected (null gnus-score-default-duration)]
698        ["Permanent"
699         (gnus-score-set-default 'gnus-score-default-duration 'p)
700         :style radio
701         :selected (eq gnus-score-default-duration 'p)]
702        ["Temporary"
703         (gnus-score-set-default 'gnus-score-default-duration 't)
704         :style radio
705         :selected (eq gnus-score-default-duration 't)]
706        ["Immediate" 
707         (gnus-score-set-default 'gnus-score-default-duration 'i)
708         :style radio
709         :selected (eq gnus-score-default-duration 'i)]))
710
711     (easy-menu-define
712      gnus-summary-article-menu gnus-summary-mode-map ""
713      '("Article"
714        ("Hide"
715         ["All" gnus-article-hide t]
716         ["Headers" gnus-article-hide-headers t]
717         ["Signature" gnus-article-hide-signature t]
718         ["Citation" gnus-article-hide-citation t]
719         ["PGP" gnus-article-hide-pgp t]
720         ["Boring headers" gnus-article-hide-boring-headers t])
721        ("Highlight"
722         ["All" gnus-article-highlight t]
723         ["Headers" gnus-article-highlight-headers t]
724         ["Signature" gnus-article-highlight-signature t]
725         ["Citation" gnus-article-highlight-citation t])
726        ("Date"
727         ["Local" gnus-article-date-local t]
728         ["UT" gnus-article-date-ut t]
729         ["Original" gnus-article-date-original t]
730         ["Lapsed" gnus-article-date-lapsed t])
731        ("Filter"
732         ["Overstrike" gnus-article-treat-overstrike t]
733         ["Word wrap" gnus-article-fill-cited-article t]
734         ["CR" gnus-article-remove-cr t]
735         ["Trailing blank lines" gnus-article-remove-trailing-blank-lines t]
736         ["Show X-Face" gnus-article-display-x-face t]
737         ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
738         ["Rot 13" gnus-summary-caesar-message t]
739         ["Add buttons" gnus-article-add-buttons t]
740         ["Add buttons to head" gnus-article-add-buttons-to-head t]
741         ["Stop page breaking" gnus-summary-stop-page-breaking t]
742         ["Toggle MIME" gnus-summary-toggle-mime t]
743         ["Verbose header" gnus-summary-verbose-headers t]
744         ["Toggle header" gnus-summary-toggle-header t])
745        ("Output"
746         ["Save in default format" gnus-summary-save-article t]
747         ["Save in file" gnus-summary-save-article-file t]
748         ["Save in Unix mail format" gnus-summary-save-article-mail t]
749         ["Save in MH folder" gnus-summary-save-article-folder t]
750         ["Save in VM folder" gnus-summary-save-article-vm t]
751         ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
752         ["Save body in file" gnus-summary-save-article-body-file t]
753         ["Pipe through a filter" gnus-summary-pipe-output t]
754         ["Add to SOUP packet" gnus-soup-add-article t])
755        ("Backend"
756         ["Respool article..." gnus-summary-respool-article t]
757         ["Move article..." gnus-summary-move-article
758          (gnus-check-backend-function
759           'request-move-article gnus-newsgroup-name)]
760         ["Copy article..." gnus-summary-copy-article t]
761         ["Crosspost article..." gnus-summary-crosspost-article
762          (gnus-check-backend-function
763           'request-replace-article gnus-newsgroup-name)]
764         ["Import file..." gnus-summary-import-article t]
765         ["Edit article" gnus-summary-edit-article
766          (not (gnus-group-read-only-p))]
767         ["Delete article" gnus-summary-delete-article
768          (gnus-check-backend-function
769           'request-expire-articles gnus-newsgroup-name)]
770         ["Query respool" gnus-summary-respool-query t]
771         ["Delete expirable articles" gnus-summary-expire-articles-now
772          (gnus-check-backend-function
773           'request-expire-articles gnus-newsgroup-name)])
774        ("Extract"
775         ["Uudecode" gnus-uu-decode-uu t]
776         ["Uudecode and save" gnus-uu-decode-uu-and-save t]
777         ["Unshar" gnus-uu-decode-unshar t]
778         ["Unshar and save" gnus-uu-decode-unshar-and-save t]
779         ["Save" gnus-uu-decode-save t]
780         ["Binhex" gnus-uu-decode-binhex t]
781         ["Postscript" gnus-uu-decode-postscript t])
782        ["Enter digest buffer" gnus-summary-enter-digest-group t]
783        ["Isearch article..." gnus-summary-isearch-article t]
784        ["Search articles forward..." gnus-summary-search-article-forward t]
785        ["Search articles backward..." gnus-summary-search-article-backward t]
786        ["Beginning of the article" gnus-summary-beginning-of-article t]
787        ["End of the article" gnus-summary-end-of-article t]
788        ["Fetch parent of article" gnus-summary-refer-parent-article t]
789        ["Fetch referenced articles" gnus-summary-refer-references t]
790        ["Fetch article with id..." gnus-summary-refer-article t]
791        ["Redisplay" gnus-summary-show-article t]))
792
793
794          
795     (easy-menu-define
796      gnus-summary-thread-menu gnus-summary-mode-map ""
797      '("Threads"
798        ["Toggle threading" gnus-summary-toggle-threads t]
799        ["Hide threads" gnus-summary-hide-all-threads t]
800        ["Show threads" gnus-summary-show-all-threads t]
801        ["Hide thread" gnus-summary-hide-thread t]
802        ["Show thread" gnus-summary-show-thread t]
803        ["Go to next thread" gnus-summary-next-thread t]
804        ["Go to previous thread" gnus-summary-prev-thread t]
805        ["Go down thread" gnus-summary-down-thread t]
806        ["Go up thread" gnus-summary-up-thread t]
807        ["Top of thread" gnus-summary-top-thread t]
808        ["Mark thread as read" gnus-summary-kill-thread t]
809        ["Lower thread score" gnus-summary-lower-thread t]
810        ["Raise thread score" gnus-summary-raise-thread t]
811        ["Rethread current" gnus-summary-rethread-current t]
812        ))
813
814     (easy-menu-define
815      gnus-summary-post-menu gnus-summary-mode-map ""
816      '("Post"
817        ["Post an article" gnus-summary-post-news t]
818        ["Followup" gnus-summary-followup t]
819        ["Followup and yank" gnus-summary-followup-with-original t]
820        ["Supersede article" gnus-summary-supersede-article t]
821        ["Cancel article" gnus-summary-cancel-article t]
822        ["Reply" gnus-summary-reply t]
823        ["Reply and yank" gnus-summary-reply-with-original t]
824        ["Mail forward" gnus-summary-mail-forward t]
825        ["Post forward" gnus-summary-post-forward t]
826        ["Digest and mail" gnus-uu-digest-mail-forward t]
827        ["Digest and post" gnus-uu-digest-post-forward t]
828        ["Resend message" gnus-summary-resend-message t]
829        ["Send bounced mail" gnus-summary-resend-bounced-mail t]
830        ["Send a mail" gnus-summary-mail-other-window t]
831        ["Uuencode and post" gnus-uu-post-news t]
832        ;;("Draft"
833        ;;["Send" gnus-summary-send-draft t]
834        ;;["Send bounced" gnus-resend-bounced-mail t])
835        ))
836     (run-hooks 'gnus-summary-menu-hook)
837     ))
838
839 (defun gnus-score-set-default (var value)
840   "A version of set that updates the GNU Emacs menu-bar."
841   (set var value)
842   ;; It is the message that forces the active status to be updated.
843   (message ""))
844
845 (defun gnus-visual-score-map (type)
846   (if t
847       nil
848     (let ((headers '(("author" "from" string)
849                      ("subject" "subject" string)
850                      ("article body" "body" string)
851                      ("article head" "head" string)
852                      ("xref" "xref" string)
853                      ("lines" "lines" number)
854                      ("followups to author" "followup" string)))
855           (types '((number ("less than" <)
856                            ("greater than" >)
857                            ("equal" =))
858                    (string ("substring" s)
859                            ("exact string" e)
860                            ("fuzzy string" f)
861                            ("regexp" r))))
862           (perms '(("temporary" (current-time-string))
863                    ("permanent" nil)
864                    ("immediate" now)))
865           header)
866       (list 
867        (apply 
868         'nconc
869         (list
870          (if (eq type 'lower)
871              "Lower score"
872            "Increase score"))
873         (let (outh)
874           (while headers
875             (setq header (car headers))
876             (setq outh 
877                   (cons 
878                    (apply 
879                     'nconc
880                     (list (car header))
881                     (let ((ts (cdr (assoc (nth 2 header) types)))
882                           outt)
883                       (while ts
884                         (setq outt
885                               (cons 
886                                (apply 
887                                 'nconc
888                                 (list (caar ts))
889                                 (let ((ps perms)
890                                       outp)
891                                   (while ps
892                                     (setq outp
893                                           (cons
894                                            (vector
895                                             (caar ps) 
896                                             (list
897                                              'gnus-summary-score-entry
898                                              (nth 1 header)
899                                              (if (or (string= (nth 1 header) 
900                                                               "head")
901                                                      (string= (nth 1 header)
902                                                               "body"))
903                                                  ""
904                                                (list 'gnus-summary-header 
905                                                      (nth 1 header)))
906                                              (list 'quote (nth 1 (car ts)))
907                                              (list 'gnus-score-default nil)
908                                              (nth 1 (car ps))
909                                              t)
910                                             t)
911                                            outp))
912                                     (setq ps (cdr ps)))
913                                   (list (nreverse outp))))
914                                outt))
915                         (setq ts (cdr ts)))
916                       (list (nreverse outt))))
917                    outh))
918             (setq headers (cdr headers)))
919           (list (nreverse outh))))))))
920  
921 ;; Article buffer
922 (defun gnus-article-make-menu-bar ()
923   (gnus-visual-turn-off-edit-menu 'summary)
924   (or
925    (boundp 'gnus-article-article-menu)
926    (progn
927      (easy-menu-define
928       gnus-article-article-menu gnus-article-mode-map ""
929       '("Article"
930         ["Scroll forwards" gnus-article-goto-next-page t]
931         ["Scroll backwards" gnus-article-goto-prev-page t]
932         ["Show summary" gnus-article-show-summary t]
933         ["Fetch Message-ID at point" gnus-article-refer-article t]
934         ["Mail to address at point" gnus-article-mail t]
935         ))
936
937      (easy-menu-define
938       gnus-article-treatment-menu gnus-article-mode-map ""
939       '("Treatment"
940         ["Hide headers" gnus-article-hide-headers t]
941         ["Hide signature" gnus-article-hide-signature t]
942         ["Hide citation" gnus-article-hide-citation t]
943         ["Treat overstrike" gnus-article-treat-overstrike t]
944         ["Remove carriage return" gnus-article-remove-cr t]
945         ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
946         ))
947      (run-hooks 'gnus-article-menu-hook))))
948
949 ;;;
950 ;;; summary highlights
951 ;;;
952
953 (defun gnus-highlight-selected-summary ()
954   ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
955   ;; Highlight selected article in summary buffer
956   (if gnus-summary-selected-face
957       (save-excursion
958         (let* ((beg (progn (beginning-of-line) (point)))
959                (end (progn (end-of-line) (point)))
960                ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
961                (from (if (get-text-property beg gnus-mouse-face-prop) 
962                          beg
963                        (1+ (or (next-single-property-change 
964                                 beg gnus-mouse-face-prop nil end) 
965                                beg))))
966                (to (1- (or (next-single-property-change
967                             from gnus-mouse-face-prop nil end)
968                            end))))
969           ;; If no mouse-face prop on line (e.g. xemacs) we 
970           ;; will have to = from = end, so we highlight the
971           ;; entire line instead.
972           (if (= (+ to 2) from)
973               (progn
974                 (setq from beg)
975                 (setq to end)))
976           (if gnus-newsgroup-selected-overlay
977               (gnus-move-overlay gnus-newsgroup-selected-overlay 
978                                  from to (current-buffer))
979             (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
980             (gnus-overlay-put gnus-newsgroup-selected-overlay 'face 
981                               gnus-summary-selected-face))))))
982
983 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
984 (defun gnus-summary-highlight-line ()
985   "Highlight current line according to `gnus-summary-highlight'."
986   (let* ((list gnus-summary-highlight)
987          (p (point))
988          (end (progn (end-of-line) (point)))
989          ;; now find out where the line starts and leave point there.
990          (beg (progn (beginning-of-line) (point)))
991          (article (gnus-summary-article-number))
992          (score (or (cdr (assq (or article gnus-current-article)
993                                gnus-newsgroup-scored))
994                     gnus-summary-default-score 0))
995          (default gnus-summary-default-score)
996          (mark (or (gnus-summary-article-mark) gnus-unread-mark))
997          (inhibit-read-only t))
998     ;; Eval the cars of the lists until we find a match.
999     (while (and list
1000                 (not (eval (caar list))))
1001       (setq list (cdr list)))
1002     (let ((face (cdar list)))
1003       (unless (eq face (get-text-property beg 'face))
1004         (gnus-put-text-property 
1005          beg end 'face 
1006          (setq face (if (boundp face) (symbol-value face) face)))
1007         (when gnus-summary-highlight-line-function
1008           (funcall gnus-summary-highlight-line-function article face))))
1009     (goto-char p)))
1010
1011 (defun gnus-group-highlight-line ()
1012   "Highlight the current line according to `gnus-group-highlight'."
1013   (let* ((list gnus-group-highlight)
1014          (p (point))
1015          (end (progn (end-of-line) (point)))
1016          ;; now find out where the line starts and leave point there.
1017          (beg (progn (beginning-of-line) (point)))
1018          (group (gnus-group-group-name))
1019          (entry (gnus-group-entry group))
1020          (unread (if (numberp (car entry)) (car entry) 0))
1021          (info (nth 2 entry))
1022          (method (gnus-server-get-method group (gnus-info-method info)))
1023          (marked (gnus-info-marks info))
1024          (mailp (memq 'mail (assoc (symbol-name
1025                                     (car (or method gnus-select-method)))
1026                                    gnus-valid-select-methods)))
1027          (level (or (gnus-info-level info) 9))
1028          (score (or (gnus-info-score info) 0))
1029          (ticked (gnus-range-length (cdr (assq 'tick marked))))
1030          (inhibit-read-only t))
1031     ;; Eval the cars of the lists until we find a match.
1032     (while (and list
1033                 (not (eval (caar list))))
1034       (setq list (cdr list)))
1035     (let ((face (cdar list)))
1036       (unless (eq face (get-text-property beg 'face))
1037         (gnus-put-text-property 
1038          beg end 'face 
1039          (setq face (if (boundp face) (symbol-value face) face)))
1040         (gnus-extent-start-open beg)))
1041     (goto-char p)))
1042
1043 ;;;
1044 ;;; gnus-carpal
1045 ;;;
1046
1047 (defvar gnus-carpal-group-buffer-buttons
1048   '(("next" . gnus-group-next-unread-group)
1049     ("prev" . gnus-group-prev-unread-group)
1050     ("read" . gnus-group-read-group)
1051     ("select" . gnus-group-select-group)
1052     ("catch-up" . gnus-group-catchup-current)
1053     ("new-news" . gnus-group-get-new-news-this-group)
1054     ("toggle-sub" . gnus-group-unsubscribe-current-group)
1055     ("subscribe" . gnus-group-unsubscribe-group)
1056     ("kill" . gnus-group-kill-group)
1057     ("yank" . gnus-group-yank-group)
1058     ("describe" . gnus-group-describe-group)
1059     "list"
1060     ("subscribed" . gnus-group-list-groups)
1061     ("all" . gnus-group-list-all-groups)
1062     ("killed" . gnus-group-list-killed)
1063     ("zombies" . gnus-group-list-zombies)
1064     ("matching" . gnus-group-list-matching)
1065     ("post" . gnus-group-post-news)
1066     ("mail" . gnus-group-mail)
1067     ("rescan" . gnus-group-get-new-news)
1068     ("browse-foreign" . gnus-group-browse-foreign)
1069     ("exit" . gnus-group-exit)))
1070
1071 (defvar gnus-carpal-summary-buffer-buttons
1072   '("mark" 
1073     ("read" . gnus-summary-mark-as-read-forward)
1074     ("tick" . gnus-summary-tick-article-forward)
1075     ("clear" . gnus-summary-clear-mark-forward)
1076     ("expirable" . gnus-summary-mark-as-expirable)
1077     "move"
1078     ("scroll" . gnus-summary-next-page)
1079     ("next-unread" . gnus-summary-next-unread-article)
1080     ("prev-unread" . gnus-summary-prev-unread-article)
1081     ("first" . gnus-summary-first-unread-article)
1082     ("best" . gnus-summary-best-unread-article)
1083     "article"
1084     ("headers" . gnus-summary-toggle-header)
1085     ("uudecode" . gnus-uu-decode-uu)
1086     ("enter-digest" . gnus-summary-enter-digest-group)
1087     ("fetch-parent" . gnus-summary-refer-parent-article)
1088     "mail"
1089     ("move" . gnus-summary-move-article)
1090     ("copy" . gnus-summary-copy-article)
1091     ("respool" . gnus-summary-respool-article)
1092     "threads"
1093     ("lower" . gnus-summary-lower-thread)
1094     ("kill" . gnus-summary-kill-thread)
1095     "post"
1096     ("post" . gnus-summary-post-news)
1097     ("mail" . gnus-summary-mail)
1098     ("followup" . gnus-summary-followup-with-original)
1099     ("reply" . gnus-summary-reply-with-original)
1100     ("cancel" . gnus-summary-cancel-article)
1101     "misc"
1102     ("exit" . gnus-summary-exit)
1103     ("fed-up" . gnus-summary-catchup-and-goto-next-group)))
1104
1105 (defvar gnus-carpal-server-buffer-buttons 
1106   '(("add" . gnus-server-add-server)
1107     ("browse" . gnus-server-browse-server)
1108     ("list" . gnus-server-list-servers)
1109     ("kill" . gnus-server-kill-server)
1110     ("yank" . gnus-server-yank-server)
1111     ("copy" . gnus-server-copy-server)
1112     ("exit" . gnus-server-exit)))
1113
1114 (defvar gnus-carpal-browse-buffer-buttons
1115   '(("subscribe" . gnus-browse-unsubscribe-current-group)
1116     ("exit" . gnus-browse-exit)))
1117
1118 (defvar gnus-carpal-group-buffer "*Carpal Group*")
1119 (defvar gnus-carpal-summary-buffer "*Carpal Summary*")
1120 (defvar gnus-carpal-server-buffer "*Carpal Server*")
1121 (defvar gnus-carpal-browse-buffer "*Carpal Browse*")
1122
1123 (defvar gnus-carpal-attached-buffer nil)
1124
1125 (defvar gnus-carpal-mode-hook nil
1126   "*Hook run in carpal mode buffers.")
1127
1128 (defvar gnus-carpal-button-face 'bold
1129   "*Face used on carpal buttons.")
1130
1131 (defvar gnus-carpal-header-face 'bold-italic
1132   "*Face used on carpal buffer headers.")
1133
1134 (defvar gnus-carpal-mode-map nil)
1135 (put 'gnus-carpal-mode 'mode-class 'special)
1136
1137 (if gnus-carpal-mode-map
1138     nil
1139   (setq gnus-carpal-mode-map (make-keymap))
1140   (suppress-keymap gnus-carpal-mode-map)
1141   (define-key gnus-carpal-mode-map " " 'gnus-carpal-select)
1142   (define-key gnus-carpal-mode-map "\r" 'gnus-carpal-select)
1143   (define-key gnus-carpal-mode-map gnus-mouse-2 'gnus-carpal-mouse-select))
1144
1145 (defun gnus-carpal-mode ()
1146   "Major mode for clicking buttons.
1147
1148 All normal editing commands are switched off.
1149 \\<gnus-carpal-mode-map>
1150 The following commands are available:
1151
1152 \\{gnus-carpal-mode-map}"
1153   (interactive)
1154   (kill-all-local-variables)
1155   (setq mode-line-modified "-- ")
1156   (setq major-mode 'gnus-carpal-mode)
1157   (setq mode-name "Gnus Carpal")
1158   (setq mode-line-process nil)
1159   (use-local-map gnus-carpal-mode-map)
1160   (buffer-disable-undo (current-buffer))
1161   (setq buffer-read-only t)
1162   (make-local-variable 'gnus-carpal-attached-buffer)
1163   (run-hooks 'gnus-carpal-mode-hook))
1164
1165 (defun gnus-carpal-setup-buffer (type)
1166   (let ((buffer (symbol-value (intern (format "gnus-carpal-%s-buffer" type)))))
1167     (if (get-buffer buffer)
1168         ()
1169       (save-excursion
1170         (set-buffer (get-buffer-create buffer))
1171         (gnus-carpal-mode)
1172         (setq gnus-carpal-attached-buffer 
1173               (intern (format "gnus-%s-buffer" type)))
1174         (gnus-add-current-to-buffer-list)
1175         (let ((buttons (symbol-value 
1176                         (intern (format "gnus-carpal-%s-buffer-buttons"
1177                                         type))))
1178               (buffer-read-only nil)
1179               button)
1180           (while buttons
1181             (setq button (car buttons)
1182                   buttons (cdr buttons))
1183             (if (stringp button)
1184                 (gnus-set-text-properties
1185                  (point)
1186                  (prog2 (insert button) (point) (insert " "))
1187                  (list 'face gnus-carpal-header-face))
1188               (gnus-set-text-properties
1189                (point)
1190                (prog2 (insert (car button)) (point) (insert " "))
1191                (list 'gnus-callback (cdr button)
1192                      'face gnus-carpal-button-face
1193                      gnus-mouse-face-prop 'highlight))))
1194           (let ((fill-column (- (window-width) 2)))
1195             (fill-region (point-min) (point-max)))
1196           (set-window-point (get-buffer-window (current-buffer)) 
1197                             (point-min)))))))
1198
1199 (defun gnus-carpal-select ()
1200   "Select the button under point."
1201   (interactive)
1202   (let ((func (get-text-property (point) 'gnus-callback)))
1203     (if (null func)
1204         ()
1205       (pop-to-buffer (symbol-value gnus-carpal-attached-buffer))
1206       (call-interactively func))))
1207
1208 (defun gnus-carpal-mouse-select (event)
1209   "Select the button under the mouse pointer."
1210   (interactive "e")
1211   (mouse-set-point event)
1212   (gnus-carpal-select))
1213
1214 ;;; 
1215 ;;; article highlights
1216 ;;;
1217
1218 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
1219
1220 ;;; Internal Variables:
1221
1222 (defvar gnus-button-regexp nil)
1223 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1224
1225 (defvar gnus-button-last nil)
1226 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1227
1228 ;;; Commands:
1229
1230 (defun gnus-article-push-button (event)
1231   "Check text under the mouse pointer for a callback function.
1232 If the text under the mouse pointer has a `gnus-callback' property,
1233 call it with the value of the `gnus-data' text property."
1234   (interactive "e")
1235   (set-buffer (window-buffer (posn-window (event-start event))))
1236   (let* ((pos (posn-point (event-start event)))
1237          (data (get-text-property pos 'gnus-data))
1238          (fun (get-text-property pos 'gnus-callback)))
1239     (if fun (funcall fun data))))
1240
1241 (defun gnus-article-press-button ()
1242   "Check text at point for a callback function.
1243 If the text at point has a `gnus-callback' property,
1244 call it with the value of the `gnus-data' text property."
1245   (interactive)
1246   (let* ((data (get-text-property (point) 'gnus-data))
1247          (fun (get-text-property (point) 'gnus-callback)))
1248     (if fun (funcall fun data))))
1249
1250 (defun gnus-article-prev-button (n)
1251   "Move point to N buttons backward.
1252 If N is negative, move forward instead."
1253   (interactive "p")
1254   (gnus-article-next-button (- n)))
1255
1256 (defun gnus-article-next-button (n)
1257   "Move point to N buttons forward.
1258 If N is negative, move backward instead."
1259   (interactive "p")
1260   (let ((function (if (< n 0) 'previous-single-property-change
1261                     'next-single-property-change))
1262         (inhibit-point-motion-hooks t)
1263         (backward (< n 0))
1264         (limit (if (< n 0) (point-min) (point-max))))
1265     (setq n (abs n))
1266     (while (and (not (= limit (point)))
1267                 (> n 0))
1268       ;; Skip past the current button.
1269       (when (get-text-property (point) 'gnus-callback)
1270         (goto-char (funcall function (point) 'gnus-callback nil limit)))
1271       ;; Go to the next (or previous) button.
1272       (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
1273       ;; Put point at the start of the button.
1274       (when (and backward (not (get-text-property (point) 'gnus-callback)))
1275         (goto-char (funcall function (point) 'gnus-callback nil limit)))
1276       ;; Skip past intangible buttons.
1277       (when (get-text-property (point) 'intangible)
1278         (incf n))
1279       (decf n))
1280     (unless (zerop n)
1281       (gnus-message 5 "No more buttons"))
1282     n))
1283
1284 (defun gnus-article-highlight (&optional force)
1285   "Highlight current article.
1286 This function calls `gnus-article-highlight-headers',
1287 `gnus-article-highlight-citation', 
1288 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
1289 do the highlighting.  See the documentation for those functions."
1290   (interactive (list 'force))
1291   (gnus-article-highlight-headers)
1292   (gnus-article-highlight-citation force)
1293   (gnus-article-highlight-signature)
1294   (gnus-article-add-buttons force)
1295   (gnus-article-add-buttons-to-head))
1296
1297 (defun gnus-article-highlight-some (&optional force)
1298   "Highlight current article.
1299 This function calls `gnus-article-highlight-headers',
1300 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
1301 do the highlighting.  See the documentation for those functions."
1302   (interactive (list 'force))
1303   (gnus-article-highlight-headers)
1304   (gnus-article-highlight-signature)
1305   (gnus-article-add-buttons))
1306
1307 (defun gnus-article-highlight-headers ()
1308   "Highlight article headers as specified by `gnus-header-face-alist'."
1309   (interactive)
1310   (save-excursion
1311     (set-buffer gnus-article-buffer)
1312     (save-restriction
1313       (let ((alist gnus-header-face-alist)
1314             (buffer-read-only nil)
1315             (case-fold-search t)
1316             (inhibit-point-motion-hooks t)
1317             entry regexp header-face field-face from hpoints fpoints)
1318         (goto-char (point-min))
1319         (when (search-forward "\n\n" nil t)
1320           (narrow-to-region (1- (point)) (point-min))
1321           (while (setq entry (pop alist))
1322             (goto-char (point-min))
1323             (setq regexp (concat "^\\("
1324                                  (if (string-equal "" (nth 0 entry))
1325                                      "[^\t ]"
1326                                    (nth 0 entry))
1327                                  "\\)")
1328                   header-face (nth 1 entry)
1329                   field-face (nth 2 entry))
1330             (while (and (re-search-forward regexp nil t)
1331                         (not (eobp)))
1332               (beginning-of-line)
1333               (setq from (point))
1334               (or (search-forward ":" nil t)
1335                   (forward-char 1))
1336               (when (and header-face
1337                          (not (memq (point) hpoints)))
1338                 (push (point) hpoints)
1339                 (gnus-put-text-property from (point) 'face header-face))
1340               (when (and field-face
1341                          (not (memq (setq from (point)) fpoints)))
1342                 (push from fpoints)
1343                 (if (re-search-forward "^[^ \t]" nil t)
1344                     (forward-char -2)
1345                   (goto-char (point-max)))
1346                 (gnus-put-text-property from (point) 'face field-face)))))))))
1347
1348 (defun gnus-article-highlight-signature ()
1349   "Highlight the signature in an article.
1350 It does this by highlighting everything after
1351 `gnus-signature-separator' using `gnus-signature-face'." 
1352   (interactive)
1353   (save-excursion
1354     (set-buffer gnus-article-buffer)
1355     (let ((buffer-read-only nil)
1356           (inhibit-point-motion-hooks t))
1357       (save-restriction
1358         (when (and gnus-signature-face
1359                    (gnus-narrow-to-signature))
1360           (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
1361                             'face gnus-signature-face)
1362           (widen)
1363           (re-search-backward gnus-signature-separator nil t)
1364           (let ((start (match-beginning 0))
1365                 (end (set-marker (make-marker) (1+ (match-end 0)))))
1366             (gnus-article-add-button start (1- end) 'gnus-signature-toggle
1367                                      end)))))))
1368
1369 (defun gnus-article-add-buttons (&optional force)
1370   "Find external references in the article and make buttons of them.
1371 \"External references\" are things like Message-IDs and URLs, as
1372 specified by `gnus-button-alist'."
1373   (interactive (list 'force))
1374   (save-excursion
1375     (set-buffer gnus-article-buffer)
1376     ;; Remove all old markers.
1377     (while gnus-button-marker-list
1378       (set-marker (pop gnus-button-marker-list) nil))
1379     (let ((buffer-read-only nil)
1380           (inhibit-point-motion-hooks t)
1381           (case-fold-search t)
1382           (alist gnus-button-alist)
1383           beg entry regexp)
1384       (goto-char (point-min))
1385       ;; We skip the headers.
1386       (unless (search-forward "\n\n" nil t)
1387         (goto-char (point-max)))
1388       (setq beg (point))
1389       (while (setq entry (pop alist))
1390         (setq regexp (car entry))
1391         (goto-char beg)
1392         (while (re-search-forward regexp nil t)
1393           (let* ((start (and entry (match-beginning (nth 1 entry))))
1394                  (end (and entry (match-end (nth 1 entry))))
1395                  (from (match-beginning 0)))
1396             (when (or (eq t (nth 1 entry))
1397                       (eval (nth 1 entry)))
1398               ;; That optional form returned non-nil, so we add the
1399               ;; button. 
1400               (gnus-article-add-button 
1401                start end 'gnus-button-push 
1402                (car (push (set-marker (make-marker) from)
1403                           gnus-button-marker-list))))))))))
1404
1405 ;; Add buttons to the head of an article.
1406 (defun gnus-article-add-buttons-to-head ()
1407   "Add buttons to the head of the article."
1408   (interactive)
1409   (save-excursion
1410     (set-buffer gnus-article-buffer)
1411     (let ((buffer-read-only nil)
1412           (inhibit-point-motion-hooks t)
1413           (case-fold-search t)
1414           (alist gnus-header-button-alist)
1415           entry beg end)
1416       (nnheader-narrow-to-headers)
1417       (while alist
1418         ;; Each alist entry.
1419         (setq entry (car alist)
1420               alist (cdr alist))
1421         (goto-char (point-min))
1422         (while (re-search-forward (car entry) nil t)
1423           ;; Each header matching the entry.
1424           (setq beg (match-beginning 0))
1425           (setq end (or (and (re-search-forward "^[^ \t]" nil t)
1426                              (match-beginning 0))
1427                         (point-max)))
1428           (goto-char beg)
1429           (while (re-search-forward (nth 1 entry) end t)
1430             ;; Each match within a header.
1431             (let* ((from (match-beginning 0))
1432                    (entry (cdr entry))
1433                    (start (match-beginning (nth 1 entry)))
1434                    (end (match-end (nth 1 entry)))
1435                    (form (nth 2 entry)))
1436               (goto-char (match-end 0))
1437               (and (eval form)
1438                    (gnus-article-add-button 
1439                     start end (nth 3 entry)
1440                     (buffer-substring (match-beginning (nth 4 entry))
1441                                       (match-end (nth 4 entry)))))))
1442           (goto-char end))))
1443     (widen)))
1444
1445 ;;; External functions:
1446
1447 (defun gnus-article-add-button (from to fun &optional data)
1448   "Create a button between FROM and TO with callback FUN and data DATA."
1449   (and gnus-article-button-face
1450        (gnus-overlay-put (gnus-make-overlay from to)
1451                          'face gnus-article-button-face))
1452   (gnus-add-text-properties 
1453    from to
1454    (nconc (and gnus-article-mouse-face
1455                (list gnus-mouse-face-prop gnus-article-mouse-face))
1456           (list 'gnus-callback fun)
1457           (and data (list 'gnus-data data)))))
1458
1459 ;;; Internal functions:
1460
1461 (defun gnus-signature-toggle (end)
1462   (save-excursion
1463     (set-buffer gnus-article-buffer)
1464     (let ((buffer-read-only nil)
1465           (inhibit-point-motion-hooks t))
1466       (if (get-text-property end 'invisible)
1467           (gnus-unhide-text end (point-max))
1468         (gnus-hide-text end (point-max) gnus-hidden-properties)))))
1469
1470 (defun gnus-button-entry ()
1471   ;; Return the first entry in `gnus-button-alist' matching this place.
1472   (let ((alist gnus-button-alist)
1473         (entry nil))
1474     (while alist
1475       (setq entry (pop alist))
1476       (if (looking-at (car entry))
1477           (setq alist nil)
1478         (setq entry nil)))
1479     entry))
1480
1481 (defun gnus-button-push (marker)
1482   ;; Push button starting at MARKER.
1483   (save-excursion
1484     (set-buffer gnus-article-buffer)
1485     (goto-char marker)
1486     (let* ((entry (gnus-button-entry))
1487            (inhibit-point-motion-hooks t)
1488            (fun (nth 3 entry))
1489            (args (mapcar (lambda (group) 
1490                            (let ((string (buffer-substring
1491                                           (match-beginning group)
1492                                           (match-end group))))
1493                              (gnus-set-text-properties
1494                               0 (length string) nil string)
1495                              string))
1496                          (nthcdr 4 entry))))
1497       (cond ((fboundp fun)
1498              (apply fun args))
1499             ((and (boundp fun)
1500                   (fboundp (symbol-value fun)))
1501              (apply (symbol-value fun) args))
1502             (t
1503              (gnus-message 1 "You must define `%S' to use this button"
1504                            (cons fun args)))))))
1505
1506 (defun gnus-button-message-id (message-id)
1507   "Fetch MESSAGE-ID."
1508   (save-excursion
1509     (set-buffer gnus-summary-buffer)
1510     (gnus-summary-refer-article message-id)))
1511
1512 (defun gnus-button-mailto (address)
1513   ;; Mail to ADDRESS.
1514   (set-buffer (gnus-copy-article-buffer))
1515   (message-reply address))
1516
1517 (defun gnus-button-reply (address)
1518   ;; Reply to ADDRESS.
1519   (message-reply))
1520
1521 (defun gnus-button-url (address)
1522   "Browse ADDRESS."
1523   (funcall browse-url-browser-function address))
1524
1525 ;;; Next/prev buttons in the article buffer.
1526
1527 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
1528 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
1529
1530 (defvar gnus-prev-page-map nil)
1531 (unless gnus-prev-page-map
1532   (setq gnus-prev-page-map (make-sparse-keymap))
1533   (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
1534   (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
1535
1536 (defun gnus-insert-prev-page-button ()
1537   (let ((buffer-read-only nil))
1538     (gnus-eval-format 
1539      gnus-prev-page-line-format nil
1540      `(gnus-prev t local-map ,gnus-prev-page-map
1541                  gnus-callback gnus-article-button-prev-page))))
1542
1543 (defvar gnus-next-page-map nil)
1544 (unless gnus-next-page-map
1545   (setq gnus-next-page-map (make-keymap))
1546   (suppress-keymap gnus-prev-page-map)
1547   (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
1548   (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
1549
1550 (defun gnus-button-next-page ()
1551   "Go to the next page."
1552   (interactive)
1553   (let ((win (selected-window)))
1554     (select-window (get-buffer-window gnus-article-buffer t))
1555     (gnus-article-next-page)
1556     (select-window win)))
1557
1558 (defun gnus-button-prev-page ()
1559   "Go to the prev page."
1560   (interactive)
1561   (let ((win (selected-window)))
1562     (select-window (get-buffer-window gnus-article-buffer t))
1563     (gnus-article-prev-page)
1564     (select-window win)))
1565
1566 (defun gnus-insert-next-page-button ()
1567   (let ((buffer-read-only nil))
1568     (gnus-eval-format gnus-next-page-line-format nil
1569                       `(gnus-next t local-map ,gnus-next-page-map
1570                                   gnus-callback 
1571                                   gnus-article-button-next-page))))
1572
1573 (defun gnus-article-button-next-page (arg)
1574   "Go to the next page."
1575   (interactive "P")
1576   (let ((win (selected-window)))
1577     (select-window (get-buffer-window gnus-article-buffer t))
1578     (gnus-article-next-page)
1579     (select-window win)))
1580
1581 (defun gnus-article-button-prev-page (arg)
1582   "Go to the prev page."
1583   (interactive "P")
1584   (let ((win (selected-window)))
1585     (select-window (get-buffer-window gnus-article-buffer t))
1586     (gnus-article-prev-page)
1587     (select-window win)))
1588
1589 ;;; Compatibility Functions:
1590
1591 (or (fboundp 'rassoc)
1592     ;; Introduced in Emacs 19.29.
1593     (defun rassoc (elt list)
1594       "Return non-nil if ELT is `equal' to the cdr of an element of LIST.
1595 The value is actually the element of LIST whose cdr is ELT."
1596       (let (result)
1597         (while list
1598           (setq result (car list))
1599           (if (equal (cdr result) elt)
1600               (setq list nil)
1601             (setq result nil
1602                   list (cdr list))))
1603         result)))
1604
1605 ; (require 'gnus-cus)
1606 (gnus-ems-redefine)
1607 (provide 'gnus-vis)
1608
1609 ;;; gnus-vis.el ends here