annotate lisp/=gnuspost.el @ 776:a1d724d96f6b

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