aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Malabarba2015-01-12 23:35:46 -0200
committerArtur Malabarba2015-01-16 22:19:17 -0200
commitbc2f8d064bad4da0325a09179b420f75c941ffd9 (patch)
tree04111e7ad7a461a476a5c8bdcfef7a240c41619d
parent2fe6110d710b71b90f90c84bfa8eaf6b129eb0a6 (diff)
downloademacs-bc2f8d064bad4da0325a09179b420f75c941ffd9.tar.gz
emacs-bc2f8d064bad4da0325a09179b420f75c941ffd9.zip
(package-install-from-buffer): Install packages from dired buffer.
-rw-r--r--lisp/ChangeLog1
-rw-r--r--lisp/emacs-lisp/package.el39
2 files changed, 35 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dce08a42255..13a87225bad 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -5,6 +5,7 @@
5 the pkg-desc, with desc-kind set to KIND. 5 the pkg-desc, with desc-kind set to KIND.
6 (package-dir-info): New function. Find package information for a 6 (package-dir-info): New function. Find package information for a
7 directory. The return result is a `package-desc'. 7 directory. The return result is a `package-desc'.
8 (package-install-from-buffer): Install packages from dired buffer.
8 9
92015-01-16 Jorgen Schaefer <contact@jorgenschaefer.de> 102015-01-16 Jorgen Schaefer <contact@jorgenschaefer.de>
10 11
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 77b15c104ef..78138e9ebcd 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -800,6 +800,20 @@ untar into a directory named DIR; otherwise, signal an error."
800 (dirname (package-desc-full-name pkg-desc)) 800 (dirname (package-desc-full-name pkg-desc))
801 (pkg-dir (expand-file-name dirname package-user-dir))) 801 (pkg-dir (expand-file-name dirname package-user-dir)))
802 (pcase (package-desc-kind pkg-desc) 802 (pcase (package-desc-kind pkg-desc)
803 (`dir
804 (make-directory pkg-dir t)
805 (let ((file-list
806 (directory-files
807 default-directory 'full "\\`[^.].*\\.el\\'" 'nosort)))
808 (dolist (source-file file-list)
809 (let ((target-el-file
810 (expand-file-name (file-name-nondirectory source-file) pkg-dir)))
811 (copy-file source-file target-el-file t)))
812 ;; Now that the files have been installed, this package is
813 ;; indistinguishable from a `tar' or a `single'. Let's make
814 ;; things simple by ensuring we're one of them.
815 (setf (package-desc-kind pkg-desc)
816 (if (> (length file-list) 1) 'tar 'single))))
803 (`tar 817 (`tar
804 (make-directory package-user-dir t) 818 (make-directory package-user-dir t)
805 ;; FIXME: should we delete PKG-DIR if it exists? 819 ;; FIXME: should we delete PKG-DIR if it exists?
@@ -1318,13 +1332,28 @@ Return the pkg-desc, with desc-kind set to KIND."
1318;;;###autoload 1332;;;###autoload
1319(defun package-install-from-buffer () 1333(defun package-install-from-buffer ()
1320 "Install a package from the current buffer. 1334 "Install a package from the current buffer.
1321The current buffer is assumed to be a single .el or .tar file that follows the 1335The current buffer is assumed to be a single .el or .tar file or
1322packaging guidelines; see info node `(elisp)Packaging'. 1336a directory. These must follow the packaging guidelines (see
1337info node `(elisp)Packaging').
1338
1339Specially, if current buffer is a directory, the -pkg.el
1340description file is not mandatory, in which case the information
1341is derived from the main .el file in the directory.
1342
1323Downloads and installs required packages as needed." 1343Downloads and installs required packages as needed."
1324 (interactive) 1344 (interactive)
1325 (let ((pkg-desc (if (derived-mode-p 'tar-mode) 1345 (let ((pkg-desc
1326 (package-tar-file-info) 1346 (cond
1327 (package-buffer-info)))) 1347 ((derived-mode-p 'dired-mode)
1348 ;; This is the only way a package-desc object with a `dir'
1349 ;; desc-kind can be created. Such packages can't be
1350 ;; uploaded or installed from archives, they can only be
1351 ;; installed from local buffers or directories.
1352 (package-dir-info))
1353 ((derived-mode-p 'tar-mode)
1354 (package-tar-file-info))
1355 (t
1356 (package-buffer-info)))))
1328 ;; Download and install the dependencies. 1357 ;; Download and install the dependencies.
1329 (let* ((requires (package-desc-reqs pkg-desc)) 1358 (let* ((requires (package-desc-reqs pkg-desc))
1330 (transaction (package-compute-transaction nil requires))) 1359 (transaction (package-compute-transaction nil requires)))