Emacs personal configuration
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

57 Zeilen
1.8KB

  1. ;;; Set load path
  2. (eval-when-compile (require 'cl))
  3. (defun sanityinc/add-subdirs-to-load-path (parent-dir)
  4. "Adds every non-hidden subdir of PARENT-DIR to `load-path'."
  5. (let* ((default-directory parent-dir))
  6. (progn
  7. (setq load-path
  8. (append
  9. (loop for dir in (directory-files parent-dir)
  10. unless (string-match "^\\." dir)
  11. collecting (expand-file-name dir))
  12. load-path)))))
  13. (sanityinc/add-subdirs-to-load-path
  14. (expand-file-name "site-lisp/" user-emacs-directory))
  15. ;;; Utilities for grabbing upstream libs
  16. (defun site-lisp-dir-for (name)
  17. (expand-file-name (format "site-lisp/%s" name) user-emacs-directory))
  18. (defun site-lisp-library-el-path (name)
  19. (expand-file-name (format "%s.el" name) (site-lisp-dir-for name)))
  20. (defun download-site-lisp-module (name url)
  21. (let ((dir (site-lisp-dir-for name)))
  22. (message "Downloading %s from %s" name url)
  23. (unless (file-directory-p dir)
  24. (make-directory dir t))
  25. (add-to-list 'load-path dir)
  26. (let ((el-file (site-lisp-library-el-path name)))
  27. (url-copy-file url el-file t nil)
  28. el-file)))
  29. (defun ensure-lib-from-url (name url)
  30. (unless (site-lisp-library-loadable-p name)
  31. (byte-compile-file (download-site-lisp-module name url))))
  32. (defun site-lisp-library-loadable-p (name)
  33. "Return whether or not the library `name' can be loaded from a
  34. source file under ~/.emacs.d/site-lisp/name/"
  35. (let ((f (locate-library (symbol-name name))))
  36. (and f (string-prefix-p (file-name-as-directory (site-lisp-dir-for name)) f))))
  37. ;; Download these upstream libs
  38. (unless (> emacs-major-version 23)
  39. (ensure-lib-from-url
  40. 'package
  41. "http://repo.or.cz/w/emacs.git/blob_plain/1a0a666f941c99882093d7bd08ced15033bc3f0c:/lisp/emacs-lisp/package.el"))
  42. (provide 'init-site-lisp)