1 ;;; gnus-vis.el --- display-oriented parts of Gnus
2 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
5 ;; Per Abrahamsen <abraham@iesd.auc.dk>
8 ;; This file is part of GNU Emacs.
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)
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.
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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
29 (require gnus-easymenu)
33 (defvar gnus-summary-selected-face 'underline
34 "*Face used for highlighting the current article in the summary buffer.")
36 (defvar gnus-summary-highlight
37 '(((> score default) . bold)
38 ((< score default) . italic))
39 "*Alist of `(FORM . FACE)'.
40 Summary lines are highlighted with the FACE for the first FORM which
41 evaluate to a non-nil value.
43 Point will be at the beginning of the line when FORM is evaluated.
44 The following can be used for convenience:
46 score: (gnus-summary-article-score)
47 default: gnus-summary-default-score
48 below: gnus-summary-mark-below
50 To check for marks, e.g. to underline replied articles, use
51 `gnus-summary-article-mark':
53 ((= (gnus-summary-article-mark) gnus-replied-mark) . underline)")
55 ;;; article highlights
57 (defvar gnus-make-foreground t
58 "Non nil means foreground color to highlight citations.")
60 (defvar gnus-article-button-face 'bold
61 "Face used for text buttons.")
63 (defvar gnus-article-mouse-face (if (boundp 'gnus-mouse-face)
66 "Face used when the mouse is over the button.")
68 (defvar gnus-header-face-alist '(("" bold italic))
69 "Alist of headers and faces used for highlighting them.
70 The entries in the list has the form `(REGEXP NAME CONTENT)', where
71 REGEXP is a regeular expression matching the beginning of the header,
72 NAME is the face used for highlighting the header name and CONTENT is
73 the face used for highlighting the header content.
75 The first non-nil NAME or CONTENT with a matching REGEXP in the list
78 (defvar gnus-signature-face 'italic
79 "Face used for signature.")
81 (defvar gnus-button-alist
82 '(("in\\( +article\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
83 (assq (count-lines (point-min) (match-end 0))
84 gnus-cite-attribution-alist)
85 gnus-button-message-id 3)
86 ;; This is how URLs _should_ be embedded in text...
87 ("<URL:\\([^\n\r>]*\\)>" 0 t gnus-button-url 1)
88 ;; Next regexp stolen from highlight-headers.el
89 ("\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]+" 0 t
91 "Alist of regexps matching buttons in an article.
93 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
94 REGEXP: is the string matching text around the button,
95 BUTTON: is the number of the regexp grouping actually matching the button,
96 FORM: is a lisp expression which must eval to true for the button to
98 CALLBACK: is the function to call when the user push this button, and each
99 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
101 CALLBACK can also be a variable, in that case the value of that
102 variable it the real callback function.")
104 (defvar gnus-button-url (cond ((fboundp 'w3-fetch)
106 ((fboundp 'highlight-headers-follow-url-netscape)
107 'highlight-headers-follow-url-netscape)
109 "Function to fetch URL.
110 The function will be called with one argument, the URL to fetch.
111 Useful values of this function are:
114 defined in the w3 emacs package by William M. Perry.
115 highlight-headers-follow-url-netscape:
116 from `highlight-headers.el' for loading NetScape 1.1.")
121 (autoload 'nnkiboze-generate-groups "nnkiboze")
122 (autoload 'gnus-cite-parse-maybe "gnus-cite" nil t))
130 (defun gnus-group-make-menu-bar ()
132 gnus-group-reading-menu
136 ["Read" gnus-group-read-group t]
137 ["Select" gnus-group-select-group t]
138 ["Catch up" gnus-group-catchup-current t]
139 ["Catch up all articles" gnus-group-catchup-current-all t]
140 ["Check for new articles" gnus-group-get-new-news-this-group t]
141 ["Toggle subscription" gnus-group-unsubscribe-current-group t]
142 ["Kill" gnus-group-kill-group t]
143 ["Yank" gnus-group-yank-group t]
144 ["Describe" gnus-group-describe-group t]
145 ["Fetch FAQ" gnus-group-fetch-faq t]
146 ["Edit kill file" gnus-group-edit-local-kill t]
147 ["Expire articles" gnus-group-expire-articles t]
148 ["Set group level" gnus-group-set-current-level t]
152 gnus-group-group-menu
157 ["List subscribed groups" gnus-group-list-groups t]
158 ["List all groups" gnus-group-list-all-groups t]
159 ["List groups matching..." gnus-group-list-matching t]
160 ["List killed groups" gnus-group-list-killed t]
161 ["List zombie groups" gnus-group-list-zombies t]
162 ["Describe all groups" gnus-group-describe-all-groups t]
163 ["Group apropos" gnus-group-apropos t]
164 ["Group and description apropos" gnus-group-description-apropos t]
165 ["List groups matching..." gnus-group-list-matching t])
167 ["Mark group" gnus-group-mark-group t]
168 ["Unmark group" gnus-group-unmark-group t]
169 ["Mark region" gnus-group-mark-region t])
171 ["Subscribe to random group" gnus-group-unsubscribe-group t]
172 ["Kill all newsgroups in region" gnus-group-kill-region t]
173 ["Kill all zombie groups" gnus-group-kill-all-zombies t])
175 ["Make a foreign group" gnus-group-make-group t]
176 ["Edit a group entry" gnus-group-edit-group t]
177 ["Add a directory group" gnus-group-make-directory-group t]
178 ["Add the help group" gnus-group-make-help-group t]
179 ["Add the archive group" gnus-group-make-archive-group t]
180 ["Make a doc group" gnus-group-make-doc-group t]
181 ["Make a kiboze group" gnus-group-make-kiboze-group t]
182 ["Make a virtual group" gnus-group-make-empty-virtual t]
183 ["Add a group to a virtual" gnus-group-add-to-virtual t])
184 ["Read a directory as a group" gnus-group-enter-directory t]
185 ["Jump to group" gnus-group-jump-to-group t]
186 ["Best unread group" gnus-group-best-unread-group t]
194 ["Send a mail" gnus-group-mail t]
195 ["Post an article" gnus-group-post-news t]
203 ["Send a bug report" gnus-bug t]
204 ["Check for new news" gnus-group-get-new-news t]
205 ["Delete bogus groups" gnus-group-check-bogus-groups t]
206 ["Find new newsgroups" gnus-find-new-newsgroups t]
207 ["Restart Gnus" gnus-group-restart t]
208 ["Read init file" gnus-group-read-init-file t]
209 ["Browse foreign server" gnus-group-browse-foreign-server t]
210 ["Enter server buffer" gnus-group-enter-server-mode t]
211 ["Edit the global kill file" gnus-group-edit-global-kill t]
212 ["Expire all expirable articles" gnus-group-expire-all-groups t]
213 ["Generate any kiboze groups" nnkiboze-generate-groups t]
214 ["Gnus version" gnus-version t]
215 ["Save .newsrc files" gnus-group-save-newsrc t]
216 ["Suspend Gnus" gnus-group-suspend t]
217 ["Clear dribble buffer" gnus-group-clear-dribble t]
218 ["Exit from Gnus" gnus-group-exit t]
219 ["Exit without saving" gnus-group-quit t]
220 ["Sort group buffer" gnus-group-sort-groups t]
221 ["Edit global KILL file" gnus-group-edit-global-kill t]
227 (defun gnus-server-make-menu-bar ()
233 ["Add" gnus-server-add-server t]
234 ["Browse" gnus-server-read-server t]
235 ["List" gnus-server-list-servers t]
236 ["Kill" gnus-server-kill-server t]
237 ["Yank" gnus-server-yank-server t]
238 ["Copy" gnus-server-copy-server t]
239 ["Edit" gnus-server-edit-server t]
240 ["Exit" gnus-server-exit t]
244 (defun gnus-browse-make-menu-bar ()
250 ["Subscribe" gnus-browse-unsubscribe-current-group t]
251 ["Read" gnus-group-read-group t]
252 ["Exit" gnus-browse-exit t]
256 (defun gnus-summary-make-menu-bar ()
259 gnus-summary-mark-menu
260 gnus-summary-mode-map
264 ["Mark as read" gnus-summary-mark-as-read-forward t]
265 ["Mark same subject and select" gnus-summary-kill-same-subject-and-select t]
266 ["Mark same subject" gnus-summary-kill-same-subject t]
267 ["Catchup" gnus-summary-catchup t]
268 ["Catchup all" gnus-summary-catchup-all t]
269 ["Catchup to here" gnus-summary-catchup-to-here t]
270 ["Catchup region" gnus-summary-mark-region-as-read t])
272 ["Tick" gnus-summary-tick-article-forward t]
273 ["Mark as dormant" gnus-summary-mark-as-dormant t]
274 ["Remove marks" gnus-summary-clear-mark-forward t]
275 ["Set expirable mark" gnus-summary-mark-as-expirable t]
276 ["Set bookmark" gnus-summary-set-bookmark t]
277 ["Remove bookmark" gnus-summary-remove-bookmark t])
279 ["Remove lines marked as read" gnus-summary-remove-lines-marked-as-read t]
280 ["Remove lines marked with..." gnus-summary-remove-lines-marked-with t]
281 ["Show dormant articles" gnus-summary-show-all-dormant t]
282 ["Hide dormant articles" gnus-summary-hide-all-dormant t]
283 ["Show expunged articles" gnus-summary-show-all-expunged t])
285 ["Set mark" gnus-summary-mark-as-processable t]
286 ["Remove mark" gnus-summary-unmark-as-processable t]
287 ["Remove all marks" gnus-summary-unmark-all-processable t]
288 ["Mark series" gnus-uu-mark-series t]
289 ["Mark region" gnus-uu-mark-region t]
290 ["Mark by regexp" gnus-uu-mark-by-regexp t]
291 ["Mark all" gnus-uu-mark-all t]
292 ["Mark sparse" gnus-uu-mark-sparse t]
293 ["Mark thread" gnus-uu-mark-thread t]
298 gnus-summary-move-menu
299 gnus-summary-mode-map
302 ["Scroll article forwards" gnus-summary-next-page t]
303 ["Next unread article" gnus-summary-next-unread-article t]
304 ["Previous unread article" gnus-summary-prev-unread-article t]
305 ["Next article" gnus-summary-next-article t]
306 ["Previous article" gnus-summary-prev-article t]
307 ["Next article same subject" gnus-summary-next-same-subject t]
308 ["Previous article same subject" gnus-summary-prev-same-subject t]
309 ["First unread article" gnus-summary-first-unread-article t]
310 ["Go to subject number..." gnus-summary-goto-subject t]
311 ["Go to the last article" gnus-summary-goto-last-article t]
312 ["Pop article off history" gnus-summary-pop-article t]
316 gnus-summary-article-menu
317 gnus-summary-mode-map
322 ["Local" gnus-article-date-local t]
323 ["UT" gnus-article-date-local t]
324 ["Lapsed" gnus-article-date-local t])
325 ["Headers" gnus-article-hide-headers t]
326 ["Signature" gnus-article-hide-signature t]
327 ["Citation" gnus-article-hide-citation t]
328 ["Overstrike" gnus-article-treat-overstrike t]
329 ["Word wrap" gnus-article-word-wrap t]
330 ["CR" gnus-article-remove-cr t]
331 ["Show X-Face" gnus-article-display-x-face t]
332 ["Quoted-Printable" gnus-article-de-quoted-unreadable t])
334 ["Uudecode" gnus-uu-decode-uu t]
335 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
336 ["Unshar" gnus-uu-decode-unshar t]
337 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
338 ["Save" gnus-uu-decode-save t]
339 ["Binhex" gnus-uu-decode-binhex t])
340 ["Enter digest buffer" gnus-summary-enter-digest-group t]
341 ["Isearch article" gnus-summary-isearch-article t]
342 ["Search all articles" gnus-summary-search-article-forward t]
343 ["Beginning of the article" gnus-summary-beginning-of-article t]
344 ["End of the article" gnus-summary-end-of-article t]
345 ["Fetch parent of article" gnus-summary-refer-parent-article t]
346 ["Fetch article with id..." gnus-summary-refer-article t]
347 ["Stop page breaking" gnus-summary-stop-page-breaking t]
348 ["Caesar rotate" gnus-summary-caesar-message t]
349 ["Redisplay" gnus-summary-show-article t]
350 ["Toggle header" gnus-summary-toggle-header t]
351 ["Toggle MIME" gnus-summary-toggle-mime t]
352 ["Save" gnus-summary-save-article t]
353 ["Save in mail format" gnus-summary-save-article-mail t]
354 ["Pipe through a filter" gnus-summary-pipe-output t]
356 ["Respool article" gnus-summary-respool-article t]
357 ["Move article" gnus-summary-move-article t]
358 ["Copy article" gnus-summary-copy-article t]
359 ["Import file" gnus-summary-import-article t]
360 ["Edit article" gnus-summary-edit-article t]
361 ["Delete article" gnus-summary-delete-article t])
365 gnus-summary-thread-menu
366 gnus-summary-mode-map
369 ["Toggle threading" gnus-summary-toggle-threads t]
370 ["Display hidden thread" gnus-summary-show-thread t]
371 ["Hide thread" gnus-summary-hide-thread t]
372 ["Go to next thread" gnus-summary-next-thread t]
373 ["Go to previous thread" gnus-summary-prev-thread t]
374 ["Go down thread" gnus-summary-down-thread t]
375 ["Go up thread" gnus-summary-up-thread t]
376 ["Mark thread as read" gnus-summary-kill-thread t]
377 ["Lower thread score" gnus-summary-lower-thread t]
378 ["Raise thread score" gnus-summary-raise-thread t]
382 gnus-summary-misc-menu
383 gnus-summary-mode-map
387 ["Sort by number" gnus-summary-sort-by-number t]
388 ["Sort by author" gnus-summary-sort-by-author t]
389 ["Sort by subject" gnus-summary-sort-by-subject t]
390 ["Sort by date" gnus-summary-sort-by-date t]
391 ["Sort by score" gnus-summary-sort-by-score t])
393 ["Catchup and exit" gnus-summary-catchup-and-exit t]
394 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
395 ["Exit group" gnus-summary-exit t]
396 ["Exit group without updating" gnus-summary-exit-no-update t]
397 ["Reselect group" gnus-summary-reselect-current-group t]
398 ["Rescan group" gnus-summary-rescan-group t])
399 ["Fetch group FAQ" gnus-summary-fetch-faq t]
400 ["Filter articles" gnus-summary-execute-command t]
401 ["Toggle line truncation" gnus-summary-toggle-truncation t]
402 ["Expire expirable articles" gnus-summary-expire-articles t]
403 ["Describe group" gnus-summary-describe-group t]
404 ["Edit local kill file" gnus-summary-edit-local-kill t]
405 ["Edit global kill file" gnus-summary-edit-global-kill t]
409 gnus-summary-post-menu
410 gnus-summary-mode-map
413 ["Post an article" gnus-summary-post-news t]
414 ["Followup" gnus-summary-followup t]
415 ["Followup and yank" gnus-summary-followup-with-original t]
416 ["Supersede article" gnus-summary-supersede-article t]
417 ["Cancel article" gnus-summary-cancel-article t]
418 ["Reply" gnus-summary-reply t]
419 ["Reply and yank" gnus-summary-reply-with-original t]
420 ["Mail forward" gnus-summary-mail-forward t]
421 ["Post forward" gnus-summary-post-forward t]
422 ["Digest and mail" gnus-uu-digest-mail-forward t]
423 ["Digest and post" gnus-uu-digest-post-forward t]
424 ["Send a mail" gnus-summary-mail-other-window t]
425 ["Reply & followup" gnus-summary-followup-and-reply t]
426 ["Reply & followup and yank" gnus-summary-followup-and-reply-with-original t]
427 ["Uuencode and post" gnus-uu-post-news t]
431 gnus-summary-kill-menu
432 gnus-summary-mode-map
435 ["Enter score" gnus-summary-score-entry t]
436 ["Raise score" gnus-summary-increase-score t]
437 ["Lower score" gnus-summary-lower-score t]
438 ["Current score" gnus-summary-current-score t]
439 ["Set score" gnus-summary-set-score t]
441 ["Switch current score file" gnus-score-change-score-file t]
442 ["Set mark below" gnus-score-set-mark-below t]
443 ["Set expunge below" gnus-score-set-expunge-below t]
444 ["Edit current score file" gnus-score-edit-alist t]
445 ["Edit score file" gnus-score-edit-file t]
446 ["Trace score" gnus-score-find-trace t])
451 (defun gnus-article-make-menu-bar ()
454 gnus-article-article-menu
455 gnus-article-mode-map
458 ["Scroll forwards" gnus-article-next-page t]
459 ["Scroll backwards" gnus-article-prev-page t]
460 ["Show summary" gnus-article-show-summary t]
461 ["Fetch Message-ID at point" gnus-article-refer-article t]
462 ["Mail to address at point" gnus-article-mail t]
463 ["Mail to address at point and include original"
464 gnus-article-mail-with-original t]
468 gnus-article-treatment-menu
469 gnus-article-mode-map
472 ["Hide headers" gnus-article-hide-headers t]
473 ["Hide signature" gnus-article-hide-signature t]
474 ["Hide citation" gnus-article-hide-citation t]
475 ["Treat overstrike" gnus-article-treat-overstrike t]
476 ["Remove carriage return" gnus-article-remove-cr t]
477 ["Remove quoted-unreadble" gnus-article-de-quoted-unreadable t]
482 ;;; summary highlights
485 (defun gnus-highlight-selected-summary ()
486 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
487 ;; Highlight selected article in summary buffer
488 (if gnus-summary-selected-face
490 (let* ((beg (progn (beginning-of-line) (point)))
491 (end (progn (end-of-line) (point)))
492 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
493 (from (if (get-text-property beg 'mouse-face)
495 (1+ (or (next-single-property-change
496 beg 'mouse-face nil end)
498 (to (1- (or (next-single-property-change
499 from 'mouse-face nil end)
501 ;; If no mouse-face prop on line (e.g. xemacs) we
502 ;; will have to = from = end, so we highlight the
503 ;; entire line instead.
508 (if gnus-newsgroup-selected-overlay
509 (move-overlay gnus-newsgroup-selected-overlay
510 from to (current-buffer))
511 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
512 (overlay-put gnus-newsgroup-selected-overlay 'face
513 gnus-summary-selected-face))))))
516 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
517 (defun gnus-summary-highlight-line ()
518 "Highlight current line according to `gnus-summary-highlight'."
519 (let* ((list gnus-summary-highlight)
521 (end (progn (end-of-line) (point)))
522 ;; now find out where the line starts and leave point there.
523 (beg (progn (beginning-of-line) (point)))
524 (score (or (cdr (assq (or (get-text-property beg 'gnus-number)
525 gnus-current-article)
526 gnus-newsgroup-scored))
527 gnus-summary-default-score 0))
528 (default gnus-summary-default-score)
529 (mark (get-text-property beg 'gnus-mark))
530 (inhibit-read-only t))
531 (while (and list (not (eval (car (car list)))))
532 (setq list (cdr list)))
533 (let ((face (and list (cdr (car list)))))
534 ;; BUG! For some reason the text properties of the first
535 ;; characters get mangled.
537 (eq face (get-text-property beg 'face))
538 (put-text-property beg end 'face face)))
545 (defvar gnus-carpal-group-buffer-buttons
546 '(("next" . gnus-group-next-unread-group)
547 ("prev" . gnus-group-prev-unread-group)
548 ("read" . gnus-group-read-group)
549 ("select" . gnus-group-select-group)
550 ("catch up" . gnus-group-catchup-current)
551 ("new news" . gnus-group-get-new-news-this-group)
552 ("toggle sub" . gnus-group-unsubscribe-current-group)
553 ("subscribe" . gnus-group-unsubscribe-group)
554 ("kill" . gnus-group-kill-group)
555 ("yank" . gnus-group-yank-group)
556 ("describe" . gnus-group-describe-group)
558 ("subscribed" . gnus-group-list-groups)
559 ("all" . gnus-group-list-all-groups)
560 ("killed" . gnus-group-list-killed)
561 ("zombies" . gnus-group-list-zombies)
562 ("matching" . gnus-group-list-matching)
563 ("post" . gnus-group-post-news)
564 ("mail" . gnus-group-mail)
565 ("new news" . gnus-group-get-new-news)
566 ("browse foreign" . gnus-group-browse-foreign)
567 ("exit" . gnus-group-exit)))
569 (defvar gnus-carpal-summary-buffer-buttons
571 ("read" . gnus-summary-mark-as-read-forward)
572 ("tick" . gnus-summary-tick-article-forward)
573 ("clear" . gnus-summary-clear-mark-forward)
574 ("expirable" . gnus-summary-mark-as-expirable)
576 ("scroll" . gnus-summary-next-page)
577 ("next unread" . gnus-summary-next-unread-article)
578 ("prev unread" . gnus-summary-prev-unread-article)
579 ("first" . gnus-summary-first-unread-article)
580 ("best" . gnus-summary-best-unread-article)
582 ("headers" . gnus-summary-toggle-header)
583 ("uudecode" . gnus-uu-decode-uu)
584 ("enter digest" . gnus-summary-enter-digest-group)
585 ("fetch parent" . gnus-summary-refer-parent-article)
587 ("move" . gnus-summary-move-article)
588 ("copy" . gnus-summary-copy-article)
589 ("respool" . gnus-summary-respool-article)
591 ("lower" . gnus-summary-lower-thread)
592 ("kill" . gnus-summary-kill-thread)
594 ("post" . gnus-summary-post-news)
595 ("mail" . gnus-summary-mail)
596 ("followup" . gnus-summary-followup-with-original)
597 ("reply" . gnus-summary-reply-with-original)
598 ("cancel" . gnus-summary-cancel-article)
600 ("exit" . gnus-summary-exit)
601 ("fed up" . gnus-summary-catchup-and-goto-next-group)))
603 (defvar gnus-carpal-server-buffer-buttons
604 '(("add" . gnus-server-add-server)
605 ("browse" . gnus-server-browse-server)
606 ("list" . gnus-server-list-servers)
607 ("kill" . gnus-server-kill-server)
608 ("yank" . gnus-server-yank-server)
609 ("copy" . gnus-server-copy-server)
610 ("exit" . gnus-server-exit)))
612 (defvar gnus-carpal-browse-buffer-buttons
613 '(("subscribe" . gnus-browse-unsubscribe-current-group)
614 ("exit" . gnus-browse-exit)))
616 (defvar gnus-carpal-group-buffer "*Carpal Group*")
617 (defvar gnus-carpal-summary-buffer "*Carpal Summary*")
618 (defvar gnus-carpal-server-buffer "*Carpal Server*")
619 (defvar gnus-carpal-browse-buffer "*Carpal Browse*")
621 (defvar gnus-carpal-attached-buffer nil)
623 (defvar gnus-carpal-mode-hook nil
624 "*Hook run in carpal mode buffers.")
626 (defvar gnus-carpal-button-face 'bold
627 "*Face used on carpal buttons.")
629 (defvar gnus-carpal-header-face 'bold-italic
630 "*Face used on carpal buffer headers.")
632 (defvar gnus-carpal-mode-map nil)
633 (put 'gnus-carpal-mode 'mode-class 'special)
635 (if gnus-carpal-mode-map
637 (setq gnus-carpal-mode-map (make-keymap))
638 (suppress-keymap gnus-carpal-mode-map)
639 (define-key gnus-carpal-mode-map " " 'gnus-carpal-select)
640 (define-key gnus-carpal-mode-map "\r" 'gnus-carpal-select)
641 (define-key gnus-carpal-mode-map gnus-mouse-2 'gnus-carpal-mouse-select))
643 (defun gnus-carpal-mode ()
644 "Major mode clicking buttons.
646 All normal editing commands are switched off.
647 \\<gnus-carpal-mode-map>
648 The following commands are available:
650 \\{gnus-carpal-mode-map}"
652 (kill-all-local-variables)
653 (setq mode-line-modified "-- ")
654 (setq major-mode 'gnus-carpal-mode)
655 (setq mode-name "Gnus Carpal")
656 (setq mode-line-process nil)
657 (use-local-map gnus-carpal-mode-map)
658 (buffer-disable-undo (current-buffer))
659 (setq buffer-read-only t)
660 (make-local-variable 'gnus-carpal-attached-buffer)
661 (run-hooks 'gnus-carpal-mode-hook))
663 (defun gnus-carpal-setup-buffer (type)
664 (let ((buffer (symbol-value (intern (format "gnus-carpal-%s-buffer" type)))))
665 (if (get-buffer buffer)
668 (set-buffer (get-buffer-create buffer))
670 (setq gnus-carpal-attached-buffer
671 (intern (format "gnus-%s-buffer" type)))
672 (gnus-add-current-to-buffer-list)
673 (let ((buttons (symbol-value
674 (intern (format "gnus-carpal-%s-buffer-buttons"
676 (buffer-read-only nil)
679 (setq button (car buttons)
680 buttons (cdr buttons))
684 (prog2 (insert button) (point) (insert " "))
685 (list 'face gnus-carpal-header-face))
688 (prog2 (insert (car button)) (point) (insert " "))
689 (list 'gnus-callback (cdr button)
690 'face gnus-carpal-button-face
691 'mouse-face 'highlight))))
692 (let ((fill-column (- (window-width) 2)))
693 (fill-region (point-min) (point-max)))
694 (set-window-point (get-buffer-window (current-buffer))
697 (defun gnus-carpal-select ()
698 "Select the button under point."
700 (let ((func (get-text-property (point) 'gnus-callback)))
703 (pop-to-buffer (symbol-value gnus-carpal-attached-buffer))
704 (call-interactively func))))
706 (defun gnus-carpal-mouse-select (event)
707 "Select the button under the mouse pointer."
709 (mouse-set-point event)
710 (gnus-carpal-select))
713 ;;; article highlights
716 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
718 ;;; Internal Variables:
720 (defvar gnus-button-regexp nil)
721 ;; Regexp matching any of the regexps from `gnus-button-alist'.
723 (defvar gnus-button-last nil)
724 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
728 (defun gnus-article-push-button (event)
729 "Check text under the mouse pointer for a callback function.
730 If the text under the mouse pointer has a `gnus-callback' property,
731 call it with the value of the `gnus-data' text property."
733 (set-buffer (window-buffer (posn-window (event-start event))))
734 (let* ((pos (posn-point (event-start event)))
735 (data (get-text-property pos 'gnus-data))
736 (fun (get-text-property pos 'gnus-callback)))
737 (if fun (funcall fun data))))
739 (defun gnus-article-press-button ()
740 "Check text at point for a callback function.
741 If the text at point has a `gnus-callback' property,
742 call it with the value of the `gnus-data' text property."
744 (let* ((data (get-text-property (point) 'gnus-data))
745 (fun (get-text-property (point) 'gnus-callback)))
746 (if fun (funcall fun data))))
748 ;; Suggested by Arne Elofsson <arne@hodgkin.mbi.ucla.edu>
749 (defun gnus-article-next-button ()
750 "Move point to next button."
752 (if (get-text-property (point) 'gnus-callback)
753 (goto-char (next-single-property-change (point) 'gnus-callback
755 (let ((pos (next-single-property-change (point) 'gnus-callback)))
758 (setq pos (next-single-property-change (point-min) 'gnus-callback))
761 (error "No buttons found")))))
763 (defun gnus-article-highlight ()
764 "Highlight current article.
765 This function calls `gnus-article-highlight-headers',
766 `gnus-article-highlight-citation',
767 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
768 do the highlighting. See the documentation for those functions."
770 (gnus-article-highlight-headers)
771 (gnus-article-highlight-citation)
772 (gnus-article-highlight-signature)
773 (gnus-article-add-buttons))
775 (defun gnus-article-hide ()
776 "Hide current article.
777 This function calls `gnus-article-hide-headers',
778 `gnus-article-hide-citation-maybe', and `gnus-article-hide-signature'
779 to do the hiding. See the documentation for those functions."
781 (gnus-article-hide-headers)
782 (gnus-article-hide-citation-maybe)
783 (gnus-article-hide-signature))
785 (defun gnus-article-highlight-headers ()
786 "Highlight article headers as specified by `gnus-header-face-alist'."
789 (set-buffer gnus-article-buffer)
790 (goto-char (point-min))
791 (search-forward "\n\n")
792 (beginning-of-line 0)
794 (let ((alist gnus-header-face-alist)
795 (buffer-read-only nil)
798 (inhibit-point-motion-hooks t)
799 begin entry regexp header-face field-face header-found field-found)
800 (re-search-backward "^[^ \t]" nil t)
803 (setq entry (car alist)
805 header-face (nth 1 entry)
806 field-face (nth 2 entry)
808 (if (looking-at regexp)
809 (let ((from (point)))
810 (skip-chars-forward "^:\n")
811 (and (not header-found)
814 (put-text-property from (point) 'face header-face)
815 (setq header-found t)))
816 (and (not field-found)
819 (skip-chars-forward ": \t")
820 (let ((from (point)))
822 (skip-chars-backward " \t")
823 (put-text-property from (point) 'face field-face)
824 (setq field-found t))))))
825 (goto-char begin))))))
827 (defun gnus-article-highlight-signature ()
828 "Highlight the signature in an article.
829 It does this by highlighting everything after
830 `gnus-signature-separator' using `gnus-signature-face'."
833 (set-buffer gnus-article-buffer)
834 (let ((buffer-read-only nil)
835 (inhibit-point-motion-hooks t))
836 (goto-char (point-max))
837 (and (re-search-backward gnus-signature-separator nil t)
839 (let ((start (match-beginning 0))
841 (gnus-article-add-button start end 'gnus-signature-toggle end)
842 (overlay-put (make-overlay end (point-max))
843 'face gnus-signature-face))))))
845 (defun gnus-article-hide-signature ()
846 "Hide the signature in an article.
847 It does this by making everything after `gnus-signature-separator' invisible."
850 (set-buffer gnus-article-buffer)
851 (let ((buffer-read-only nil))
852 (goto-char (point-max))
853 (and (re-search-backward gnus-signature-separator nil t)
855 (add-text-properties (match-end 0) (point-max)
856 gnus-hidden-properties)))))
858 (defun gnus-article-add-buttons ()
859 "Find external references in article and make them to buttons.
861 External references are things like message-ids and URLs, as specified by
862 `gnus-button-alist'."
864 (if (eq gnus-button-last gnus-button-alist)
866 (setq gnus-button-regexp (mapconcat 'car gnus-button-alist "\\|")
867 gnus-button-last gnus-button-alist))
869 (set-buffer gnus-article-buffer)
870 (gnus-cite-parse-maybe)
871 (let ((buffer-read-only nil)
872 (inhibit-point-motion-hooks t)
873 (case-fold-search t))
874 (goto-char (point-min))
875 (search-forward "\n\n")
876 (while (re-search-forward gnus-button-regexp nil t)
877 (goto-char (match-beginning 0))
878 (let* ((from (point))
879 (entry (gnus-button-entry))
880 (start (and entry (match-beginning (nth 1 entry))))
881 (end (and entry (match-end (nth 1 entry))))
886 (goto-char (match-end 0))
888 (gnus-article-add-button start end 'gnus-button-push
889 (set-marker (make-marker)
892 ;;; External functions:
894 (defun gnus-article-add-button (from to fun &optional data)
895 "Create a button between FROM and TO with callback FUN and data DATA."
896 (add-text-properties from to
897 (append (if gnus-article-button-face
898 (list 'face gnus-article-button-face))
899 (if gnus-article-mouse-face
900 (list 'mouse-face gnus-article-mouse-face))
901 (list 'gnus-callback fun)
902 (if data (list 'gnus-data data)))))
904 ;;; Internal functions:
906 (defun gnus-signature-toggle (end)
908 (set-buffer gnus-article-buffer)
909 (let ((buffer-read-only nil))
910 (if (get-text-property end 'invisible)
911 (remove-text-properties end (point-max) gnus-hidden-properties)
912 (add-text-properties end (point-max) gnus-hidden-properties)))))
914 (defun gnus-make-face (color)
915 ;; Create entry for face with background COLOR.
916 (let ((name (intern (concat "gnus " color))))
918 (if gnus-make-foreground
919 (set-face-foreground name color)
920 (set-face-background name color))
923 (defun gnus-button-entry ()
924 ;; Return the first entry in `gnus-button-alist' matching this place.
925 (let ((alist gnus-button-alist)
928 (setq entry (car alist)
930 (if (looking-at (car entry))
935 (defun gnus-button-push (marker)
936 ;; Push button starting at MARKER.
938 (set-buffer gnus-article-buffer)
940 (let* ((entry (gnus-button-entry))
941 (inhibit-point-motion-hooks t)
943 (args (mapcar (lambda (group)
944 (let ((string (buffer-substring
945 (match-beginning group)
947 (set-text-properties 0 (length string) nil string)
953 (fboundp (symbol-value fun)))
954 (apply (symbol-value fun) args))
956 (message "You must define `%S' to use this button"
957 (cons fun args)))))))
959 (defun gnus-button-message-id (message-id)
960 ;; Push on MESSAGE-ID.
962 (set-buffer gnus-summary-buffer)
963 (gnus-summary-refer-article message-id)))
965 ;;; Compatibility Functions:
967 (or (fboundp 'rassoc)
968 ;; Introduced in Emacs 19.29.
969 (defun rassoc (elt list)
970 "Return non-nil if ELT is `equal' to the cdr of an element of LIST.
971 The value is actually the element of LIST whose cdr is ELT."
974 (setq result (car list))
975 (if (equal (cdr result) elt)
983 ;;; gnus-vis.el ends here