annotate lisp/=gnuspost.el @ 1087:6c410cc87574

* ralloc.c (r_re_alloc): Instead of allocating a new bloc at the end of the heap, copying the data to it, and then freeing the original bloc, just expand the original block. This saves a copy and a call to sbrk, and also removes the large spike in memory allocation that would occur when resizing large buffers. And it's less code.
author Jim Blandy <jimb@redhat.com>
date Wed, 09 Sep 1992 00:05:42 +0000
parents 9620f7edf04d
children b65cf676a09b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; gnuspost.el --- post news commands for GNUS newsreader
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
3 ;; Copyright (C) 1989, 1990 Free Software Foundation, Inc.
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 711
diff changeset
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Keywords: news
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 711
diff changeset
7
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
711
22b98190b7ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
10 ;; 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
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 711
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
711
22b98190b7ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
13 ;; any later version.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
711
22b98190b7ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
15 ;; 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
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22b98190b7ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22b98190b7ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
18 ;; GNU General Public License for more details.
22b98190b7ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
19
22b98190b7ef *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 660
diff changeset
20 ;; 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
21 ;; 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
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 711
diff changeset
24 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 711
diff changeset
25
267
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 (require 'gnus)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 (defvar gnus-organization-file "/usr/lib/news/organization"
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 "*Local news organization file.")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 (defvar gnus-post-news-buffer "*post-news*")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 (defvar gnus-winconf-post-news nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 (autoload 'news-reply-mode "rnewspost")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;;; Post news commands of GNUS Group Mode and Subject Mode
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 (defun gnus-Group-post-news ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 "Post an article."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 ;; Save window configuration.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 (setq gnus-winconf-post-news (current-window-configuration))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 (unwind-protect
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 (gnus-post-news)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 (not (zerop (buffer-size))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 ;; Restore last window configuration.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (set-window-configuration gnus-winconf-post-news)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 ;; We don't want to return to Subject buffer nor Article buffer later.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 (if (get-buffer gnus-Subject-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (bury-buffer gnus-Subject-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (if (get-buffer gnus-Article-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (bury-buffer gnus-Article-buffer)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (defun gnus-Subject-post-news ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 "Post an article."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (gnus-Subject-select-article t nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 ;; Save window configuration.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (setq gnus-winconf-post-news (current-window-configuration))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (unwind-protect
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (switch-to-buffer gnus-Article-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 (widen)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 (delete-other-windows)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 (gnus-post-news))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (not (zerop (buffer-size))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 ;; Restore last window configuration.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (set-window-configuration gnus-winconf-post-news)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 ;; We don't want to return to Article buffer later.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (bury-buffer gnus-Article-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 (defun gnus-Subject-post-reply (yank)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 "Post a reply article.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 If prefix argument YANK is non-nil, original article is yanked automatically."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 (interactive "P")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 (gnus-Subject-select-article t nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 ;; Check Followup-To: poster.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (set-buffer gnus-Article-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (if (and gnus-use-followup-to
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (string-equal "poster" (gnus-fetch-field "followup-to"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (or (not (eq gnus-use-followup-to t))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 (not (y-or-n-p "Do you want to ignore `Followup-To: poster'? "))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 ;; Mail to the poster. GNUS is now RFC1036 compliant.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (gnus-Subject-mail-reply yank)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 ;; Save window configuration.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 (setq gnus-winconf-post-news (current-window-configuration))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 (unwind-protect
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 (switch-to-buffer gnus-Article-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 (widen)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 (delete-other-windows)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (gnus-news-reply yank))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (not (zerop (buffer-size))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 ;; Restore last window configuration.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 (set-window-configuration gnus-winconf-post-news)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 ;; We don't want to return to Article buffer later.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (bury-buffer gnus-Article-buffer)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (defun gnus-Subject-post-reply-with-original ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 "Post a reply article with original article."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 (gnus-Subject-post-reply t))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (defun gnus-Subject-cancel-article ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 "Cancel an article you posted."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (gnus-Subject-select-article t nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (gnus-eval-in-buffer-window gnus-Article-buffer
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (gnus-cancel-news)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 ;;; Post a News using NNTP
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 ;;;###autoload
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (fset 'sendnews 'gnus-post-news)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 ;;;###autoload
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 (fset 'postnews 'gnus-post-news)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 ;;;###autoload
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (defun gnus-post-news ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 "Begin editing a new USENET news article to be posted.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 Type \\[describe-mode] once editing the article to get a list of commands."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (if (or (not gnus-novice-user)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (y-or-n-p "Are you sure you want to post to all of USENET? "))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (let ((artbuf (current-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (newsgroups ;Default newsgroup.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 (if (eq major-mode 'gnus-Article-mode) gnus-newsgroup-name))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 (subject nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (distribution nil))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (save-restriction
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (and (not (zerop (buffer-size)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 ;;(equal major-mode 'news-mode)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (equal major-mode 'gnus-Article-mode)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 ;;(news-show-all-headers)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (gnus-Article-show-all-headers)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (narrow-to-region (point-min)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (progn (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (search-forward "\n\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (point)))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (setq news-reply-yank-from (mail-fetch-field "from"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (setq news-reply-yank-message-id (mail-fetch-field "message-id")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (pop-to-buffer gnus-post-news-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (news-reply-mode)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (gnus-overload-functions)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (if (and (buffer-modified-p)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (> (buffer-size) 0)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (not (y-or-n-p "Unsent article being composed; erase it? ")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 ;; Continue composition.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 ;; Make news-reply-yank-original work on the current article.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (setq mail-reply-buffer artbuf)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (erase-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (if gnus-interactive-post
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 ;; Newsgroups, subject and distribution are asked for.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 ;; Suggested by yuki@flab.fujitsu.junet.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 ;; Subscribed newsgroup names are required for
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 ;; completing read of newsgroup.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 (or gnus-newsrc-assoc
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (gnus-read-newsrc-file))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 ;; Which do you like? (UMERIN)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 ;; (setq newsgroups (read-string "Newsgroups: " "general"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (or newsgroups ;Use the default newsgroup.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (setq newsgroups
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (completing-read "Newsgroup: " gnus-newsrc-assoc
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 nil 'require-match
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 newsgroups ;Default newsgroup.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 )))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (setq subject (read-string "Subject: "))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 (setq distribution
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (substring newsgroups 0 (string-match "\\." newsgroups)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (if (string-equal distribution newsgroups)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 ;; Newsgroup may be general or control. In this
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 ;; case, use default distribution.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (setq distribution gnus-default-distribution))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (setq distribution
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (read-string "Distribution: " distribution))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 ;; An empty string is ok to ignore gnus-default-distribution.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 ;;(if (string-equal distribution "")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 ;; (setq distribution nil))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 (news-setup () subject () newsgroups artbuf)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 ;; Make sure the article is posted by GNUS.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 ;;(mail-position-on-field "Posting-Software")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 ;;(insert "GNUS: NNTP-based News Reader for GNU Emacs")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 ;; Insert Distribution: field.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 ;; Suggested by ichikawa@flab.fujitsu.junet.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (mail-position-on-field "Distribution")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (insert (or distribution gnus-default-distribution ""))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 ;; Handle author copy using FCC field.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (if gnus-author-copy
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 (mail-position-on-field "FCC")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (insert gnus-author-copy)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (if gnus-interactive-post
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 ;; All fields are filled in.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (goto-char (point-max))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 ;; Move point to Newsgroup: field.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (end-of-line))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (message "")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (defun gnus-news-reply (&optional yank)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 "Compose and post a reply (aka a followup) to the current article on USENET.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 While composing the followup, use \\[news-reply-yank-original] to yank the
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 original message into it."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (if (or (not gnus-novice-user)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (y-or-n-p "Are you sure you want to followup to all of USENET? "))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 (let (from cc subject date to followup-to newsgroups message-of
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 references distribution message-id
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (artbuf (current-buffer)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (save-restriction
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (and (not (zerop (buffer-size)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 ;;(equal major-mode 'news-mode)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (equal major-mode 'gnus-Article-mode)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 ;; (news-show-all-headers)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (gnus-Article-show-all-headers)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (narrow-to-region (point-min)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (progn (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (search-forward "\n\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (point)))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (setq from (mail-fetch-field "from"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (setq news-reply-yank-from from)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (setq subject (mail-fetch-field "subject"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (setq date (mail-fetch-field "date"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (setq followup-to (mail-fetch-field "followup-to"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 ;; Ignore Followup-To: poster.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (if (or (null gnus-use-followup-to) ;Ignore followup-to: field.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (string-equal "" followup-to) ;Bogus header.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (string-equal "poster" followup-to))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (setq followup-to nil))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (setq newsgroups (or followup-to (mail-fetch-field "newsgroups")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (setq references (mail-fetch-field "references"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (setq distribution (mail-fetch-field "distribution"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (setq message-id (mail-fetch-field "message-id"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (setq news-reply-yank-message-id message-id))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (pop-to-buffer gnus-post-news-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (news-reply-mode)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 (gnus-overload-functions)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 (if (and (buffer-modified-p)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (> (buffer-size) 0)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (not (y-or-n-p "Unsent article being composed; erase it? ")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 ;; Continue composition.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 ;; Make news-reply-yank-original work on current article.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (setq mail-reply-buffer artbuf)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (erase-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (and subject
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (setq subject
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (concat "Re: " (gnus-simplify-subject subject 're-only))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (and from
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (let ((stop-pos
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (string-match " *at \\| *@ \\| *(\\| *<" from)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (setq message-of
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (concat
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 (if stop-pos (substring from 0 stop-pos) from)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 "'s message of "
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 date)))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (news-setup nil subject message-of newsgroups artbuf)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (if followup-to
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (progn (news-reply-followup-to)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (insert followup-to)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 ;; Fold long references line to follow RFC1036.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 (mail-position-on-field "References")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (let ((begin (point))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (fill-column 79)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (fill-prefix "\t"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (if references
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (insert references))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (if (and references message-id)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (insert " "))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (if message-id
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (insert message-id))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 ;; The region must end with a newline to fill the region
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 ;; without inserting extra newline.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (fill-region-as-paragraph begin (1+ (point))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 ;; Make sure the article is posted by GNUS.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 ;;(mail-position-on-field "Posting-Software")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 ;;(insert "GNUS: NNTP-based News Reader for GNU Emacs")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 ;; Distribution must be the same as original article.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (mail-position-on-field "Distribution")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (insert (or distribution ""))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 ;; Handle author copy using FCC field.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (if gnus-author-copy
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (mail-position-on-field "FCC")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (insert gnus-author-copy)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (goto-char (point-max)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 ;; Yank original article automatically.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (if yank
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 (let ((last (point)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (goto-char (point-max))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (news-reply-yank-original nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 (goto-char last)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 )
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (message "")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 (defun gnus-inews-news ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 "Send a news message."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (let* ((case-fold-search nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 (server-running (gnus-server-opened)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 ;; It is possible to post a news without reading news using
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 ;; `gnus' before.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 ;; Suggested by yuki@flab.fujitsu.junet.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (gnus-start-news-server) ;Use default server.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 ;; NNTP server must be opened before current buffer is modified.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (widen)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 (run-hooks 'news-inews-hook)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (search-forward (concat "\n" mail-header-separator "\n"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (replace-match "\n\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (goto-char (point-max))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 ;; require a newline at the end for inews to append .signature to
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (or (= (preceding-char) ?\n)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (insert ?\n))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (message "Posting to USENET...")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 ;; Post to NNTP server.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (if (gnus-inews-article)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (message "Posting to USENET... done")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 ;; We cannot signal an error.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (ding) (message "Article rejected: %s" (gnus-status-message)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (goto-char (point-min)) ;restore internal header separator
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 (search-forward "\n\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (replace-match (concat "\n" mail-header-separator "\n"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (set-buffer-modified-p nil))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (or server-running
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (gnus-close-server))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (and (fboundp 'bury-buffer) (bury-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 ;; Restore last window configuration.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (and gnus-winconf-post-news
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (set-window-configuration gnus-winconf-post-news))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (setq gnus-winconf-post-news nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (defun gnus-cancel-news ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 "Cancel an article you posted."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 (interactive)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (if (yes-or-no-p "Do you really want to cancel this article? ")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (let ((from nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (newsgroups nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (message-id nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (distribution nil))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 ;; Get header info. from original article.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 (save-restriction
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 (gnus-Article-show-all-headers)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 (search-forward "\n\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 (narrow-to-region (point-min) (point))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (setq from (mail-fetch-field "from"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 (setq newsgroups (mail-fetch-field "newsgroups"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 (setq message-id (mail-fetch-field "message-id"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 (setq distribution (mail-fetch-field "distribution")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 ;; Verify if the article is absolutely user's by comparing
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 ;; user id with value of its From: field.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 (if (not
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 (string-equal
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 (downcase (mail-strip-quoted-names from))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 (ding) (message "This article is not yours"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 ;; Make control article.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (set-buffer (get-buffer-create " *GNUS-posting*"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (buffer-flush-undo (current-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (erase-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (insert "Newsgroups: " newsgroups "\n"
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 "Subject: cancel " message-id "\n"
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 "Control: cancel " message-id "\n"
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 ;; We should not use the value of
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 ;; `gnus-default-distribution' as default value,
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 ;; because distribution must be as same as original
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 ;; article.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 "Distribution: " (or distribution "") "\n"
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 )
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 ;; Prepare article headers.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (gnus-inews-insert-headers)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (goto-char (point-max))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 ;; Insert empty line.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (insert "\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 ;; Send the control article to NNTP server.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 (message "Canceling your article...")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 (if (gnus-request-post)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 (message "Canceling your article... done")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 (ding) (message "Failed to cancel your article"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (kill-buffer (current-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 )))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 ;;; Lowlevel inews interface
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (defun gnus-inews-article ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 "NNTP inews interface."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (let ((signature
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (if gnus-signature-file
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 (expand-file-name gnus-signature-file nil)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (distribution nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (artbuf (current-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 (tmpbuf (get-buffer-create " *GNUS-posting*")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (set-buffer tmpbuf)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (buffer-flush-undo (current-buffer))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (erase-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (insert-buffer-substring artbuf)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 ;; Get distribution.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (save-restriction
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (search-forward "\n\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (narrow-to-region (point-min) (point))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (setq distribution (mail-fetch-field "distribution")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 (widen)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 (if signature
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 ;; Change signature file by distribution.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 ;; Suggested by hyoko@flab.fujitsu.junet.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (if (file-exists-p (concat signature "-" distribution))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (setq signature (concat signature "-" distribution)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 ;; Insert signature.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (if (file-exists-p signature)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (goto-char (point-max))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (insert "--\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (insert-file-contents signature)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 ;; Prepare article headers.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436 (save-restriction
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 (search-forward "\n\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (narrow-to-region (point-min) (point))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (gnus-inews-insert-headers)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 ;; Save author copy of posted article. The article must be
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 ;; copied before being posted because `gnus-request-post'
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 ;; modifies the buffer.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (let ((case-fold-search t))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 ;; Find and handle any FCC fields.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 (if (re-search-forward "^FCC:" nil t)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (gnus-inews-do-fcc))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (widen)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 ;; Run final inews hooks.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (run-hooks 'gnus-Inews-article-hook)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 ;; Post an article to NNTP server.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 ;; Return NIL if post failed.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 (prog1
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (gnus-request-post)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (kill-buffer (current-buffer)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 )))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (defun gnus-inews-do-fcc ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 "Process FCC: fields."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (let ((fcc-list nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 (fcc-file nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (case-fold-search t)) ;Should ignore case.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 (save-restriction
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (while (re-search-forward "^FCC:[ \t]*" nil t)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (setq fcc-list (cons (buffer-substring (point)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (progn
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 (end-of-line)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (skip-chars-backward " \t")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 (point)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 fcc-list))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 (delete-region (match-beginning 0)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (progn (forward-line 1) (point))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 ;; Process FCC operations.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 (widen)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 (while fcc-list
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
479 (setq fcc-file (car fcc-list))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 (setq fcc-list (cdr fcc-list))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 (let ((program (substring fcc-file
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483 (match-beginning 1) (match-end 1))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 ;; Suggested by yuki@flab.fujitsu.junet.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 ;; Send article to named program.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 (call-process-region (point-min) (point-max) shell-file-name
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 nil nil nil "-c" program)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489 (t
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 ;; Suggested by hyoko@flab.fujitsu.junet.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 ;; Save article in Unix mail format by default.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 (funcall (or gnus-author-copy-saver 'rmail-output) fcc-file)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 )
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 (defun gnus-inews-insert-headers ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 "Prepare article headers.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500 Path:, From:, Subject: and Distribution: are generated.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 Message-ID:, Date: and Organization: are optional."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 (let ((date (gnus-inews-date))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 (message-id (gnus-inews-message-id))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (organization (gnus-inews-organization)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 ;; Insert from the top of headers.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (goto-char (point-min))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 (insert "Path: " (gnus-inews-path) "\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (insert "From: " (gnus-inews-user-name) "\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 ;; If there is no subject, make Subject: field.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (or (mail-fetch-field "subject")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 (insert "Subject: \n"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 ;; Insert random headers.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514 (if message-id
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (insert "Message-ID: " message-id "\n"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 (if date
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (insert "Date: " date "\n"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518 (if organization
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 (let ((begin (point))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 (fill-column 79)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 (fill-prefix "\t"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (insert "Organization: " organization "\n")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 (fill-region-as-paragraph begin (point))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (or (mail-fetch-field "distribution")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (insert "Distribution: \n"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 )))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 (defun gnus-inews-path ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 "Return uucp path."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 (let ((login-name (gnus-inews-login-name)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 (cond ((null gnus-use-generic-path)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (concat gnus-nntp-server "!" login-name))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 ((stringp gnus-use-generic-path)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 (concat gnus-use-generic-path "!" login-name))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 (t login-name))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 (defun gnus-inews-user-name ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 "Return user's network address as `NAME@DOMAIN (FULL NAME)'."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 (let ((login-name (gnus-inews-login-name))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 (full-name (gnus-inews-full-name)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 (concat login-name "@" (gnus-inews-domain-name gnus-use-generic-from)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 ;; User's full name.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 (cond ((string-equal full-name "") "")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 ((string-equal full-name "&") ;Unix hack.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 (concat " (" login-name ")"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (t
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (concat " (" full-name ")")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 )))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552 (defun gnus-inews-login-name ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 "Return user login name.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 Got from the variable `gnus-user-login-name', the environment variables
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
555 USER and LOGNAME, and the function `user-login-name'."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (or gnus-user-login-name
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (getenv "USER") (getenv "LOGNAME") (user-login-name)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (defun gnus-inews-full-name ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560 "Return user full name.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 Got from the variable `gnus-user-full-name', the environment variable
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 NAME, and the function `user-full-name'."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 (or gnus-user-full-name
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 (getenv "NAME") (user-full-name)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566 (defun gnus-inews-domain-name (&optional genericfrom)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 "Return user's domain name.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 If optional argument GENERICFROM is a string, use it as the domain
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 name; if it is non-nil, strip of local host name from the domain name.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 If the function `system-name' returns full internet name and the
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 domain is undefined, the domain name is got from it."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 (let ((domain (or (if (stringp genericfrom) genericfrom)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (getenv "DOMAINNAME")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 gnus-your-domain
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575 ;; Function `system-name' may return full internet name.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 (if (string-match "\\." (system-name))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 (substring (system-name) (match-end 0)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 (read-string "Domain name (no host): ")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 (host (or (if (string-match "\\." (system-name))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 (substring (system-name) 0 (match-beginning 0)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (system-name))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 (if (string-equal "." (substring domain 0 1))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 (setq domain (substring domain 1)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (if (null gnus-your-domain)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 (setq gnus-your-domain domain))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587 ;; Support GENERICFROM as same as standard Bnews system.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 (cond ((null genericfrom)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 (concat host "." domain))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 ;;((stringp genericfrom) genericfrom)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 (t domain))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 (defun gnus-inews-message-id ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 "Generate unique Message-ID for user."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 ;; Message-ID should not contain a slash and should be terminated by
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 ;; a number. I don't know the reason why it is so.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-domain-name) ">"))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
601 (defun gnus-inews-unique-id ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 "Generate unique ID from user name and current time."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
603 (let ((date (current-time-string))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
604 (name (gnus-inews-login-name)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605 (if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) [0-9][0-9]\\([0-9][0-9]\\)"
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 date)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 (concat (upcase name) "."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608 (substring date (match-beginning 6) (match-end 6)) ;Year
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (substring date (match-beginning 1) (match-end 1)) ;Month
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 (substring date (match-beginning 2) (match-end 2)) ;Day
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 (substring date (match-beginning 3) (match-end 3)) ;Hour
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
612 (substring date (match-beginning 4) (match-end 4)) ;Minute
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 (substring date (match-beginning 5) (match-end 5)) ;Second
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 )
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 (error "Cannot understand current-time-string: %s." date))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 (defun gnus-inews-date ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 "Bnews date format string of today. Time zone is ignored."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 ;; Insert buggy date (time zone is ignored), but I don't worry about
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 ;; it since inews will rewrite it.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 (let ((date (current-time-string)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 (if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9:]+\\) [0-9][0-9]\\([0-9][0-9]\\)"
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
624 date)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625 (concat (substring date (match-beginning 2) (match-end 2)) ;Day
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 " "
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 (substring date (match-beginning 1) (match-end 1)) ;Month
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 " "
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (substring date (match-beginning 4) (match-end 4)) ;Year
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 " "
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631 (substring date (match-beginning 3) (match-end 3))) ;Time
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
632 (error "Cannot understand current-time-string: %s." date))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
634
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 (defun gnus-inews-organization ()
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636 "Return user's organization.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 The ORGANIZATION environment variable is used if defined.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 If not, the variable `gnus-your-organization' is used instead.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 If the value begins with a slash, it is taken as the name of a file
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 containing the organization."
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 ;; The organization must be got in this order since the ORGANIZATION
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 ;; environment variable is intended for user specific while
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 ;; gnus-your-organization is for machine or organization specific.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 (let ((organization (or (getenv "ORGANIZATION")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 gnus-your-organization
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646 (expand-file-name "~/.organization" nil))))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 (and (stringp organization)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 (string-equal (substring organization 0 1) "/")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
649 ;; Get it from the user and system file.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 ;; Suggested by roland@wheaties.ai.mit.edu (Roland McGrath).
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 (let ((dist (mail-fetch-field "distribution")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
652 (setq organization
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
653 (cond ((file-exists-p (concat organization "-" dist))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 (concat organization "-" dist))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 ((file-exists-p organization) organization)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
656 ((file-exists-p gnus-organization-file)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657 gnus-organization-file)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 (t organization)))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 ))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 (cond ((not (stringp organization)) nil)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 ((and (string-equal (substring organization 0 1) "/")
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662 (file-exists-p organization))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 ;; If the first character is `/', assume it is the name of
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 ;; a file containing the organization.
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 (save-excursion
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 (let ((tmpbuf (get-buffer-create " *GNUS organization*")))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 (set-buffer tmpbuf)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
668 (erase-buffer)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
669 (insert-file-contents organization)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
670 (prog1 (buffer-string)
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 (kill-buffer tmpbuf))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 )))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
673 (t organization))
d83efd759350 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 ))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 267
diff changeset
675
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 267
diff changeset
676 (provide 'gnuspost)
660
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
677
08eb386dd0f3 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
678 ;;; gnuspost.el ends here