 
 
 ;;;
-;;; Startup-related utility functions
-;;;
+;;; package.el support
+;;;
+
+(defvar homectl-package-el-ready-p nil
+  "Have we already loaded/initialized package.el?")
+
+(defun homectl-require-package-el ()
+  (when (not homectl-package-el-ready-p)
+    (homectl-load-package-el)
+    (package-initialize)
+    (setq homectl-package-el-ready-p t)))
 
 (defun homectl-load-package-el ()
   "Download a version of package.el if it's not available."

environment."
  (interactive)

  ; Make sure we're ready to fetch remote packages
  (when (homectl-load-package-el)
    (package-initialize))

  ; The following is a Darwin-specific hack to make sure the shell's $PATH
  ; is picked up by Emacs when running in Aqua mode.
  (when (and (string= system-type "darwin") homectl-darwin-fixup-path)


   ; Else try to fetch the package
   (t
    (homectl-require-package-el)
    (when (not (assoc repo-name package-archives))
      (add-to-list 'package-archives (cons repo-name repo-url)))
    (package-install pkg-symbol)
