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