Mercurial > emacs
annotate lisp/url/url-news.el @ 83219:e86fc76a45e4
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-611
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-612
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-613
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-614
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-615
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-46
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-47
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-48
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-49
Add {arch}/=commit-merge-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-50
{arch}/=commit-merge-make-log: Don't die if there are no ChangeLog changes
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-259
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Thu, 14 Oct 2004 14:42:03 +0000 |
parents | 47f53c5c9620 202c408c174b |
children | ae7fab96922c |
rev | line source |
---|---|
54695 | 1 ;;; url-news.el --- News Uniform Resource Locator retrieval code |
2 ;; Keywords: comm, data, processes | |
3 | |
4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
57449
202c408c174b
url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents:
57427
diff
changeset
|
5 ;;; Copyright (c) 1996 - 1999, 2004 Free Software Foundation, Inc. |
54695 | 6 ;;; |
7 ;;; This file is part of GNU Emacs. | |
8 ;;; | |
9 ;;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;;; it under the terms of the GNU General Public License as published by | |
11 ;;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;;; any later version. | |
13 ;;; | |
14 ;;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;;; GNU General Public License for more details. | |
18 ;;; | |
19 ;;; You should have received a copy of the GNU General Public License | |
20 ;;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;;; Boston, MA 02111-1307, USA. | |
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
24 (require 'url-vars) | |
25 (require 'url-util) | |
26 (require 'url-parse) | |
27 (require 'nntp) | |
28 (autoload 'url-warn "url") | |
29 (autoload 'gnus-group-read-ephemeral-group "gnus-group") | |
30 (eval-when-compile (require 'cl)) | |
31 | |
32 (defgroup url-news nil | |
33 "News related options" | |
34 :group 'url) | |
35 | |
36 (defun url-news-open-host (host port user pass) | |
37 (if (fboundp 'nnheader-init-server-buffer) | |
38 (nnheader-init-server-buffer)) | |
39 (nntp-open-server host (list (string-to-int port))) | |
40 (if (and user pass) | |
41 (progn | |
42 (nntp-send-command "^.*\r?\n" "AUTHINFO USER" user) | |
43 (nntp-send-command "^.*\r?\n" "AUTHINFO PASS" pass) | |
44 (if (not (nntp-server-opened host)) | |
45 (url-warn 'url (format "NNTP authentication to `%s' as `%s' failed" | |
46 host user)))))) | |
47 | |
48 (defun url-news-fetch-message-id (host message-id) | |
49 (let ((buf (generate-new-buffer " *url-news*"))) | |
50 (if (eq ?> (aref message-id (1- (length message-id)))) | |
51 nil | |
52 (setq message-id (concat "<" message-id ">"))) | |
53 (if (cdr-safe (nntp-request-article message-id nil host buf)) | |
54 ;; Successfully retrieved the article | |
55 nil | |
56 (save-excursion | |
57 (set-buffer buf) | |
58 (insert "Content-type: text/html\n\n" | |
59 "<html>\n" | |
60 " <head>\n" | |
61 " <title>Error</title>\n" | |
62 " </head>\n" | |
63 " <body>\n" | |
64 " <div>\n" | |
65 " <h1>Error requesting article...</h1>\n" | |
66 " <p>\n" | |
67 " The status message returned by the NNTP server was:" | |
68 "<br><hr>\n" | |
69 " <xmp>\n" | |
70 (nntp-status-message) | |
71 " </xmp>\n" | |
72 " </p>\n" | |
73 " <p>\n" | |
74 " If you If you feel this is an error, <a href=\"" | |
54801
8561817c6e37
Minor text changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
75 "mailto:" url-bug-address "\">send mail</a>\n" |
54695 | 76 " </p>\n" |
77 " </div>\n" | |
78 " </body>\n" | |
79 "</html>\n" | |
80 "<!-- Automatically generated by URL v" url-version " -->\n" | |
81 ))) | |
82 buf)) | |
83 | |
84 (defun url-news-fetch-newsgroup (newsgroup host) | |
85 (declare (special gnus-group-buffer)) | |
86 (if (string-match "^/+" newsgroup) | |
87 (setq newsgroup (substring newsgroup (match-end 0)))) | |
88 (if (string-match "/+$" newsgroup) | |
89 (setq newsgroup (substring newsgroup 0 (match-beginning 0)))) | |
90 | |
54801
8561817c6e37
Minor text changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
91 ;; This saves us from checking new news if Gnus is already running |
54695 | 92 ;; FIXME - is it relatively safe to use gnus-alive-p here? FIXME |
93 (if (or (not (get-buffer gnus-group-buffer)) | |
94 (save-excursion | |
95 (set-buffer gnus-group-buffer) | |
96 (not (eq major-mode 'gnus-group-mode)))) | |
97 (gnus)) | |
98 (set-buffer gnus-group-buffer) | |
99 (goto-char (point-min)) | |
100 (gnus-group-read-ephemeral-group newsgroup | |
101 (list 'nntp host | |
102 'nntp-open-connection-function | |
103 nntp-open-connection-function) | |
104 nil | |
105 (cons (current-buffer) 'browse))) | |
106 | |
107 ;;;###autoload | |
108 (defun url-news (url) | |
109 ;; Find a news reference | |
110 (let* ((host (or (url-host url) url-news-server)) | |
111 (port (url-port url)) | |
112 (article-brackets nil) | |
113 (buf nil) | |
114 (article (url-filename url))) | |
115 (url-news-open-host host port (url-user url) (url-password url)) | |
116 (setq article (url-unhex-string article)) | |
117 (cond | |
118 ((string-match "@" article) ; Its a specific article | |
119 (setq buf (url-news-fetch-message-id host article))) | |
120 ((string= article "") ; List all newsgroups | |
121 (gnus)) | |
122 (t ; Whole newsgroup | |
123 (url-news-fetch-newsgroup article host))) | |
124 buf)) | |
125 | |
126 ;;;###autoload | |
127 (defun url-snews (url) | |
57449
202c408c174b
url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents:
57427
diff
changeset
|
128 (let ((nntp-open-connection-function (if (eq 'tls url-gateway-method) |
202c408c174b
url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents:
57427
diff
changeset
|
129 nntp-open-tls-stream |
202c408c174b
url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents:
57427
diff
changeset
|
130 nntp-open-ssl-stream))) |
54695 | 131 (url-news url))) |
132 | |
133 (provide 'url-news) | |
54699 | 134 |
135 ;;; arch-tag: 8975be13-04e8-4d38-bfff-47918e3ad311 |