Merge pull request #1397 from npostavs/elpa-pkg-dir

be more precise about elpa package dir names
This commit is contained in:
yagnesh రాఘవ 2013-10-20 22:12:37 -07:00
commit 807a0ca754
2 changed files with 24 additions and 22 deletions

View File

@ -28,28 +28,14 @@
(defun el-get-elpa-package-directory (package)
"Return the directory where ELPA stores PACKAGE, or nil if
PACKAGE isn't currently installed by ELPA."
(let* ((pname (format "%s" package)) ; easy way to cope with symbols etc.
(ls-command (if (memq system-type '(ms-dos windows-nt)) "dir /B " "ls -1 "))
(l
;; we use try-completion to find the realname of the directory
;; ELPA used, and this wants an alist, we trick ls -i -1 into
;; that.
(mapcar 'split-string
(split-string
(shell-command-to-string
(concat
ls-command
(shell-quote-argument
(expand-file-name
(file-name-as-directory package-user-dir))))))))
(realnames (all-completions pname l)))
(when realnames
(concat (file-name-as-directory package-user-dir) (car realnames)))))
;; package directories are named <package>-<version>.
(let* ((pname (el-get-as-string package))
(version-offset (+ (length pname) 1)))
(loop for pkg-dir in (directory-files package-user-dir nil
(concat "^" (regexp-quote pname) "-"))
if (ignore-errors
(version-to-list (substring pkg-dir version-offset)))
return (expand-file-name pkg-dir package-user-dir))))
(defun el-get-elpa-package-repo (package)
"Get the ELPA repository cons cell for PACKAGE.

16
test/el-get-issue-1189.el Normal file
View File

@ -0,0 +1,16 @@
;;; When installing a package whose name is a prefix of an already
;;; installed package, `el-get-elpa-package-directory' gets confused.
(setq el-get-sources
'((:name load-dir ; I tried to pick the smallest package
:type elpa
:description "Load all Emacs Lisp files in a given directory"
:repo ("gnu" . "http://elpa.gnu.org/packages/"))))
(el-get 'sync 'load-dir)
(assert (not (equal (el-get-elpa-package-directory 'load)
(el-get-elpa-package-directory 'load-dir)))
nil
"a package name `load' shouldn't use the same directory
as `load-dir'.")