[Emacs] Update imalison:use-package to do git clones

This commit is contained in:
Ivan Malison 2017-04-17 23:25:44 -07:00
parent a99f0b044b
commit fad0231afe
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -382,25 +382,30 @@ Works in the same way as os.path.join in python
#+END_SRC #+END_SRC
** Use Package Wrapper With Local Load Path Support ** Use Package Wrapper With Local Load Path Support
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(put 'imalison:use-package 'lisp-indent-function 'defun) (put 'imalison:use-package 'lisp-indent-function 'defun)
(put 'imalison:use-package* 'lisp-indent-function 'defun) (put 'imalison:use-package* 'lisp-indent-function 'defun)
(put 'imalison:use-package** 'lisp-indent-function 'defun)
(defmacro imalison:use-package* (package target-directory &rest forms) (defmacro imalison:use-package* (package target-github-name &rest forms)
(let* ((actual-target (if (file-exists-p target-directory) (let* ((clone-url
target-directory (format "git@github.com:IvanMalison/%s" target-github-name))
(let ((in-projects (imalison:join-paths imalison:projects-directory (target-directory
target-directory))) (imalison:join-paths imalison:projects-directory target-github-name)))
(when (file-exists-p in-projects) `(imalison:use-package** ,package ,target-directory ,clone-url ,@forms)))
in-projects))))
(additional-forms
(when actual-target
(list
:load-path actual-target
:ensure nil))))
`(use-package ,package
,@additional-forms ,@forms)))
(defmacro imalison:use-package (package &rest forms) (defmacro imalison:use-package** (package target-directory target-clone-url &rest forms)
`(progn
(or (file-exists-p ,target-directory)
(equal (call-process
(executable-find "git")
nil nil nil "clone" ,target-clone-url ,target-directory) 0))
(use-package ,package
:load-path ,target-directory
:ensure nil
:preface
,@forms)))
(defmacro imalison:use-package (package &rest forms)
`(imalison:use-package* ,package ,(symbol-name package) ,@forms)) `(imalison:use-package* ,package ,(symbol-name package) ,@forms))
#+END_SRC #+END_SRC
** Required Packages ** Required Packages
@ -419,7 +424,7 @@ but provide support for writing custom elisp.
#+END_SRC #+END_SRC
*** gh *** gh
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(imalison:use-package* gh "gh.el" (imalison:use-package** gh "gh.el" "git@github.com:sigma/gh.el.git"
:demand t) :demand t)
#+END_SRC #+END_SRC
*** shut-up *** shut-up