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