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