Skip to content

Commit

Permalink
Added a load path function
Browse files Browse the repository at this point in the history
  • Loading branch information
hardaker committed Apr 17, 2012
1 parent 449a4ad commit e54e708
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions configel.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,18 @@
(defun configel-load-everything ()
"Loads all the packages it can find"
(interactive)
(mapc 'configel-add-path configel-search-paths)
(mapc 'configel-load-path configel-search-paths)
)

(defun configel-add-path (path)
"Adds available packages in a path to the load-path"
(interactive)
(setq configel-current-path path)
(let ((dirs (directory-files-and-attributes path)))
(mapc 'configel-add-load-path dirs)
))

(defun configel-load-path (path)
"Loads everything usable in a given path"
(interactive)
Expand Down Expand Up @@ -100,8 +109,6 @@
(if (file-exists-p (concat fullitem "/lisp"))
;; XXX: this assumes it isn't a file
(setq loadpath (concat fullitem "/lisp")))
;; add the load path to our path list
(add-to-list 'load-path loadpath)
;; load our config first
(if (file-exists-p elcfile)
(load-file elcfile)
Expand All @@ -115,4 +122,30 @@
(require (intern item))))
))

(defun configel-add-load-path (attributes)
"Add a package's path to the list of load-paths"
(interactive)
(let*
((item (car attributes))
(fullitem (concat configel-current-path "/" item))
(loadpath fullitem)
(isdir (cadr attributes))
(elfile (concat fullitem ".el"))
(elcfile (concat elfile "c"))
(configexists (or (file-exists-p elfile) (file-exists-p elcfile)))
)
(when (and isdir
(or configexists configel-load-every-package)
(not (equal item "."))
(not (equal item ".."))
)
(message "Adding %s package's lisp path for you..." item)
; if there is a lisp subdir, use that
(if (file-exists-p (concat fullitem "/lisp"))
;; XXX: this assumes it isn't a file
(setq loadpath (concat fullitem "/lisp")))
;; add the load path to our path list
(add-to-list 'load-path loadpath)
)))

(provide 'configel)

0 comments on commit e54e708

Please sign in to comment.