comparison lisp/gnus/gnus-salt.el @ 31716:9968f55ad26e

Update to emacs-21-branch of the Gnus CVS repository.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 19 Sep 2000 13:37:09 +0000
parents 15fc6acbae7a
children 6055a1f6073c
comparison
equal deleted inserted replaced
31715:7c896543d225 31716:9968f55ad26e
1 ;;; gnus-salt.el --- alternate summary mode interfaces for Gnus 1 ;;; gnus-salt.el --- alternate summary mode interfaces for Gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc. 2
3 ;; Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3 4
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> 5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: news 6 ;; Keywords: news
6 7
7 ;; This file is part of GNU Emacs. 8 ;; This file is part of GNU Emacs.
25 26
26 ;;; Code: 27 ;;; Code:
27 28
28 (eval-when-compile (require 'cl)) 29 (eval-when-compile (require 'cl))
29 30
30 (eval-when-compile (require 'cl))
31
32 (require 'gnus) 31 (require 'gnus)
33 (require 'gnus-sum) 32 (require 'gnus-sum)
34 33
35 ;;; 34 ;;;
36 ;;; gnus-pick-mode 35 ;;; gnus-pick-mode
53 "*If non-nil, mark all unpicked articles as read." 52 "*If non-nil, mark all unpicked articles as read."
54 :type 'boolean 53 :type 'boolean
55 :group 'gnus-summary-pick) 54 :group 'gnus-summary-pick)
56 55
57 (defcustom gnus-pick-elegant-flow t 56 (defcustom gnus-pick-elegant-flow t
58 "If non-nil, gnus-pick-start-reading will run gnus-summary-next-group when no articles have been picked." 57 "If non-nil, `gnus-pick-start-reading' runs `gnus-summary-next-group' when no articles have been picked."
59 :type 'boolean 58 :type 'boolean
60 :group 'gnus-summary-pick) 59 :group 'gnus-summary-pick)
61 60
62 (defcustom gnus-summary-pick-line-format 61 (defcustom gnus-summary-pick-line-format
63 "%-5P %U\%R\%z\%I\%(%[%4L: %-20,20n%]%) %s\n" 62 "%-5P %U\%R\%z\%I\%(%[%4L: %-20,20n%]%) %s\n"
76 (gnus-define-keys gnus-pick-mode-map 75 (gnus-define-keys gnus-pick-mode-map
77 " " gnus-pick-next-page 76 " " gnus-pick-next-page
78 "u" gnus-pick-unmark-article-or-thread 77 "u" gnus-pick-unmark-article-or-thread
79 "." gnus-pick-article-or-thread 78 "." gnus-pick-article-or-thread
80 gnus-down-mouse-2 gnus-pick-mouse-pick-region 79 gnus-down-mouse-2 gnus-pick-mouse-pick-region
81 "\r" gnus-pick-start-reading 80 "\r" gnus-pick-start-reading))
82 ))
83 81
84 (defun gnus-pick-make-menu-bar () 82 (defun gnus-pick-make-menu-bar ()
85 (unless (boundp 'gnus-pick-menu) 83 (unless (boundp 'gnus-pick-menu)
86 (easy-menu-define 84 (easy-menu-define
87 gnus-pick-menu gnus-pick-mode-map "" 85 gnus-pick-menu gnus-pick-mode-map ""
121 (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message) 119 (add-hook 'gnus-message-setup-hook 'gnus-pick-setup-message)
122 (set (make-local-variable 'gnus-summary-goto-unread) 'never) 120 (set (make-local-variable 'gnus-summary-goto-unread) 'never)
123 ;; Set up the menu. 121 ;; Set up the menu.
124 (when (gnus-visual-p 'pick-menu 'menu) 122 (when (gnus-visual-p 'pick-menu 'menu)
125 (gnus-pick-make-menu-bar)) 123 (gnus-pick-make-menu-bar))
126 (gnus-add-minor-mode 'gnus-pick-mode " Pick" gnus-pick-mode-map) 124 (gnus-add-minor-mode 'gnus-pick-mode " Pick" gnus-pick-mode-map
125 nil 'gnus-pick-mode)
127 (gnus-run-hooks 'gnus-pick-mode-hook)))) 126 (gnus-run-hooks 'gnus-pick-mode-hook))))
128 127
129 (defun gnus-pick-setup-message () 128 (defun gnus-pick-setup-message ()
130 "Make Message do the right thing on exit." 129 "Make Message do the right thing on exit."
131 (when (and (gnus-buffer-live-p gnus-summary-buffer) 130 (when (and (gnus-buffer-live-p gnus-summary-buffer)
132 (save-excursion 131 (save-excursion
133 (set-buffer gnus-summary-buffer) 132 (set-buffer gnus-summary-buffer)
134 gnus-pick-mode)) 133 gnus-pick-mode))
135 (message-add-action 134 (message-add-action
136 '(gnus-configure-windows 'pick t) 'send 'exit 'postpone 'kill))) 135 '(gnus-configure-windows ,gnus-current-window-configuration t)
136 'send 'exit 'postpone 'kill)))
137 137
138 (defvar gnus-pick-line-number 1) 138 (defvar gnus-pick-line-number 1)
139 (defun gnus-pick-line-number () 139 (defun gnus-pick-line-number ()
140 "Return the current line number." 140 "Return the current line number."
141 (if (bobp) 141 (if (bobp)
162 (gnus-summary-exit) 162 (gnus-summary-exit)
163 (gnus-summary-next-group))) 163 (gnus-summary-next-group)))
164 (error "No articles have been picked")))) 164 (error "No articles have been picked"))))
165 165
166 (defun gnus-pick-goto-article (arg) 166 (defun gnus-pick-goto-article (arg)
167 "Go to the article number indicated by ARG. If ARG is an invalid 167 "Go to the article number indicated by ARG.
168 article number, then stay on current line." 168 If ARG is an invalid article number, then stay on current line."
169 (let (pos) 169 (let (pos)
170 (save-excursion 170 (save-excursion
171 (goto-char (point-min)) 171 (goto-char (point-min))
172 (when (zerop (forward-line (1- (prefix-numeric-value arg)))) 172 (when (zerop (forward-line (1- (prefix-numeric-value arg))))
173 (setq pos (point)))) 173 (setq pos (point))))
174 (if (not pos) 174 (if (not pos)
175 (gnus-error 2 "No such line: %s" arg) 175 (gnus-error 2 "No such line: %s" arg)
176 (goto-char pos)))) 176 (goto-char pos))))
177 177
178 (defun gnus-pick-article (&optional arg) 178 (defun gnus-pick-article (&optional arg)
179 "Pick the article on the current line. 179 "Pick the article on the current line.
180 If ARG, pick the article on that line instead." 180 If ARG, pick the article on that line instead."
181 (interactive "P") 181 (interactive "P")
182 (when arg 182 (when arg
183 (gnus-pick-goto-article arg)) 183 (gnus-pick-goto-article arg))
184 (gnus-summary-mark-as-processable 1)) 184 (gnus-summary-mark-as-processable 1))
185 185
186 (defun gnus-pick-article-or-thread (&optional arg) 186 (defun gnus-pick-article-or-thread (&optional arg)
187 "If gnus-thread-hide-subtree is t, then pick the thread on the current line. 187 "If `gnus-thread-hide-subtree' is t, then pick the thread on the current line.
188 Otherwise pick the article on the current line. 188 Otherwise pick the article on the current line.
189 If ARG, pick the article/thread on that line instead." 189 If ARG, pick the article/thread on that line instead."
190 (interactive "P") 190 (interactive "P")
191 (when arg 191 (when arg
192 (gnus-pick-goto-article arg)) 192 (gnus-pick-goto-article arg))
193 (if gnus-thread-hide-subtree 193 (if gnus-thread-hide-subtree
194 (gnus-uu-mark-thread) 194 (progn
195 (save-excursion
196 (gnus-uu-mark-thread))
197 (forward-line 1))
195 (gnus-summary-mark-as-processable 1))) 198 (gnus-summary-mark-as-processable 1)))
196 199
197 (defun gnus-pick-unmark-article-or-thread (&optional arg) 200 (defun gnus-pick-unmark-article-or-thread (&optional arg)
198 "If gnus-thread-hide-subtree is t, then unmark the thread on current line. 201 "If `gnus-thread-hide-subtree' is t, then unmark the thread on current line.
199 Otherwise unmark the article on current line. 202 Otherwise unmark the article on current line.
200 If ARG, unmark thread/article on that line instead." 203 If ARG, unmark thread/article on that line instead."
201 (interactive "P") 204 (interactive "P")
202 (when arg 205 (when arg
203 (gnus-pick-goto-article arg)) 206 (gnus-pick-goto-article arg))
204 (if gnus-thread-hide-subtree 207 (if gnus-thread-hide-subtree
205 (gnus-uu-unmark-thread) 208 (save-excursion
209 (gnus-uu-unmark-thread))
206 (gnus-summary-unmark-as-processable 1))) 210 (gnus-summary-unmark-as-processable 1)))
207 211
208 (defun gnus-pick-mouse-pick (e) 212 (defun gnus-pick-mouse-pick (e)
209 (interactive "e") 213 (interactive "e")
210 (mouse-set-point e) 214 (mouse-set-point e)
211 (save-excursion 215 (save-excursion
212 (gnus-summary-mark-as-processable 1))) 216 (gnus-summary-mark-as-processable 1)))
240 ;; end-of-range is used only in the single-click case. 244 ;; end-of-range is used only in the single-click case.
241 ;; It is the place where the drag has reached so far 245 ;; It is the place where the drag has reached so far
242 ;; (but not outside the window where the drag started). 246 ;; (but not outside the window where the drag started).
243 (let (event end end-point (end-of-range (point))) 247 (let (event end end-point (end-of-range (point)))
244 (track-mouse 248 (track-mouse
245 (while (progn 249 (while (progn
246 (setq event (cdr (gnus-read-event-char))) 250 (setq event (cdr (gnus-read-event-char)))
247 (or (mouse-movement-p event) 251 (or (mouse-movement-p event)
248 (eq (car-safe event) 'switch-frame))) 252 (eq (car-safe event) 'switch-frame)))
249 (if (eq (car-safe event) 'switch-frame) 253 (if (eq (car-safe event) 'switch-frame)
250 nil 254 nil
251 (setq end (event-end event) 255 (setq end (event-end event)
252 end-point (posn-point end)) 256 end-point (posn-point end))
253 257
254 (cond 258 (cond
255 ;; Are we moving within the original window? 259 ;; Are we moving within the original window?
256 ((and (eq (posn-window end) start-window) 260 ((and (eq (posn-window end) start-window)
257 (integer-or-marker-p end-point)) 261 (integer-or-marker-p end-point))
258 ;; Go to START-POINT first, so that when we move to END-POINT, 262 ;; Go to START-POINT first, so that when we move to END-POINT,
259 ;; if it's in the middle of intangible text, 263 ;; if it's in the middle of intangible text,
260 ;; point jumps in the direction away from START-POINT. 264 ;; point jumps in the direction away from START-POINT.
261 (goto-char start-point) 265 (goto-char start-point)
262 (goto-char end-point) 266 (goto-char end-point)
263 (gnus-pick-article) 267 (gnus-pick-article)
264 ;; In case the user moved his mouse really fast, pick 268 ;; In case the user moved his mouse really fast, pick
265 ;; articles on the line between this one and the last one. 269 ;; articles on the line between this one and the last one.
266 (let* ((this-line (1+ (count-lines 1 end-point))) 270 (let* ((this-line (1+ (count-lines 1 end-point)))
267 (min-line (min this-line start-line)) 271 (min-line (min this-line start-line))
268 (max-line (max this-line start-line))) 272 (max-line (max this-line start-line)))
269 (while (< min-line max-line) 273 (while (< min-line max-line)
270 (goto-line min-line) 274 (goto-line min-line)
271 (gnus-pick-article) 275 (gnus-pick-article)
272 (setq min-line (1+ min-line))) 276 (setq min-line (1+ min-line)))
273 (setq start-line this-line)) 277 (setq start-line this-line))
274 (when (zerop (% click-count 3)) 278 (when (zerop (% click-count 3))
275 (setq end-of-range (point)))) 279 (setq end-of-range (point))))
276 (t 280 (t
277 (let ((mouse-row (cdr (cdr (mouse-position))))) 281 (let ((mouse-row (cdr (cdr (mouse-position)))))
278 (cond 282 (cond
279 ((null mouse-row)) 283 ((null mouse-row))
280 ((< mouse-row top) 284 ((< mouse-row top)
281 (mouse-scroll-subr start-window (- mouse-row top))) 285 (mouse-scroll-subr start-window (- mouse-row top)))
282 ((>= mouse-row bottom) 286 ((>= mouse-row bottom)
283 (mouse-scroll-subr start-window 287 (mouse-scroll-subr start-window
284 (1+ (- mouse-row bottom))))))))))) 288 (1+ (- mouse-row bottom)))))))))))
285 (when (consp event) 289 (when (consp event)
286 (let ((fun (key-binding (vector (car event))))) 290 (let ((fun (key-binding (vector (car event)))))
287 ;; Run the binding of the terminating up-event, if possible. 291 ;; Run the binding of the terminating up-event, if possible.
288 ;; In the case of a multiple click, it gives the wrong results, 292 ;; In the case of a multiple click, it gives the wrong results,
289 ;; because it would fail to set up a region. 293 ;; because it would fail to set up a region.
321 325
322 (unless gnus-binary-mode-map 326 (unless gnus-binary-mode-map
323 (setq gnus-binary-mode-map (make-sparse-keymap)) 327 (setq gnus-binary-mode-map (make-sparse-keymap))
324 328
325 (gnus-define-keys 329 (gnus-define-keys
326 gnus-binary-mode-map 330 gnus-binary-mode-map
327 "g" gnus-binary-show-article)) 331 "g" gnus-binary-show-article))
328 332
329 (defun gnus-binary-make-menu-bar () 333 (defun gnus-binary-make-menu-bar ()
330 (unless (boundp 'gnus-binary-menu) 334 (unless (boundp 'gnus-binary-menu)
331 (easy-menu-define 335 (easy-menu-define
332 gnus-binary-menu gnus-binary-mode-map "" 336 gnus-binary-menu gnus-binary-mode-map ""
348 (make-local-variable 'gnus-summary-display-article-function) 352 (make-local-variable 'gnus-summary-display-article-function)
349 (setq gnus-summary-display-article-function 'gnus-binary-display-article) 353 (setq gnus-summary-display-article-function 'gnus-binary-display-article)
350 ;; Set up the menu. 354 ;; Set up the menu.
351 (when (gnus-visual-p 'binary-menu 'menu) 355 (when (gnus-visual-p 'binary-menu 'menu)
352 (gnus-binary-make-menu-bar)) 356 (gnus-binary-make-menu-bar))
353 (gnus-add-minor-mode 'gnus-binary-mode " Binary" gnus-binary-mode-map) 357 (gnus-add-minor-mode 'gnus-binary-mode " Binary"
358 gnus-binary-mode-map nil 'gnus-binary-mode-map)
354 (gnus-run-hooks 'gnus-binary-mode-hook)))) 359 (gnus-run-hooks 'gnus-binary-mode-hook))))
355 360
356 (defun gnus-binary-display-article (article &optional all-header) 361 (defun gnus-binary-display-article (article &optional all-header)
357 "Run ARTICLE through the binary decode functions." 362 "Run ARTICLE through the binary decode functions."
358 (when (gnus-summary-goto-subject article) 363 (when (gnus-summary-goto-subject article)
430 435
431 (defvar gnus-tree-node-length nil) 436 (defvar gnus-tree-node-length nil)
432 (defvar gnus-selected-tree-overlay nil) 437 (defvar gnus-selected-tree-overlay nil)
433 438
434 (defvar gnus-tree-displayed-thread nil) 439 (defvar gnus-tree-displayed-thread nil)
440 (defvar gnus-tree-inhibit nil)
435 441
436 (defvar gnus-tree-mode-map nil) 442 (defvar gnus-tree-mode-map nil)
437 (put 'gnus-tree-mode 'mode-class 'special) 443 (put 'gnus-tree-mode 'mode-class 'special)
438 444
439 (unless gnus-tree-mode-map 445 (unless gnus-tree-mode-map
440 (setq gnus-tree-mode-map (make-keymap)) 446 (setq gnus-tree-mode-map (make-keymap))
441 (suppress-keymap gnus-tree-mode-map) 447 (suppress-keymap gnus-tree-mode-map)
442 (gnus-define-keys 448 (gnus-define-keys
443 gnus-tree-mode-map 449 gnus-tree-mode-map
444 "\r" gnus-tree-select-article 450 "\r" gnus-tree-select-article
445 gnus-mouse-2 gnus-tree-pick-article 451 gnus-mouse-2 gnus-tree-pick-article
446 "\C-?" gnus-tree-read-summary-keys 452 "\C-?" gnus-tree-read-summary-keys
447 "h" gnus-tree-show-summary 453 "h" gnus-tree-show-summary
448 454
449 "\C-c\C-i" gnus-info-find-node) 455 "\C-c\C-i" gnus-info-find-node)
450 456
451 (substitute-key-definition 457 (substitute-key-definition
452 'undefined 'gnus-tree-read-summary-keys gnus-tree-mode-map)) 458 'undefined 'gnus-tree-read-summary-keys gnus-tree-mode-map))
453 459
454 (defun gnus-tree-make-menu-bar () 460 (defun gnus-tree-make-menu-bar ()
468 (kill-all-local-variables) 474 (kill-all-local-variables)
469 (gnus-simplify-mode-line) 475 (gnus-simplify-mode-line)
470 (setq mode-name "Tree") 476 (setq mode-name "Tree")
471 (setq major-mode 'gnus-tree-mode) 477 (setq major-mode 'gnus-tree-mode)
472 (use-local-map gnus-tree-mode-map) 478 (use-local-map gnus-tree-mode-map)
473 (buffer-disable-undo (current-buffer)) 479 (buffer-disable-undo)
474 (setq buffer-read-only t) 480 (setq buffer-read-only t)
475 (setq truncate-lines t) 481 (setq truncate-lines t)
476 (save-excursion 482 (save-excursion
477 (gnus-set-work-buffer) 483 (gnus-set-work-buffer)
478 (gnus-tree-node-insert (make-mail-header "") nil) 484 (gnus-tree-node-insert (make-mail-header "") nil)
480 (gnus-run-hooks 'gnus-tree-mode-hook)) 486 (gnus-run-hooks 'gnus-tree-mode-hook))
481 487
482 (defun gnus-tree-read-summary-keys (&optional arg) 488 (defun gnus-tree-read-summary-keys (&optional arg)
483 "Read a summary buffer key sequence and execute it." 489 "Read a summary buffer key sequence and execute it."
484 (interactive "P") 490 (interactive "P")
485 (let ((buf (current-buffer)) 491 (unless gnus-tree-inhibit
486 win) 492 (let ((buf (current-buffer))
487 (set-buffer gnus-article-buffer) 493 (gnus-tree-inhibit t)
488 (gnus-article-read-summary-keys arg nil t) 494 win)
489 (when (setq win (get-buffer-window buf)) 495 (set-buffer gnus-article-buffer)
490 (select-window win) 496 (gnus-article-read-summary-keys arg nil t)
491 (when gnus-selected-tree-overlay 497 (when (setq win (get-buffer-window buf))
492 (goto-char (or (gnus-overlay-end gnus-selected-tree-overlay) 1))) 498 (select-window win)
493 (gnus-tree-minimize)))) 499 (when gnus-selected-tree-overlay
500 (goto-char (or (gnus-overlay-end gnus-selected-tree-overlay) 1)))
501 (gnus-tree-minimize)))))
494 502
495 (defun gnus-tree-show-summary () 503 (defun gnus-tree-show-summary ()
496 "Reconfigure windows to show summary buffer." 504 "Reconfigure windows to show summary buffer."
497 (interactive) 505 (interactive)
498 (if (not (gnus-buffer-live-p gnus-summary-buffer)) 506 (if (not (gnus-buffer-live-p gnus-summary-buffer))
519 (defun gnus-tree-article-number () 527 (defun gnus-tree-article-number ()
520 (get-text-property (point) 'gnus-number)) 528 (get-text-property (point) 'gnus-number))
521 529
522 (defun gnus-tree-article-region (article) 530 (defun gnus-tree-article-region (article)
523 "Return a cons with BEG and END of the article region." 531 "Return a cons with BEG and END of the article region."
524 (let ((pos (text-property-any (point-min) (point-max) 'gnus-number article))) 532 (let ((pos (text-property-any
533 (point-min) (point-max) 'gnus-number article)))
525 (when pos 534 (when pos
526 (cons pos (next-single-property-change pos 'gnus-number))))) 535 (cons pos (next-single-property-change pos 'gnus-number)))))
527 536
528 (defun gnus-tree-goto-article (article) 537 (defun gnus-tree-goto-article (article)
529 (let ((pos (text-property-any (point-min) (point-max) 'gnus-number article))) 538 (let ((pos (text-property-any
539 (point-min) (point-max) 'gnus-number article)))
530 (when pos 540 (when pos
531 (goto-char pos)))) 541 (goto-char pos))))
532 542
533 (defun gnus-tree-recenter () 543 (defun gnus-tree-recenter ()
534 "Center point in the tree window." 544 "Center point in the tree window."
702 (setq col (- (setq beg (point)) (gnus-point-at-bol) 1)) 712 (setq col (- (setq beg (point)) (gnus-point-at-bol) 1))
703 ;; Draw "|" lines upwards. 713 ;; Draw "|" lines upwards.
704 (while (progn 714 (while (progn
705 (forward-line -1) 715 (forward-line -1)
706 (forward-char col) 716 (forward-char col)
707 (= (following-char) ? )) 717 (eq (char-after) ? ))
708 (delete-char 1) 718 (delete-char 1)
709 (insert (caddr gnus-tree-parent-child-edges))) 719 (insert (caddr gnus-tree-parent-child-edges)))
710 (goto-char beg))) 720 (goto-char beg)))
711 (setq dummyp nil) 721 (setq dummyp nil)
712 ;; Insert the article node. 722 ;; Insert the article node.
760 (insert (cadr gnus-tree-parent-child-edges)) 770 (insert (cadr gnus-tree-parent-child-edges))
761 (setq beg (point)) 771 (setq beg (point))
762 (forward-char -1) 772 (forward-char -1)
763 ;; Draw "-" lines leftwards. 773 ;; Draw "-" lines leftwards.
764 (while (and (> (point) 1) 774 (while (and (> (point) 1)
765 (= (char-after (1- (point))) ? )) 775 (eq (char-after (1- (point))) ? ))
766 (delete-char -1) 776 (delete-char -1)
767 (insert (car gnus-tree-parent-child-edges)) 777 (insert (car gnus-tree-parent-child-edges))
768 (forward-char -1)) 778 (forward-char -1))
769 (goto-char beg) 779 (goto-char beg)
770 (gnus-tree-forward-line 1))) 780 (gnus-tree-forward-line 1)))
967 (setq mode-line-modified (cdr gnus-mode-line-modified)) 977 (setq mode-line-modified (cdr gnus-mode-line-modified))
968 (setq major-mode 'gnus-carpal-mode) 978 (setq major-mode 'gnus-carpal-mode)
969 (setq mode-name "Gnus Carpal") 979 (setq mode-name "Gnus Carpal")
970 (setq mode-line-process nil) 980 (setq mode-line-process nil)
971 (use-local-map gnus-carpal-mode-map) 981 (use-local-map gnus-carpal-mode-map)
972 (buffer-disable-undo (current-buffer)) 982 (buffer-disable-undo)
973 (setq buffer-read-only t) 983 (setq buffer-read-only t)
974 (make-local-variable 'gnus-carpal-attached-buffer) 984 (make-local-variable 'gnus-carpal-attached-buffer)
975 (gnus-run-hooks 'gnus-carpal-mode-hook)) 985 (gnus-run-hooks 'gnus-carpal-mode-hook))
976 986
977 (defun gnus-carpal-setup-buffer (type) 987 (defun gnus-carpal-setup-buffer (type)