mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-05 11:21:04 -08:00
(package-install-from-buffer): Install packages from dired buffer.
This commit is contained in:
parent
2fe6110d71
commit
bc2f8d064b
2 changed files with 35 additions and 5 deletions
|
|
@ -800,6 +800,20 @@ untar into a directory named DIR; otherwise, signal an error."
|
|||
(dirname (package-desc-full-name pkg-desc))
|
||||
(pkg-dir (expand-file-name dirname package-user-dir)))
|
||||
(pcase (package-desc-kind pkg-desc)
|
||||
(`dir
|
||||
(make-directory pkg-dir t)
|
||||
(let ((file-list
|
||||
(directory-files
|
||||
default-directory 'full "\\`[^.].*\\.el\\'" 'nosort)))
|
||||
(dolist (source-file file-list)
|
||||
(let ((target-el-file
|
||||
(expand-file-name (file-name-nondirectory source-file) pkg-dir)))
|
||||
(copy-file source-file target-el-file t)))
|
||||
;; Now that the files have been installed, this package is
|
||||
;; indistinguishable from a `tar' or a `single'. Let's make
|
||||
;; things simple by ensuring we're one of them.
|
||||
(setf (package-desc-kind pkg-desc)
|
||||
(if (> (length file-list) 1) 'tar 'single))))
|
||||
(`tar
|
||||
(make-directory package-user-dir t)
|
||||
;; FIXME: should we delete PKG-DIR if it exists?
|
||||
|
|
@ -1318,13 +1332,28 @@ Return the pkg-desc, with desc-kind set to KIND."
|
|||
;;;###autoload
|
||||
(defun package-install-from-buffer ()
|
||||
"Install a package from the current buffer.
|
||||
The current buffer is assumed to be a single .el or .tar file that follows the
|
||||
packaging guidelines; see info node `(elisp)Packaging'.
|
||||
The current buffer is assumed to be a single .el or .tar file or
|
||||
a directory. These must follow the packaging guidelines (see
|
||||
info node `(elisp)Packaging').
|
||||
|
||||
Specially, if current buffer is a directory, the -pkg.el
|
||||
description file is not mandatory, in which case the information
|
||||
is derived from the main .el file in the directory.
|
||||
|
||||
Downloads and installs required packages as needed."
|
||||
(interactive)
|
||||
(let ((pkg-desc (if (derived-mode-p 'tar-mode)
|
||||
(package-tar-file-info)
|
||||
(package-buffer-info))))
|
||||
(let ((pkg-desc
|
||||
(cond
|
||||
((derived-mode-p 'dired-mode)
|
||||
;; This is the only way a package-desc object with a `dir'
|
||||
;; desc-kind can be created. Such packages can't be
|
||||
;; uploaded or installed from archives, they can only be
|
||||
;; installed from local buffers or directories.
|
||||
(package-dir-info))
|
||||
((derived-mode-p 'tar-mode)
|
||||
(package-tar-file-info))
|
||||
(t
|
||||
(package-buffer-info)))))
|
||||
;; Download and install the dependencies.
|
||||
(let* ((requires (package-desc-reqs pkg-desc))
|
||||
(transaction (package-compute-transaction nil requires)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue