[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/gnus/gnus-group.el,v
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/gnus/gnus-group.el,v |
Date: |
Thu, 10 Jan 2008 14:18:25 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Miles Bader <miles> 08/01/10 14:18:24
Index: lisp/gnus/gnus-group.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/gnus/gnus-group.el,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- lisp/gnus/gnus-group.el 8 Jan 2008 14:16:13 -0000 1.67
+++ lisp/gnus/gnus-group.el 10 Jan 2008 14:18:23 -0000 1.68
@@ -2320,44 +2320,94 @@
(message "Quit reading the ephemeral group")
nil)))))
-(defvar gnus-group-gmane-group-download-format
- "http://download.gmane.org/%s/%s/%s")
-(autoload 'url-insert-file-contents "url-handlers")
+(defcustom gnus-group-gmane-group-download-format
+ "http://download.gmane.org/%s/%s/%s"
+ "URL for downloading mbox files.
+It must contain three \"%s\". They correspond to the group, the
+minimal and maximal article numbers, respectively."
+ :group 'gnus-group-foreign
+ :version "23.0" ;; No Gnus
+ :type 'string)
-;; FIXME: Make gnus-group-gmane-group-download-format customizable. Add
-;; documentation, menu, key bindings...
+(autoload 'url-insert-file-contents "url-handlers")
+;; FIXME:
+;; - Add documentation, menu, key bindings, ...
-(defun gnus-group-read-ephemeral-gmane-group (group start end)
+(defun gnus-group-read-ephemeral-gmane-group (group start &optional range)
"Read articles from Gmane group GROUP as an ephemeral group.
-START and END specify the articles range. The articles are
-downloaded via HTTP using the URL specified by
-`gnus-group-gmane-group-download-format'."
+START is the first article. RANGE specifies how many articles
+are fetched. The articles are downloaded via HTTP using the URL
+specified by `gnus-group-gmane-group-download-format'."
;; See <http://gmane.org/export.php> for more information.
(interactive
(list
(gnus-group-completing-read "Gmane group: ")
(read-number "Start article number: ")
- (read-number "End article number: ")))
- (when (< (- end start) 0)
- (error "Invalid range."))
- (when (> (- end start)
- (min (or gnus-large-ephemeral-newsgroup 100) 100))
- (unless (y-or-n-p
- (format "Large range (%s to %s), continue anyway? "
- start end))
- (error "Range too large. Aborted.")))
- (let ((tmpfile (make-temp-file "gmane.gnus-temp-group-")))
+ (read-number "How many articles: ")))
+ (unless range (setq range 500))
+ (when (< range 1)
+ (error "Invalid range: %s" range))
+ (let ((tmpfile (make-temp-file
+ (format "%s.start-%s.range-%s." group start range)))
+ (gnus-thread-sort-functions '(gnus-thread-sort-by-number)))
(with-temp-file tmpfile
(url-insert-file-contents
(format gnus-group-gmane-group-download-format
- group start end))
+ group start (+ start range)))
(write-region (point-min) (point-max) tmpfile)
(gnus-group-read-ephemeral-group
- "rs-gnus-read-gmane"
+ (format "%s.start-%s.range-%s" group start range)
`(nndoc ,tmpfile
(nndoc-article-type guess))))
(delete-file tmpfile)))
+(defun gnus-group-read-ephemeral-gmane-group-url (url)
+ "Create an ephemeral Gmane group from URL.
+
+Valid input formats include:
+\"http://thread.gmane.org/gmane.foo.bar/12300/focus=12399\",
+\"http://thread.gmane.org/gmane.foo.bar/12345/\",
+\"http://article.gmane.org/gmane.foo.bar/12345/\",
+\"http://news.gmane.org/group/gmane.foo.bar/thread=12345\""
+ ;; - Feel free to add other useful Gmane URLs here! Maybe the URLs should
+ ;; be customizable?
+ ;; - The URLs should be added to `gnus-button-alist'. Probably we should
+ ;; prompt the user to decide: "View via `browse-url' or in Gnus? "
+ ;; (`gnus-group-read-ephemeral-gmane-group-url')
+ (interactive
+ (list (gnus-group-completing-read "Gmane URL: ")))
+ (let (group start range)
+ (cond
+ ;; URLs providing `group', `start' and `range':
+ ((string-match
+ ;; http://thread.gmane.org/gmane.emacs.devel/86326/focus=86525
+
"^http://thread\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)/focus=\\([0-9]+\\)$"
+ url)
+ (setq group (match-string 1 url)
+ start (string-to-number (match-string 2 url))
+ ;; Ensure that `range' is large enough to ensure focus article is
+ ;; included.
+ range (- (string-to-number (match-string 3 url))
+ start -1)))
+ ;; URLs providing `group' and `start':
+ ((or (string-match
+ ;; http://article.gmane.org/gmane.comp.gnu.make.bugs/3584
+
"^http://\\(?:thread\\|article\\)\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
+ url)
+ (string-match
+ ;; Don't advertize these in the doc string yet:
+ "^\\(?:nntp\\|news\\)://news\.gmane\.org/\\([^/]+\\)/\\([0-9]+\\)"
+ url)
+ (string-match
+ ;;
http://news.gmane.org/group/gmane.emacs.gnus.general/thread=65099/force_load=t
+ "^http://news\.gmane\.org/group/\\([^/]+\\)/thread=\\([0-9]+\\)"
+ url))
+ (setq group (match-string 1 url)
+ start (string-to-number (match-string 2 url))))
+ (t
+ (error "Can't parse URL %s" url)))
+ (gnus-group-read-ephemeral-gmane-group group start range)))
+
(defun gnus-group-jump-to-group (group &optional prompt)
"Jump to newsgroup GROUP.