Mercurial > emacs
annotate lisp/=gnusmisc.el @ 793:6fb68a1460a6
*** empty log message ***
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Thu, 16 Jul 1992 07:28:05 +0000 |
parents | 22b98190b7ef |
children | 4f28bd14272c |
rev | line source |
---|---|
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
1 ;;; gnusmisc.el --- miscellaneous commands for GNUS newsreader |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
2 |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
3 ;; Copyright (C) 1989, 1990 Free Software Foundation, Inc. |
206 | 4 ;; $Header: gnusmisc.el,v 1.2 90/03/23 13:25:04 umerin Locked $ |
5 | |
6 ;; This file is part of GNU Emacs. | |
7 | |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
8 ;; GNU Emacs is free software; you can redistribute it and/or modify |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
9 ;; it under the terms of the GNU General Public License as published by |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
10 ;; the Free Software Foundation; either version 1, or (at your option) |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
11 ;; any later version. |
206 | 12 |
711
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
13 ;; GNU Emacs is distributed in the hope that it will be useful, |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
16 ;; GNU General Public License for more details. |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
17 |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
18 ;; You should have received a copy of the GNU General Public License |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
19 ;; along with GNU Emacs; see the file COPYING. If not, write to |
22b98190b7ef
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
660
diff
changeset
|
20 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
206 | 21 |
22 (require 'gnus) | |
23 | |
24 ;;; | |
25 ;;; GNUS Browse-Killed Mode | |
26 ;;; | |
27 | |
28 ;; Some ideas are due to roland@wheaties.ai.mit.edu (Roland McGrath). | |
29 ;; I'd like to thank him very much. | |
30 | |
31 (defvar gnus-Browse-killed-mode-hook nil | |
32 "*A hook for GNUS Browse-Killed Mode.") | |
33 | |
34 (defvar gnus-Browse-killed-buffer "*Killed Newsgroup*") | |
35 (defvar gnus-Browse-killed-mode-map nil) | |
36 (defvar gnus-winconf-browse-killed nil) | |
37 | |
38 (put 'gnus-Browse-killed-mode 'mode-class 'special) | |
39 | |
40 ;; Make the buffer to be managed by GNUS. | |
41 | |
42 (or (memq gnus-Browse-killed-buffer gnus-buffer-list) | |
43 (setq gnus-buffer-list | |
44 (cons gnus-Browse-killed-buffer gnus-buffer-list))) | |
45 | |
46 (if gnus-Browse-killed-mode-map | |
47 nil | |
48 (setq gnus-Browse-killed-mode-map (make-keymap)) | |
49 (suppress-keymap gnus-Browse-killed-mode-map t) | |
50 (define-key gnus-Browse-killed-mode-map " " 'gnus-Group-next-group) | |
51 (define-key gnus-Browse-killed-mode-map "\177" 'gnus-Group-prev-group) | |
52 (define-key gnus-Browse-killed-mode-map "\C-n" 'gnus-Group-next-group) | |
53 (define-key gnus-Browse-killed-mode-map "\C-p" 'gnus-Group-prev-group) | |
54 (define-key gnus-Browse-killed-mode-map "n" 'gnus-Group-next-group) | |
55 (define-key gnus-Browse-killed-mode-map "p" 'gnus-Group-prev-group) | |
56 (define-key gnus-Browse-killed-mode-map "y" 'gnus-Browse-killed-yank) | |
57 (define-key gnus-Browse-killed-mode-map "\C-y" 'gnus-Browse-killed-yank) | |
58 (define-key gnus-Browse-killed-mode-map "l" 'gnus-Browse-killed-groups) | |
59 (define-key gnus-Browse-killed-mode-map "q" 'gnus-Browse-killed-exit) | |
60 (define-key gnus-Browse-killed-mode-map "\C-c\C-c" 'gnus-Browse-killed-exit) | |
61 (define-key gnus-Browse-killed-mode-map "\C-c\C-i" 'gnus-Info-find-node)) | |
62 | |
63 (defun gnus-Browse-killed-mode () | |
64 "Major mode for browsing the killed newsgroups. | |
65 All normal editing commands are turned off. | |
66 Instead, these commands are available: | |
67 \\{gnus-Browse-killed-mode-map} | |
68 | |
69 The killed newsgroups are saved in the quick startup file \".newsrc.el\" | |
70 unless disabled inthe options line of the startup file \".newsrc\". | |
71 | |
72 Entry to this mode calls `gnus-Browse-killed-mode-hook' with no arguments | |
73 if that value is non-nil." | |
74 (interactive) | |
75 (kill-all-local-variables) | |
76 ;; Gee. Why don't you upgrade? | |
77 (cond ((boundp 'mode-line-modified) | |
78 (setq mode-line-modified "--- ")) | |
79 ((listp (default-value 'mode-line-format)) | |
80 (setq mode-line-format | |
81 (cons "--- " (cdr (default-value 'mode-line-format))))) | |
82 (t | |
83 (setq mode-line-format | |
84 "--- GNUS: Killed Newsgroups %[(%m)%]----%3p-%-"))) | |
85 (setq major-mode 'gnus-Browse-killed-mode) | |
86 (setq mode-name "Browse-Killed") | |
87 (setq mode-line-buffer-identification "GNUS: Killed Newsgroups") | |
88 (use-local-map gnus-Browse-killed-mode-map) | |
89 (buffer-flush-undo (current-buffer)) | |
90 (setq buffer-read-only t) ;Disable modification | |
91 (run-hooks 'gnus-Browse-killed-mode-hook)) | |
92 | |
93 (defun gnus-Browse-killed-groups () | |
94 "Browse the killed newsgroups. | |
95 \\<gnus-Browse-killed-mode-map>\\[gnus-Browse-killed-yank] yanks the newsgroup on the current line into the Newsgroups buffer." | |
96 (interactive) | |
97 (or gnus-killed-assoc | |
98 (error "No killed newsgroups")) | |
99 ;; Save current window configuration if this is first invocation.. | |
100 (or (get-buffer-window gnus-Browse-killed-buffer) | |
101 (setq gnus-winconf-browse-killed | |
102 (current-window-configuration))) | |
103 ;; Prepare browsing buffer. | |
104 (pop-to-buffer (get-buffer-create gnus-Browse-killed-buffer)) | |
105 (gnus-Browse-killed-mode) | |
106 (let ((buffer-read-only nil) | |
107 (killed-assoc gnus-killed-assoc)) | |
108 (erase-buffer) | |
109 (while killed-assoc | |
110 (insert (gnus-Group-prepare-line (car killed-assoc))) | |
111 (setq killed-assoc (cdr killed-assoc))) | |
112 (goto-char (point-min)) | |
113 )) | |
114 | |
115 (defun gnus-Browse-killed-yank () | |
116 "Yank current newsgroup to Newsgroup buffer." | |
117 (interactive) | |
118 (let ((group (gnus-Group-group-name))) | |
119 (if group | |
120 (let* ((buffer-read-only nil) | |
121 (killed (assoc group gnus-killed-assoc))) | |
122 (pop-to-buffer gnus-Group-buffer) ;Needed to adjust point. | |
123 (if killed | |
124 (gnus-Group-insert-group killed)) | |
125 (pop-to-buffer gnus-Browse-killed-buffer) | |
126 (beginning-of-line) | |
127 (delete-region (point) | |
128 (progn (forward-line 1) (point))) | |
129 ))) | |
130 (gnus-Browse-killed-check-buffer)) | |
131 | |
132 (defun gnus-Browse-killed-check-buffer () | |
133 "Exit if the buffer is empty by deleting the window and killing the buffer." | |
134 (and (null gnus-killed-assoc) | |
135 (get-buffer gnus-Browse-killed-buffer) | |
136 (gnus-Browse-killed-exit))) | |
137 | |
138 (defun gnus-Browse-killed-exit () | |
139 "Exit this mode by deleting the window and killing the buffer." | |
140 (interactive) | |
141 (and (get-buffer-window gnus-Browse-killed-buffer) | |
142 (delete-window (get-buffer-window gnus-Browse-killed-buffer))) | |
143 (kill-buffer gnus-Browse-killed-buffer) | |
144 ;; Restore previous window configuration if available. | |
145 (and gnus-winconf-browse-killed | |
146 (set-window-configuration gnus-winconf-browse-killed)) | |
147 (setq gnus-winconf-browse-killed nil)) | |
148 | |
149 | |
150 ;;; | |
151 ;;; kill/yank newsgroup commands of GNUS Group Mode | |
152 ;;; | |
153 | |
154 (defun gnus-Group-kill-group (n) | |
155 "Kill newsgroup on current line, repeated prefix argument N times. | |
156 The killed newsgroups can be yanked by using \\[gnus-Group-yank-group]." | |
157 (interactive "p") | |
158 (let ((buffer-read-only nil) | |
159 (group nil)) | |
160 (while (> n 0) | |
161 (setq group (gnus-Group-group-name)) | |
162 (or group | |
163 (signal 'end-of-buffer nil)) | |
164 (beginning-of-line) | |
165 (delete-region (point) | |
166 (progn (forward-line 1) (point))) | |
167 (gnus-kill-newsgroup group) | |
168 (setq n (1- n)) | |
169 ;; Add to killed newsgroups in the buffer if exists. | |
170 (if (get-buffer gnus-Browse-killed-buffer) | |
171 (save-excursion | |
172 (set-buffer gnus-Browse-killed-buffer) | |
173 (let ((buffer-read-only nil)) | |
174 (goto-char (point-min)) | |
175 (insert (gnus-Group-prepare-line (car gnus-killed-assoc))) | |
176 ))) | |
177 ) | |
178 (search-forward ":" nil t) | |
179 )) | |
180 | |
181 (defun gnus-Group-yank-group () | |
182 "Yank the last newsgroup killed with \\[gnus-Group-kill-group], | |
183 inserting it before the newsgroup on the line containging point." | |
184 (interactive) | |
185 (gnus-Group-insert-group (car gnus-killed-assoc)) | |
186 ;; Remove killed newsgroups from the buffer if exists. | |
187 (if (get-buffer gnus-Browse-killed-buffer) | |
188 (save-excursion | |
189 (set-buffer gnus-Browse-killed-buffer) | |
190 (let ((buffer-read-only nil)) | |
191 (goto-char (point-min)) | |
192 (delete-region (point-min) | |
193 (progn (forward-line 1) (point))) | |
194 ))) | |
195 (gnus-Browse-killed-check-buffer)) | |
196 | |
197 (defun gnus-Group-insert-group (info) | |
198 "Insert newsgroup at current line using `gnus-newsrc-assoc' INFO." | |
199 (if (null gnus-killed-assoc) | |
200 (error "No killed newsgroups")) | |
201 (if (not gnus-have-all-newsgroups) | |
202 (error | |
203 (substitute-command-keys | |
204 "Not all newsgroups are displayed. Type \\[gnus-Group-list-all-groups] to display all newsgroups."))) | |
205 (let ((buffer-read-only nil) | |
206 (group (gnus-Group-group-name))) | |
207 (gnus-insert-newsgroup info group) | |
208 (beginning-of-line) | |
209 (insert (gnus-Group-prepare-line info)) | |
210 (forward-line -1) | |
211 (search-forward ":" nil t) | |
212 )) | |
584 | 213 |
214 (provide 'gnusmisc) | |
660
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
215 |
08eb386dd0f3
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
584
diff
changeset
|
216 ;;; gnusmisc.el ends here |