annotate lisp/package-ui.el @ 624:59c2a61efa7d

[xemacs-hg @ 2001-06-30 23:07:06 by youngs] Patches from Robert Pluim <rpluim@bigfoot.com> - small changes to package code
author youngs
date Sat, 30 Jun 2001 23:07:06 +0000
parents d7a9135ec789
children d83885ef293b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; package-ui.el ---
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1998 by Darryl Okahata
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Author: Darryl Okahata <darrylo@sr.hp.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Keywords: internal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;;; Synched up with: Not in FSF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 (require 'package-get) ;; which, in turn, requires 'package-admin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; User-changeable variables:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 (defgroup pui nil
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
34 "Convenient interface to the package system."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 :group 'package-tools
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 :tag "Package User interface"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 :prefix "pui-")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 (defcustom pui-package-install-dest-dir nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 "*If non-nil (Automatic) path to package tree to install packages in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 Otherwise, use old path for installed packages and make a guess for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 new ones."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 :group 'pui
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 :tag "Install Location"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 :type '(choice (const :tag "Automatic" nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (directory)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 (defcustom pui-list-verbose t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 "*If non-nil, display verbose info in the package list buffer."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 :group 'pui
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 :tag "Verbose Listing"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 :type 'boolean)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (defcustom pui-up-to-date-package-face nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 "*The face to use for packages that are up-to-date."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 :group 'pui
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 :type 'face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (defcustom pui-selected-package-face 'bold
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 "*The face to use for selected packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 Set this to `nil' to use the `default' face."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 :group 'pui
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 :type 'face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (defcustom pui-deleted-package-face 'blue
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 "*The face to use for packages marked for removal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 Set this to `nil' to use the `default' face."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 :group 'pui
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 :type 'face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 (defcustom pui-outdated-package-face 'red
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 "*The face to use for outdated packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 Set this to `nil' to use the `default' face."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 :group 'pui
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 :type 'face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 (defcustom pui-uninstalled-package-face 'italic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 "*The face to use for uninstalled packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 Set this to `nil' to use the `default' face."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 :group 'pui
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 :type 'face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 (defvar pui-info-buffer "*Packages*"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 "Buffer to use for displaying package information.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 ;; End of user-changeable variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (defvar pui-selected-packages nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 "The list of user-selected packages to install.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (defvar pui-deleted-packages nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 "The list of user-selected packages to remove.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (defvar pui-actual-package "")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 (defvar pui-display-keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (let ((m (make-keymap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (suppress-keymap m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (set-keymap-name m 'pui-display-keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (define-key m "q" 'pui-quit)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (define-key m "g" 'pui-list-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 (define-key m "i" 'pui-display-info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (define-key m "?" 'describe-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 (define-key m "v" 'pui-toggle-verbosity-redisplay)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (define-key m "d" 'pui-toggle-package-delete-key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (define-key m "D" 'pui-toggle-package-delete-key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (define-key m [return] 'pui-toggle-package-key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (define-key m "x" 'pui-install-selected-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (define-key m "I" 'pui-install-selected-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (define-key m "r" 'pui-add-required-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 (define-key m "n" 'next-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 (define-key m "+" 'pui-toggle-package-key)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 (define-key m "p" 'previous-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 (define-key m " " 'scroll-up-command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 (define-key m [delete] 'scroll-down-command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 "Keymap to use in the `pui-info-buffer' buffer")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 (defvar pui-package-keymap
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (let ((m (make-sparse-keymap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (set-keymap-name m 'pui-package-keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (define-key m 'button2 'pui-toggle-package-event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 ;; We use a popup menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (define-key m 'button3 'pui-popup-context-sensitive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 "Keymap to use over package names/descriptions.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 ;; End of variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 ;; Configuration routines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (defun pui-directory-exists (dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 "Check to see if DIR exists in `package-get-remote'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (let (found)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
143 (mapcar #'(lambda (item)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
144 (if (and (null (car item))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
145 (string-equal (file-name-as-directory (car (cdr item)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 (file-name-as-directory dir)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
147 (setq found t)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
148 package-get-remote)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (defun pui-package-dir-list (buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 "In BUFFER, format the list of package binary paths."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 (let ( (count 1) paths sys dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (set-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (buffer-disable-undo buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (erase-buffer buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (insert "Existing package binary paths:\n\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (setq paths package-get-remote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 (while paths
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (setq sys (car (car paths))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 dir (car (cdr (car paths))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (insert (format "%2s. " count))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (if (null sys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (insert dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 (insert sys ":" dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (insert "\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (setq count (1+ count))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (setq paths (cdr paths))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (insert "\nThese are the places that will be searched for package binaries.\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (goto-char (point-min))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (defun package-ui-add-site (site)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 "Add site to package-get-remote and possibly offer to update package list."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (let ((had-none (null package-get-remote)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (push site package-get-remote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (when (and had-none package-get-was-current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (y-or-n-p "Update Package list?"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (setq package-get-was-current nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (package-get-require-base t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (if (get-buffer pui-info-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 (pui-list-packages))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 (set-menubar-dirty-flag)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (defun pui-add-install-directory (dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 "Add a new package binary directory to the head of `package-get-remote'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 Note that no provision is made for saving any changes made by this function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 It exists mainly as a convenience for one-time package installations from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 disk."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (interactive (let ( (tmpbuf (get-buffer-create
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 "*Existing Package Binary Paths*"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 (unwind-protect
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (pui-package-dir-list tmpbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (display-buffer tmpbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 (setq dir (read-directory-name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 "New package binary directory to add? "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 nil nil t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (kill-buffer tmpbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 (list dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (if (not (pui-directory-exists dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 (setq package-get-remote (cons (list nil dir) package-get-remote))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 (message "Package directory \"%s\" added." dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 (message "Directory \"%s\" already exists in `package-get-remote'." dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 ;; Package list/installer routines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 (defun pui-quit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 (kill-buffer nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 (defun pui-package-symbol-char (pkg-sym version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 (if (package-get-info-find-package packages-package-list pkg-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 (let ((installed (package-get-key pkg-sym :version)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 (if (>= (if (stringp installed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (string-to-number installed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 installed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 (if (stringp version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 (string-to-number version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 version))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 (list " " pui-up-to-date-package-face)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 (list "*" pui-outdated-package-face)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 (list "-" pui-uninstalled-package-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 (defun pui-update-package-display (extent &optional pkg-sym version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 "Update the package status for EXTENT.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 If PKG-SYM or VERSION are not given, they are read from the extent.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 These are used to determine whether or not the package is installed,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 and whether or not it is up-to-date."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 (let (buffer-read-only disp sym-char)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 (if (not pkg-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 (setq pkg-sym (extent-property extent 'pui-package)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 (if (not version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 (setq version (package-get-info-prop (extent-property extent 'pui-info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 'version)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 (cond ((member pkg-sym pui-selected-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 (if pui-selected-package-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 (set-extent-face extent (get-face pui-selected-package-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 (set-extent-face extent (get-face 'default)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 (setq sym-char "+"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 ((member pkg-sym pui-deleted-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 (if pui-deleted-package-face
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 (set-extent-face extent (get-face pui-deleted-package-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 (set-extent-face extent (get-face 'default)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 (setq sym-char "D"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 (setq disp (pui-package-symbol-char pkg-sym version))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 (setq sym-char (car disp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 (if (car (cdr disp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 (set-extent-face extent (get-face (car (cdr disp))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 (set-extent-face extent (get-face 'default)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 (goto-char (extent-start-position extent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 (delete-char 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 (insert sym-char)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 (set-buffer-modified-p nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 (defun pui-toggle-package (extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 (let (pkg-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 (setq pkg-sym (extent-property extent 'pui-package))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 (if (member pkg-sym pui-selected-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 (setq pui-selected-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 (delete pkg-sym pui-selected-packages))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (setq pui-selected-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (cons pkg-sym pui-selected-packages))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 (setq pui-deleted-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (delete pkg-sym pui-deleted-packages)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 (pui-update-package-display extent pkg-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (defun pui-toggle-package-key ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 "Select/unselect package for installation, using the keyboard."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 (let (extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (if (setq extent (extent-at (point) (current-buffer) 'pui))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (pui-toggle-package extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (forward-line 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (error "No package under cursor!"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 (defun pui-toggle-package-delete (extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 (let (pkg-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 (setq pkg-sym (extent-property extent 'pui-package))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 (if (member pkg-sym pui-deleted-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (setq pui-deleted-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 (delete pkg-sym pui-deleted-packages))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 (setq pui-deleted-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 (cons pkg-sym pui-deleted-packages))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
312 (setq pui-selected-packages
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 (delete pkg-sym pui-selected-packages)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 (pui-update-package-display extent pkg-sym)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 (defun pui-toggle-package-delete-key ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 "Select/unselect package for removal, using the keyboard."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 (let (extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 (if (setq extent (extent-at (point) (current-buffer) 'pui))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 (pui-toggle-package-delete extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 (forward-line 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 (error "No package under cursor!"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 (defun pui-current-package ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 (let ((extent (extent-at (point) (current-buffer) 'pui)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 (if extent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (extent-property extent 'pui-package))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 (defun pui-toggle-package-event (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 "Select/unselect package for installation, using the mouse."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 (interactive "e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 (let* ( (ep (event-point event))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (buffer (window-buffer (event-window event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (extent (extent-at ep buffer 'pui-package))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 (pui-toggle-package extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (defun pui-toggle-verbosity-redisplay ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 "Toggle verbose package info."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (setq pui-list-verbose (not pui-list-verbose))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (pui-list-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (defun pui-install-selected-packages ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 "Install selected packages."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (let ( (tmpbuf "*Packages-To-Remove*") do-delete)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (when pui-deleted-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (with-output-to-temp-buffer tmpbuf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 (display-completion-list (sort
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
361 (mapcar #'symbol-name pui-deleted-packages)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
362 #'string<)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 :activate-callback nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 :help-string "Packages selected for removal:\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 :completion-string t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 (setq tmpbuf (get-buffer-create tmpbuf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 (display-buffer tmpbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (setq do-delete (yes-or-no-p "Remove these packages? "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 (kill-buffer tmpbuf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (when do-delete
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (message "Deleting selected packages ...") (sit-for 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 (mapcar (lambda (pkg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 (package-admin-delete-binary-package
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 pkg (package-admin-get-install-dir pkg nil)))
624
59c2a61efa7d [xemacs-hg @ 2001-06-30 23:07:06 by youngs]
youngs
parents: 454
diff changeset
376 (nreverse pui-deleted-packages))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 (message "Packages deleted"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 (let ( (tmpbuf "*Packages-To-Install*") do-install)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 (if pui-selected-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 ;; Don't change window config when asking the user if he really
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 ;; wants to install the packages. We do this to avoid messing up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 ;; the window configuration if errors occur (we don't want to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 ;; display random buffers in addition to the error buffer, if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 ;; errors occur, which would normally be caused by display-buffer).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 (with-output-to-temp-buffer tmpbuf
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
389 (display-completion-list
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
390 (sort (mapcar #'symbol-name pui-selected-packages) #'string<)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
391 :activate-callback nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
392 :help-string "Packages selected for installation:\n"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
393 :completion-string t
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
394 ))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 (setq tmpbuf (get-buffer-create tmpbuf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (display-buffer tmpbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 (setq do-install (y-or-n-p "Install these packages? "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 (kill-buffer tmpbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 (if do-install
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 ;; Clear old temp buffer history
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 (set-buffer (get-buffer-create package-admin-temp-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (buffer-disable-undo package-admin-temp-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 (erase-buffer package-admin-temp-buffer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 (message "Installing selected packages ...") (sit-for 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 (if (catch 'done
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 (mapcar (lambda (pkg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 (if (not (package-get pkg nil nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 pui-package-install-dest-dir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (throw 'done nil)))
624
59c2a61efa7d [xemacs-hg @ 2001-06-30 23:07:06 by youngs]
youngs
parents: 454
diff changeset
414 (nreverse pui-selected-packages))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (pui-list-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (message "Packages installed")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (clear-message)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 (if pui-deleted-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (pui-list-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 (error "No packages have been selected!")))
454
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 442
diff changeset
427 ;; sync with windows type systems
d7a9135ec789 Import from CVS: tag r21-2-42
cvs
parents: 442
diff changeset
428 (package-net-update-installed-db)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 (defun pui-add-required-packages ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 "Select packages required by those already selected for installation."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (let ((tmpbuf "*Required-Packages*") do-select)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (if pui-selected-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (let ((dependencies
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (delq nil (mapcar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (lambda (pkg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (let ((installed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (package-get-key pkg :version))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (current
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (package-get-info-prop
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (package-get-info-version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (package-get-info-find-package
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 package-get-base pkg) nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 'version)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (if (or (null installed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (< (if (stringp installed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (string-to-number installed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 installed)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (if (stringp current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (string-to-number current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 current)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 pkg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 (package-get-dependencies pui-selected-packages)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 ;; Don't change window config when asking the user if he really
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 ;; wants to add the packages. We do this to avoid messing up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 ;; the window configuration if errors occur (we don't want to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 ;; display random buffers in addition to the error buffer, if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 ;; errors occur, which would normally be caused by display-buffer).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 (save-window-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 (with-output-to-temp-buffer tmpbuf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 (display-completion-list (sort
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 (mapcar #'(lambda (pkg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 (symbol-name pkg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 dependencies)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 'string<)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 :activate-callback nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 :help-string "Required packages:\n"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 :completion-string t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 (setq tmpbuf (get-buffer-create tmpbuf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 (display-buffer tmpbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 (setq do-select (y-or-n-p "Select these packages? "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 (kill-buffer tmpbuf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (if do-select
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 (setq pui-selected-packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (union pui-selected-packages dependencies))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 (map-extents #'(lambda (extent maparg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (pui-update-package-display extent))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 nil nil nil nil nil 'pui)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (message "added dependencies"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 (clear-message)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (error "No packages have been selected!"))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 (defun pui-help-echo (extent &optional force-update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 "Display additional package info in the modeline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 EXTENT determines the package to display (the package information is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 attached to the extent as properties)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (let (pkg-sym info inst-ver auth-ver date maintainer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (if (or force-update (not (current-message))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 (string-match ".*: .*: " (current-message))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (setq pkg-sym (extent-property extent 'pui-package)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 info (extent-property extent 'pui-info)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 inst-ver (package-get-key pkg-sym :version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 auth-ver (package-get-info-prop info 'author-version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 date (package-get-info-prop info 'date)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 maintainer (package-get-info-prop info 'maintainer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (if (not inst-ver)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 (setq inst-ver ""))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (if pui-list-verbose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 (format "Author version: %-8s %11s: %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 auth-ver date maintainer)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (format "%-6s: %-8s %11s: %s"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 inst-ver auth-ver date maintainer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 (defun pui-display-info (&optional no-error event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 "Display additional package info in the modeline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 Designed to be called interactively (from a keypress)."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 (let (extent)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 (save-excursion
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 (beginning-of-line)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 (if (setq extent (extent-at (point) (current-buffer) 'pui))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (message (pui-help-echo extent t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 (if no-error
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (clear-message nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 (error "No package under cursor!")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 (defvar pui-menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 '("Packages"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 ["Toggle install " pui-toggle-package-key :active (pui-current-package) :suffix (format "`%s'" (or (pui-current-package) "..."))]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 ["Toggle delete " pui-toggle-package-delete-key :active (pui-current-package) :suffix (format "`%s'" (or (pui-current-package) "..."))]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 ["Info on" pui-display-info :active (pui-current-package) :suffix (format "`%s'" (or (pui-current-package) "..."))]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 "---"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 ["Add Required" pui-add-required-packages t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 ["Install/Remove Selected" pui-install-selected-packages t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 "---"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 ["Verbose" pui-toggle-verbosity-redisplay
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 :active t :style toggle :selected pui-list-verbose]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 ["Refresh" pui-list-packages t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 ["Help" pui-help t]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 ["Quit" pui-quit t]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
541 ;;; "Why is there no standard function to do this?"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
542 (defun pui-popup-context-sensitive (event)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
543 (interactive "e")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
544 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
545 (set-buffer (event-buffer event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
546 (goto-char (event-point event))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
547 (popup-menu pui-menu event)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
548 ;; I agree with dired.el - this is seriously bogus.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
549 (while (popup-up-p)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
550 (dispatch-event (next-event)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (defun list-packages-mode ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 "Symbols in the leftmost column:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 + The package is marked for installation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 - The package has not been installed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 D The package has been marked for deletion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 * The currently installed package is old, and a newer version is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 available.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 Useful keys:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 `\\[pui-toggle-package-key]' to select/unselect the current package for installation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 `\\[pui-toggle-package-delete-key]' to select/unselect the current package for removal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 `\\[pui-add-required-packages]' to add any packages required by those selected.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 `\\[pui-install-selected-packages]' to install/delete selected packages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 `\\[pui-display-info]' to display additional information about the package in the modeline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 `\\[pui-list-packages]' to refresh the package list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 `\\[pui-toggle-verbosity-redisplay]' to toggle between a verbose and non-verbose display.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 `\\[pui-quit]' to kill this buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 (error "You cannot enter this mode directly. Use `pui-list-packages'"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 (put 'list-packages-mode 'mode-class 'special)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (defun pui-list-packages ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 "List all packages and package information.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 The package name, version, and description are displayed. From the displayed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 buffer, the user can see which packages are installed, which are not, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 which are out-of-date (a newer version is available). The user can then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 select packages for installation via the keyboard or mouse."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 (interactive)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 (package-get-require-base t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 (let ( (outbuf (get-buffer-create pui-info-buffer))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (sep-string "===============================================================================\n")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 start )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (message "Creating package list ...") (sit-for 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 (set-buffer outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 (setq buffer-read-only nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 (buffer-disable-undo outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 (erase-buffer outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 (kill-all-local-variables)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 (use-local-map pui-display-keymap)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 (setq major-mode 'list-packages-mode)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 (setq mode-name "Packages")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 (setq truncate-lines t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 (unless package-get-remote
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 (insert "
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 Warning: No download sites specified. Package index may be out of date.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 If you intend to install packages, specify download sites first.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 (if pui-list-verbose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 (insert " Latest Installed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 Package name Vers. Vers. Description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 ")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 (insert " Latest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 Package name Vers. Description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 "))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 (insert sep-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 (setq start (point))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
615 (mapcar
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
616 #'(lambda (pkg)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
617 (let (pkg-sym info version desc
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
618 b e extent current-vers disp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
619 (setq pkg-sym (car pkg)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
620 info (package-get-info-version (cdr pkg) nil))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
621 (setq version (package-get-info-prop info 'version)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622 desc (package-get-info-prop info 'description))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
624 (setq disp (pui-package-symbol-char pkg-sym
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
625 version))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
626 (setq b (point))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
627 (if pui-list-verbose
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
628 (progn
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
629 (setq current-vers (package-get-key pkg-sym :version))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630 (cond
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
631 ( (not current-vers)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
632 (setq current-vers "-----") )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
633 ( (stringp current-vers)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
634 (setq current-vers
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
635 (format "%.2f"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
636 (string-to-number current-vers))) )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
637 ( (numberp current-vers)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
638 (setq current-vers (format "%.2f" current-vers)) )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
639 )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
640 (insert
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
641 (format "%s %-15s %-5.2f %-5s %s\n"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
642 (car disp) pkg-sym
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
643 (if (stringp version)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
644 (string-to-number version)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
645 version)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
646 current-vers desc))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
647 ;; (insert
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
648 ;; (format "\t\t %-12s %s\n"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
649 ;; (package-get-info-prop info 'author-version)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
650 ;; (package-get-info-prop info 'date)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
651 )
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
652 (insert (format "%s %-15s %-5s %s\n"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
653 (car disp)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
654 pkg-sym version desc)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
655 (save-excursion
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
656 (setq e (progn
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
657 (forward-line -1)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
658 (end-of-line)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
659 (point))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
660 (setq extent (make-extent b e))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
661 (if (car (cdr disp))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
662 (set-extent-face extent (get-face (car (cdr disp))))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
663 (set-extent-face extent (get-face 'default)))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
664 (set-extent-property extent 'highlight t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
665 (set-extent-property extent 'pui t)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
666 (set-extent-property extent 'pui-package pkg-sym)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
667 (set-extent-property extent 'pui-info info)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
668 (set-extent-property extent 'help-echo 'pui-help-echo)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
669 (set-extent-property extent 'keymap pui-package-keymap)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
670 ))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
671 (sort (copy-sequence package-get-base)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
672 #'(lambda (a b)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
673 (string< (symbol-name (car a))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
674 (symbol-name (car b))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 (insert sep-string)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 (insert (documentation 'list-packages-mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 (set-buffer-modified-p nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 (setq buffer-read-only t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 (pop-to-buffer outbuf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 (delete-other-windows)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 (goto-char start)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 (setq pui-selected-packages nil) ; Reset list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 (setq pui-deleted-packages nil) ; Reset list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 (when (featurep 'menubar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 (set-buffer-menubar current-menubar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 (add-submenu '() pui-menu)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 (setq mode-popup-menu pui-menu))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 (clear-message)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
689 ;; (message (substitute-command-keys "Press `\\[pui-help]' for help."))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 ;;;###autoload
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 (defalias 'list-packages 'pui-list-packages)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 (provide 'package-ui)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 ;;; package-ui.el ends here