*** empty log message ***
[gnus] / lisp / gnus-visual.el
1 ;;; gnus-visual: display-oriented parts of Gnus.
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Keywords: news
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 (require 'gnus)
28 (require (if gnus-xemacs 'auc-menu 'easymenu))
29
30 (defvar gnus-summary-selected-face 'underline
31   "Face used for highlighting the current article in the summary buffer.")
32
33 (defvar gnus-visual-summary-highlight
34   '(((> score default) . bold)
35     ((< score default) . italic))
36   "Alist of `(FORM . FACE)'.
37 Summary lines are highlighted with the FACE for the first FORM which
38 evaluate to a non-nil value.  
39
40 Point will be at the beginning of the line when FORM is evaluated.
41 The following can be used for convenience:
42
43 score:   (gnus-summary-article-score)
44 default: gnus-summary-default-score
45 below:   gnus-summary-mark-below
46
47 To check for marks, e.g. to underline replied articles, use
48 `gnus-summary-article-mark': 
49
50    ((= (gnus-summary-article-mark) gnus-replied-mark) . underline)")
51
52 (eval-and-compile
53   (autoload 'nnkiboze-generate-groups "nnkiboze"))
54
55 ;; Newsgroup buffer
56
57 ;; Make a menu bar item.
58 (defun gnus-group-make-menu-bar ()
59   (easy-menu-define
60    gnus-group-reading-menu
61    gnus-group-mode-map
62    ""
63    '("Group"
64      ["Read" gnus-group-read-group t]
65      ["Select" gnus-group-select-group t]
66      ["Catch up" gnus-group-catchup-current t]
67      ["Catch up all articles" gnus-group-catchup-current-all t]
68      ["Check for new articles" gnus-group-get-new-news-this-group t]
69      ["Toggle subscription" gnus-group-unsubscribe-current-group t]
70      ["Kill" gnus-group-kill-group t]
71      ["Yank" gnus-group-yank-group t]
72      ["Describe" gnus-group-describe-group t]
73      ["Fetch FAQ" gnus-group-fetch-faq t]
74      ["Edit kill file" gnus-group-edit-local-kill t]
75      ["Expire articles" gnus-group-expire-articles t]
76      ["Set group level" gnus-group-set-current-level t]
77      ))
78   
79   (easy-menu-define
80    gnus-group-group-menu
81    gnus-group-mode-map
82    ""
83    '("Groups"
84      ("Listing"
85       ["List subscribed groups" gnus-group-list-groups t]
86       ["List all groups" gnus-group-list-all-groups t]
87       ["List groups matching..." gnus-group-list-matching t]
88       ["List killed groups" gnus-group-list-killed t]
89       ["List zombie groups" gnus-group-list-zombies t]
90       ["Describe all groups" gnus-group-describe-all-groups t]
91       ["Group apropos" gnus-group-apropos t]
92       ["Group and description apropos" gnus-group-description-apropos t]
93       ["List groups matching..." gnus-group-list-matching t])
94      ("Subscribe"
95       ["Subscribe to random group" gnus-group-unsubscribe-group t]
96       ["Kill all newsgroups in region" gnus-group-kill-region t]
97       ["Kill all zombie groups" gnus-group-kill-all-zombies t])
98      ("Foreign groups"
99       ["Make a foreign group" gnus-group-make-group t]
100       ["Edit a group entry" gnus-group-edit-group t]
101       ["Add a directory group" gnus-group-make-directory-group t]
102       ["Add the help group" gnus-group-make-help-group t]
103       ["Add the archive group" gnus-group-make-archive-group t]
104       ["Make a kiboze group" gnus-group-make-kiboze-group t])
105      ["Jump to group" gnus-group-jump-to-group t]
106      ["Best unread group" gnus-group-best-unread-group t]
107      ))
108
109   (easy-menu-define
110    gnus-group-post-menu
111    gnus-group-mode-map
112    ""
113    '("Post"
114      ["Send a mail" gnus-group-mail t]
115      ["Post an article" gnus-group-post-news t]
116      ))
117   
118   (easy-menu-define
119    gnus-group-misc-menu
120    gnus-group-mode-map
121    ""
122    '("Misc"
123      ["Check for new news" gnus-group-get-new-news t]     
124      ["Delete bogus groups" gnus-group-check-bogus-groups t]
125      ["Find new newsgroups" gnus-find-new-newsgroups t]
126      ["Restart Gnus" gnus-group-restart t]
127      ["Read init file" gnus-group-read-init-file t]
128      ["Browse foreign server" gnus-group-browse-foreign-server t]
129      ["Edit the global kill file" gnus-group-edit-global-kill t]
130      ["Expire all expirable articles" gnus-group-expire-all-groups t]
131      ["Generate any kiboze groups" nnkiboze-generate-groups t]
132      ["Gnus version" gnus-version t]
133      ["Save .newsrc files" gnus-group-save-newsrc t]
134      ["Suspend Gnus" gnus-group-suspend t]
135      ["Clear dribble buffer" gnus-group-clear-dribble t]
136      ["Exit from Gnus" gnus-group-exit t]
137      ["Exit without saving" gnus-group-quit t]
138      ["Sort group buffer" gnus-group-sort-groups t]
139      ["Edit global KILL file" gnus-group-edit-global-kill t]
140      ))
141
142   )
143
144 ;; Summary buffer
145 (defun gnus-summary-make-menu-bar ()
146
147   (easy-menu-define
148    gnus-summary-mark-menu
149    gnus-summary-mode-map
150    ""
151    '("Mark"
152      ["Tick" gnus-summary-tick-article-forward t]
153      ["Mark as read" gnus-summary-mark-as-read-forward t]
154      ["Mark as unread" gnus-summary-clear-mark-forward t]
155      ["Mark same subject and select" gnus-summary-kill-same-subject-and-select t]
156      ["Mark same subject" gnus-summary-kill-same-subject t]
157      ["Remove lines marked as read" gnus-summary-remove-lines-marked-as-read t]
158      ["Remove lines marked with..." gnus-summary-remove-lines-marked-with t]
159      ["Set expirable mark" gnus-summary-mark-as-expirable t]
160      ["Set bookmark" gnus-summary-set-bookmark t]
161      ["Remove bookmark" gnus-summary-remove-bookmark t]
162      ["Catchup" gnus-summary-catchup t]
163      ["Catchup all" gnus-summary-catchup-all t]
164      ["Catchup to here" gnus-summary-catchup-to-here t]
165      ["Raise score" gnus-summary-raise-score t]
166      ["Lower score" gnus-summary-lower-score t]
167      ["Set score" gnus-summary-set-score t]
168      ("Process mark"
169       ["Set mark" gnus-summary-mark-as-processable t]
170       ["Remove mark" gnus-summary-unmark-as-processable t]
171       ["Remove all marks" gnus-summary-unmark-all-processable t]
172       ["Mark series" gnus-uu-mark-series t]
173       ["Mark region" gnus-uu-mark-region t]
174       ["Mark by regexp" gnus-uu-mark-by-regexp t]
175       ["Mark all" gnus-uu-mark-all t]
176       ["Mark sparse" gnus-uu-mark-sparse t]
177       ["Mark thread" gnus-uu-mark-thread t]
178       )
179      ))
180
181   (easy-menu-define
182    gnus-summary-move-menu
183    gnus-summary-mode-map
184    ""
185    '("Move"
186      ["Scroll article forwards" gnus-summary-next-page t]
187      ["Next unread article" gnus-summary-next-unread-article t]
188      ["Previous unread article" gnus-summary-prev-unread-article t]
189      ["Next article" gnus-summary-next-article t]
190      ["Previous article" gnus-summary-prev-article t]
191      ["Next article same subject" gnus-summary-next-same-subject t]
192      ["Previous article same subject" gnus-summary-prev-same-subject t]
193      ["First unread article" gnus-summary-first-unread-article t]
194      ["Go to subject number..." gnus-summary-goto-subject t]
195      ["Go to the last article" gnus-summary-goto-last-article t]
196      ["Pop article off history" gnus-summary-pop-article t]
197      ))
198
199   (easy-menu-define
200    gnus-summary-article-menu
201    gnus-summary-mode-map
202    ""
203    '("Article"
204      ("Hide"
205       ["Headers" gnus-article-hide-headers t]
206       ["Signature" gnus-article-hide-signature t]
207       ["Citation" gnus-article-hide-citation t]
208       ["Overstrike" gnus-article-treat-overstrike t]
209       ["Word wrap" gnus-article-word-wrap t]
210       ["CR" gnus-article-remove-cr t]
211       ["Quoted-Printable" gnus-article-de-quoted-unreadable t])
212      ("Extract"
213       ["Uudecode" gnus-uu-decode-uu t]
214       ["Uudecode and save" gnus-uu-decode-uu-and-save t]
215       ["Unshar" gnus-uu-decode-unshar t]
216       ["Unshar and save" gnus-uu-decode-unshar-and-save t]
217       ["Save" gnus-uu-decode-save t]
218       ["Binhex" gnus-uu-decode-binhex t])
219      ["Enter digest buffer" gnus-summary-enter-digest-group t]
220      ["Isearch article" gnus-summary-isearch-article t]
221      ["Search all articles" gnus-summary-search-article-forward t]
222      ["Beginning of the article" gnus-summary-beginning-of-article t]
223      ["End of the article" gnus-summary-end-of-article t]
224      ["Fetch parent of article" gnus-summary-refer-parent-article t]
225      ["Fetch article with id..." gnus-summary-refer-article t]
226      ["Stop page breaking" gnus-summary-stop-page-breaking t]
227      ["Caesar rotate" gnus-summary-caesar-message t]
228      ["Redisplay" gnus-summary-show-article t]
229      ["Toggle header" gnus-summary-toggle-header t]
230      ["Toggle MIME" gnus-summary-toggle-mime t]
231      ["Save" gnus-summary-save-article t]
232      ["Save in mail format" gnus-summary-save-article-mail t]
233      ["Pipe through a filter" gnus-summary-pipe-output t]
234      ("Mail articles"
235       ["Respool article" gnus-summary-respool-article t]
236       ["Move article" gnus-summary-move-article t]
237       ["Edit article" gnus-summary-edit-article t]
238       ["Delete article" gnus-summary-delete-article t])
239      ))
240
241   (easy-menu-define
242    gnus-summary-thread-menu
243    gnus-summary-mode-map
244    ""
245    '("Threads"
246      ["Toggle threading" gnus-summary-toggle-threads t]
247      ["Display hidden thread" gnus-summary-show-thread t]
248      ["Hide thread" gnus-summary-hide-thread t]
249      ["Go to next thread" gnus-summary-next-thread t]
250      ["Go to previous thread" gnus-summary-prev-thread t]
251      ["Go down thread" gnus-summary-down-thread t]
252      ["Go up thread" gnus-summary-up-thread t]
253      ["Mark thread as read" gnus-summary-kill-thread t]
254      ["Lower thread score" gnus-summary-lower-thread t]
255      ["Raise thread score" gnus-summary-raise-thread t]
256      ))
257
258   (easy-menu-define
259    gnus-summary-misc-menu
260    gnus-summary-mode-map
261    ""
262    '("Misc"
263      ("Sort"
264       ["Sort by number" gnus-summary-sort-by-number t]
265       ["Sort by author" gnus-summary-sort-by-author t]
266       ["Sort by subject" gnus-summary-sort-by-subject t]
267       ["Sort by date" gnus-summary-sort-by-date t])
268      ["Fetch group FAQ" gnus-summary-fetch-faq t]
269      ["Filter articles" gnus-summary-execute-command t]
270      ["Catchup and exit" gnus-summary-catchup-and-exit t]
271      ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
272      ["Toggle line truncation" gnus-summary-toggle-truncation t]
273      ["Expire expirable articles" gnus-summary-expire-articles t]
274      ["Show dormant articles" gnus-summary-show-all-dormant t]
275      ["Hide dormant articles" gnus-summary-hide-all-dormant t]
276      ["Show expunged articles" gnus-summary-show-all-expunged t]
277      ["Reselect group" gnus-summary-reselect-current-group t]
278      ["Rescan group" gnus-summary-rescan-group t]
279      ["Describe group" gnus-summary-describe-group t]
280      ["Exit group" gnus-summary-exit t]
281      ["Exit group without updating" gnus-summary-quit t]
282      ["Edit local kill file" gnus-summary-edit-local-kill t]
283      ["Edit global kill file" gnus-summary-edit-global-kill t]
284      ))
285
286   (easy-menu-define
287    gnus-summary-post-menu
288    gnus-summary-mode-map
289    ""
290    '("Post"
291      ["Post an article" gnus-summary-post-news t]
292      ["Followup" gnus-summary-followup t]
293      ["Followup and yank" gnus-summary-followup-with-original t]
294      ["Supersede article" gnus-summary-supersede-article t]
295      ["Cancel article" gnus-summary-cancel-article t]
296      ["Reply" gnus-summary-reply t]
297      ["Reply and yank" gnus-summary-reply-with-original t]
298      ["Forward" gnus-summary-mail-forward t]
299      ["Digest and forward" gnus-uu-digest-and-forward t]
300      ["Send a mail" gnus-summary-mail-other-window t]
301      ["Reply & followup" gnus-summary-followup-and-reply t]
302      ["Reply & followup and yank" gnus-summary-followup-and-reply-with-original t]
303      ["Uuencode and post" gnus-uu-post-news t]
304      ))
305
306   (easy-menu-define
307    gnus-summary-kill-menu
308    gnus-summary-mode-map
309    ""
310    '("Score"
311      ("Score file"
312       ["Switch current score file" gnus-score-change-score-file t]
313       ["Set mark below" gnus-score-set-mark-below t]
314       ["Set expunge below" gnus-score-set-expunge-below t]
315       ["Edit current score file" gnus-score-edit-alist t]
316       ["Edit score file" gnus-score-edit-file t])
317      ["Raise score with current subject" 
318       gnus-summary-temporarily-raise-by-subject t]
319      ["Raise score with current author" 
320       gnus-summary-temporarily-raise-by-author t]
321      ["Raise score with current thread" 
322       gnus-summary-temporarily-raise-by-thread t]
323      ["Raise score with current crossposting" 
324       gnus-summary-temporarily-raise-by-xref t]
325      ["Permanently raise score with current subject"
326       gnus-summary-raise-by-subject t]
327      ["Permanently raise score with current author" 
328       gnus-summary-raise-by-author t]
329      ["Permanently raise score with current crossposting" 
330       gnus-summary-raise-by-xref t]
331      ["Permanently raise score for followups to current author"
332       gnus-summary-raise-followups-to-author t]
333      ["Lower score with current subject" 
334       gnus-summary-temporarily-lower-by-subject t]
335      ["Lower score with current author" 
336       gnus-summary-temporarily-lower-by-author t]
337      ["Lower score with current thread" 
338       gnus-summary-temporarily-lower-by-thread t]
339      ["Lower score with current crossposting" 
340       gnus-summary-temporarily-lower-by-xref t]
341      ["Permanently lower score with current subject"
342       gnus-summary-lower-by-subject t]
343      ["Permanently lower score with current author" 
344       gnus-summary-lower-by-author t]
345      ["Permanently lower score with current crossposting" 
346       gnus-summary-lower-by-xref t]
347      ["Permanently lower score for followups to current author"
348       gnus-summary-lower-followups-to-author t]
349      ))
350   )
351  
352 ;; Article buffer
353 (defun gnus-article-make-menu-bar ()
354
355  (easy-menu-define
356    gnus-article-article-menu
357    gnus-article-mode-map
358    ""
359    '("Article"
360      ["Scroll forwards" gnus-article-next-page t]
361      ["Scroll backwards" gnus-article-prev-page t]
362      ["Show summary" gnus-article-show-summary t]
363      ["Fetch Message-ID at point" gnus-article-refer-article t]
364      ["Mail to address at point" gnus-article-mail t]
365      ["Mail to address at point and include original"
366       gnus-article-mail-with-original t]
367      ))
368
369  (easy-menu-define
370    gnus-article-treatment-menu
371    gnus-article-mode-map
372    ""
373    '("Treatment"
374      ["Hide headers" gnus-article-hide-headers t]
375      ["Hide signature" gnus-article-hide-signature t]
376      ["Hide citation" gnus-article-hide-citation t]
377      ["Treat overstrike" gnus-article-treat-overstrike t]
378      ["Remove carriage return" gnus-article-remove-cr t]
379      ["Remove quoted-unreadble" gnus-article-de-quoted-unreadable t]
380      ))
381  )
382
383 (if gnus-xemacs
384     (defun gnus-visual-highlight-selected-summary ()
385       (if gnus-summary-selected-face
386           (save-excursion
387             (let* ((beg (progn (beginning-of-line) (point)))
388                    (end (progn (end-of-line) (point)))
389                    (from (or
390                           (next-single-property-change beg 'mouse-face nil end)
391                           beg))
392                    (to (or (next-single-property-change from 'mouse-face nil end)
393                            end)))
394               (if gnus-newsgroup-selected-overlay
395                   (move-overlay gnus-newsgroup-selected-overlay 
396                                 from to (current-buffer))
397                 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
398                 (overlay-put gnus-newsgroup-selected-overlay 'face 
399                              gnus-summary-selected-face))))))
400
401   (defun gnus-visual-highlight-selected-summary ()
402     ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
403     ;; Highlight selected article in summary buffer
404     (if gnus-summary-selected-face
405         (save-excursion
406           (let* ((beg (progn (beginning-of-line) (point)))
407                  (end (progn (end-of-line) (point)))
408                  (to (max 1 (1- (previous-single-property-change
409                                  end 'mouse-face nil beg))))
410                  (from (1+ (previous-single-property-change 
411                             to 'mouse-face nil beg))))
412             (if gnus-newsgroup-selected-overlay
413                 (move-overlay gnus-newsgroup-selected-overlay 
414                               from to (current-buffer))
415               (setq gnus-newsgroup-selected-overlay (make-overlay from to))
416               (overlay-put gnus-newsgroup-selected-overlay 'face 
417                            gnus-summary-selected-face)))))))
418
419 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
420 (defun gnus-visual-summary-highlight-line ()
421   "Highlight current line according to `gnus-visual-summary-highlight'."
422   (let* ((list gnus-visual-summary-highlight)
423          (p (point))
424          (end (progn (end-of-line) (point)))
425          ;; now find out where the line starts and leave point there.
426          (beg (progn (beginning-of-line) (point)))
427          (score (or (cdr (assq (or (get-text-property beg 'gnus-number)
428                                    gnus-current-article)
429                                gnus-newsgroup-scored))
430                     gnus-summary-default-score 0))
431          (default gnus-summary-default-score)
432          (mark (get-text-property beg 'gnus-mark))
433          (inhibit-read-only t))
434     (while (and list (not (eval (car (car list)))))
435       (setq list (cdr list)))
436     (let ((face (and list (cdr (car list)))))
437       ;; BUG! For some reason the text properties of the first
438       ;; characters get mangled.
439       (or (eq face (get-text-property (+ beg 10) 'face))
440           (put-text-property beg end 'face face)))
441     (goto-char p)))
442
443 (if (not gnus-xemacs)
444     ()
445   (setq gnus-group-mode-hook
446         (cons
447          (lambda ()
448            (easy-menu-add gnus-group-reading-menu)
449            (easy-menu-add gnus-group-group-menu)
450            (easy-menu-add gnus-group-post-menu)
451            (easy-menu-add gnus-group-misc-menu)) 
452          gnus-group-mode-hook))
453   (setq gnus-summary-mode-hook
454         (cons
455          (lambda ()
456            (easy-menu-add gnus-summary-mark-menu)
457            (easy-menu-add gnus-summary-move-menu)
458            (easy-menu-add gnus-summary-article-menu)
459            (easy-menu-add gnus-summary-thread-menu)
460            (easy-menu-add gnus-summary-misc-menu)
461            (easy-menu-add gnus-summary-post-menu)
462            (easy-menu-add gnus-summary-kill-menu))
463          gnus-summary-mode-hook))
464   (setq gnus-article-mode-hook
465         (cons
466          (lambda ()
467            (easy-menu-add gnus-article-article-menu)
468            (easy-menu-add gnus-article-treatment-menu)) 
469          gnus-article-mode-hook)))
470
471 (provide 'gnus-visual)
472
473 ;;; gnus-visual.el ends here