Mercurial > emacs
annotate lisp/url/url-news.el @ 91585:4fe734146ac9
revert the `vc-status' keybindings
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Wed, 06 Feb 2008 19:06:34 +0000 |
parents | 107ccd98fa12 |
children | 8259d0d8e107 |
rev | line source |
---|---|
54695 | 1 ;;; url-news.el --- News Uniform Resource Locator retrieval code |
57612 | 2 |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2004, |
79720 | 4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
57612 | 5 |
54695 | 6 ;; Keywords: comm, data, processes |
7 | |
57612 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
78222
8932997d0b62
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
12 ;; the Free Software Foundation; either version 3, or (at your option) |
57612 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64084 | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 ;; Boston, MA 02110-1301, USA. | |
57612 | 24 |
25 ;;; Code: | |
26 | |
54695 | 27 (require 'url-vars) |
28 (require 'url-util) | |
29 (require 'url-parse) | |
30 (require 'nntp) | |
31 (autoload 'url-warn "url") | |
32 (autoload 'gnus-group-read-ephemeral-group "gnus-group") | |
33 | |
34 (defgroup url-news nil | |
63992
462374eda8a7
(url-news): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
57886
diff
changeset
|
35 "News related options." |
54695 | 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 | |
68247
b96fcf6e016c
Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65098
diff
changeset
|
58 (with-current-buffer buf |
54695 | 59 (insert "Content-type: text/html\n\n" |
60 "<html>\n" | |
61 " <head>\n" | |
62 " <title>Error</title>\n" | |
63 " </head>\n" | |
64 " <body>\n" | |
65 " <div>\n" | |
66 " <h1>Error requesting article...</h1>\n" | |
67 " <p>\n" | |
68 " The status message returned by the NNTP server was:" | |
69 "<br><hr>\n" | |
70 " <xmp>\n" | |
71 (nntp-status-message) | |
72 " </xmp>\n" | |
73 " </p>\n" | |
74 " <p>\n" | |
75 " 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
|
76 "mailto:" url-bug-address "\">send mail</a>\n" |
54695 | 77 " </p>\n" |
78 " </div>\n" | |
79 " </body>\n" | |
80 "</html>\n" | |
81 "<!-- Automatically generated by URL v" url-version " -->\n" | |
82 ))) | |
83 buf)) | |
84 | |
86935
e31c1cf9dca9
(top-level): Don't require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
78856
diff
changeset
|
85 (defvar gnus-group-buffer) |
e31c1cf9dca9
(top-level): Don't require cl when compiling.
Glenn Morris <rgm@gnu.org>
parents:
78856
diff
changeset
|
86 |
54695 | 87 (defun url-news-fetch-newsgroup (newsgroup host) |
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)) | |
68247
b96fcf6e016c
Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65098
diff
changeset
|
96 (with-current-buffer gnus-group-buffer |
54695 | 97 (not (eq major-mode 'gnus-group-mode)))) |
98 (gnus)) | |
99 (set-buffer gnus-group-buffer) | |
100 (goto-char (point-min)) | |
101 (gnus-group-read-ephemeral-group newsgroup | |
102 (list 'nntp host | |
78856
1fbf6e886ce2
Diane Murray <disumu at x3y2z1.net>
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
103 (list 'nntp-open-connection-function |
1fbf6e886ce2
Diane Murray <disumu at x3y2z1.net>
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
104 nntp-open-connection-function)) |
54695 | 105 nil |
106 (cons (current-buffer) 'browse))) | |
63992
462374eda8a7
(url-news): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
57886
diff
changeset
|
107 |
54695 | 108 ;;;###autoload |
109 (defun url-news (url) | |
110 ;; Find a news reference | |
111 (let* ((host (or (url-host url) url-news-server)) | |
112 (port (url-port url)) | |
113 (article-brackets nil) | |
114 (buf nil) | |
68247
b96fcf6e016c
Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65098
diff
changeset
|
115 (article (url-unhex-string (url-filename url)))) |
54695 | 116 (url-news-open-host host port (url-user url) (url-password url)) |
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) | |
79525
877fc182a600
(nntp-open-tls-stream, nntp-open-ssl-stream):
Glenn Morris <rgm@gnu.org>
parents:
78856
diff
changeset
|
128 (let ((nntp-open-connection-function (if (eq 'ssl url-gateway-method) |
877fc182a600
(nntp-open-tls-stream, nntp-open-ssl-stream):
Glenn Morris <rgm@gnu.org>
parents:
78856
diff
changeset
|
129 'nntp-open-ssl-stream |
877fc182a600
(nntp-open-tls-stream, nntp-open-ssl-stream):
Glenn Morris <rgm@gnu.org>
parents:
78856
diff
changeset
|
130 'nntp-open-tls-stream))) |
54695 | 131 (url-news url))) |
132 | |
133 (provide 'url-news) | |
54699 | 134 |
68247
b96fcf6e016c
Move defvars out of eval-when-compile.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
65098
diff
changeset
|
135 ;; arch-tag: 8975be13-04e8-4d38-bfff-47918e3ad311 |
57612 | 136 ;;; url-news.el ends here |