From ff7157d1b2868ca6752123fafefb7db3fc03b6b6 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 24 Jul 2016 01:10:37 +0200 Subject: Add some packages --- emacs/.emacs.d/init.el | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'emacs') diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index f0bbbf5..bfdf935 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -26,6 +26,49 @@ ;;; Code: +;;;; Package configuration: +;;; Require package.el since we immediately start using its variables +;;; and functions anyway, no need to delay loading. +(require 'package) + +;; Add the MELPA and org package archives because I like living on the +;; bleeding edge. This should be done both at run-time and +;; compile-time so I can install packages at compile time. +(eval-and-compile + (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) + (add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))) + +;; Initialize package.el so that packages can be loaded and used. This +;; also needs to be done at both run-time and compile-time so packages +;; can be installed at compile-time. +(eval-and-compile (package-initialize)) + +;; Refresh the package contents so packages can be installed from all +;; configured archives. Don't do this at run-time because it slows +;; down the process too much. +(eval-when-compile (package-refresh-contents)) + +;; This macro is inspired by use-package, but I want to maintain some +;; control of the syntax I use to configure my settings. +(defmacro ensure-package (package &rest args) + "Make sure PACKAGE is installed. + +ARGS should be a plist which may contain one of the following options: + +- :from + + Specify which package should actually be installed to ensure + the library named in PACKAGE exists." + (let ((library-symbol (cl-gensym)) + (package-symbol (cl-gensym))) + `(eval-when-compile + (let ((,library-symbol ',package) + (,package-symbol ',(or (plist-get args :from) package))) + (unless (and (package-installed-p ,package-symbol) + (locate-library (symbol-name ,library-symbol))) + (package-install ,package-symbol)) + (require ,library-symbol))))) + ;;;; Helper functions: ;; I have noticed that I refer to the combination of @@ -107,5 +150,23 @@ This is currently the data directory under the ;; whereabouts I am, so they just take up space. (scroll-bar-mode -1) +;;;; Minor modes: + +;;;;; Paredit: + +(ensure-package paredit) + +;;;; Major modes: + +;;;;; Scheme mode: + +(add-hook 'scheme-mode-hook 'paredit-mode) + +;;;; Applications: + +;;;;; Magit: + +(ensure-package magit) + (provide 'init) ;;; init.el ends here -- cgit v1.2.3-54-g00ecf