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 ;;; Summary highlights.
35 (defvar gnus-summary-selected-face 'underline
36 "*Face used for highlighting the current article in the summary buffer.")
38 (defvar gnus-summary-highlight
39 (cond ((not (eq gnus-display-type 'color))
40 '(((> score default) . bold)
41 ((< score default) . italic)))
42 ((eq gnus-background-mode 'dark)
43 (list (cons '(= mark gnus-canceled-mark)
44 (custom-face-lookup "yellow" "black" nil nil nil nil))
45 (cons '(and (> score default)
46 (or (= mark gnus-dormant-mark)
47 (= mark gnus-ticked-mark)))
48 (custom-face-lookup "red" nil nil t nil nil))
49 (cons '(and (< score default)
50 (or (= mark gnus-dormant-mark)
51 (= mark gnus-ticked-mark)))
52 (custom-face-lookup "red" nil nil nil t nil))
53 (cons '(or (= mark gnus-dormant-mark)
54 (= mark gnus-ticked-mark))
55 (custom-face-lookup "red" nil nil nil nil nil))
57 (cons '(and (> score default) (= mark gnus-ancient-mark))
58 (custom-face-lookup "blue" nil nil t nil nil))
59 (cons '(and (< score default) (= mark gnus-ancient-mark))
60 (custom-face-lookup "blue" nil nil nil t nil))
61 (cons '(= mark gnus-ancient-mark)
62 (custom-face-lookup "blue" nil nil nil nil nil))
64 (cons '(and (> score default) (= mark gnus-unread-mark))
65 (custom-face-lookup "green" nil nil t nil nil))
66 (cons '(and (< score default) (= mark gnus-unread-mark))
67 (custom-face-lookup "green" nil nil nil t nil))
68 (cons '(= mark gnus-unread-mark)
69 (custom-face-lookup "green" nil nil nil nil nil))
71 (cons '(> score default) 'bold)
72 (cons '(< score default) 'italic)))
74 (list (cons '(= mark gnus-canceled-mark)
75 (custom-face-lookup "yellow" "black" nil nil nil nil))
76 (cons '(and (> score default)
77 (or (= mark gnus-dormant-mark)
78 (= mark gnus-ticked-mark)))
79 (custom-face-lookup "firebrick" nil nil t nil nil))
80 (cons '(and (< score default)
81 (or (= mark gnus-dormant-mark)
82 (= mark gnus-ticked-mark)))
83 (custom-face-lookup "firebrick" nil nil nil t nil))
84 (cons '(or (= mark gnus-dormant-mark)
85 (= mark gnus-ticked-mark))
86 (custom-face-lookup "firebrick" nil nil nil nil nil))
88 (cons '(and (> score default) (= mark gnus-ancient-mark))
89 (custom-face-lookup "RoyalBlue" nil nil t nil nil))
90 (cons '(and (< score default) (= mark gnus-ancient-mark))
91 (custom-face-lookup "RoyalBlue" nil nil nil t nil))
92 (cons '(= mark gnus-ancient-mark)
93 (custom-face-lookup "RoyalBlue" nil nil nil nil nil))
95 (cons '(and (> score default) (= mark gnus-unread-mark))
96 (custom-face-lookup "DarkGreen" nil nil t nil nil))
97 (cons '(and (< score default) (= mark gnus-unread-mark))
98 (custom-face-lookup "DarkGreen" nil nil nil t nil))
99 (cons '(= mark gnus-unread-mark)
100 (custom-face-lookup "DarkGreen" nil nil nil nil nil))
102 (cons '(> score default) 'bold)
103 (cons '(< score default) 'italic))))
104 "*Alist of `(FORM . FACE)'.
105 Summary lines are highlighted with the FACE for the first FORM which
106 evaluate to a non-nil value.
108 Point will be at the beginning of the line when FORM is evaluated.
109 The following can be used for convenience:
111 score: (gnus-summary-article-score)
112 default: gnus-summary-default-score
113 below: gnus-summary-mark-below
114 mark: (gnus-summary-article-mark)
116 The latter can be used like this:
117 ((= mark gnus-replied-mark) . underline)")
119 ;;; article highlights
121 (defvar gnus-header-face-alist
122 (cond ((not (eq gnus-display-type 'color))
124 ((eq gnus-background-mode 'dark)
125 (list (list "From" nil
126 (custom-face-lookup "blue" nil nil t t nil))
128 (custom-face-lookup "red" nil nil t t nil))
129 (list "Newsgroups:.*," nil
130 (custom-face-lookup "firebrick" nil nil t t nil))
132 (custom-face-lookup "green" nil nil nil t nil))))
134 (list (list "From" nil
135 (custom-face-lookup "red" nil nil t t nil))
137 (custom-face-lookup "firebrick" nil nil t t nil))
138 (list "Newsgroups:.*," nil
139 (custom-face-lookup "firebrick" nil nil t t nil))
141 (custom-face-lookup "DarkGreen" nil nil nil t nil)))))
142 "Alist of headers and faces used for highlighting them.
143 The entries in the list has the form `(REGEXP NAME CONTENT)', where
144 REGEXP is a regular expression matching the beginning of the header,
145 NAME is the face used for highlighting the header name and CONTENT is
146 the face used for highlighting the header content.
148 The first non-nil NAME or CONTENT with a matching REGEXP in the list
152 (defvar gnus-make-foreground t
153 "Non nil means foreground color to highlight citations.")
155 (defvar gnus-article-button-face 'bold
156 "Face used for text buttons.")
158 (defvar gnus-article-mouse-face (if (boundp 'gnus-mouse-face)
161 "Face used when the mouse is over the button.")
163 (defvar gnus-summary-highlight
164 '(((> score default) . bold)
165 ((< score default) . italic))
166 "*Alist of `(FORM . FACE)'.
167 Summary lines are highlighted with the FACE for the first FORM which
168 evaluate to a non-nil value.
170 Point will be at the beginning of the line when FORM is evaluated.
171 The following can be used for convenience:
173 score: (gnus-summary-article-score)
174 default: gnus-summary-default-score
175 below: gnus-summary-mark-below
177 To check for marks, e.g. to underline replied articles, use
178 `gnus-summary-article-mark':
180 ((= (gnus-summary-article-mark) gnus-replied-mark) . underline)")
182 (defvar gnus-signature-face 'italic
183 "Face used for signature.")
185 (defvar gnus-button-alist
186 '(("in\\( +article\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
187 (assq (count-lines (point-min) (match-end 0))
188 gnus-cite-attribution-alist)
189 gnus-button-message-id 3)
190 ;; This is how URLs _should_ be embedded in text...
191 ("<URL:\\([^\n\r>]*\\)>" 0 t gnus-button-url 1)
192 ;; Next regexp stolen from highlight-headers.el
193 ("\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]+" 0 t
195 "Alist of regexps matching buttons in an article.
197 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
198 REGEXP: is the string matching text around the button,
199 BUTTON: is the number of the regexp grouping actually matching the button,
200 FORM: is a lisp expression which must eval to true for the button to
202 CALLBACK: is the function to call when the user push this button, and each
203 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
205 CALLBACK can also be a variable, in that case the value of that
206 variable it the real callback function.")
208 (defvar gnus-button-url (cond ((fboundp 'w3-fetch)
210 ((fboundp 'highlight-headers-follow-url-netscape)
211 'highlight-headers-follow-url-netscape)
213 "Function to fetch URL.
214 The function will be called with one argument, the URL to fetch.
215 Useful values of this function are:
218 defined in the w3 emacs package by William M. Perry.
219 highlight-headers-follow-url-netscape:
220 from `highlight-headers.el' for loading NetScape 1.1.")
225 (autoload 'nnkiboze-generate-groups "nnkiboze")
226 (autoload 'gnus-cite-parse-maybe "gnus-cite" nil t))
234 (defun gnus-group-make-menu-bar ()
236 gnus-group-reading-menu
240 ["Read" gnus-group-read-group t]
241 ["Select" gnus-group-select-group t]
242 ["Catch up" gnus-group-catchup-current t]
243 ["Catch up all articles" gnus-group-catchup-current-all t]
244 ["Check for new articles" gnus-group-get-new-news-this-group t]
245 ["Toggle subscription" gnus-group-unsubscribe-current-group t]
246 ["Kill" gnus-group-kill-group t]
247 ["Yank" gnus-group-yank-group t]
248 ["Describe" gnus-group-describe-group t]
249 ["Fetch FAQ" gnus-group-fetch-faq t]
250 ["Edit kill file" gnus-group-edit-local-kill t]
251 ["Expire articles" gnus-group-expire-articles t]
252 ["Set group level" gnus-group-set-current-level t]
256 gnus-group-group-menu
261 ["List subscribed groups" gnus-group-list-groups t]
262 ["List all groups" gnus-group-list-all-groups t]
263 ["List groups matching..." gnus-group-list-matching t]
264 ["List killed groups" gnus-group-list-killed t]
265 ["List zombie groups" gnus-group-list-zombies t]
266 ["Describe all groups" gnus-group-describe-all-groups t]
267 ["Group apropos" gnus-group-apropos t]
268 ["Group and description apropos" gnus-group-description-apropos t]
269 ["List groups matching..." gnus-group-list-matching t])
271 ["Mark group" gnus-group-mark-group t]
272 ["Unmark group" gnus-group-unmark-group t]
273 ["Mark region" gnus-group-mark-region t])
275 ["Subscribe to random group" gnus-group-unsubscribe-group t]
276 ["Kill all newsgroups in region" gnus-group-kill-region t]
277 ["Kill all zombie groups" gnus-group-kill-all-zombies t])
279 ["Make a foreign group" gnus-group-make-group t]
280 ["Edit a group entry" gnus-group-edit-group t]
281 ["Add a directory group" gnus-group-make-directory-group t]
282 ["Add the help group" gnus-group-make-help-group t]
283 ["Add the archive group" gnus-group-make-archive-group t]
284 ["Make a doc group" gnus-group-make-doc-group t]
285 ["Make a kiboze group" gnus-group-make-kiboze-group t]
286 ["Make a virtual group" gnus-group-make-empty-virtual t]
287 ["Add a group to a virtual" gnus-group-add-to-virtual t])
288 ["Read a directory as a group" gnus-group-enter-directory t]
289 ["Jump to group" gnus-group-jump-to-group t]
290 ["Best unread group" gnus-group-best-unread-group t]
298 ["Send a mail" gnus-group-mail t]
299 ["Post an article" gnus-group-post-news t]
307 ["Send a bug report" gnus-bug t]
308 ["Check for new news" gnus-group-get-new-news t]
309 ["Delete bogus groups" gnus-group-check-bogus-groups t]
310 ["Find new newsgroups" gnus-find-new-newsgroups t]
311 ["Restart Gnus" gnus-group-restart t]
312 ["Read init file" gnus-group-read-init-file t]
313 ["Browse foreign server" gnus-group-browse-foreign-server t]
314 ["Enter server buffer" gnus-group-enter-server-mode t]
315 ["Expire expirable articles" gnus-group-expire-all-groups t]
316 ["Generate any kiboze groups" nnkiboze-generate-groups t]
317 ["Gnus version" gnus-version t]
318 ["Save .newsrc files" gnus-group-save-newsrc t]
319 ["Suspend Gnus" gnus-group-suspend t]
320 ["Clear dribble buffer" gnus-group-clear-dribble t]
321 ["Exit from Gnus" gnus-group-exit t]
322 ["Exit without saving" gnus-group-quit t]
323 ["Edit global kill file" gnus-group-edit-global-kill t]
324 ["Sort group buffer" gnus-group-sort-groups t]
330 (defun gnus-server-make-menu-bar ()
336 ["Add" gnus-server-add-server t]
337 ["Browse" gnus-server-read-server t]
338 ["List" gnus-server-list-servers t]
339 ["Kill" gnus-server-kill-server t]
340 ["Yank" gnus-server-yank-server t]
341 ["Copy" gnus-server-copy-server t]
342 ["Edit" gnus-server-edit-server t]
343 ["Exit" gnus-server-exit t]
347 (defun gnus-browse-make-menu-bar ()
353 ["Subscribe" gnus-browse-unsubscribe-current-group t]
354 ["Read" gnus-group-read-group t]
355 ["Exit" gnus-browse-exit t]
359 (defun gnus-summary-make-menu-bar ()
362 gnus-summary-mark-menu
363 gnus-summary-mode-map
367 ["Mark as read" gnus-summary-mark-as-read-forward t]
368 ["Mark same subject and select" gnus-summary-kill-same-subject-and-select t]
369 ["Mark same subject" gnus-summary-kill-same-subject t]
370 ["Catchup" gnus-summary-catchup t]
371 ["Catchup all" gnus-summary-catchup-all t]
372 ["Catchup to here" gnus-summary-catchup-to-here t]
373 ["Catchup region" gnus-summary-mark-region-as-read t])
375 ["Tick" gnus-summary-tick-article-forward t]
376 ["Mark as dormant" gnus-summary-mark-as-dormant t]
377 ["Remove marks" gnus-summary-clear-mark-forward t]
378 ["Set expirable mark" gnus-summary-mark-as-expirable t]
379 ["Set bookmark" gnus-summary-set-bookmark t]
380 ["Remove bookmark" gnus-summary-remove-bookmark t])
382 ["Remove lines marked as read" gnus-summary-remove-lines-marked-as-read t]
383 ["Remove lines marked with..." gnus-summary-remove-lines-marked-with t]
384 ["Show dormant articles" gnus-summary-show-all-dormant t]
385 ["Hide dormant articles" gnus-summary-hide-all-dormant t]
386 ["Show expunged articles" gnus-summary-show-all-expunged t])
388 ["Set mark" gnus-summary-mark-as-processable t]
389 ["Remove mark" gnus-summary-unmark-as-processable t]
390 ["Remove all marks" gnus-summary-unmark-all-processable t]
391 ["Mark series" gnus-uu-mark-series t]
392 ["Mark region" gnus-uu-mark-region t]
393 ["Mark by regexp" gnus-uu-mark-by-regexp t]
394 ["Mark all" gnus-uu-mark-all t]
395 ["Mark sparse" gnus-uu-mark-sparse t]
396 ["Mark thread" gnus-uu-mark-thread t]
401 gnus-summary-move-menu
402 gnus-summary-mode-map
405 ["Scroll article forwards" gnus-summary-next-page t]
406 ["Next unread article" gnus-summary-next-unread-article t]
407 ["Previous unread article" gnus-summary-prev-unread-article t]
408 ["Next article" gnus-summary-next-article t]
409 ["Previous article" gnus-summary-prev-article t]
410 ["Next article same subject" gnus-summary-next-same-subject t]
411 ["Previous article same subject" gnus-summary-prev-same-subject t]
412 ["First unread article" gnus-summary-first-unread-article t]
413 ["Go to subject number..." gnus-summary-goto-subject t]
414 ["Go to the last article" gnus-summary-goto-last-article t]
415 ["Pop article off history" gnus-summary-pop-article t]
419 gnus-summary-article-menu
420 gnus-summary-mode-map
425 ["Local" gnus-article-date-local t]
426 ["UT" gnus-article-date-local t]
427 ["Lapsed" gnus-article-date-local t])
428 ["Headers" gnus-article-hide-headers t]
429 ["Signature" gnus-article-hide-signature t]
430 ["Citation" gnus-article-hide-citation t]
431 ["Overstrike" gnus-article-treat-overstrike t]
432 ["Word wrap" gnus-article-word-wrap t]
433 ["CR" gnus-article-remove-cr t]
434 ["Show X-Face" gnus-article-display-x-face t]
435 ["Quoted-Printable" gnus-article-de-quoted-unreadable t])
437 ["Uudecode" gnus-uu-decode-uu t]
438 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
439 ["Unshar" gnus-uu-decode-unshar t]
440 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
441 ["Save" gnus-uu-decode-save t]
442 ["Binhex" gnus-uu-decode-binhex t])
443 ["Enter digest buffer" gnus-summary-enter-digest-group t]
444 ["Isearch article" gnus-summary-isearch-article t]
445 ["Search all articles" gnus-summary-search-article-forward t]
446 ["Beginning of the article" gnus-summary-beginning-of-article t]
447 ["End of the article" gnus-summary-end-of-article t]
448 ["Fetch parent of article" gnus-summary-refer-parent-article t]
449 ["Fetch article with id..." gnus-summary-refer-article t]
450 ["Stop page breaking" gnus-summary-stop-page-breaking t]
451 ["Caesar rotate" gnus-summary-caesar-message t]
452 ["Redisplay" gnus-summary-show-article t]
453 ["Toggle header" gnus-summary-toggle-header t]
454 ["Toggle MIME" gnus-summary-toggle-mime t]
455 ["Save" gnus-summary-save-article t]
456 ["Save in mail format" gnus-summary-save-article-mail t]
457 ["Pipe through a filter" gnus-summary-pipe-output t]
459 ["Respool article" gnus-summary-respool-article t]
460 ["Move article" gnus-summary-move-article t]
461 ["Copy article" gnus-summary-copy-article t]
462 ["Import file" gnus-summary-import-article t]
463 ["Edit article" gnus-summary-edit-article t]
464 ["Delete article" gnus-summary-delete-article t])
468 gnus-summary-thread-menu
469 gnus-summary-mode-map
472 ["Toggle threading" gnus-summary-toggle-threads t]
473 ["Display hidden thread" gnus-summary-show-thread t]
474 ["Hide thread" gnus-summary-hide-thread t]
475 ["Go to next thread" gnus-summary-next-thread t]
476 ["Go to previous thread" gnus-summary-prev-thread t]
477 ["Go down thread" gnus-summary-down-thread t]
478 ["Go up thread" gnus-summary-up-thread t]
479 ["Mark thread as read" gnus-summary-kill-thread t]
480 ["Lower thread score" gnus-summary-lower-thread t]
481 ["Raise thread score" gnus-summary-raise-thread t]
485 gnus-summary-misc-menu
486 gnus-summary-mode-map
490 ["Sort by number" gnus-summary-sort-by-number t]
491 ["Sort by author" gnus-summary-sort-by-author t]
492 ["Sort by subject" gnus-summary-sort-by-subject t]
493 ["Sort by date" gnus-summary-sort-by-date t]
494 ["Sort by score" gnus-summary-sort-by-score t])
496 ["Catchup and exit" gnus-summary-catchup-and-exit t]
497 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
498 ["Exit group" gnus-summary-exit t]
499 ["Exit group without updating" gnus-summary-exit-no-update t]
500 ["Reselect group" gnus-summary-reselect-current-group t]
501 ["Rescan group" gnus-summary-rescan-group t])
502 ["Fetch group FAQ" gnus-summary-fetch-faq t]
503 ["Filter articles" gnus-summary-execute-command t]
504 ["Toggle line truncation" gnus-summary-toggle-truncation t]
505 ["Expire expirable articles" gnus-summary-expire-articles t]
506 ["Describe group" gnus-summary-describe-group t]
507 ["Edit local kill file" gnus-summary-edit-local-kill t]
511 gnus-summary-post-menu
512 gnus-summary-mode-map
515 ["Post an article" gnus-summary-post-news t]
516 ["Followup" gnus-summary-followup t]
517 ["Followup and yank" gnus-summary-followup-with-original t]
518 ["Supersede article" gnus-summary-supersede-article t]
519 ["Cancel article" gnus-summary-cancel-article t]
520 ["Reply" gnus-summary-reply t]
521 ["Reply and yank" gnus-summary-reply-with-original t]
522 ["Mail forward" gnus-summary-mail-forward t]
523 ["Post forward" gnus-summary-post-forward t]
524 ["Digest and mail" gnus-uu-digest-mail-forward t]
525 ["Digest and post" gnus-uu-digest-post-forward t]
526 ["Send a mail" gnus-summary-mail-other-window t]
527 ["Reply & followup" gnus-summary-followup-and-reply t]
528 ["Reply & followup and yank" gnus-summary-followup-and-reply-with-original t]
529 ["Uuencode and post" gnus-uu-post-news t]
533 gnus-summary-kill-menu
534 gnus-summary-mode-map
540 ["Enter score" gnus-summary-score-entry t])
541 (gnus-visual-score-map 'increase)
542 (gnus-visual-score-map 'lower)
543 '(["Current score" gnus-summary-current-score t]
544 ["Set score" gnus-summary-set-score t]
546 ["Customize score file" gnus-score-customize t]
547 ["Switch current score file" gnus-score-change-score-file t]
548 ["Set mark below" gnus-score-set-mark-below t]
549 ["Set expunge below" gnus-score-set-expunge-below t]
550 ["Edit current score file" gnus-score-edit-alist t]
551 ["Edit score file" gnus-score-edit-file t]
552 ["Trace score" gnus-score-find-trace t])
557 (defun gnus-visual-score-map (type)
558 (let ((headers '(("author" "from" string)
559 ("subject" "subject" string)
560 ("article body" "body" string)
561 ("article head" "head" string)
562 ("xref" "xref" string)
563 ("lines" "lines" number)
564 ("followups to author" "followup" string)))
565 (types '((number ("less than" <)
568 (string ("substring" s)
572 (perms '(("temporary" (current-time-string))
585 (setq header (car headers))
591 (let ((ts (cdr (assoc (nth 2 header) types)))
598 (list (car (car ts)))
607 'gnus-summary-score-entry
609 (if (or (string= (nth 1 header) "head")
610 (string= (nth 1 header) "body"))
612 (list 'gnus-summary-header
614 (list 'quote (nth 1 (car ts)))
615 (list 'gnus-score-default nil)
621 (list (nreverse outp))))
624 (list (nreverse outt))))
626 (setq headers (cdr headers)))
627 (list (nreverse outh)))))))
630 (defun gnus-article-make-menu-bar ()
633 gnus-article-article-menu
634 gnus-article-mode-map
637 ["Scroll forwards" gnus-article-next-page t]
638 ["Scroll backwards" gnus-article-prev-page t]
639 ["Show summary" gnus-article-show-summary t]
640 ["Fetch Message-ID at point" gnus-article-refer-article t]
641 ["Mail to address at point" gnus-article-mail t]
642 ["Mail to address at point and include original"
643 gnus-article-mail-with-original t]
647 gnus-article-treatment-menu
648 gnus-article-mode-map
651 ["Hide headers" gnus-article-hide-headers t]
652 ["Hide signature" gnus-article-hide-signature t]
653 ["Hide citation" gnus-article-hide-citation t]
654 ["Treat overstrike" gnus-article-treat-overstrike t]
655 ["Remove carriage return" gnus-article-remove-cr t]
656 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
661 ;;; summary highlights
664 (defun gnus-highlight-selected-summary ()
665 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
666 ;; Highlight selected article in summary buffer
667 (if gnus-summary-selected-face
669 (let* ((beg (progn (beginning-of-line) (point)))
670 (end (progn (end-of-line) (point)))
671 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
672 (from (if (get-text-property beg 'mouse-face)
674 (1+ (or (next-single-property-change
675 beg 'mouse-face nil end)
677 (to (1- (or (next-single-property-change
678 from 'mouse-face nil end)
680 ;; If no mouse-face prop on line (e.g. xemacs) we
681 ;; will have to = from = end, so we highlight the
682 ;; entire line instead.
687 (if gnus-newsgroup-selected-overlay
688 (move-overlay gnus-newsgroup-selected-overlay
689 from to (current-buffer))
690 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
691 (overlay-put gnus-newsgroup-selected-overlay 'face
692 gnus-summary-selected-face))))))
694 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
695 (defun gnus-summary-highlight-line ()
696 "Highlight current line according to `gnus-summary-highlight'."
697 (let* ((list gnus-summary-highlight)
699 (end (progn (end-of-line) (point)))
700 ;; now find out where the line starts and leave point there.
701 (beg (progn (beginning-of-line) (point)))
702 (score (or (cdr (assq (or (get-text-property beg 'gnus-number)
703 gnus-current-article)
704 gnus-newsgroup-scored))
705 gnus-summary-default-score 0))
706 (default gnus-summary-default-score)
707 (mark (get-text-property beg 'gnus-mark))
708 (inhibit-read-only t))
709 (while (and list (not (eval (car (car list)))))
710 (setq list (cdr list)))
711 (let ((face (and list (cdr (car list)))))
712 ;; BUG! For some reason the text properties of the first
713 ;; characters get mangled.
715 (eq face (get-text-property beg 'face))
716 (put-text-property beg end 'face face)))
723 (defvar gnus-carpal-group-buffer-buttons
724 '(("next" . gnus-group-next-unread-group)
725 ("prev" . gnus-group-prev-unread-group)
726 ("read" . gnus-group-read-group)
727 ("select" . gnus-group-select-group)
728 ("catch up" . gnus-group-catchup-current)
729 ("new news" . gnus-group-get-new-news-this-group)
730 ("toggle sub" . gnus-group-unsubscribe-current-group)
731 ("subscribe" . gnus-group-unsubscribe-group)
732 ("kill" . gnus-group-kill-group)
733 ("yank" . gnus-group-yank-group)
734 ("describe" . gnus-group-describe-group)
736 ("subscribed" . gnus-group-list-groups)
737 ("all" . gnus-group-list-all-groups)
738 ("killed" . gnus-group-list-killed)
739 ("zombies" . gnus-group-list-zombies)
740 ("matching" . gnus-group-list-matching)
741 ("post" . gnus-group-post-news)
742 ("mail" . gnus-group-mail)
743 ("rescan" . gnus-group-get-new-news)
744 ("browse foreign" . gnus-group-browse-foreign)
745 ("exit" . gnus-group-exit)))
747 (defvar gnus-carpal-summary-buffer-buttons
749 ("read" . gnus-summary-mark-as-read-forward)
750 ("tick" . gnus-summary-tick-article-forward)
751 ("clear" . gnus-summary-clear-mark-forward)
752 ("expirable" . gnus-summary-mark-as-expirable)
754 ("scroll" . gnus-summary-next-page)
755 ("next unread" . gnus-summary-next-unread-article)
756 ("prev unread" . gnus-summary-prev-unread-article)
757 ("first" . gnus-summary-first-unread-article)
758 ("best" . gnus-summary-best-unread-article)
760 ("headers" . gnus-summary-toggle-header)
761 ("uudecode" . gnus-uu-decode-uu)
762 ("enter digest" . gnus-summary-enter-digest-group)
763 ("fetch parent" . gnus-summary-refer-parent-article)
765 ("move" . gnus-summary-move-article)
766 ("copy" . gnus-summary-copy-article)
767 ("respool" . gnus-summary-respool-article)
769 ("lower" . gnus-summary-lower-thread)
770 ("kill" . gnus-summary-kill-thread)
772 ("post" . gnus-summary-post-news)
773 ("mail" . gnus-summary-mail)
774 ("followup" . gnus-summary-followup-with-original)
775 ("reply" . gnus-summary-reply-with-original)
776 ("cancel" . gnus-summary-cancel-article)
778 ("exit" . gnus-summary-exit)
779 ("fed up" . gnus-summary-catchup-and-goto-next-group)))
781 (defvar gnus-carpal-server-buffer-buttons
782 '(("add" . gnus-server-add-server)
783 ("browse" . gnus-server-browse-server)
784 ("list" . gnus-server-list-servers)
785 ("kill" . gnus-server-kill-server)
786 ("yank" . gnus-server-yank-server)
787 ("copy" . gnus-server-copy-server)
788 ("exit" . gnus-server-exit)))
790 (defvar gnus-carpal-browse-buffer-buttons
791 '(("subscribe" . gnus-browse-unsubscribe-current-group)
792 ("exit" . gnus-browse-exit)))
794 (defvar gnus-carpal-group-buffer "*Carpal Group*")
795 (defvar gnus-carpal-summary-buffer "*Carpal Summary*")
796 (defvar gnus-carpal-server-buffer "*Carpal Server*")
797 (defvar gnus-carpal-browse-buffer "*Carpal Browse*")
799 (defvar gnus-carpal-attached-buffer nil)
801 (defvar gnus-carpal-mode-hook nil
802 "*Hook run in carpal mode buffers.")
804 (defvar gnus-carpal-button-face 'bold
805 "*Face used on carpal buttons.")
807 (defvar gnus-carpal-header-face 'bold-italic
808 "*Face used on carpal buffer headers.")
810 (defvar gnus-carpal-mode-map nil)
811 (put 'gnus-carpal-mode 'mode-class 'special)
813 (if gnus-carpal-mode-map
815 (setq gnus-carpal-mode-map (make-keymap))
816 (suppress-keymap gnus-carpal-mode-map)
817 (define-key gnus-carpal-mode-map " " 'gnus-carpal-select)
818 (define-key gnus-carpal-mode-map "\r" 'gnus-carpal-select)
819 (define-key gnus-carpal-mode-map gnus-mouse-2 'gnus-carpal-mouse-select))
821 (defun gnus-carpal-mode ()
822 "Major mode clicking buttons.
824 All normal editing commands are switched off.
825 \\<gnus-carpal-mode-map>
826 The following commands are available:
828 \\{gnus-carpal-mode-map}"
830 (kill-all-local-variables)
831 (setq mode-line-modified "-- ")
832 (setq major-mode 'gnus-carpal-mode)
833 (setq mode-name "Gnus Carpal")
834 (setq mode-line-process nil)
835 (use-local-map gnus-carpal-mode-map)
836 (buffer-disable-undo (current-buffer))
837 (setq buffer-read-only t)
838 (make-local-variable 'gnus-carpal-attached-buffer)
839 (run-hooks 'gnus-carpal-mode-hook))
841 (defun gnus-carpal-setup-buffer (type)
842 (let ((buffer (symbol-value (intern (format "gnus-carpal-%s-buffer" type)))))
843 (if (get-buffer buffer)
846 (set-buffer (get-buffer-create buffer))
848 (setq gnus-carpal-attached-buffer
849 (intern (format "gnus-%s-buffer" type)))
850 (gnus-add-current-to-buffer-list)
851 (let ((buttons (symbol-value
852 (intern (format "gnus-carpal-%s-buffer-buttons"
854 (buffer-read-only nil)
857 (setq button (car buttons)
858 buttons (cdr buttons))
862 (prog2 (insert button) (point) (insert " "))
863 (list 'face gnus-carpal-header-face))
866 (prog2 (insert (car button)) (point) (insert " "))
867 (list 'gnus-callback (cdr button)
868 'face gnus-carpal-button-face
869 'mouse-face 'highlight))))
870 (let ((fill-column (- (window-width) 2)))
871 (fill-region (point-min) (point-max)))
872 (set-window-point (get-buffer-window (current-buffer))
875 (defun gnus-carpal-select ()
876 "Select the button under point."
878 (let ((func (get-text-property (point) 'gnus-callback)))
881 (pop-to-buffer (symbol-value gnus-carpal-attached-buffer))
882 (call-interactively func))))
884 (defun gnus-carpal-mouse-select (event)
885 "Select the button under the mouse pointer."
887 (mouse-set-point event)
888 (gnus-carpal-select))
891 ;;; article highlights
894 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
896 ;;; Internal Variables:
898 (defvar gnus-button-regexp nil)
899 ;; Regexp matching any of the regexps from `gnus-button-alist'.
901 (defvar gnus-button-last nil)
902 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
906 (defun gnus-article-push-button (event)
907 "Check text under the mouse pointer for a callback function.
908 If the text under the mouse pointer has a `gnus-callback' property,
909 call it with the value of the `gnus-data' text property."
911 (set-buffer (window-buffer (posn-window (event-start event))))
912 (let* ((pos (posn-point (event-start event)))
913 (data (get-text-property pos 'gnus-data))
914 (fun (get-text-property pos 'gnus-callback)))
915 (if fun (funcall fun data))))
917 (defun gnus-article-press-button ()
918 "Check text at point for a callback function.
919 If the text at point has a `gnus-callback' property,
920 call it with the value of the `gnus-data' text property."
922 (let* ((data (get-text-property (point) 'gnus-data))
923 (fun (get-text-property (point) 'gnus-callback)))
924 (if fun (funcall fun data))))
926 ;; Suggested by Arne Elofsson <arne@hodgkin.mbi.ucla.edu>
927 (defun gnus-article-next-button ()
928 "Move point to next button."
930 (if (get-text-property (point) 'gnus-callback)
931 (goto-char (next-single-property-change (point) 'gnus-callback
933 (let ((pos (next-single-property-change (point) 'gnus-callback)))
936 (setq pos (next-single-property-change (point-min) 'gnus-callback))
939 (error "No buttons found")))))
941 (defun gnus-article-highlight ()
942 "Highlight current article.
943 This function calls `gnus-article-highlight-headers',
944 `gnus-article-highlight-citation',
945 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
946 do the highlighting. See the documentation for those functions."
948 (gnus-article-highlight-headers)
949 (gnus-article-highlight-citation)
950 (gnus-article-highlight-signature)
951 (gnus-article-add-buttons))
953 (defun gnus-article-hide ()
954 "Hide current article.
955 This function calls `gnus-article-hide-headers',
956 `gnus-article-hide-citation-maybe', and `gnus-article-hide-signature'
957 to do the hiding. See the documentation for those functions."
959 (gnus-article-hide-headers)
960 (gnus-article-hide-citation-maybe)
961 (gnus-article-hide-signature))
963 (defun gnus-article-highlight-headers ()
964 "Highlight article headers as specified by `gnus-header-face-alist'."
967 (set-buffer gnus-article-buffer)
968 (goto-char (point-min))
969 (if (not (search-forward "\n\n" nil t))
971 (beginning-of-line 0)
973 (let ((alist gnus-header-face-alist)
974 (buffer-read-only nil)
977 (inhibit-point-motion-hooks t)
978 begin entry regexp header-face field-face
979 header-found field-found)
980 (re-search-backward "^[^ \t]" nil t)
983 (setq entry (car alist)
985 header-face (nth 1 entry)
986 field-face (nth 2 entry)
988 (if (looking-at regexp)
989 (let ((from (point)))
990 (skip-chars-forward "^:\n")
991 (and (not header-found)
994 (put-text-property from (point) 'face header-face)
995 (setq header-found t)))
996 (and (not field-found)
999 (skip-chars-forward ": \t")
1000 (let ((from (point)))
1002 (skip-chars-backward " \t")
1003 (put-text-property from (point) 'face field-face)
1004 (setq field-found t))))))
1005 (goto-char begin)))))))
1007 (defun gnus-article-highlight-signature ()
1008 "Highlight the signature in an article.
1009 It does this by highlighting everything after
1010 `gnus-signature-separator' using `gnus-signature-face'."
1013 (set-buffer gnus-article-buffer)
1014 (let ((buffer-read-only nil)
1015 (inhibit-point-motion-hooks t))
1016 (goto-char (point-max))
1017 (and (re-search-backward gnus-signature-separator nil t)
1019 (let ((start (match-beginning 0))
1020 (end (match-end 0)))
1021 (gnus-article-add-button start end 'gnus-signature-toggle end)
1022 (overlay-put (make-overlay end (point-max))
1023 'face gnus-signature-face))))))
1025 (defun gnus-article-hide-signature ()
1026 "Hide the signature in an article.
1027 It does this by making everything after `gnus-signature-separator' invisible."
1030 (set-buffer gnus-article-buffer)
1031 (let ((buffer-read-only nil))
1032 (goto-char (point-max))
1033 (and (re-search-backward gnus-signature-separator nil t)
1035 (add-text-properties (match-end 0) (point-max)
1036 gnus-hidden-properties)))))
1038 (defun gnus-article-add-buttons ()
1039 "Find external references in article and make them to buttons.
1041 External references are things like message-ids and URLs, as specified by
1042 `gnus-button-alist'."
1044 (if (eq gnus-button-last gnus-button-alist)
1046 (setq gnus-button-regexp (mapconcat 'car gnus-button-alist "\\|")
1047 gnus-button-last gnus-button-alist))
1049 (set-buffer gnus-article-buffer)
1050 (gnus-cite-parse-maybe)
1051 (let ((buffer-read-only nil)
1052 (inhibit-point-motion-hooks t)
1053 (case-fold-search t))
1054 (goto-char (point-min))
1055 (search-forward "\n\n")
1056 (while (re-search-forward gnus-button-regexp nil t)
1057 (goto-char (match-beginning 0))
1058 (let* ((from (point))
1059 (entry (gnus-button-entry))
1060 (start (and entry (match-beginning (nth 1 entry))))
1061 (end (and entry (match-end (nth 1 entry))))
1062 (form (nth 2 entry)))
1065 (goto-char (match-end 0))
1067 (gnus-article-add-button start end 'gnus-button-push
1068 (set-marker (make-marker)
1071 ;;; External functions:
1073 (defun gnus-article-add-button (from to fun &optional data)
1074 "Create a button between FROM and TO with callback FUN and data DATA."
1075 (add-text-properties from to
1076 (append (if gnus-article-button-face
1077 (list 'face gnus-article-button-face))
1078 (if gnus-article-mouse-face
1079 (list 'mouse-face gnus-article-mouse-face))
1080 (list 'gnus-callback fun)
1081 (if data (list 'gnus-data data)))))
1083 ;;; Internal functions:
1085 (defun gnus-signature-toggle (end)
1087 (set-buffer gnus-article-buffer)
1088 (let ((buffer-read-only nil))
1089 (if (get-text-property end 'invisible)
1090 (remove-text-properties end (point-max) gnus-hidden-properties)
1091 (add-text-properties end (point-max) gnus-hidden-properties)))))
1093 (defun gnus-make-face (color)
1094 ;; Create entry for face with COLOR.
1095 (if gnus-make-foreground
1096 (custom-face-lookup color nil nil nil nil nil)
1097 (custom-face-lookup nil color nil nil nil nil)))
1099 (defun gnus-button-entry ()
1100 ;; Return the first entry in `gnus-button-alist' matching this place.
1101 (let ((alist gnus-button-alist)
1104 (setq entry (car alist)
1106 (if (looking-at (car entry))
1111 (defun gnus-button-push (marker)
1112 ;; Push button starting at MARKER.
1114 (set-buffer gnus-article-buffer)
1116 (let* ((entry (gnus-button-entry))
1117 (inhibit-point-motion-hooks t)
1119 (args (mapcar (lambda (group)
1120 (let ((string (buffer-substring
1121 (match-beginning group)
1122 (match-end group))))
1123 (set-text-properties 0 (length string) nil string)
1126 (cond ((fboundp fun)
1129 (fboundp (symbol-value fun)))
1130 (apply (symbol-value fun) args))
1132 (message "You must define `%S' to use this button"
1133 (cons fun args)))))))
1135 (defun gnus-button-message-id (message-id)
1136 ;; Push on MESSAGE-ID.
1138 (set-buffer gnus-summary-buffer)
1139 (gnus-summary-refer-article message-id)))
1141 ;;; Compatibility Functions:
1143 (or (fboundp 'rassoc)
1144 ;; Introduced in Emacs 19.29.
1145 (defun rassoc (elt list)
1146 "Return non-nil if ELT is `equal' to the cdr of an element of LIST.
1147 The value is actually the element of LIST whose cdr is ELT."
1150 (setq result (car list))
1151 (if (equal (cdr result) elt)
1161 ;;; gnus-vis.el ends here