Commit bc2f8d06 authored by Artur Malabarba's avatar Artur Malabarba
Browse files

(package-install-from-buffer): Install packages from dired buffer.

parent 2fe6110d
......@@ -5,6 +5,7 @@
the pkg-desc, with desc-kind set to KIND.
(package-dir-info): New function. Find package information for a
directory. The return result is a `package-desc'.
(package-install-from-buffer): Install packages from dired buffer.
2015-01-16 Jorgen Schaefer <>
......@@ -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)
(make-directory pkg-dir t)
(let ((file-list
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))))
(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."
(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."
(let ((pkg-desc (if (derived-mode-p 'tar-mode)
(let ((pkg-desc
((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.
((derived-mode-p 'tar-mode)
;; Download and install the dependencies.
(let* ((requires (package-desc-reqs pkg-desc))
(transaction (package-compute-transaction nil requires)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment