Mercurial > emacs
annotate lisp/url/url-news.el @ 58698:10ecc7ffdc5a
2004-11-30 Mark A. Hershberger <mah@everybody.org>
* xml.el (xml-substitute-special): Fix validity error messages to
actually show the unexpandable entity. Added validity error if &
isn't followed by an entity.
(xml-parse-tag): Concatnate any string following the a
<![CDATA[]]> section to the parsed CDATA.
author | Mark A. Hershberger <mah@everybody.org> |
---|---|
date | Wed, 01 Dec 2004 04:45:08 +0000 |
parents | 60d07d8a52e1 |
children | 462374eda8a7 7a0245dd1848 |
rev | line source |
---|---|
54695 | 1 ;;; url-news.el --- News Uniform Resource Locator retrieval code |
57612 | 2 |
3 ;; Copyright (c) 1996 - 1999, 2004 Free Software Foundation, Inc. | |
4 | |
54695 | 5 ;; Keywords: comm, data, processes |
6 | |
57612 | 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 ;;; Code: | |
25 | |
54695 | 26 (require 'url-vars) |
27 (require 'url-util) | |
28 (require 'url-parse) | |
29 (require 'nntp) | |
30 (autoload 'url-warn "url") | |
31 (autoload 'gnus-group-read-ephemeral-group "gnus-group") | |
32 (eval-when-compile (require 'cl)) | |
33 | |
34 (defgroup url-news nil | |
35 "News related options" | |
36 :group 'url) | |
37 | |
38 (defun url-news-open-host (host port user pass) | |
39 (if (fboundp 'nnheader-init-server-buffer) | |
40 (nnheader-init-server-buffer)) | |
57886
60d07d8a52e1
* url-imap.el (url-imap-open-host): Don't use
Masatake YAMATO <jet@gyve.org>
parents:
57612
diff
changeset
|
41 (nntp-open-server host (list port)) |
54695 | 42 (if (and user pass) |
43 (progn | |
44 (nntp-send-command "^.*\r?\n" "AUTHINFO USER" user) | |
45 (nntp-send-command "^.*\r?\n" "AUTHINFO PASS" pass) | |
46 (if (not (nntp-server-opened host)) | |
47 (url-warn 'url (format "NNTP authentication to `%s' as `%s' failed" | |
48 host user)))))) | |
49 | |
50 (defun url-news-fetch-message-id (host message-id) | |
51 (let ((buf (generate-new-buffer " *url-news*"))) | |
52 (if (eq ?> (aref message-id (1- (length message-id)))) | |
53 nil | |
54 (setq message-id (concat "<" message-id ">"))) | |
55 (if (cdr-safe (nntp-request-article message-id nil host buf)) | |
56 ;; Successfully retrieved the article | |
57 nil | |
58 (save-excursion | |
59 (set-buffer buf) | |
60 (insert "Content-type: text/html\n\n" | |
61 "<html>\n" | |
62 " <head>\n" | |
63 " <title>Error</title>\n" | |
64 " </head>\n" | |
65 " <body>\n" | |
66 " <div>\n" | |
67 " <h1>Error requesting article...</h1>\n" | |
68 " <p>\n" | |
69 " The status message returned by the NNTP server was:" | |
70 "<br><hr>\n" | |
71 " <xmp>\n" | |
72 (nntp-status-message) | |
73 " </xmp>\n" | |
74 " </p>\n" | |
75 " <p>\n" | |
76 " 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
|
77 "mailto:" url-bug-address "\">send mail</a>\n" |
54695 | 78 " </p>\n" |
79 " </div>\n" | |
80 " </body>\n" | |
81 "</html>\n" | |
82 "<!-- Automatically generated by URL v" url-version " -->\n" | |
83 ))) | |
84 buf)) | |
85 | |
86 (defun url-news-fetch-newsgroup (newsgroup host) | |
87 (declare (special gnus-group-buffer)) | |
88 (if (string-match "^/+" newsgroup) | |
89 (setq newsgroup (substring newsgroup (match-end 0)))) | |
90 (if (string-match "/+$" newsgroup) | |
91 (setq newsgroup (substring newsgroup 0 (match-beginning 0)))) | |
92 | |
54801
8561817c6e37
Minor text changes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54770
diff
changeset
|
93 ;; This saves us from checking new news if Gnus is already running |
54695 | 94 ;; FIXME - is it relatively safe to use gnus-alive-p here? FIXME |
95 (if (or (not (get-buffer gnus-group-buffer)) | |
96 (save-excursion | |
97 (set-buffer gnus-group-buffer) | |
98 (not (eq major-mode 'gnus-group-mode)))) | |
99 (gnus)) | |
100 (set-buffer gnus-group-buffer) | |
101 (goto-char (point-min)) | |
102 (gnus-group-read-ephemeral-group newsgroup | |
103 (list 'nntp host | |
104 'nntp-open-connection-function | |
105 nntp-open-connection-function) | |
106 nil | |
107 (cons (current-buffer) 'browse))) | |
108 | |
109 ;;;###autoload | |
110 (defun url-news (url) | |
111 ;; Find a news reference | |
112 (let* ((host (or (url-host url) url-news-server)) | |
113 (port (url-port url)) | |
114 (article-brackets nil) | |
115 (buf nil) | |
116 (article (url-filename url))) | |
117 (url-news-open-host host port (url-user url) (url-password url)) | |
118 (setq article (url-unhex-string article)) | |
119 (cond | |
120 ((string-match "@" article) ; Its a specific article | |
121 (setq buf (url-news-fetch-message-id host article))) | |
122 ((string= article "") ; List all newsgroups | |
123 (gnus)) | |
124 (t ; Whole newsgroup | |
125 (url-news-fetch-newsgroup article host))) | |
126 buf)) | |
127 | |
128 ;;;###autoload | |
129 (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
|
130 (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
|
131 nntp-open-tls-stream |
202c408c174b
url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents:
57427
diff
changeset
|
132 nntp-open-ssl-stream))) |
54695 | 133 (url-news url))) |
134 | |
135 (provide 'url-news) | |
54699 | 136 |
137 ;;; arch-tag: 8975be13-04e8-4d38-bfff-47918e3ad311 | |
57612 | 138 ;;; url-news.el ends here |