1 ;;; gnus-salt.el --- alternate summary mode interfaces for Gnus
2 ;; Copyright (C) 1996 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
34 (defvar gnus-pick-mode nil
35 "Minor mode for providing a pick-and-read interface in Gnus summary buffers.")
37 (defvar gnus-pick-display-summary nil
38 "*Display summary while reading.")
40 (defvar gnus-pick-mode-hook nil
41 "Hook run in summary pick mode buffers.")
43 (defvar gnus-mark-unpicked-articles-as-read nil
44 "*If non-nil, mark all unpicked articles as read.")
46 (defvar gnus-pick-elegant-flow t
47 "If non-nil, gnus-pick-start-reading will run gnus-summary-next-group when no articles have been picked.")
49 (defvar gnus-summary-pick-line-format
50 "%-5P %U\%R\%z\%I\%(%[%4L: %-20,20n%]%) %s\n"
51 "*The format specification of the lines in pick buffers.
52 It accepts the same format specs that `gnus-summary-line-format' does.")
54 ;;; Internal variables.
56 (defvar gnus-pick-mode-map nil)
58 (unless gnus-pick-mode-map
59 (setq gnus-pick-mode-map (make-sparse-keymap))
63 "t" gnus-uu-mark-thread
64 "T" gnus-uu-unmark-thread
65 " " gnus-pick-next-page
66 "u" gnus-summary-unmark-as-processable
67 "U" gnus-summary-unmark-all-processable
69 "r" gnus-uu-mark-region
70 "R" gnus-uu-unmark-region
71 "e" gnus-uu-mark-by-regexp
72 "E" gnus-uu-mark-by-regexp
73 "b" gnus-uu-mark-buffer
74 "B" gnus-uu-unmark-buffer
76 gnus-down-mouse-2 gnus-pick-mouse-pick-region
77 ;;gnus-mouse-2 gnus-pick-mouse-pick
78 "\r" gnus-pick-start-reading))
80 (defun gnus-pick-make-menu-bar ()
81 (unless (boundp 'gnus-pick-menu)
83 gnus-pick-menu gnus-pick-mode-map ""
86 ["Article" gnus-summary-mark-as-processable t]
87 ["Thread" gnus-uu-mark-thread t]
88 ["Region" gnus-uu-mark-region t]
89 ["Regexp" gnus-uu-mark-regexp t]
90 ["Buffer" gnus-uu-mark-buffer t])
92 ["Article" gnus-summary-unmark-as-processable t]
93 ["Thread" gnus-uu-unmark-thread t]
94 ["Region" gnus-uu-unmark-region t]
95 ["Regexp" gnus-uu-unmark-regexp t]
96 ["Buffer" gnus-uu-unmark-buffer t])
97 ["Start reading" gnus-pick-start-reading t]
98 ["Switch pick mode off" gnus-pick-mode gnus-pick-mode]))))
100 (defun gnus-pick-mode (&optional arg)
101 "Minor mode for providing a pick-and-read interface in Gnus summary buffers.
103 \\{gnus-pick-mode-map}"
105 (when (eq major-mode 'gnus-summary-mode)
106 (when (set (make-local-variable 'gnus-pick-mode)
107 (if (null arg) (not gnus-pick-mode)
108 (> (prefix-numeric-value arg) 0)))
109 ;; Make sure that we don't select any articles upon group entry.
110 (set (make-local-variable 'gnus-auto-select-first) nil)
111 ;; Change line format.
112 (setq gnus-summary-line-format gnus-summary-pick-line-format)
113 (setq gnus-summary-line-format-spec nil)
114 (gnus-update-format-specifications nil 'summary)
115 (gnus-update-summary-mark-positions)
116 (set (make-local-variable 'gnus-summary-goto-unread) 'never)
118 (when (and menu-bar-mode
119 (gnus-visual-p 'pick-menu 'menu))
120 (gnus-pick-make-menu-bar))
121 (unless (assq 'gnus-pick-mode minor-mode-alist)
122 (push '(gnus-pick-mode " Pick") minor-mode-alist))
123 (unless (assq 'gnus-pick-mode minor-mode-map-alist)
124 (push (cons 'gnus-pick-mode gnus-pick-mode-map)
125 minor-mode-map-alist))
126 (run-hooks 'gnus-pick-mode-hook))))
128 (defvar gnus-pick-line-number 1)
129 (defun gnus-pick-line-number ()
130 "Return the current line number."
132 (setq gnus-pick-line-number 1)
133 (incf gnus-pick-line-number)))
135 (defun gnus-pick-start-reading (&optional catch-up)
136 "Start reading the picked articles.
137 If given a prefix, mark all unpicked articles as read."
139 (if gnus-newsgroup-processable
141 (gnus-summary-limit-to-articles nil)
142 (when (or catch-up gnus-mark-unpicked-articles-as-read)
143 (gnus-summary-limit-mark-excluded-as-read))
144 (gnus-summary-first-unread-article)
145 (gnus-configure-windows
146 (if gnus-pick-display-summary 'article 'pick) t))
147 (if gnus-pick-elegant-flow
148 (if (gnus-group-quit-config gnus-newsgroup-name)
150 (gnus-summary-next-group))
151 (error "No articles have been picked"))))
153 (defun gnus-pick-article (&optional arg)
154 "Pick the article on the current line.
155 If ARG, pick the article on that line instead."
160 (goto-char (point-min))
161 (when (zerop (forward-line (1- (prefix-numeric-value arg))))
164 (gnus-error 2 "No such line: %s" arg)
166 (gnus-summary-mark-as-processable 1))
168 (defun gnus-pick-mouse-pick (e)
172 (gnus-summary-mark-as-processable 1)))
174 (defun gnus-pick-mouse-pick-region (start-event)
175 "Pick articles that the mouse is dragged over.
176 This must be bound to a button-down mouse event."
178 (mouse-minibuffer-check start-event)
179 (let* ((echo-keystrokes 0)
180 (start-posn (event-start start-event))
181 (start-point (posn-point start-posn))
182 (start-line (1+ (count-lines 1 start-point)))
183 (start-window (posn-window start-posn))
184 (start-frame (window-frame start-window))
185 (bounds (window-edges start-window))
187 (bottom (if (window-minibuffer-p start-window)
189 ;; Don't count the mode line.
190 (1- (nth 3 bounds))))
191 (click-count (1- (event-click-count start-event))))
192 (setq mouse-selection-click-count click-count)
193 (setq mouse-selection-click-count-buffer (current-buffer))
194 (mouse-set-point start-event)
195 ;; In case the down click is in the middle of some intangible text,
196 ;; use the end of that text, and put it in START-POINT.
197 (when (< (point) start-point)
198 (goto-char start-point))
200 (setq start-point (point))
201 ;; end-of-range is used only in the single-click case.
202 ;; It is the place where the drag has reached so far
203 ;; (but not outside the window where the drag started).
204 (let (event end end-point last-end-point (end-of-range (point)))
207 (setq event (read-event))
208 (or (mouse-movement-p event)
209 (eq (car-safe event) 'switch-frame)))
210 (if (eq (car-safe event) 'switch-frame)
212 (setq end (event-end event)
213 end-point (posn-point end))
215 (setq last-end-point end-point))
218 ;; Are we moving within the original window?
219 ((and (eq (posn-window end) start-window)
220 (integer-or-marker-p end-point))
221 ;; Go to START-POINT first, so that when we move to END-POINT,
222 ;; if it's in the middle of intangible text,
223 ;; point jumps in the direction away from START-POINT.
224 (goto-char start-point)
225 (goto-char end-point)
227 ;; In case the user moved his mouse really fast, pick
228 ;; articles on the line between this one and the last one.
229 (let* ((this-line (1+ (count-lines 1 end-point)))
230 (min-line (min this-line start-line))
231 (max-line (max this-line start-line)))
232 (while (< min-line max-line)
235 (setq min-line (1+ min-line)))
236 (setq start-line this-line))
237 (when (zerop (% click-count 3))
238 (setq end-of-range (point))))
240 (let ((mouse-row (cdr (cdr (mouse-position)))))
244 (mouse-scroll-subr start-window (- mouse-row top)))
245 ((>= mouse-row bottom)
246 (mouse-scroll-subr start-window
247 (1+ (- mouse-row bottom)))))))))))
249 (let ((fun (key-binding (vector (car event)))))
250 ;; Run the binding of the terminating up-event, if possible.
251 ;; In the case of a multiple click, it gives the wrong results,
252 ;; because it would fail to set up a region.
254 ;; (and (= (mod mouse-selection-click-count 3) 0) (fboundp fun))
255 ;; In this case, we can just let the up-event execute normally.
256 (let ((end (event-end event)))
257 ;; Set the position in the event before we replay it,
258 ;; because otherwise it may have a position in the wrong
260 (setcar (cdr end) end-of-range)
261 ;; Delete the overlay before calling the function,
262 ;; because delete-overlay increases buffer-modified-tick.
263 (push event unread-command-events))))))))
265 (defun gnus-pick-next-page ()
266 "Go to the next page. If at the end of the buffer, start reading articles."
270 (end-of-buffer (gnus-pick-start-reading))))
276 (defvar gnus-binary-mode nil
277 "Minor mode for providing a binary group interface in Gnus summary buffers.")
279 (defvar gnus-binary-mode-hook nil
280 "Hook run in summary binary mode buffers.")
282 (defvar gnus-binary-mode-map nil)
284 (unless gnus-binary-mode-map
285 (setq gnus-binary-mode-map (make-sparse-keymap))
289 "g" gnus-binary-show-article))
291 (defun gnus-binary-make-menu-bar ()
292 (unless (boundp 'gnus-binary-menu)
294 gnus-binary-menu gnus-binary-mode-map ""
296 ["Switch binary mode off" gnus-binary-mode t]))))
298 (defun gnus-binary-mode (&optional arg)
299 "Minor mode for providing a binary group interface in Gnus summary buffers."
301 (when (eq major-mode 'gnus-summary-mode)
302 (make-local-variable 'gnus-binary-mode)
303 (setq gnus-binary-mode
304 (if (null arg) (not gnus-binary-mode)
305 (> (prefix-numeric-value arg) 0)))
306 (when gnus-binary-mode
307 ;; Make sure that we don't select any articles upon group entry.
308 (make-local-variable 'gnus-auto-select-first)
309 (setq gnus-auto-select-first nil)
310 (make-local-variable 'gnus-summary-display-article-function)
311 (setq gnus-summary-display-article-function 'gnus-binary-display-article)
313 (when (and menu-bar-mode
314 (gnus-visual-p 'binary-menu 'menu))
315 (gnus-binary-make-menu-bar))
316 (unless (assq 'gnus-binary-mode minor-mode-alist)
317 (push '(gnus-binary-mode " Binary") minor-mode-alist))
318 (unless (assq 'gnus-binary-mode minor-mode-map-alist)
319 (push (cons 'gnus-binary-mode gnus-binary-mode-map)
320 minor-mode-map-alist))
321 (run-hooks 'gnus-binary-mode-hook))))
323 (defun gnus-binary-display-article (article &optional all-header)
324 "Run ARTICLE through the binary decode functions."
325 (when (gnus-summary-goto-subject article)
326 (let ((gnus-view-pseudos 'automatic))
327 (gnus-uu-decode-uu))))
329 (defun gnus-binary-show-article (&optional arg)
330 "Bypass the binary functions and show the article."
332 (let (gnus-summary-display-article-function)
333 (gnus-summary-show-article arg)))
339 (defvar gnus-tree-line-format "%(%[%3,3n%]%)"
340 "Format of tree elements.")
342 (defvar gnus-tree-minimize-window t
343 "If non-nil, minimize the tree buffer window.
344 If a number, never let the tree buffer grow taller than that number of
347 (defvar gnus-selected-tree-face 'modeline
348 "*Face used for highlighting selected articles in the thread tree.")
350 (defvar gnus-tree-brackets '((?\[ . ?\]) (?\( . ?\))
351 (?\{ . ?\}) (?< . ?>))
352 "Brackets used in tree nodes.")
354 (defvar gnus-tree-parent-child-edges '(?- ?\\ ?|)
355 "Characters used to connect parents with children.")
357 (defvar gnus-tree-mode-line-format "Gnus: %%b %S %Z"
358 "*The format specification for the tree mode line.")
360 (defvar gnus-generate-tree-function 'gnus-generate-vertical-tree
361 "*Function for generating a thread tree.
362 Two predefined functions are available:
363 `gnus-generate-horizontal-tree' and `gnus-generate-vertical-tree'.")
365 (defvar gnus-tree-mode-hook nil
366 "*Hook run in tree mode buffers.")
368 ;;; Internal variables.
370 (defvar gnus-tree-line-format-alist
371 `((?n gnus-tmp-name ?s)
372 (?f gnus-tmp-from ?s)
373 (?N gnus-tmp-number ?d)
374 (?\[ gnus-tmp-open-bracket ?c)
375 (?\] gnus-tmp-close-bracket ?c)
376 (?s gnus-tmp-subject ?s)))
378 (defvar gnus-tree-mode-line-format-alist gnus-summary-mode-line-format-alist)
380 (defvar gnus-tree-mode-line-format-spec nil)
381 (defvar gnus-tree-line-format-spec nil)
383 (defvar gnus-tree-node-length nil)
384 (defvar gnus-selected-tree-overlay nil)
386 (defvar gnus-tree-displayed-thread nil)
388 (defvar gnus-tree-mode-map nil)
389 (put 'gnus-tree-mode 'mode-class 'special)
391 (unless gnus-tree-mode-map
392 (setq gnus-tree-mode-map (make-keymap))
393 (suppress-keymap gnus-tree-mode-map)
396 "\r" gnus-tree-select-article
397 gnus-mouse-2 gnus-tree-pick-article
398 "\C-?" gnus-tree-read-summary-keys
400 "\C-c\C-i" gnus-info-find-node)
402 (substitute-key-definition
403 'undefined 'gnus-tree-read-summary-keys gnus-tree-mode-map))
405 (defun gnus-tree-make-menu-bar ()
406 (unless (boundp 'gnus-tree-menu)
408 gnus-tree-menu gnus-tree-mode-map ""
410 ["Select article" gnus-tree-select-article t]))))
412 (defun gnus-tree-mode ()
413 "Major mode for displaying thread trees."
415 (setq gnus-tree-mode-line-format-spec
416 (gnus-parse-format gnus-tree-mode-line-format
417 gnus-summary-mode-line-format-alist))
418 (setq gnus-tree-line-format-spec
419 (gnus-parse-format gnus-tree-line-format
420 gnus-tree-line-format-alist t))
421 (when (and menu-bar-mode
422 (gnus-visual-p 'tree-menu 'menu))
423 (gnus-tree-make-menu-bar))
424 (kill-all-local-variables)
425 (gnus-simplify-mode-line)
426 (setq mode-name "Tree")
427 (setq major-mode 'gnus-tree-mode)
428 (use-local-map gnus-tree-mode-map)
429 (buffer-disable-undo (current-buffer))
430 (setq buffer-read-only t)
431 (setq truncate-lines t)
433 (gnus-set-work-buffer)
434 (gnus-tree-node-insert (make-mail-header "") nil)
435 (setq gnus-tree-node-length (1- (point))))
436 (run-hooks 'gnus-tree-mode-hook))
438 (defun gnus-tree-read-summary-keys (&optional arg)
439 "Read a summary buffer key sequence and execute it."
441 (let ((buf (current-buffer))
443 (gnus-article-read-summary-keys arg nil t)
444 (when (setq win (get-buffer-window buf))
446 (when gnus-selected-tree-overlay
447 (goto-char (or (gnus-overlay-end gnus-selected-tree-overlay) 1)))
448 (gnus-tree-minimize))))
450 (defun gnus-tree-select-article (article)
451 "Select the article under point, if any."
452 (interactive (list (gnus-tree-article-number)))
453 (let ((buf (current-buffer)))
456 (set-buffer gnus-summary-buffer)
457 (gnus-summary-goto-article article))
458 (select-window (get-buffer-window buf)))))
460 (defun gnus-tree-pick-article (e)
461 "Select the article under the mouse pointer."
464 (gnus-tree-select-article (gnus-tree-article-number)))
466 (defun gnus-tree-article-number ()
467 (get-text-property (point) 'gnus-number))
469 (defun gnus-tree-article-region (article)
470 "Return a cons with BEG and END of the article region."
471 (let ((pos (text-property-any (point-min) (point-max) 'gnus-number article)))
473 (cons pos (next-single-property-change pos 'gnus-number)))))
475 (defun gnus-tree-goto-article (article)
476 (let ((pos (text-property-any (point-min) (point-max) 'gnus-number article)))
480 (defun gnus-tree-recenter ()
481 "Center point in the tree window."
482 (let ((selected (selected-window))
483 (tree-window (get-buffer-window gnus-tree-buffer t)))
485 (select-window tree-window)
486 (when gnus-selected-tree-overlay
487 (goto-char (or (gnus-overlay-end gnus-selected-tree-overlay) 1)))
488 (let* ((top (cond ((< (window-height) 4) 0)
489 ((< (window-height) 7) 1)
491 (height (1- (window-height)))
492 (bottom (save-excursion (goto-char (point-max))
493 (forward-line (- height))
495 ;; Set the window start to either `bottom', which is the biggest
496 ;; possible valid number, or the second line from the top,
497 ;; whichever is the least.
499 tree-window (min bottom (save-excursion
500 (forward-line (- top)) (point)))))
501 (select-window selected))))
503 (defun gnus-get-tree-buffer ()
504 "Return the tree buffer properly initialized."
506 (set-buffer (get-buffer-create gnus-tree-buffer))
507 (unless (eq major-mode 'gnus-tree-mode)
508 (gnus-add-current-to-buffer-list)
512 (defun gnus-tree-minimize ()
513 (when (and gnus-tree-minimize-window
514 (not (one-window-p)))
517 (walk-windows (lambda (window) (incf windows)))
520 (* window-min-height (1- windows))
522 (let* ((window-min-height 2)
523 (height (count-lines (point-min) (point-max)))
524 (min (max (1- window-min-height) height))
525 (tot (if (numberp gnus-tree-minimize-window)
526 (min gnus-tree-minimize-window min)
528 (win (get-buffer-window (current-buffer)))
529 (wh (and win (1- (window-height win)))))
530 (setq tot (min tot tot-win-height))
533 (let ((selected (selected-window)))
535 (enlarge-window (- tot wh))
536 (select-window selected)))))))
538 ;;; Generating the tree.
540 (defun gnus-tree-node-insert (header sparse &optional adopted)
541 (let* ((dummy (stringp header))
542 (header (if (vectorp header) header
544 (setq header (make-mail-header "*****"))
545 (mail-header-set-number header 0)
546 (mail-header-set-lines header 0)
547 (mail-header-set-chars header 0)
549 (gnus-tmp-from (mail-header-from header))
550 (gnus-tmp-subject (mail-header-subject header))
551 (gnus-tmp-number (mail-header-number header))
554 ((string-match "(.+)" gnus-tmp-from)
555 (substring gnus-tmp-from
556 (1+ (match-beginning 0)) (1- (match-end 0))))
557 ((string-match "<[^>]+> *$" gnus-tmp-from)
558 (let ((beg (match-beginning 0)))
559 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
560 (substring gnus-tmp-from (1+ (match-beginning 0))
562 (substring gnus-tmp-from 0 beg))))
563 ((memq gnus-tmp-number sparse)
566 (gnus-tmp-open-bracket
567 (cond ((memq gnus-tmp-number sparse)
568 (caadr gnus-tree-brackets))
569 (dummy (caaddr gnus-tree-brackets))
570 (adopted (car (nth 3 gnus-tree-brackets)))
571 (t (caar gnus-tree-brackets))))
572 (gnus-tmp-close-bracket
573 (cond ((memq gnus-tmp-number sparse)
574 (cdadr gnus-tree-brackets))
575 (adopted (cdr (nth 3 gnus-tree-brackets)))
577 (cdaddr gnus-tree-brackets))
578 (t (cdar gnus-tree-brackets))))
579 (buffer-read-only nil)
581 (gnus-add-text-properties
583 (setq end (progn (eval gnus-tree-line-format-spec) (point)))
584 (list 'gnus-number gnus-tmp-number))
585 (when (or t (gnus-visual-p 'tree-highlight 'highlight))
586 (gnus-tree-highlight-node gnus-tmp-number beg end))))
588 (defun gnus-tree-highlight-node (article beg end)
589 "Highlight current line according to `gnus-summary-highlight'."
590 (let ((list gnus-summary-highlight)
593 (set-buffer gnus-summary-buffer)
594 (let* ((score (or (cdr (assq article gnus-newsgroup-scored))
595 gnus-summary-default-score 0))
596 (default gnus-summary-default-score)
597 (mark (or (gnus-summary-article-mark article) gnus-unread-mark)))
598 ;; Eval the cars of the lists until we find a match.
600 (not (eval (caar list))))
601 (setq list (cdr list)))))
602 (unless (eq (setq face (cdar list)) (get-text-property beg 'face))
603 (gnus-put-text-property
605 (if (boundp face) (symbol-value face) face)))))
607 (defun gnus-tree-indent (level)
608 (insert (make-string (1- (* (1+ gnus-tree-node-length) level)) ? )))
610 (defvar gnus-tmp-limit)
611 (defvar gnus-tmp-sparse)
612 (defvar gnus-tmp-indent)
614 (defun gnus-generate-tree (thread)
615 "Generate a thread tree for THREAD."
617 (set-buffer (gnus-get-tree-buffer))
618 (let ((buffer-read-only nil)
621 (funcall gnus-generate-tree-function thread 0)
622 (gnus-set-mode-line 'tree)
623 (goto-char (point-min))
626 (let ((selected (selected-window)))
627 (when (get-buffer-window (set-buffer gnus-tree-buffer) t)
628 (select-window (get-buffer-window (set-buffer gnus-tree-buffer) t))
629 (gnus-horizontal-recenter)
630 (select-window selected))))))
632 (defun gnus-generate-horizontal-tree (thread level &optional dummyp adopted)
633 "Generate a horizontal tree."
634 (let* ((dummy (stringp (car thread)))
636 (memq (mail-header-number (car thread)) gnus-tmp-limit)))
639 ;; We don't want this article.
640 (setq thread (cdr thread))
642 ;; Not the first article on the line, so we insert a "-".
643 (insert (car gnus-tree-parent-child-edges))
644 ;; If the level isn't zero, then we insert some indentation.
645 (unless (zerop level)
646 (gnus-tree-indent level)
647 (insert (cadr gnus-tree-parent-child-edges))
648 (setq col (- (setq beg (point)) (gnus-point-at-bol) 1))
649 ;; Draw "|" lines upwards.
653 (= (following-char) ? ))
655 (insert (caddr gnus-tree-parent-child-edges)))
658 ;; Insert the article node.
659 (gnus-tree-node-insert (pop thread) gnus-tmp-sparse adopted))
661 ;; End of the thread, so we go to the next line.
664 ;; Recurse downwards in all children of this article.
666 (gnus-generate-horizontal-tree
667 (pop thread) (if do (1+ level) level)
668 (or dummyp dummy) dummy)))))
670 (defsubst gnus-tree-indent-vertical ()
671 (let ((len (- (* (1+ gnus-tree-node-length) gnus-tmp-indent)
672 (- (point) (gnus-point-at-bol)))))
674 (insert (make-string len ? )))))
676 (defsubst gnus-tree-forward-line (n)
677 (while (>= (decf n) 0)
678 (unless (zerop (forward-line 1))
683 (defun gnus-generate-vertical-tree (thread level &optional dummyp adopted)
684 "Generate a vertical tree."
685 (let* ((dummy (stringp (car thread)))
687 (memq (mail-header-number (car thread)) gnus-tmp-limit)))
690 ;; We don't want this article.
691 (setq thread (cdr thread))
692 (if (not (save-excursion (beginning-of-line) (bobp)))
693 ;; Not the first article on the line, so we insert a "-".
695 (gnus-tree-indent-vertical)
696 (insert (make-string (/ gnus-tree-node-length 2) ? ))
697 (insert (caddr gnus-tree-parent-child-edges))
698 (gnus-tree-forward-line 1))
699 ;; If the level isn't zero, then we insert some indentation.
700 (unless (zerop gnus-tmp-indent)
701 (gnus-tree-forward-line (1- (* 2 level)))
702 (gnus-tree-indent-vertical)
704 (insert (cadr gnus-tree-parent-child-edges))
706 ;; Draw "-" lines leftwards.
709 (= (following-char) ? ))
711 (insert (car gnus-tree-parent-child-edges)))
713 (gnus-tree-forward-line 1)))
715 ;; Insert the article node.
716 (gnus-tree-indent-vertical)
717 (gnus-tree-node-insert (pop thread) gnus-tmp-sparse adopted)
718 (gnus-tree-forward-line 1))
720 ;; End of the thread, so we go to the next line.
722 (goto-char (point-min))
724 (incf gnus-tmp-indent))
725 ;; Recurse downwards in all children of this article.
727 (gnus-generate-vertical-tree
728 (pop thread) (if do (1+ level) level)
729 (or dummyp dummy) dummy)))))
731 ;;; Interface functions.
733 (defun gnus-possibly-generate-tree (article &optional force)
734 "Generate the thread tree for ARTICLE if it isn't displayed already."
735 (when (save-excursion
736 (set-buffer gnus-summary-buffer)
739 (vectorp (gnus-summary-article-header article))))
741 (let ((top (save-excursion
742 (set-buffer gnus-summary-buffer)
746 (gnus-summary-article-header article))
748 (gnus-tmp-limit gnus-newsgroup-limit)
749 (gnus-tmp-sparse gnus-newsgroup-sparse))
751 (not (eq top gnus-tree-displayed-thread)))
752 (gnus-generate-tree top)
753 (setq gnus-tree-displayed-thread top))))))
755 (defun gnus-tree-open (group)
756 (gnus-get-tree-buffer))
758 (defun gnus-tree-close (group)
759 ;(gnus-kill-buffer gnus-tree-buffer)
762 (defun gnus-highlight-selected-tree (article)
763 "Highlight the selected article in the tree."
764 (let ((buf (current-buffer))
766 (set-buffer gnus-tree-buffer)
767 (when (setq region (gnus-tree-article-region article))
768 (when (or (not gnus-selected-tree-overlay)
769 (gnus-extent-detached-p gnus-selected-tree-overlay))
770 ;; Create a new overlay.
772 (setq gnus-selected-tree-overlay (gnus-make-overlay 1 2))
773 'face gnus-selected-tree-face))
774 ;; Move the overlay to the article.
776 gnus-selected-tree-overlay (goto-char (car region)) (cdr region))
779 (let ((selected (selected-window)))
780 (when (get-buffer-window (set-buffer gnus-tree-buffer) t)
781 (select-window (get-buffer-window (set-buffer gnus-tree-buffer) t))
782 (gnus-horizontal-recenter)
783 (select-window selected))))
784 ;; If we remove this save-excursion, it updates the wrong mode lines?!?
786 (set-buffer gnus-tree-buffer)
787 (gnus-set-mode-line 'tree))
790 (defun gnus-tree-highlight-article (article face)
792 (set-buffer (gnus-get-tree-buffer))
794 (when (setq region (gnus-tree-article-region article))
795 (gnus-put-text-property (car region) (cdr region) 'face face)
797 (get-buffer-window (current-buffer) t) (cdr region))))))
803 (defvar gnus-carpal-group-buffer-buttons
804 '(("next" . gnus-group-next-unread-group)
805 ("prev" . gnus-group-prev-unread-group)
806 ("read" . gnus-group-read-group)
807 ("select" . gnus-group-select-group)
808 ("catch-up" . gnus-group-catchup-current)
809 ("new-news" . gnus-group-get-new-news-this-group)
810 ("toggle-sub" . gnus-group-unsubscribe-current-group)
811 ("subscribe" . gnus-group-unsubscribe-group)
812 ("kill" . gnus-group-kill-group)
813 ("yank" . gnus-group-yank-group)
814 ("describe" . gnus-group-describe-group)
816 ("subscribed" . gnus-group-list-groups)
817 ("all" . gnus-group-list-all-groups)
818 ("killed" . gnus-group-list-killed)
819 ("zombies" . gnus-group-list-zombies)
820 ("matching" . gnus-group-list-matching)
821 ("post" . gnus-group-post-news)
822 ("mail" . gnus-group-mail)
823 ("rescan" . gnus-group-get-new-news)
824 ("browse-foreign" . gnus-group-browse-foreign)
825 ("exit" . gnus-group-exit)))
827 (defvar gnus-carpal-summary-buffer-buttons
829 ("read" . gnus-summary-mark-as-read-forward)
830 ("tick" . gnus-summary-tick-article-forward)
831 ("clear" . gnus-summary-clear-mark-forward)
832 ("expirable" . gnus-summary-mark-as-expirable)
834 ("scroll" . gnus-summary-next-page)
835 ("next-unread" . gnus-summary-next-unread-article)
836 ("prev-unread" . gnus-summary-prev-unread-article)
837 ("first" . gnus-summary-first-unread-article)
838 ("best" . gnus-summary-best-unread-article)
840 ("headers" . gnus-summary-toggle-header)
841 ("uudecode" . gnus-uu-decode-uu)
842 ("enter-digest" . gnus-summary-enter-digest-group)
843 ("fetch-parent" . gnus-summary-refer-parent-article)
845 ("move" . gnus-summary-move-article)
846 ("copy" . gnus-summary-copy-article)
847 ("respool" . gnus-summary-respool-article)
849 ("lower" . gnus-summary-lower-thread)
850 ("kill" . gnus-summary-kill-thread)
852 ("post" . gnus-summary-post-news)
853 ("mail" . gnus-summary-mail)
854 ("followup" . gnus-summary-followup-with-original)
855 ("reply" . gnus-summary-reply-with-original)
856 ("cancel" . gnus-summary-cancel-article)
858 ("exit" . gnus-summary-exit)
859 ("fed-up" . gnus-summary-catchup-and-goto-next-group)))
861 (defvar gnus-carpal-server-buffer-buttons
862 '(("add" . gnus-server-add-server)
863 ("browse" . gnus-server-browse-server)
864 ("list" . gnus-server-list-servers)
865 ("kill" . gnus-server-kill-server)
866 ("yank" . gnus-server-yank-server)
867 ("copy" . gnus-server-copy-server)
868 ("exit" . gnus-server-exit)))
870 (defvar gnus-carpal-browse-buffer-buttons
871 '(("subscribe" . gnus-browse-unsubscribe-current-group)
872 ("exit" . gnus-browse-exit)))
874 (defvar gnus-carpal-group-buffer "*Carpal Group*")
875 (defvar gnus-carpal-summary-buffer "*Carpal Summary*")
876 (defvar gnus-carpal-server-buffer "*Carpal Server*")
877 (defvar gnus-carpal-browse-buffer "*Carpal Browse*")
879 (defvar gnus-carpal-attached-buffer nil)
881 (defvar gnus-carpal-mode-hook nil
882 "*Hook run in carpal mode buffers.")
884 (defvar gnus-carpal-button-face 'bold
885 "*Face used on carpal buttons.")
887 (defvar gnus-carpal-header-face 'bold-italic
888 "*Face used on carpal buffer headers.")
890 (defvar gnus-carpal-mode-map nil)
891 (put 'gnus-carpal-mode 'mode-class 'special)
893 (if gnus-carpal-mode-map
895 (setq gnus-carpal-mode-map (make-keymap))
896 (suppress-keymap gnus-carpal-mode-map)
897 (define-key gnus-carpal-mode-map " " 'gnus-carpal-select)
898 (define-key gnus-carpal-mode-map "\r" 'gnus-carpal-select)
899 (define-key gnus-carpal-mode-map gnus-mouse-2 'gnus-carpal-mouse-select))
901 (defun gnus-carpal-mode ()
902 "Major mode for clicking buttons.
904 All normal editing commands are switched off.
905 \\<gnus-carpal-mode-map>
906 The following commands are available:
908 \\{gnus-carpal-mode-map}"
910 (kill-all-local-variables)
911 (setq mode-line-modified "-- ")
912 (setq major-mode 'gnus-carpal-mode)
913 (setq mode-name "Gnus Carpal")
914 (setq mode-line-process nil)
915 (use-local-map gnus-carpal-mode-map)
916 (buffer-disable-undo (current-buffer))
917 (setq buffer-read-only t)
918 (make-local-variable 'gnus-carpal-attached-buffer)
919 (run-hooks 'gnus-carpal-mode-hook))
921 (defun gnus-carpal-setup-buffer (type)
922 (let ((buffer (symbol-value (intern (format "gnus-carpal-%s-buffer" type)))))
923 (if (get-buffer buffer)
926 (set-buffer (get-buffer-create buffer))
928 (setq gnus-carpal-attached-buffer
929 (intern (format "gnus-%s-buffer" type)))
930 (gnus-add-current-to-buffer-list)
931 (let ((buttons (symbol-value
932 (intern (format "gnus-carpal-%s-buffer-buttons"
934 (buffer-read-only nil)
937 (setq button (car buttons)
938 buttons (cdr buttons))
940 (gnus-set-text-properties
942 (prog2 (insert button) (point) (insert " "))
943 (list 'face gnus-carpal-header-face))
944 (gnus-set-text-properties
946 (prog2 (insert (car button)) (point) (insert " "))
947 (list 'gnus-callback (cdr button)
948 'face gnus-carpal-button-face
949 gnus-mouse-face-prop 'highlight))))
950 (let ((fill-column (- (window-width) 2)))
951 (fill-region (point-min) (point-max)))
952 (set-window-point (get-buffer-window (current-buffer))
955 (defun gnus-carpal-select ()
956 "Select the button under point."
958 (let ((func (get-text-property (point) 'gnus-callback)))
961 (pop-to-buffer (symbol-value gnus-carpal-attached-buffer))
962 (call-interactively func))))
964 (defun gnus-carpal-mouse-select (event)
965 "Select the button under the mouse pointer."
967 (mouse-set-point event)
968 (gnus-carpal-select))
970 ;;; Allow redefinition of functions.
975 ;;; gnus-salt.el ends here