annotate lisp/emacs-lisp/package-x.el @ 110709:f07cd17d0a5a

* keyboard.c (command_loop_1): Make sure the mark is really alive before using it (Bug#7044).
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 02 Oct 2010 20:59:02 -0400
parents 280c8ae2476d
children 6378d1b57038
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; package-x.el --- Package extras
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Tom Tromey <tromey@redhat.com>
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Created: 10 Mar 2007
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Version: 0.9
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; Keywords: tools
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109731
diff changeset
9 ;; Package: package
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 3, or (at your option)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; any later version.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Boston, MA 02110-1301, USA.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;; Commentary:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; This file currently contains parts of the package system most
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; people won't need, such as package uploading.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;; Code:
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34
109026
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109016
diff changeset
35 (require 'package)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109016
diff changeset
36 (defvar gnus-article-buffer)
c138aa96dae8 Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents: 109016
diff changeset
37
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;; Note that this only works if you have the password, which you
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; probably don't :-).
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (defvar package-archive-upload-base nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 "Base location for uploading to package archive.")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (defun package--encode (string)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 "Encode a string by replacing some characters with XML entities."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; We need a special case for translating "&" to "&amp;".
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 (let ((index))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (while (setq index (string-match "[&]" string index))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (setq string (replace-match "&amp;" t nil string))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (setq index (1+ index))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (while (string-match "[<]" string)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 (setq string (replace-match "&lt;" t nil string)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (while (string-match "[>]" string)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 (setq string (replace-match "&gt;" t nil string)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 (while (string-match "[']" string)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (setq string (replace-match "&apos;" t nil string)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 (while (string-match "[\"]" string)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (setq string (replace-match "&quot;" t nil string)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 string)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
60 (defun package--make-rss-entry (title text archive-url)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (let ((date-string (format-time-string "%a, %d %B %Y %T %z")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (concat "<item>\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 "<title>" (package--encode title) "</title>\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;; FIXME: should have a link in the web page.
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
65 "<link>" archive-url "news.html</link>\n"
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 "<description>" (package--encode text) "</description>\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 "<pubDate>" date-string "</pubDate>\n"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 "</item>\n")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 (defun package--make-html-entry (title text)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (concat "<li> " (format-time-string "%B %e") " - "
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 title " - " (package--encode text)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 " </li>\n"))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 (defun package--update-file (file location text)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 (let ((old-buffer (find-buffer-visiting file)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 (with-current-buffer (let ((find-file-visit-truename t))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (or old-buffer (find-file-noselect file)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 (goto-char (point-min))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (search-forward location)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (forward-line)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 (insert text)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (let ((file-precious-flag t))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (save-buffer))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 (unless old-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (kill-buffer (current-buffer)))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
89 (defun package-maint-add-news-item (title description archive-url)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 "Add a news item to the ELPA web pages.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 TITLE is the title of the news item.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 DESCRIPTION is the text of the news item.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 You need administrative access to ELPA to use this."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 (interactive "sTitle: \nsText: ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 (package--update-file (concat package-archive-upload-base "elpa.rss")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 "<description>"
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
97 (package--make-rss-entry title description archive-url))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (package--update-file (concat package-archive-upload-base "news.html")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 "New entries go here"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (package--make-html-entry title description)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
102 (defun package--update-news (package version description archive-url)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 "Update the ELPA web pages when a package is uploaded."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 (package-maint-add-news-item (concat package " version " version)
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
105 description
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
106 archive-url))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
108 (defun package-upload-buffer-internal (pkg-info extension &optional archive-url)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 "Upload a package whose contents are in the current buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 PKG-INFO is the package info, see `package-buffer-info'.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 EXTENSION is the file extension, a string. It can be either
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
112 \"el\" or \"tar\".
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
113
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
114 Optional arg ARCHIVE-URL is the URL of the destination archive.
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
115 If nil, the \"gnu\" archive is used."
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
116 (unless archive-url
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
117 (or (setq archive-url (cdr (assoc "gnu" package-archives)))
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
118 (error "No destination URL")))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (save-restriction
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (let* ((file-type (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 ((equal extension "el") 'single)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 ((equal extension "tar") 'tar)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (t (error "Unknown extension `%s'" extension))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (file-name (aref pkg-info 0))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (pkg-name (intern file-name))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (requires (aref pkg-info 1))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (desc (if (string= (aref pkg-info 2) "")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (read-string "Description of package: ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (aref pkg-info 2)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 (pkg-version (aref pkg-info 3))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (commentary (aref pkg-info 4))
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
133 (split-version (version-to-list pkg-version))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (pkg-buffer (current-buffer))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 ;; Download latest archive-contents.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (buffer (url-retrieve-synchronously
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
138 (concat archive-url "archive-contents"))))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 ;; Parse archive-contents.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (set-buffer buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 (package-handle-response)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (re-search-forward "^$" nil 'move)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (forward-char)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 (delete-region (point-min) (point))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (let ((contents (package-read-from-string
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 (buffer-substring-no-properties (point-min)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (point-max))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (new-desc (vector split-version requires desc file-type)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (if (> (car contents) package-archive-version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 (error "Unrecognized archive version %d" (car contents)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 (let ((elt (assq pkg-name (cdr contents))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (if elt
109731
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
154 (if (version-list-<= split-version
01af31a38d9e Use version-list-* functions in package.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 109580
diff changeset
155 (package-desc-vers (cdr elt)))
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (error "New package has smaller version: %s" pkg-version)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 (setcdr elt new-desc))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (setq contents (cons (car contents)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (cons (cons pkg-name new-desc)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (cdr contents))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 ;; Now CONTENTS is the updated archive contents. Upload
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 ;; this and the package itself. For now we assume ELPA is
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 ;; writable via file primitives.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (let ((print-level nil)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (print-length nil))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (write-region (concat (pp-to-string contents) "\n")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (concat package-archive-upload-base
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 "archive-contents")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 ;; If there is a commentary section, write it.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (when commentary
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 (write-region commentary nil
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (concat package-archive-upload-base
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (symbol-name pkg-name) "-readme.txt")))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (set-buffer pkg-buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (kill-buffer buffer)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (write-region (point-min) (point-max)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (concat package-archive-upload-base
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 file-name "-" pkg-version
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 "." extension)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 nil nil nil 'excl)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 ;; Write a news entry.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 (package--update-news (concat file-name "." extension)
109580
3021343b766a Update package-x to latest package.el changes.
Chong Yidong <cyd@stupidchicken.com>
parents: 109026
diff changeset
188 pkg-version desc archive-url)
109016
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 ;; special-case "package": write a second copy so that the
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 ;; installer can easily find the latest version.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (if (string= file-name "package")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (write-region (point-min) (point-max)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (concat package-archive-upload-base
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 file-name "." extension)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 nil nil nil 'ask)))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (defun package-upload-buffer ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 "Upload a single .el file to ELPA from the current buffer."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (save-excursion
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (save-restriction
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 ;; Find the package in this buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (let ((pkg-info (package-buffer-info)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (package-upload-buffer-internal pkg-info "el")))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (defun package-upload-file (file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 (interactive "fPackage file name: ")
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (with-temp-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (insert-file-contents-literally file)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 (let ((info (cond
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 ((string-match "\\.tar$" file) (package-tar-file-info file))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 ((string-match "\\.el$" file) (package-buffer-info))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (t (error "Unrecognized extension `%s'"
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 (file-name-extension file))))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (package-upload-buffer-internal info (file-name-extension file)))))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (defun package-gnus-summary-upload ()
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 "Upload a package contained in the current *Article* buffer.
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 This should be invoked from the gnus *Summary* buffer."
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (interactive)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (with-current-buffer gnus-article-buffer
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (package-upload-buffer)))
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (provide 'package-x)
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226
d73c5483c3d2 Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 ;;; package.el ends here