Mercurial > emacs
annotate lisp/emacs-lisp/package-x.el @ 109366:2a3fdfdeb7b3
* language/tai-viet.el ("TaiViet"): Try to fix re-encoding bugs. (Bug#5806)
author | Andreas Schwab <schwab@linux-m68k.org> |
---|---|
date | Mon, 12 Jul 2010 20:10:49 +0200 |
parents | c138aa96dae8 |
children | 3021343b766a |
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 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 ;; 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
|
11 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; 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
|
13 ;; 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
|
14 ;; 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
|
15 ;; any later version. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; 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
|
18 ;; 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
|
19 ;; 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
|
20 ;; 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
|
21 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; 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
|
23 ;; 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
|
24 ;; 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
|
25 ;; Boston, MA 02110-1301, USA. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;;; Commentary: |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; 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
|
30 ;; 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
|
31 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;;; Code: |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 |
109026
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109016
diff
changeset
|
34 (require 'package) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109016
diff
changeset
|
35 (defvar gnus-article-buffer) |
c138aa96dae8
Add preliminary describe-package functionality, and some cleanup.
Chong Yidong <cyd@stupidchicken.com>
parents:
109016
diff
changeset
|
36 |
109016
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ;; 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
|
38 ;; probably don't :-). |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 (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
|
40 "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
|
41 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 (defun package--encode (string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 "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
|
44 ;; We need a special case for translating "&" to "&". |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 (let ((index)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 (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
|
47 (setq string (replace-match "&" t nil string)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 (setq index (1+ index)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 (while (string-match "[<]" string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 (setq string (replace-match "<" t nil string))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 (while (string-match "[>]" string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 (setq string (replace-match ">" t nil string))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 (while (string-match "[']" string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 (setq string (replace-match "'" t nil string))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 (while (string-match "[\"]" string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 (setq string (replace-match """ t nil string))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 string) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 (defun package--make-rss-entry (title text) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 (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
|
61 (concat "<item>\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 "<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
|
63 ;; FIXME: should have a link in the web page. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 "<link>" package-archive-base "news.html</link>\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 "<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
|
66 "<pubDate>" date-string "</pubDate>\n" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 "</item>\n"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 (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
|
70 (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
|
71 title " - " (package--encode text) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 " </li>\n")) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 (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
|
75 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 (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
|
77 (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
|
78 (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
|
79 (goto-char (point-min)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 (search-forward location) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (forward-line) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 (insert text) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 (let ((file-precious-flag t)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (save-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 (unless old-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 (kill-buffer (current-buffer))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 (defun package-maint-add-news-item (title description) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 "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
|
90 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
|
91 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
|
92 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
|
93 (interactive "sTitle: \nsText: ") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 (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
|
95 "<description>" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 (package--make-rss-entry title description)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (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
|
98 "New entries go here" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 (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
|
100 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 (defun package--update-news (package version description) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 "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
|
103 (package-maint-add-news-item (concat package " version " version) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 description)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 (defun package-upload-buffer-internal (pkg-info extension) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 "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
|
108 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
|
109 EXTENSION is the file extension, a string. It can be either |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 \"el\" or \"tar\"." |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 (save-restriction |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (let* ((file-type (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 ((equal extension "el") 'single) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 ((equal extension "tar") 'tar) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 (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
|
117 (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
|
118 (pkg-name (intern file-name)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 (requires (aref pkg-info 1)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 (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
|
121 (read-string "Description of package: ") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (aref pkg-info 2))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (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
|
124 (commentary (aref pkg-info 4)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 (split-version (package-version-split pkg-version)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 (pkg-buffer (current-buffer)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ;; Download latest archive-contents. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 (buffer (url-retrieve-synchronously |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 (concat package-archive-base "archive-contents")))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 ;; Parse archive-contents. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 (set-buffer buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (package-handle-response) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 (re-search-forward "^$" nil 'move) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 (forward-char) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 (delete-region (point-min) (point)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 (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
|
139 (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
|
140 (point-max)))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 (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
|
142 (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
|
143 (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
|
144 (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
|
145 (if elt |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (if (package-version-compare split-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (package-desc-vers (cdr elt)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 '<=) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 (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
|
150 (setcdr elt new-desc)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 (setq contents (cons (car contents) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 (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
|
153 (cdr contents)))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 ;; 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
|
156 ;; 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
|
157 ;; writable via file primitives. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 (let ((print-level nil) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (print-length nil)) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 (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
|
161 nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 (concat package-archive-upload-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 "archive-contents"))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 ;; 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
|
166 (when commentary |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (write-region commentary nil |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 (concat package-archive-upload-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 (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
|
170 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 (set-buffer pkg-buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (kill-buffer buffer) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 (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
|
174 (concat package-archive-upload-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 file-name "-" pkg-version |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 "." extension) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 nil nil nil 'excl) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 ;; Write a news entry. |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 (package--update-news (concat file-name "." extension) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 pkg-version desc) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 ;; 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
|
184 ;; 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
|
185 (if (string= file-name "package") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 (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
|
187 (concat package-archive-upload-base |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 file-name "." extension) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 nil nil nil 'ask))))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (defun package-upload-buffer () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 "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
|
193 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (save-excursion |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (save-restriction |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 ;; 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
|
197 (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
|
198 (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
|
199 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 (defun package-upload-file (file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 (interactive "fPackage file name: ") |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 (with-temp-buffer |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 (insert-file-contents-literally file) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 (let ((info (cond |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 ((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
|
206 ((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
|
207 (t (error "Unrecognized extension `%s'" |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 (file-name-extension file)))))) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 (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
|
210 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (defun package-gnus-summary-upload () |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 "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
|
213 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
|
214 (interactive) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (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
|
216 (package-upload-buffer))) |
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 (provide 'package-x) |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 |
d73c5483c3d2
Merge package.el, written by Tom Tromey <tromey@redhat.com>.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 ;;; package.el ends here |