1 ;;; gnus-salt.el --- alternate summary mode interfaces for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2001
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl
))
40 (defvar gnus-pick-mode nil
41 "Minor mode for providing a pick-and-read interface in Gnus
44 (defcustom gnus-pick-display-summary nil
45 "*Display summary while reading."
47 :group
'gnus-summary-pick
)
49 (defcustom gnus-pick-mode-hook nil
50 "Hook run in summary pick mode buffers."
52 :group
'gnus-summary-pick
)
54 (when (featurep 'xemacs
)
55 (add-hook 'gnus-pick-mode-hook
'gnus-xmas-pick-menu-add
))
57 (defcustom gnus-mark-unpicked-articles-as-read nil
58 "*If non-nil, mark all unpicked articles as read."
60 :group
'gnus-summary-pick
)
62 (defcustom gnus-pick-elegant-flow t
63 "If non-nil, `gnus-pick-start-reading' runs
64 `gnus-summary-next-group' when no articles have been picked."
66 :group
'gnus-summary-pick
)
68 (defcustom gnus-summary-pick-line-format
69 "%-5P %U\%R\%z\%I\%(%[%4L: %-23,23n%]%) %s\n"
70 "*The format specification of the lines in pick buffers.
71 It accepts the same format specs that `gnus-summary-line-format' does."
73 :group
'gnus-summary-pick
)
75 ;;; Internal variables.
77 (defvar gnus-pick-mode-map nil
)
79 (unless gnus-pick-mode-map
80 (setq gnus-pick-mode-map
(make-sparse-keymap))
82 (gnus-define-keys gnus-pick-mode-map
83 " " gnus-pick-next-page
84 "u" gnus-pick-unmark-article-or-thread
85 "." gnus-pick-article-or-thread
86 gnus-down-mouse-2 gnus-pick-mouse-pick-region
87 "\r" gnus-pick-start-reading
))
89 (defun gnus-pick-make-menu-bar ()
90 (unless (boundp 'gnus-pick-menu
)
92 gnus-pick-menu gnus-pick-mode-map
""
95 ["Article" gnus-summary-mark-as-processable t
]
96 ["Thread" gnus-uu-mark-thread t
]
97 ["Region" gnus-uu-mark-region t
]
98 ["Regexp" gnus-uu-mark-by-regexp t
]
99 ["Buffer" gnus-uu-mark-buffer t
])
101 ["Article" gnus-summary-unmark-as-processable t
]
102 ["Thread" gnus-uu-unmark-thread t
]
103 ["Region" gnus-uu-unmark-region t
]
104 ["Regexp" gnus-uu-unmark-by-regexp t
]
105 ["Buffer" gnus-summary-unmark-all-processable t
])
106 ["Start reading" gnus-pick-start-reading t
]
107 ["Switch pick mode off" gnus-pick-mode gnus-pick-mode
]))))
109 (defun gnus-pick-mode (&optional arg
)
110 "Minor mode for providing a pick-and-read interface in Gnus summary buffers.
112 \\{gnus-pick-mode-map}"
114 (when (eq major-mode
'gnus-summary-mode
)
115 (if (not (set (make-local-variable 'gnus-pick-mode
)
116 (if (null arg
) (not gnus-pick-mode
)
117 (> (prefix-numeric-value arg
) 0))))
118 (remove-hook 'gnus-message-setup-hook
'gnus-pick-setup-message
)
119 ;; Make sure that we don't select any articles upon group entry.
120 (set (make-local-variable 'gnus-auto-select-first
) nil
)
121 ;; Change line format.
122 (setq gnus-summary-line-format gnus-summary-pick-line-format
)
123 (setq gnus-summary-line-format-spec nil
)
124 (gnus-update-format-specifications nil
'summary
)
125 (gnus-update-summary-mark-positions)
126 (add-hook 'gnus-message-setup-hook
'gnus-pick-setup-message
)
127 (set (make-local-variable 'gnus-summary-goto-unread
) 'never
)
129 (when (gnus-visual-p 'pick-menu
'menu
)
130 (gnus-pick-make-menu-bar))
131 (gnus-add-minor-mode 'gnus-pick-mode
" Pick" gnus-pick-mode-map
133 (gnus-run-hooks 'gnus-pick-mode-hook
))))
135 (defun gnus-pick-setup-message ()
136 "Make Message do the right thing on exit."
137 (when (and (gnus-buffer-live-p gnus-summary-buffer
)
139 (set-buffer gnus-summary-buffer
)
142 '(gnus-configure-windows ,gnus-current-window-configuration t
)
143 'send
'exit
'postpone
'kill
)))
145 (defvar gnus-pick-line-number
1)
146 (defun gnus-pick-line-number ()
147 "Return the current line number."
149 (setq gnus-pick-line-number
1)
150 (incf gnus-pick-line-number
)))
152 (defun gnus-pick-start-reading (&optional catch-up
)
153 "Start reading the picked articles.
154 If given a prefix, mark all unpicked articles as read."
156 (if gnus-newsgroup-processable
158 (gnus-summary-limit-to-articles nil
)
159 (when (or catch-up gnus-mark-unpicked-articles-as-read
)
160 (gnus-summary-limit-mark-excluded-as-read))
161 (gnus-summary-first-article)
162 (gnus-configure-windows
163 (if gnus-pick-display-summary
'article
'pick
) t
))
164 (if gnus-pick-elegant-flow
166 (when (or catch-up gnus-mark-unpicked-articles-as-read
)
167 (gnus-summary-catchup nil t
))
168 (if (gnus-group-quit-config gnus-newsgroup-name
)
170 (gnus-summary-next-group)))
171 (error "No articles have been picked"))))
173 (defun gnus-pick-goto-article (arg)
174 "Go to the article number indicated by ARG.
175 If ARG is an invalid article number, then stay on current line."
178 (goto-char (point-min))
179 (when (zerop (forward-line (1- (prefix-numeric-value arg
))))
182 (gnus-error 2 "No such line: %s" arg
)
185 (defun gnus-pick-article (&optional arg
)
186 "Pick the article on the current line.
187 If ARG, pick the article on that line instead."
190 (gnus-pick-goto-article arg
))
191 (gnus-summary-mark-as-processable 1))
193 (defun gnus-pick-article-or-thread (&optional arg
)
194 "If `gnus-thread-hide-subtree' is t, then pick the thread on the current line.
195 Otherwise pick the article on the current line.
196 If ARG, pick the article/thread on that line instead."
199 (gnus-pick-goto-article arg
))
200 (if gnus-thread-hide-subtree
203 (gnus-uu-mark-thread))
205 (gnus-summary-mark-as-processable 1)))
207 (defun gnus-pick-unmark-article-or-thread (&optional arg
)
208 "If `gnus-thread-hide-subtree' is t, then unmark the thread on current line.
209 Otherwise unmark the article on current line.
210 If ARG, unmark thread/article on that line instead."
213 (gnus-pick-goto-article arg
))
214 (if gnus-thread-hide-subtree
216 (gnus-uu-unmark-thread))
217 (gnus-summary-unmark-as-processable 1)))
219 (defun gnus-pick-mouse-pick (e)
223 (gnus-summary-mark-as-processable 1)))
225 (defun gnus-pick-mouse-pick-region (start-event)
226 "Pick articles that the mouse is dragged over.
227 This must be bound to a button-down mouse event."
229 (mouse-minibuffer-check start-event
)
230 (let* ((echo-keystrokes 0)
231 (start-posn (event-start start-event
))
232 (start-point (posn-point start-posn
))
233 (start-line (1+ (count-lines (point-min) start-point
)))
234 (start-window (posn-window start-posn
))
235 (bounds (gnus-window-edges start-window
))
237 (bottom (if (window-minibuffer-p start-window
)
239 ;; Don't count the mode line.
240 (1- (nth 3 bounds
))))
241 (click-count (1- (event-click-count start-event
))))
242 (setq mouse-selection-click-count click-count
)
243 (setq mouse-selection-click-count-buffer
(current-buffer))
244 (mouse-set-point start-event
)
245 ;; In case the down click is in the middle of some intangible text,
246 ;; use the end of that text, and put it in START-POINT.
247 (when (< (point) start-point
)
248 (goto-char start-point
))
250 (setq start-point
(point))
251 ;; end-of-range is used only in the single-click case.
252 ;; It is the place where the drag has reached so far
253 ;; (but not outside the window where the drag started).
254 (let (event end end-point
(end-of-range (point)))
257 (setq event
(cdr (gnus-read-event-char)))
258 (or (mouse-movement-p event
)
259 (eq (car-safe event
) 'switch-frame
)))
260 (if (eq (car-safe event
) 'switch-frame
)
262 (setq end
(event-end event
)
263 end-point
(posn-point end
))
266 ;; Are we moving within the original window?
267 ((and (eq (posn-window end
) start-window
)
268 (integer-or-marker-p end-point
))
269 ;; Go to START-POINT first, so that when we move to END-POINT,
270 ;; if it's in the middle of intangible text,
271 ;; point jumps in the direction away from START-POINT.
272 (goto-char start-point
)
273 (goto-char end-point
)
275 ;; In case the user moved his mouse really fast, pick
276 ;; articles on the line between this one and the last one.
277 (let* ((this-line (1+ (count-lines (point-min) end-point
)))
278 (min-line (min this-line start-line
))
279 (max-line (max this-line start-line
)))
280 ;; Why not use `forward-line'? --Stef
281 (while (< min-line max-line
)
284 (setq min-line
(1+ min-line
)))
285 (setq start-line this-line
))
286 (when (zerop (% click-count
3))
287 (setq end-of-range
(point))))
289 (let ((mouse-row (cdr (cdr (mouse-position)))))
293 (mouse-scroll-subr start-window
(- mouse-row top
)))
294 ((>= mouse-row bottom
)
295 (mouse-scroll-subr start-window
296 (1+ (- mouse-row bottom
)))))))))))
298 (let ((fun (key-binding (vector (car event
)))))
299 ;; Run the binding of the terminating up-event, if possible.
300 ;; In the case of a multiple click, it gives the wrong results,
301 ;; because it would fail to set up a region.
303 ;; (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun))
304 ;; In this case, we can just let the up-event execute normally.
305 (let ((end (event-end event
)))
306 ;; Set the position in the event before we replay it,
307 ;; because otherwise it may have a position in the wrong
309 (setcar (cdr end
) end-of-range
)
310 ;; Delete the overlay before calling the function,
311 ;; because delete-overlay increases buffer-modified-tick.
312 (push event unread-command-events
))))))))
314 (defun gnus-pick-next-page ()
315 "Go to the next page. If at the end of the buffer, start reading articles."
317 (let ((scroll-in-place nil
))
320 (end-of-buffer (gnus-pick-start-reading)))))
326 (defvar gnus-binary-mode nil
327 "Minor mode for providing a binary group interface in Gnus summary buffers.")
329 (defvar gnus-binary-mode-hook nil
330 "Hook run in summary binary mode buffers.")
332 (defvar gnus-binary-mode-map nil
)
334 (unless gnus-binary-mode-map
335 (setq gnus-binary-mode-map
(make-sparse-keymap))
339 "g" gnus-binary-show-article
))
341 (defun gnus-binary-make-menu-bar ()
342 (unless (boundp 'gnus-binary-menu
)
344 gnus-binary-menu gnus-binary-mode-map
""
346 ["Switch binary mode off" gnus-binary-mode t
]))))
348 (defun gnus-binary-mode (&optional arg
)
349 "Minor mode for providing a binary group interface in Gnus summary buffers."
351 (when (eq major-mode
'gnus-summary-mode
)
352 (make-local-variable 'gnus-binary-mode
)
353 (setq gnus-binary-mode
354 (if (null arg
) (not gnus-binary-mode
)
355 (> (prefix-numeric-value arg
) 0)))
356 (when gnus-binary-mode
357 ;; Make sure that we don't select any articles upon group entry.
358 (make-local-variable 'gnus-auto-select-first
)
359 (setq gnus-auto-select-first nil
)
360 (make-local-variable 'gnus-summary-display-article-function
)
361 (setq gnus-summary-display-article-function
'gnus-binary-display-article
)
363 (when (gnus-visual-p 'binary-menu
'menu
)
364 (gnus-binary-make-menu-bar))
365 (gnus-add-minor-mode 'gnus-binary-mode
" Binary"
366 gnus-binary-mode-map nil
'gnus-binary-mode
)
367 (gnus-run-hooks 'gnus-binary-mode-hook
))))
369 (defun gnus-binary-display-article (article &optional all-header
)
370 "Run ARTICLE through the binary decode functions."
371 (when (gnus-summary-goto-subject article
)
372 (let ((gnus-view-pseudos (or gnus-view-pseudos
'automatic
)))
373 (gnus-uu-decode-uu))))
375 (defun gnus-binary-show-article (&optional arg
)
376 "Bypass the binary functions and show the article."
378 (let (gnus-summary-display-article-function)
379 (gnus-summary-show-article arg
)))
385 (defcustom gnus-tree-line-format
"%(%[%3,3n%]%)"
386 "Format of tree elements."
388 :group
'gnus-summary-tree
)
390 (defcustom gnus-tree-minimize-window t
391 "If non-nil, minimize the tree buffer window.
392 If a number, never let the tree buffer grow taller than that number of
394 :type
'(choice boolean
396 :group
'gnus-summary-tree
)
398 (defcustom gnus-selected-tree-face
'modeline
399 "*Face used for highlighting selected articles in the thread tree."
401 :group
'gnus-summary-tree
)
403 (defvar gnus-tree-brackets
'((?\
[ . ?\
]) (?\
( . ?\
))
404 (?\
{ . ?\
}) (?
< . ?
>))
405 "Brackets used in tree nodes.")
407 (defvar gnus-tree-parent-child-edges
'(?- ?
\\ ?|
)
408 "Characters used to connect parents with children.")
410 (defcustom gnus-tree-mode-line-format
"Gnus: %%b %S %Z"
411 "*The format specification for the tree mode line."
413 :group
'gnus-summary-tree
)
415 (defcustom gnus-generate-tree-function
'gnus-generate-vertical-tree
416 "*Function for generating a thread tree.
417 Two predefined functions are available:
418 `gnus-generate-horizontal-tree' and `gnus-generate-vertical-tree'."
419 :type
'(radio (function-item gnus-generate-vertical-tree
)
420 (function-item gnus-generate-horizontal-tree
)
421 (function :tag
"Other" nil
))
422 :group
'gnus-summary-tree
)
424 (defcustom gnus-tree-mode-hook nil
425 "*Hook run in tree mode buffers."
427 :group
'gnus-summary-tree
)
429 (when (featurep 'xemacs
)
430 (add-hook 'gnus-tree-mode-hook
'gnus-xmas-tree-menu-add
)
431 (add-hook 'gnus-tree-mode-hook
'gnus-xmas-switch-horizontal-scrollbar-off
))
434 ;;; Internal variables.
436 (defvar gnus-tree-line-format-alist
437 `((?n gnus-tmp-name ?s
)
438 (?f gnus-tmp-from ?s
)
439 (?N gnus-tmp-number ?d
)
440 (?\
[ gnus-tmp-open-bracket ?c
)
441 (?\
] gnus-tmp-close-bracket ?c
)
442 (?s gnus-tmp-subject ?s
)))
444 (defvar gnus-tree-mode-line-format-alist gnus-summary-mode-line-format-alist
)
446 (defvar gnus-tree-mode-line-format-spec nil
)
447 (defvar gnus-tree-line-format-spec nil
)
449 (defvar gnus-tree-node-length nil
)
450 (defvar gnus-selected-tree-overlay nil
)
452 (defvar gnus-tree-displayed-thread nil
)
453 (defvar gnus-tree-inhibit nil
)
455 (defvar gnus-tree-mode-map nil
)
456 (put 'gnus-tree-mode
'mode-class
'special
)
458 (unless gnus-tree-mode-map
459 (setq gnus-tree-mode-map
(make-keymap))
460 (suppress-keymap gnus-tree-mode-map
)
463 "\r" gnus-tree-select-article
464 gnus-mouse-2 gnus-tree-pick-article
465 "\C-?" gnus-tree-read-summary-keys
466 "h" gnus-tree-show-summary
468 "\C-c\C-i" gnus-info-find-node
)
470 (substitute-key-definition
471 'undefined
'gnus-tree-read-summary-keys gnus-tree-mode-map
))
473 (defun gnus-tree-make-menu-bar ()
474 (unless (boundp 'gnus-tree-menu
)
476 gnus-tree-menu gnus-tree-mode-map
""
478 ["Select article" gnus-tree-select-article t
]))))
480 (defun gnus-tree-mode ()
481 "Major mode for displaying thread trees."
483 (gnus-set-format 'tree-mode
)
484 (gnus-set-format 'tree t
)
485 (when (gnus-visual-p 'tree-menu
'menu
)
486 (gnus-tree-make-menu-bar))
487 (kill-all-local-variables)
488 (gnus-simplify-mode-line)
489 (setq mode-name
"Tree")
490 (setq major-mode
'gnus-tree-mode
)
491 (use-local-map gnus-tree-mode-map
)
492 (buffer-disable-undo)
493 (setq buffer-read-only t
)
494 (setq truncate-lines t
)
496 (gnus-set-work-buffer)
497 (gnus-tree-node-insert (make-mail-header "") nil
)
498 (setq gnus-tree-node-length
(1- (point))))
499 (gnus-run-hooks 'gnus-tree-mode-hook
))
501 (defun gnus-tree-read-summary-keys (&optional arg
)
502 "Read a summary buffer key sequence and execute it."
504 (unless gnus-tree-inhibit
505 (let ((buf (current-buffer))
506 (gnus-tree-inhibit t
)
508 (set-buffer gnus-article-buffer
)
509 (gnus-article-read-summary-keys arg nil t
)
510 (when (setq win
(get-buffer-window buf
))
512 (when gnus-selected-tree-overlay
513 (goto-char (or (gnus-overlay-end gnus-selected-tree-overlay
) 1)))
514 (gnus-tree-minimize)))))
516 (defun gnus-tree-show-summary ()
517 "Reconfigure windows to show summary buffer."
519 (if (not (gnus-buffer-live-p gnus-summary-buffer
))
520 (error "There is no summary buffer for this tree buffer")
521 (gnus-configure-windows 'article
)
522 (gnus-summary-goto-subject gnus-current-article
)))
524 (defun gnus-tree-select-article (article)
525 "Select the article under point, if any."
526 (interactive (list (gnus-tree-article-number)))
527 (let ((buf (current-buffer)))
530 (set-buffer gnus-summary-buffer
)
531 (gnus-summary-goto-article article
))
532 (select-window (get-buffer-window buf
)))))
534 (defun gnus-tree-pick-article (e)
535 "Select the article under the mouse pointer."
538 (gnus-tree-select-article (gnus-tree-article-number)))
540 (defun gnus-tree-article-number ()
541 (get-text-property (point) 'gnus-number
))
543 (defun gnus-tree-article-region (article)
544 "Return a cons with BEG and END of the article region."
545 (let ((pos (text-property-any
546 (point-min) (point-max) 'gnus-number article
)))
548 (cons pos
(next-single-property-change pos
'gnus-number
)))))
550 (defun gnus-tree-goto-article (article)
551 (let ((pos (text-property-any
552 (point-min) (point-max) 'gnus-number article
)))
556 (defun gnus-tree-recenter ()
557 "Center point in the tree window."
558 (let ((selected (selected-window))
559 (tree-window (gnus-get-buffer-window gnus-tree-buffer t
)))
561 (select-window tree-window
)
562 (when gnus-selected-tree-overlay
563 (goto-char (or (gnus-overlay-end gnus-selected-tree-overlay
) 1)))
564 (let* ((top (cond ((< (window-height) 4) 0)
565 ((< (window-height) 7) 1)
567 (height (1- (window-height)))
568 (bottom (save-excursion (goto-char (point-max))
569 (forward-line (- height
))
571 ;; Set the window start to either `bottom', which is the biggest
572 ;; possible valid number, or the second line from the top,
573 ;; whichever is the least.
575 tree-window
(min bottom
(save-excursion
576 (forward-line (- top
)) (point)))))
577 (select-window selected
))))
579 (defun gnus-get-tree-buffer ()
580 "Return the tree buffer properly initialized."
582 (set-buffer (gnus-get-buffer-create gnus-tree-buffer
))
583 (unless (eq major-mode
'gnus-tree-mode
)
587 (defun gnus-tree-minimize ()
588 (when (and gnus-tree-minimize-window
589 (not (one-window-p)))
592 (walk-windows (lambda (window) (incf windows
)))
595 (* window-min-height
(1- windows
))
597 (let* ((window-min-height 2)
598 (height (count-lines (point-min) (point-max)))
599 (min (max (1- window-min-height
) height
))
600 (tot (if (numberp gnus-tree-minimize-window
)
601 (min gnus-tree-minimize-window min
)
603 (win (get-buffer-window (current-buffer)))
604 (wh (and win
(1- (window-height win
)))))
605 (setq tot
(min tot tot-win-height
))
608 (let ((selected (selected-window)))
609 (when (ignore-errors (select-window win
))
610 (enlarge-window (- tot wh
))
611 (select-window selected
))))))))
613 ;;; Generating the tree.
615 (defun gnus-tree-node-insert (header sparse
&optional adopted
)
616 (let* ((dummy (stringp header
))
617 (header (if (vectorp header
) header
619 (setq header
(make-mail-header "*****"))
620 (mail-header-set-number header
0)
621 (mail-header-set-lines header
0)
622 (mail-header-set-chars header
0)
624 (gnus-tmp-from (mail-header-from header
))
625 (gnus-tmp-subject (mail-header-subject header
))
626 (gnus-tmp-number (mail-header-number header
))
629 ((string-match "(.+)" gnus-tmp-from
)
630 (substring gnus-tmp-from
631 (1+ (match-beginning 0)) (1- (match-end 0))))
632 ((string-match "<[^>]+> *$" gnus-tmp-from
)
633 (let ((beg (match-beginning 0)))
634 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from
)
635 (substring gnus-tmp-from
(1+ (match-beginning 0))
637 (substring gnus-tmp-from
0 beg
))))
638 ((memq gnus-tmp-number sparse
)
641 (gnus-tmp-open-bracket
642 (cond ((memq gnus-tmp-number sparse
)
643 (caadr gnus-tree-brackets
))
644 (dummy (caaddr gnus-tree-brackets
))
645 (adopted (car (nth 3 gnus-tree-brackets
)))
646 (t (caar gnus-tree-brackets
))))
647 (gnus-tmp-close-bracket
648 (cond ((memq gnus-tmp-number sparse
)
649 (cdadr gnus-tree-brackets
))
650 (adopted (cdr (nth 3 gnus-tree-brackets
)))
652 (cdaddr gnus-tree-brackets
))
653 (t (cdar gnus-tree-brackets
))))
654 (buffer-read-only nil
)
656 (gnus-add-text-properties
658 (setq end
(progn (eval gnus-tree-line-format-spec
) (point)))
659 (list 'gnus-number gnus-tmp-number
))
660 (when (or t
(gnus-visual-p 'tree-highlight
'highlight
))
661 (gnus-tree-highlight-node gnus-tmp-number beg end
))))
663 (defun gnus-tree-highlight-node (article beg end
)
664 "Highlight current line according to `gnus-summary-highlight'."
665 (let ((list gnus-summary-highlight
)
668 (set-buffer gnus-summary-buffer
)
669 (let* ((score (or (cdr (assq article gnus-newsgroup-scored
))
670 gnus-summary-default-score
0))
671 (default gnus-summary-default-score
)
672 (default-high gnus-summary-default-high-score
)
673 (default-low gnus-summary-default-low-score
)
674 (uncached (memq article gnus-newsgroup-undownloaded
))
675 (downloaded (not uncached
))
676 (mark (or (gnus-summary-article-mark article
) gnus-unread-mark
)))
677 ;; Eval the cars of the lists until we find a match.
679 (not (eval (caar list
))))
680 (setq list
(cdr list
)))))
681 (unless (eq (setq face
(cdar list
)) (get-text-property beg
'face
))
682 (gnus-put-text-property-excluding-characters-with-faces
684 (if (boundp face
) (symbol-value face
) face
)))))
686 (defun gnus-tree-indent (level)
687 (insert (make-string (1- (* (1+ gnus-tree-node-length
) level
)) ?
)))
689 (defvar gnus-tmp-limit
)
690 (defvar gnus-tmp-sparse
)
691 (defvar gnus-tmp-indent
)
693 (defun gnus-generate-tree (thread)
694 "Generate a thread tree for THREAD."
696 (set-buffer (gnus-get-tree-buffer))
697 (let ((buffer-read-only nil
)
700 (funcall gnus-generate-tree-function thread
0)
701 (gnus-set-mode-line 'tree
)
702 (goto-char (point-min))
705 (let ((selected (selected-window)))
706 (when (gnus-get-buffer-window (set-buffer gnus-tree-buffer
) t
)
707 (select-window (gnus-get-buffer-window (set-buffer gnus-tree-buffer
) t
))
708 (gnus-horizontal-recenter)
709 (select-window selected
))))))
711 (defun gnus-generate-horizontal-tree (thread level
&optional dummyp adopted
)
712 "Generate a horizontal tree."
713 (let* ((dummy (stringp (car thread
)))
716 (memq (mail-header-number (car thread
))
720 ;; We don't want this article.
721 (setq thread
(cdr thread
))
723 ;; Not the first article on the line, so we insert a "-".
724 (insert (car gnus-tree-parent-child-edges
))
725 ;; If the level isn't zero, then we insert some indentation.
726 (unless (zerop level
)
727 (gnus-tree-indent level
)
728 (insert (cadr gnus-tree-parent-child-edges
))
729 (setq col
(- (setq beg
(point)) (gnus-point-at-bol) 1))
730 ;; Draw "|" lines upwards.
734 (eq (char-after) ?
))
736 (insert (caddr gnus-tree-parent-child-edges
)))
739 ;; Insert the article node.
740 (gnus-tree-node-insert (pop thread
) gnus-tmp-sparse adopted
))
742 ;; End of the thread, so we go to the next line.
745 ;; Recurse downwards in all children of this article.
747 (gnus-generate-horizontal-tree
748 (pop thread
) (if do
(1+ level
) level
)
749 (or dummyp dummy
) dummy
)))))
751 (defsubst gnus-tree-indent-vertical
()
752 (let ((len (- (* (1+ gnus-tree-node-length
) gnus-tmp-indent
)
753 (- (point) (gnus-point-at-bol)))))
755 (insert (make-string len ?
)))))
757 (defsubst gnus-tree-forward-line
(n)
758 (while (>= (decf n
) 0)
759 (unless (zerop (forward-line 1))
764 (defun gnus-generate-vertical-tree (thread level
&optional dummyp adopted
)
765 "Generate a vertical tree."
766 (let* ((dummy (stringp (car thread
)))
769 (memq (mail-header-number (car thread
))
773 ;; We don't want this article.
774 (setq thread
(cdr thread
))
775 (if (not (save-excursion (beginning-of-line) (bobp)))
776 ;; Not the first article on the line, so we insert a "-".
778 (gnus-tree-indent-vertical)
779 (insert (make-string (/ gnus-tree-node-length
2) ?
))
780 (insert (caddr gnus-tree-parent-child-edges
))
781 (gnus-tree-forward-line 1))
782 ;; If the level isn't zero, then we insert some indentation.
783 (unless (zerop gnus-tmp-indent
)
784 (gnus-tree-forward-line (1- (* 2 level
)))
785 (gnus-tree-indent-vertical)
787 (insert (cadr gnus-tree-parent-child-edges
))
790 ;; Draw "-" lines leftwards.
791 (while (and (not (bobp))
792 (eq (char-after (1- (point))) ?
))
794 (insert (car gnus-tree-parent-child-edges
))
797 (gnus-tree-forward-line 1)))
799 ;; Insert the article node.
800 (gnus-tree-indent-vertical)
801 (gnus-tree-node-insert (pop thread
) gnus-tmp-sparse adopted
)
802 (gnus-tree-forward-line 1))
804 ;; End of the thread, so we go to the next line.
806 (goto-char (point-min))
808 (incf gnus-tmp-indent
))
809 ;; Recurse downwards in all children of this article.
811 (gnus-generate-vertical-tree
812 (pop thread
) (if do
(1+ level
) level
)
813 (or dummyp dummy
) dummy
)))))
815 ;;; Interface functions.
817 (defun gnus-possibly-generate-tree (article &optional force
)
818 "Generate the thread tree for ARTICLE if it isn't displayed already."
819 (when (save-excursion
820 (set-buffer gnus-summary-buffer
)
823 (vectorp (gnus-summary-article-header article
))))
825 (let ((top (save-excursion
826 (set-buffer gnus-summary-buffer
)
830 (gnus-summary-article-header article
))
832 (gnus-tmp-limit gnus-newsgroup-limit
)
833 (gnus-tmp-sparse gnus-newsgroup-sparse
))
835 (not (eq top gnus-tree-displayed-thread
)))
836 (gnus-generate-tree top
)
837 (setq gnus-tree-displayed-thread top
))))))
839 (defun gnus-tree-open (group)
840 (gnus-get-tree-buffer))
842 (defun gnus-tree-close (group)
843 (gnus-kill-buffer gnus-tree-buffer
))
845 (defun gnus-tree-perhaps-minimize ()
846 (when (and gnus-tree-minimize-window
847 (get-buffer gnus-tree-buffer
))
849 (set-buffer gnus-tree-buffer
)
850 (gnus-tree-minimize))))
852 (defun gnus-highlight-selected-tree (article)
853 "Highlight the selected article in the tree."
854 (let ((buf (current-buffer))
856 (set-buffer gnus-tree-buffer
)
857 (when (setq region
(gnus-tree-article-region article
))
858 (when (or (not gnus-selected-tree-overlay
)
859 (gnus-extent-detached-p gnus-selected-tree-overlay
))
860 ;; Create a new overlay.
862 (setq gnus-selected-tree-overlay
863 (gnus-make-overlay (point-min) (1+ (point-min))))
864 'face gnus-selected-tree-face
))
865 ;; Move the overlay to the article.
867 gnus-selected-tree-overlay
(goto-char (car region
)) (cdr region
))
870 (let ((selected (selected-window)))
871 (when (gnus-get-buffer-window (set-buffer gnus-tree-buffer
) t
)
872 (select-window (gnus-get-buffer-window (set-buffer gnus-tree-buffer
) t
))
873 (gnus-horizontal-recenter)
874 (select-window selected
))))
875 ;; If we remove this save-excursion, it updates the wrong mode lines?!?
877 (set-buffer gnus-tree-buffer
)
878 (gnus-set-mode-line 'tree
))
881 (defun gnus-tree-highlight-article (article face
)
883 (set-buffer (gnus-get-tree-buffer))
885 (when (setq region
(gnus-tree-article-region article
))
886 (gnus-put-text-property (car region
) (cdr region
) 'face face
)
888 (gnus-get-buffer-window (current-buffer) t
) (cdr region
))))))
894 (defvar gnus-carpal-group-buffer-buttons
895 '(("next" . gnus-group-next-unread-group
)
896 ("prev" . gnus-group-prev-unread-group
)
897 ("read" . gnus-group-read-group
)
898 ("select" . gnus-group-select-group
)
899 ("catch-up" . gnus-group-catchup-current
)
900 ("new-news" . gnus-group-get-new-news-this-group
)
901 ("toggle-sub" . gnus-group-unsubscribe-current-group
)
902 ("subscribe" . gnus-group-unsubscribe-group
)
903 ("kill" . gnus-group-kill-group
)
904 ("yank" . gnus-group-yank-group
)
905 ("describe" . gnus-group-describe-group
)
907 ("subscribed" . gnus-group-list-groups
)
908 ("all" . gnus-group-list-all-groups
)
909 ("killed" . gnus-group-list-killed
)
910 ("zombies" . gnus-group-list-zombies
)
911 ("matching" . gnus-group-list-matching
)
912 ("post" . gnus-group-post-news
)
913 ("mail" . gnus-group-mail
)
914 ("local" .
(lambda () (interactive) (gnus-group-news 0)))
915 ("rescan" . gnus-group-get-new-news
)
916 ("browse-foreign" . gnus-group-browse-foreign
)
917 ("exit" . gnus-group-exit
)))
919 (defvar gnus-carpal-summary-buffer-buttons
921 ("read" . gnus-summary-mark-as-read-forward
)
922 ("tick" . gnus-summary-tick-article-forward
)
923 ("clear" . gnus-summary-clear-mark-forward
)
924 ("expirable" . gnus-summary-mark-as-expirable
)
926 ("scroll" . gnus-summary-next-page
)
927 ("next-unread" . gnus-summary-next-unread-article
)
928 ("prev-unread" . gnus-summary-prev-unread-article
)
929 ("first" . gnus-summary-first-unread-article
)
930 ("best" . gnus-summary-best-unread-article
)
932 ("headers" . gnus-summary-toggle-header
)
933 ("uudecode" . gnus-uu-decode-uu
)
934 ("enter-digest" . gnus-summary-enter-digest-group
)
935 ("fetch-parent" . gnus-summary-refer-parent-article
)
937 ("move" . gnus-summary-move-article
)
938 ("copy" . gnus-summary-copy-article
)
939 ("respool" . gnus-summary-respool-article
)
941 ("lower" . gnus-summary-lower-thread
)
942 ("kill" . gnus-summary-kill-thread
)
944 ("post" . gnus-summary-post-news
)
945 ("local" . gnus-summary-news-other-window
)
946 ("mail" . gnus-summary-mail-other-window
)
947 ("followup" . gnus-summary-followup-with-original
)
948 ("reply" . gnus-summary-reply-with-original
)
949 ("cancel" . gnus-summary-cancel-article
)
951 ("exit" . gnus-summary-exit
)
952 ("fed-up" . gnus-summary-catchup-and-goto-next-group
)))
954 (defvar gnus-carpal-server-buffer-buttons
955 '(("add" . gnus-server-add-server
)
956 ("browse" . gnus-server-browse-server
)
957 ("list" . gnus-server-list-servers
)
958 ("kill" . gnus-server-kill-server
)
959 ("yank" . gnus-server-yank-server
)
960 ("copy" . gnus-server-copy-server
)
961 ("exit" . gnus-server-exit
)))
963 (defvar gnus-carpal-browse-buffer-buttons
964 '(("subscribe" . gnus-browse-unsubscribe-current-group
)
965 ("exit" . gnus-browse-exit
)))
967 (defvar gnus-carpal-group-buffer
"*Carpal Group*")
968 (defvar gnus-carpal-summary-buffer
"*Carpal Summary*")
969 (defvar gnus-carpal-server-buffer
"*Carpal Server*")
970 (defvar gnus-carpal-browse-buffer
"*Carpal Browse*")
972 (defvar gnus-carpal-attached-buffer nil
)
974 (defvar gnus-carpal-mode-hook nil
975 "*Hook run in carpal mode buffers.")
977 (defvar gnus-carpal-button-face
'bold
978 "*Face used on carpal buttons.")
980 (defvar gnus-carpal-header-face
'bold-italic
981 "*Face used on carpal buffer headers.")
983 (defvar gnus-carpal-mode-map nil
)
984 (put 'gnus-carpal-mode
'mode-class
'special
)
986 (if gnus-carpal-mode-map
988 (setq gnus-carpal-mode-map
(make-keymap))
989 (suppress-keymap gnus-carpal-mode-map
)
990 (define-key gnus-carpal-mode-map
" " 'gnus-carpal-select
)
991 (define-key gnus-carpal-mode-map
"\r" 'gnus-carpal-select
)
992 (define-key gnus-carpal-mode-map gnus-mouse-2
'gnus-carpal-mouse-select
))
994 (defun gnus-carpal-mode ()
995 "Major mode for clicking buttons.
997 All normal editing commands are switched off.
998 \\<gnus-carpal-mode-map>
999 The following commands are available:
1001 \\{gnus-carpal-mode-map}"
1003 (kill-all-local-variables)
1004 (setq mode-line-modified
(cdr gnus-mode-line-modified
))
1005 (setq major-mode
'gnus-carpal-mode
)
1006 (setq mode-name
"Gnus Carpal")
1007 (setq mode-line-process nil
)
1008 (use-local-map gnus-carpal-mode-map
)
1009 (buffer-disable-undo)
1010 (setq buffer-read-only t
)
1011 (make-local-variable 'gnus-carpal-attached-buffer
)
1012 (gnus-run-hooks 'gnus-carpal-mode-hook
))
1014 (defun gnus-carpal-setup-buffer (type)
1015 (let ((buffer (symbol-value (intern (format "gnus-carpal-%s-buffer" type
)))))
1016 (if (get-buffer buffer
)
1019 (set-buffer (gnus-get-buffer-create buffer
))
1021 (setq gnus-carpal-attached-buffer
1022 (intern (format "gnus-%s-buffer" type
)))
1023 (let ((buttons (symbol-value
1024 (intern (format "gnus-carpal-%s-buffer-buttons"
1026 (buffer-read-only nil
)
1029 (setq button
(car buttons
)
1030 buttons
(cdr buttons
))
1031 (if (stringp button
)
1032 (gnus-set-text-properties
1034 (prog2 (insert button
) (point) (insert " "))
1035 (list 'face gnus-carpal-header-face
))
1036 (gnus-set-text-properties
1038 (prog2 (insert (car button
)) (point) (insert " "))
1039 (list 'gnus-callback
(cdr button
)
1040 'face gnus-carpal-button-face
1041 gnus-mouse-face-prop
'highlight
))))
1042 (let ((fill-column (- (window-width) 2)))
1043 (fill-region (point-min) (point-max)))
1044 (set-window-point (get-buffer-window (current-buffer))
1047 (defun gnus-carpal-select ()
1048 "Select the button under point."
1050 (let ((func (get-text-property (point) 'gnus-callback
)))
1053 (pop-to-buffer (symbol-value gnus-carpal-attached-buffer
))
1054 (call-interactively func
))))
1056 (defun gnus-carpal-mouse-select (event)
1057 "Select the button under the mouse pointer."
1059 (mouse-set-point event
)
1060 (gnus-carpal-select))
1062 ;;; Allow redefinition of functions.
1065 (provide 'gnus-salt
)
1067 ;; arch-tag: 35449164-77b3-4398-bcbd-a2e3e998f810
1068 ;;; gnus-salt.el ends here