From 02bdf698cbcad8213937730031a686a611dc43a6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 28 Nov 2015 23:31:06 +0100 Subject: Emacs: Switch from req-package to use-package --- tag-emacs/emacs.d/init.org | 392 ++++++++++++++++++++++----------------------- 1 file changed, 189 insertions(+), 203 deletions(-) (limited to 'tag-emacs') diff --git a/tag-emacs/emacs.d/init.org b/tag-emacs/emacs.d/init.org index 7aa864f..1629bdd 100644 --- a/tag-emacs/emacs.d/init.org +++ b/tag-emacs/emacs.d/init.org @@ -29,7 +29,7 @@ the buffer to be empty. * Packaging -** Req-package +** Use-package #+BEGIN_SRC emacs-lisp (let ((trustfile @@ -52,11 +52,12 @@ the buffer to be empty. ("melpa-stable" . "https://stable.melpa.org/packages/")) package-user-dir (concat "~/.emacs.d/packages/" emacs-version "/elpa")) (package-initialize) - (unless (package-installed-p 'req-package) + (unless (package-installed-p 'use-package) (package-refresh-contents) - (package-install 'req-package)) - (require 'req-package)) - (setq use-package-verbose t) + (package-install 'use-package)) + (require 'use-package)) + (setq use-package-verbose t + use-package-ensure-always-ensure t) #+END_SRC * Customize @@ -87,7 +88,7 @@ pass =:noerror= to =load= ** The Silver Searcher #+BEGIN_SRC emacs-lisp - (req-package ag + (use-package ag :defer 30 :config (setq ag-project-root-function #'projectile-project-root)) #+END_SRC @@ -99,7 +100,7 @@ ones. I added a couple of functions to allow me to open new projects based upon some folder conventions I use. #+BEGIN_SRC emacs-lisp -(req-package projectile +(use-package projectile :bind (("C-c C-f" . projectile-find-file) ("s-x s-f" . projectile-find-file) ("C-x g" . projectile-vc) @@ -147,13 +148,12 @@ filtering the candidates to those within the project. For it to work, it needs hooking into projectile and a key bound to switch between projects. #+BEGIN_SRC emacs-lisp - (req-package perspective + (use-package perspective :bind (("s-p" . persp-switch)) :init (progn (persp-mode))) - (req-package persp-projectile - :require (projectile perspective)) + (use-package persp-projectile) #+END_SRC ** vc @@ -162,7 +162,7 @@ This is nice for some things that magit doesn’t do, and for those rare occasions that I’m working with something other than git. #+BEGIN_SRC emacs-lisp -(req-package vc +(use-package vc :defer t :bind (("C-x v C" . vc-resolve-conflicts)) :config (progn @@ -175,7 +175,7 @@ It’s nice to be able to see at a glance which lines of a file have changed. This package colours the fringe #+BEGIN_SRC emacs-lisp - (req-package diff-hl + (use-package diff-hl :defer 2 :init (progn (global-diff-hl-mode 1) @@ -188,7 +188,7 @@ Magit is my favourite way to use git. I use selective staging all the time. Make sure to set it up with a nice =completing-read-function= #+BEGIN_SRC emacs-lisp - (req-package magit + (use-package magit :defer 5 :commands (magit-status) :config (progn (setq magit-last-seen-setup-instructions "1.4.0" @@ -209,7 +209,7 @@ in the past. I often find it useful when I remember writing something a particular way, but it changed later. #+BEGIN_SRC emacs-lisp - (req-package git-timemachine) + (use-package git-timemachine) #+END_SRC * Styles @@ -243,7 +243,7 @@ Ring the bell sometimes, but not so often When I’m using dash in emacs lisp, it’s nice to have proper font locking for it. #+BEGIN_SRC emacs-lisp - (req-package dash + (use-package dash :commands (dash-enable-font-lock) :init (progn (add-hook 'emacs-lisp-mode-hook #'dash-enable-font-lock))) @@ -254,7 +254,7 @@ locking for it. I quite like solarized. I don’t think it’s perfect, but it supports a lot of modes. #+BEGIN_SRC emacs-lisp - (req-package solarized-theme + (use-package solarized-theme :config (progn (load-theme 'solarized-light t))) #+END_SRC @@ -262,7 +262,7 @@ lot of modes. Colourise colour names in certain types of buffer. I don’t use this in modes for webdev because [[web-mode]] includes that functionality. #+BEGIN_SRC emacs-lisp -(req-package rainbow-mode +(use-package rainbow-mode :commands (rainbow-turn-on rainbow-turn-off) :config (progn @@ -271,7 +271,7 @@ in modes for webdev because [[web-mode]] includes that functionality. Highlighting quasi-quoted expressions in lisps is quite useful. #+BEGIN_SRC emacs-lisp -(req-package highlight-stages +(use-package highlight-stages :defer t :diminish highlight-stages-mode :init (progn @@ -324,7 +324,7 @@ these settings are particularly useful By default, Emacs displays page breaks as ^L. Lines look much nicer. #+BEGIN_SRC emacs-lisp - (req-package page-break-lines + (use-package page-break-lines :defer 5 :config (global-page-break-lines-mode)) #+END_SRC @@ -359,7 +359,7 @@ trash for deleting on OS X. ** autorevert #+BEGIN_SRC emacs-lisp -(req-package autorevert +(use-package autorevert :init (progn (global-auto-revert-mode 1) (setq auto-revert-verbose nil))) @@ -443,7 +443,7 @@ I don’t like it when editors change an entire file’s layout when I open it. Whitespace butler fixes whitespace only for lines that I’m editing. #+BEGIN_SRC emacs-lisp -(req-package ws-butler +(use-package ws-butler :if window-system :config (ws-butler-global-mode 1)) (if (daemonp) @@ -456,7 +456,7 @@ DWIM whitespace removal. So I don’t need =M-SPC=, =M-\= and =C-x o= for similar things any more. #+BEGIN_SRC emacs-lisp - (req-package shrink-whitespace + (use-package shrink-whitespace :bind ("M-SPC" . shrink-whitespace)) #+END_SRC @@ -465,7 +465,7 @@ for similar things any more. I only use this occasionally, but it’s nice for files outside of projects. #+BEGIN_SRC emacs-lisp -(req-package recentf +(use-package recentf :init (progn (setq recentf-auto-cleanup 'never recentf-save-file (expand-file-name "recentf" user-emacs-directory)) (recentf-mode 1))) @@ -476,7 +476,7 @@ I only use this occasionally, but it’s nice for files outside of projects. An awesome way to open files on OS X. #+BEGIN_SRC emacs-lisp - (req-package spotlight + (use-package spotlight :defer 10 :if (eq system-type 'darwin) :config (setq spotlight-tmp-file "/tmp/.emacs-spotlight-tmp-file")) @@ -488,7 +488,7 @@ It.. saves the position I visited a file at last. Might try turning it off to see if I notice it. #+BEGIN_SRC emacs-lisp -(req-package saveplace +(use-package saveplace :config (progn (setq-default save-place nil) (setq save-place-file (expand-file-name ".saveplace" user-emacs-directory)))) #+END_SRC @@ -499,7 +499,7 @@ Tramp is awesome. It makes SSH feel Unix-y. The proxy setup is so that I can sudo on remote machines #+BEGIN_SRC emacs-lisp - (req-package tramp + (use-package tramp :defer 7 :config (progn (setq tramp-default-method (if (eq system-type 'windows-nt) "plinkx" "ssh") @@ -516,8 +516,7 @@ that I can sudo on remote machines (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) (add-to-list 'tramp-default-proxies-alist '("router" nil nil)))) - (req-package tramp-sh - :require tramp + (use-package tramp-sh :defer t :config (progn (add-to-list 'tramp-remote-path "/usr/local/sbin") @@ -529,7 +528,7 @@ that I can sudo on remote machines I like a horizonal diff setup, with everything in one frame. #+BEGIN_SRC emacs-lisp -(req-package ediff +(use-package ediff :defer t :config (progn (setq ediff-split-window-function 'split-window-horizontally @@ -557,7 +556,7 @@ Don’t make me think, just indent it! Unless it’s a whitespace-sensitive language, of course. #+BEGIN_SRC emacs-lisp - (req-package auto-indent-mode + (use-package auto-indent-mode :config (progn (setq auto-indent-key-for-end-of-line-then-newline "" auto-indent-key-for-end-of-line-insert-char-then-newline "" @@ -584,15 +583,18 @@ Not related to [[smart-tab][=smart-tab=]], this mode indents with tabs and align with spaces. Perfect! #+BEGIN_SRC emacs-lisp - (req-package smart-tabs-mode + (use-package smart-tabs-mode :defer 1 :config (progn - (smart-tabs-mode/no-tabs-mode-advice align) - (smart-tabs-mode/no-tabs-mode-advice align-regexp) - (smart-tabs-mode/no-tabs-mode-advice indent-relative) - (smart-tabs-mode/no-tabs-mode-advice comment-dwim) - (smart-tabs-mode/no-tabs-mode-advice comment-box) - (smart-tabs-mode/no-tabs-mode-advice comment-indent) + (with-eval-after-load 'align + (smart-tabs-mode/no-tabs-mode-advice align) + (smart-tabs-mode/no-tabs-mode-advice align-regexp)) + (eval-after-load "indent.el" + '(smart-tabs-mode/no-tabs-mode-advice indent-relative)) + (eval-after-load "newcomment.el" + '(progn (smart-tabs-mode/no-tabs-mode-advice comment-dwim) + (smart-tabs-mode/no-tabs-mode-advice comment-box) + (smart-tabs-mode/no-tabs-mode-advice comment-indent))) (unless (ad-find-advice 'indent-according-to-mode 'around 'smart-tabs) @@ -617,7 +619,7 @@ Sometimes people use different indentation settings. [[https://github.com/jschei guesses the correct settings for me. #+BEGIN_SRC emacs-lisp - (req-package dtrt-indent + (use-package dtrt-indent :init (dtrt-indent-mode 1) :config (progn (defadvice dtrt-indent-try-set-offset (after toggle-smart-tabs activate) @@ -630,7 +632,7 @@ guesses the correct settings for me. This is a frontend to the GPG-powered =pass= program. #+BEGIN_SRC emacs-lisp - (req-package password-store + (use-package password-store :defer 15 :config (progn (setq password-store-password-length 16))) @@ -642,7 +644,7 @@ Ibuffer is quite nice for listing all buffers. I don’t use it very often though, as it doesn’t really work with perspectives. #+BEGIN_SRC emacs-lisp -(req-package ibuffer +(use-package ibuffer :bind (("C-x C-b" . ibuffer)) :config (progn (setq ibuffer-saved-filter-groups @@ -677,7 +679,7 @@ often though, as it doesn’t really work with perspectives. ** Relative Buffer names #+BEGIN_SRC emacs-lisp - (req-package relative-buffers + (use-package relative-buffers :init (progn (global-relative-buffers-mode))) #+END_SRC @@ -697,7 +699,7 @@ I don’t often have many windows open at once, but when I do, =ace-window= is really nice to jump around them in the same way that =ace-jump= or =avy= work. #+BEGIN_SRC emacs-lisp -(req-package ace-window +(use-package ace-window :bind (("s-s" . ace-window)) :config (progn (setq aw-dispatch-always t @@ -751,7 +753,7 @@ A dedicated window always keeps the same buffer in view. Undo, for window-based commands. #+BEGIN_SRC emacs-lisp -(req-package winner +(use-package winner :init (progn (winner-mode 1) (setq winner-boring-buffers '("*Completions*" "*Help*" "*Apropos*" "*Buffer List*" "*info*" "*Compile-Log*")))) @@ -762,7 +764,7 @@ Undo, for window-based commands. Directional window movement #+BEGIN_SRC emacs-lisp -(req-package windmove +(use-package windmove :bind (("S-" . windmove-left) ("S-" . windmove-right) ("S-" . windmove-up) @@ -788,7 +790,7 @@ tries to do the right thing depending on the location of the point and the line’s current indentation. #+BEGIN_SRC emacs-lisp -(req-package smart-tab +(use-package smart-tab :commands (global-smart-tab-mode) :init (global-smart-tab-mode) :diminish smart-tab-mode @@ -804,7 +806,7 @@ auto-complete-mode. I’ve not tried auto-complete-mode as company seems to work perfectly well for me. #+BEGIN_SRC emacs-lisp -(req-package company +(use-package company :commands (company-mode) :diminish "Cmpl" :bind (("C-" . company-complete)) @@ -826,7 +828,7 @@ seems to work perfectly well for me. Weeks start on Monday for me and I prefer ISO-style dates. #+BEGIN_SRC emacs-lisp - (req-package calendar + (use-package calendar :defer 1 :config (progn (setq calendar-week-start-day 1) @@ -865,14 +867,14 @@ Sometimes I want to insert a date or time into a buffer. ** Time of Day #+BEGIN_SRC emacs-lisp - (req-package osx-location + (use-package osx-location :if (eq system-type 'darwin) :config (progn (add-hook 'osx-location-changed-hook (lambda () (setq calendar-latitude osx-location-latitude calendar-longitude osx-location-longitude) - (when (featurep 'solar) + (when (boundp 'calendar-location-name) calendar-location-name (format "%s, %s" osx-location-latitude osx-location-longitude)))) (osx-location-watch))) #+END_SRC @@ -885,7 +887,7 @@ have two dired windows open, assume that I’m going to be copying/moving files between them. #+BEGIN_SRC emacs-lisp -(req-package dired +(use-package dired :defer 3 :config (progn (bind-key "" #'dired-find-file dired-mode-map) @@ -903,8 +905,7 @@ copying/moving files between them. I work with a lot of git projects. Dired-k adds colours based upon the file’s git status. #+BEGIN_SRC emacs-lisp - (req-package dired-k - :require dired + (use-package dired-k :defer 5 :init (progn (add-hook 'dired-initial-position-hook #'dired-k)) @@ -917,7 +918,11 @@ the file’s git status. Don’t show uninteresting files in dired listings. #+BEGIN_SRC emacs-lisp - (req-package dired-x + (defun turn-on-dired-omit-mode () + (interactive) + (dired-omit-mode 1)) + + (use-package dired-x :commands (dired-omit-mode dired-expunge) :config (progn @@ -925,16 +930,12 @@ Don’t show uninteresting files in dired listings. dired-omit-verbose nil dired-find-subdir t)) :init (progn - (defun turn-on-dired-omit-mode () - (interactive) - (dired-omit-mode 1)) (add-hook 'dired-mode-hook #'turn-on-dired-omit-mode))) #+END_SRC #+BEGIN_SRC emacs-lisp - (req-package dired+ + (use-package dired+ :defer 5 - :require dired :config (progn (diredp-toggle-find-file-reuse-dir 1) (unbind-key "C-h C-m" dired-mode-map) @@ -944,10 +945,11 @@ Don’t show uninteresting files in dired listings. Expand subfolders like a tree inside the parent #+BEGIN_SRC emacs-lisp - (req-package dired-subtree - :defer t - :require dired - :config (progn + (with-eval-after-load 'dired + (use-package dired-subtree + :functions (dired-subtree--get-ov + dired-subtree-maybe-up) + :init (progn (setq dired-subtree-use-backgrounds nil) (defun dired-subtree-maybe-up () "Jump up one subtree or directory" @@ -957,9 +959,8 @@ Expand subfolders like a tree inside the parent (progn (goto-char (overlay-start ov)) (dired-previous-line 1)) (dired-up-directory)))) - (bind-key "^" #'dired-subtree-maybe-up dired-mode-map)) - :init (progn - (bind-key "i" #'dired-subtree-toggle dired-mode-map))) + (bind-key "^" #'dired-subtree-maybe-up dired-mode-map) + (bind-key "i" #'dired-subtree-toggle dired-mode-map)))) #+END_SRC * Documentation @@ -970,30 +971,32 @@ Emacs’ documentation is great to read from inside Emacs. Helm-dash helps to make documentation for other languages easier to access #+BEGIN_SRC emacs-lisp -(req-package helm-dash - :defer 20 - :init (progn - (defmacro ap/create-helm-dash-hook (mode docsets) - (let* ((mode-s (symbol-name mode)) - (fun (intern (concat "helm-dash-hook-" mode-s))) - (hook (intern (concat mode-s "-mode-hook")))) - `(progn - (defun ,fun () - (when (require 'helm-dash nil :noerror) - (-each (-difference ',docsets - (helm-dash-installed-docsets)) - #'helm-dash-install-docset) - (setq-local helm-dash-docsets ',docsets))) - (add-hook (quote ,hook) (function ,fun))))) - (ap/create-helm-dash-hook nginx ("Nginx")) - (ap/create-helm-dash-hook ansible ("Ansible")) - (ap/create-helm-dash-hook php ("PHP" "Symfony")) - (ap/create-helm-dash-hook twig ("Twig")) - (ap/create-helm-dash-hook js2 ("JavaScript" "NodeJS" "jQuery" "Express")) - (ap/create-helm-dash-hook markdown ("Markdown")) - (ap/create-helm-dash-hook saltstack ("SaltStack")) - (ap/create-helm-dash-hook clojure ("Clojure")) - (ap/create-helm-dash-hook sql ("PostgreSQL" "MySQL")))) + (defmacro ap/create-helm-dash-hook (mode docsets) + (let* ((mode-s (symbol-name mode)) + (fun (intern (concat "helm-dash-hook-" mode-s))) + (hook (intern (concat mode-s "-mode-hook")))) + `(progn + (defun ,fun () + (when (require 'helm-dash nil :noerror) + (-each (-difference ',docsets + (helm-dash-installed-docsets)) + #'helm-dash-install-docset) + (setq-local helm-dash-docsets ',docsets))) + (add-hook (quote ,hook) (function ,fun))))) + + (use-package helm-dash + :defer 20 + :defines helm-dash-docsets + :config (progn + (ap/create-helm-dash-hook nginx ("Nginx")) + (ap/create-helm-dash-hook ansible ("Ansible")) + (ap/create-helm-dash-hook php ("PHP" "Symfony")) + (ap/create-helm-dash-hook twig ("Twig")) + (ap/create-helm-dash-hook js2 ("JavaScript" "NodeJS" "jQuery" "Express")) + (ap/create-helm-dash-hook markdown ("Markdown")) + (ap/create-helm-dash-hook saltstack ("SaltStack")) + (ap/create-helm-dash-hook clojure ("Clojure")) + (ap/create-helm-dash-hook sql ("PostgreSQL" "MySQL")))) #+END_SRC ** which-func @@ -1001,7 +1004,7 @@ helps to make documentation for other languages easier to access Use the modeline to show which function definition the point is in. #+BEGIN_SRC emacs-lisp -(req-package which-func +(use-package which-func :init (which-function-mode) :config (setq which-func-modes t)) #+END_SRC @@ -1011,7 +1014,7 @@ Use the modeline to show which function definition the point is in. A nicer way to browse keybindings for major modes. #+BEGIN_SRC emacs-lisp -(req-package discover-my-major +(use-package discover-my-major :bind ("C-h C-m" . discover-my-major)) #+END_SRC @@ -1021,7 +1024,7 @@ Makes some context menus for dired and other things, similarly to the way magit’s popups work. #+BEGIN_SRC emacs-lisp -(req-package discover +(use-package discover :config (global-discover-mode)) #+END_SRC @@ -1031,7 +1034,7 @@ Documentation in the echo-area (where the minibuffer is displayed) is rather useful. #+BEGIN_SRC emacs-lisp -(req-package eldoc +(use-package eldoc :commands (eldoc-mode) :diminish eldoc-mode :config (progn @@ -1109,7 +1112,7 @@ Option/alt, then Control. " nil t) (replace-match "")))) - (req-package rect + (use-package rect :init (defun copy-rectangle (start end) "Copy the region-rectangle." (interactive "r") @@ -1168,7 +1171,7 @@ Ivy is the new kid on the completion block. I wonder if it can replace helm and ido. #+BEGIN_SRC emacs-lisp - (req-package swiper + (use-package swiper :bind (("C-s" . swiper) ("C-r" . swiper) ("C-c C-r" . ivy-resume) @@ -1190,7 +1193,7 @@ replace helm and ido. ** counsel #+BEGIN_SRC emacs-lisp - (req-package counsel + (use-package counsel :bind (("M-x" . counsel-M-x) ("" . counsel-M-x) ("" . counsel-M-x) @@ -1224,8 +1227,7 @@ function uses it internally, so I’m keeping it around, even though I don’t use it directly. #+BEGIN_SRC emacs-lisp - (req-package smex - :require ido + (use-package smex :config (progn (setq smex-key-advice-ignore-menu-bar t smex-auto-update nil) @@ -1343,7 +1345,7 @@ Diminishing major modes does not happen in the same manner as minor modes. #+BEGIN_SRC emacs-lisp - (req-package cyphejor + (use-package cyphejor :init (progn (setq cyphejor-rules `(("emacs" "ε") ("diff" "Δ") @@ -1377,17 +1379,17 @@ set environment variables for projects. Some modes that I don’t really customise much, mostly for configuration files. #+BEGIN_SRC emacs-lisp - (req-package xrdb-mode + (use-package xrdb-mode :mode (("\\.Xdefaults\\'" . xrdb-mode) ("\\.Xresources\\'" . xrdb-mode))) - (req-package haskell-mode + (use-package haskell-mode :mode (("\\.hs\\'" . haskell-mode))) - (req-package dockerfile-mode + (use-package dockerfile-mode :mode (("Dockerfile\\'" . dockerfile-mode))) - (req-package nix-mode + (use-package nix-mode :mode (("\\.nix\\'" . nix-mode)) :config (progn (add-hook 'nix-mode-hook (lambda () @@ -1397,33 +1399,33 @@ configuration files. (add-to-list 'auto-mode-alist '("xmobarrc\\'" . xmonad-mode)) (add-to-list 'auto-mode-alist '("xmonad.hs\\'" . xmonad-mode)) - (req-package nginx-mode + (use-package nginx-mode :defer t :mode (("/nginx/servers/" . nginx-mode) ("/nginx/.*\\.d/" . nginx-mode)) :config (progn (setq nginx-indent-tabs-mode t))) - (req-package lua-mode + (use-package lua-mode :defer t) - (req-package ruby-mode + (use-package ruby-mode :mode (("\\.rb\\'" . ruby-mode) ("\\.cap\\'" . ruby-mode))) - (req-package go-mode + (use-package go-mode :mode (("\\.go\\'" . go-mode))) - (req-package jinja2-mode + (use-package jinja2-mode :mode (("\\.j2\\'" . jinja2-mode) ("\\.jinja\\'" . jinja2-mode))) - (req-package scss-mode + (use-package scss-mode :defer t :config (progn (setq scss-compile-at-save nil))) - (req-package yaml-mode + (use-package yaml-mode :mode (("/group_vars/.*" . yaml-mode) ("/host_vars/.*" . yaml-mode))) @@ -1440,7 +1442,7 @@ I use [[http://ledger-cli.org/][=ledger=]] to manage my finances. It has an Ema works really nicely. #+BEGIN_SRC emacs-lisp -(req-package ledger-mode +(use-package ledger-mode :mode ("\\.ledger\\'" . ledger-mode) :config (progn (defun setup-ledger-mode () @@ -1458,7 +1460,7 @@ works really nicely. ** Markdown #+BEGIN_SRC emacs-lisp -(req-package markdown-mode +(use-package markdown-mode :defer t :config (progn (add-hook 'markdown-mode-hook #'turn-on-auto-fill))) @@ -1471,7 +1473,7 @@ Org is wünderbar. *** TODO Check whether all this configuration is necessary or helpful. #+BEGIN_SRC emacs-lisp - (req-package org + (use-package org :bind (("C-c C-a" . org-agenda-list) ("C-c a" . org-agenda) ("C-c l" . org-store-link)) @@ -1535,8 +1537,7 @@ to have my =ledger= setup in an org file with some graph processing with R or something. #+BEGIN_SRC emacs-lisp -(req-package org-babel - :require org +(use-package org-babel :defer t :config (org-babel-do-load-languages 'org-babel-load-languages @@ -1549,8 +1550,7 @@ with R or something. I can use this to keep a journal. I should use it. #+BEGIN_SRC emacs-lisp - (req-package org-journal - :require org + (use-package org-journal :bind ("s-j" . org-journal-new-entry) :defer 20 :config (progn @@ -1565,8 +1565,7 @@ I can use this to keep a journal. I should use it. ***** TODO Setup org-mobile #+BEGIN_SRC emacs-lisp - (req-package org-mobile - :require org + (use-package org-mobile :defer 30 :config (progn (setq org-mobile-directory "~/Mobile/Org" @@ -1618,7 +1617,7 @@ I can use this to keep a journal. I should use it. On-the-fly error checking in programming modes? Yes please. #+BEGIN_SRC emacs-lisp -(req-package flycheck +(use-package flycheck :diminish " ✓" :init (global-flycheck-mode)) #+END_SRC @@ -1628,30 +1627,23 @@ On-the-fly error checking in programming modes? Yes please. Go has a few packages to inter-operate with other emacs packages. #+BEGIN_SRC emacs-lisp -(when (file-exists-p "src/code.google.com/p/go.tools/cmd/oracle/oracle.el") - (req-package oracle - :load-path ,(expand-file-name "src/code.google.com/p/go.tools/cmd/oracle/oracle.el" (getenv "GOPATH")) + (use-package company-go + :config (progn + (setq company-go-show-annotation t)) :init (progn - (add-hook 'go-mode-hook #'go-oracle-mode)))) - -(req-package company-go - :require go-mode - :config (progn - (setq company-go-show-annotation t) (defun ap/company-go-setup () (set (make-local-variable 'company-backends) '(company-go))) (add-hook 'go-mode-hook #'ap/company-go-setup))) -(req-package go-eldoc - :require go-mode - :config (progn + (use-package go-eldoc + :init (progn (add-hook 'go-mode-hook #'go-eldoc-setup))) -(req-package go-projectile - :require (go-mode go-eldoc projectile) - :config (progn - (setq go-projectile-switch-gopath 'maybe))) + (use-package go-projectile + :defer t + :config (progn + (setq go-projectile-switch-gopath 'maybe))) #+END_SRC @@ -1661,7 +1653,7 @@ Go has a few packages to inter-operate with other emacs packages. A nice completion backend for programming modes. #+BEGIN_SRC emacs-lisp -(req-package ggtags +(use-package ggtags :commands turn-on-ggtags-mode :config (progn (bind-key "q" #'ggtags-navigation-mode-abort ggtags-navigation-mode-map)) @@ -1697,7 +1689,7 @@ Lisp syntax allows for really easy refactoring. Redshank gives some operations that aren’t part of paredit, like extracting variables into let bindings. #+BEGIN_SRC emacs-lisp -(req-package redshank +(use-package redshank :diminish " Λ" :defer t :init (progn @@ -1717,7 +1709,7 @@ it runs the common lisp hooks. Go-to function for elisp. Except it works through the entire Emacs ecosystem. #+BEGIN_SRC emacs-lisp - (req-package elisp-slime-nav + (use-package elisp-slime-nav :commands elisp-slime-nav-mode :diminish elisp-slime-nav-mode :init (progn @@ -1727,7 +1719,7 @@ Go-to function for elisp. Except it works through the entire Emacs ecosystem. Interactive elisp #+BEGIN_SRC emacs-lisp -(req-package ielm +(use-package ielm :defer t :config (progn (add-hook 'ielm-mode-hook (lambda () @@ -1771,7 +1763,7 @@ A REPL thing for Scheme. Hopefully I’ll get to use it more in the future. #+BEGIN_SRC emacs-lisp -(req-package geiser +(use-package geiser :commands (geiser-mode geiser run-geiser @@ -1783,7 +1775,7 @@ future. A REPL thing (and more) for Lisp. #+BEGIN_SRC emacs-lisp -(req-package slime +(use-package slime :commands (slime) :config (progn (let ((ql-slime-helper (expand-file-name "~/quicklisp/slime-helper.el"))) @@ -1796,21 +1788,20 @@ A REPL thing (and more) for Lisp. *** Clojure #+BEGIN_SRC emacs-lisp -(req-package clojure-mode - :defer t - :init (progn - (add-hook 'cider-repl-mode-hook (lambda () (highlight-changes-mode -1))) - (add-hook 'clojure-mode-hook #'ap/lisp-setup))) + (use-package clojure-mode + :defer t + :init (progn + (add-hook 'cider-repl-mode-hook (lambda () (highlight-changes-mode -1))) + (add-hook 'clojure-mode-hook #'ap/lisp-setup))) -(req-package clj-refactor - :defer t - :require clojure-mode - :config (progn - (cljr-add-keybindings-with-prefix "C-c C-m")) - :init (progn - (defun turn-on-clj-refactor-mode () - (clj-refactor-mode 1)) - (add-hook 'clojure-mode-hook #'turn-on-clj-refactor-mode))) + (use-package clj-refactor + :defer t + :config (progn + (cljr-add-keybindings-with-prefix "C-c C-m")) + :init (progn + (defun turn-on-clj-refactor-mode () + (clj-refactor-mode 1)) + (add-hook 'clojure-mode-hook #'turn-on-clj-refactor-mode))) #+END_SRC **** cider @@ -1818,8 +1809,7 @@ A REPL thing (and more) for Lisp. A REPL thing for Clojure #+BEGIN_SRC emacs-lisp -(req-package cider - :require clojure-mode +(use-package cider :defer t :config (progn (setq nrepl-hide-special-buffers t) @@ -1831,7 +1821,7 @@ A REPL thing for Clojure Auto-compile emacs lisp when saving. #+BEGIN_SRC emacs-lisp -(req-package auto-compile +(use-package auto-compile :defer t :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) #+END_SRC @@ -1842,7 +1832,7 @@ Although I don’t use C or C++, setting up the mode is helpful because quite a few other modes are derived from it. #+BEGIN_SRC emacs-lisp -(req-package cc-mode +(use-package cc-mode :defer 5 :init (progn (add-hook 'c-mode-common-hook #'electric-indent-mode)) @@ -1859,7 +1849,7 @@ quite a few other modes are derived from it. It’s nice to be able to quickly evaluate some code. Although I don’t really seem to use it. #+BEGIN_SRC emacs-lisp -(req-package quickrun +(use-package quickrun :bind (("C-c C-e" . quickrun))) #+END_SRC @@ -1873,7 +1863,7 @@ think there’s anything as good as paredit/redshank for refactoring in it though #+BEGIN_SRC emacs-lisp - (req-package js2-mode + (use-package js2-mode :mode ("\\.js\\'" . js2-mode) :functions js2-next-error :config (progn @@ -1894,7 +1884,7 @@ it though *** coffee-mode #+BEGIN_SRC emacs-lisp - (req-package coffee-mode + (use-package coffee-mode :mode ("\\.coffee\\'" . coffee-mode)) #+END_SRC @@ -1904,7 +1894,7 @@ Tern understands javascript. It adds really clever documented completions, besides other IDE-like things. #+BEGIN_SRC emacs-lisp - (req-package tern + (use-package tern :commands ap/enable-tern :defer 5 :config (progn @@ -1913,15 +1903,14 @@ completions, besides other IDE-like things. (tern-mode 1)) (add-hook 'js2-mode-hook #'ap/enable-tern))) - (req-package company-tern - :defer 5 - :require (tern company)) + (with-eval-after-load 'tern + (use-package company-tern)) #+END_SRC *** json-mode #+BEGIN_SRC emacs-lisp - (req-package json-mode + (use-package json-mode :mode (("\\.json\\'" . json-mode) ("\\.sailsrc\\'" . json-mode))) #+END_SRC @@ -1933,7 +1922,7 @@ calls. Feels a bit like using =org-babel=. I wonder if there’s an integration between the two yet. #+BEGIN_SRC emacs-lisp -(req-package restclient +(use-package restclient :mode ("\\.api\\'" . restclient-mode) :config (progn (defun imenu-restclient-sections () @@ -1947,7 +1936,7 @@ integration between the two yet. This is for HTML, since old versions of HTML were derived from SGML. #+BEGIN_SRC emacs-lisp -(req-package sgml-mode +(use-package sgml-mode :defer t :config (setq sgml-basic-offset 4)) #+END_SRC @@ -1957,7 +1946,7 @@ This is for HTML, since old versions of HTML were derived from SGML. Emmet is really nice to write HTML quickly. Especially with frameworks that require multiple nested elements to do anything useful. #+BEGIN_SRC emacs-lisp -(req-package emmet-mode +(use-package emmet-mode :commands (emmet-mode) :diminish (emmet-mode . " >") :init (progn @@ -1972,7 +1961,7 @@ is really nice, because it handles the HTML part the same way in all of them as well. #+BEGIN_SRC emacs-lisp -(req-package web-mode +(use-package web-mode :mode (("/views/.*\\.php\\'" . web-mode) ("/layouts/.*\\.html\\'" . web-mode) ("/templates/.*\\.php\\'" . web-mode) @@ -1999,7 +1988,7 @@ With =web-mode= being so good, I don’t really use this much. It’s good for embedded SQL though. #+BEGIN_SRC emacs-lisp - (req-package mmm-auto + (use-package mmm-auto :ensure mmm-mode :config (progn (mmm-add-classes @@ -2035,7 +2024,7 @@ good for embedded SQL though. * Spelling #+BEGIN_SRC emacs-lisp -(req-package ispell +(use-package ispell :bind (("" . ispell-word)) :config (progn (setq ispell-program-name "aspell" @@ -2052,7 +2041,7 @@ Make a shell-script buffer executable after saving it, if it has a shebang. (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) -(req-package sh-script +(use-package sh-script :mode (("\\.zsh\\'" . shell-script-mode)) :config (setq sh-shell-file "/usr/bin/env zsh")) #+END_SRC @@ -2067,15 +2056,15 @@ I should try to get into the habit of using this more. It’s really nice, when I remember to use it. #+BEGIN_SRC emacs-lisp - (req-package eshell + (use-package eshell :bind ("C-c s" . eshell) :config (progn (setq eshell-directory-name "~/.emacs.d/eshell") (add-hook 'eshell-load-hook (lambda () (bind-key "C-c C-l" #'helm-eshell-history eshell-mode-map))))) - (req-package em-smart - :require eshell + (use-package em-smart + :commands eshell-smart-initialize :init (progn (add-hook 'eshell-load-hook #'eshell-smart-initialize)) :config (progn @@ -2095,23 +2084,23 @@ nice, when I remember to use it. #+END_SRC #+BEGIN_SRC emacs-lisp - (req-package esh-buf-stack - :require eshell - :config (progn - (setup-eshell-buf-stack) + (with-eval-after-load 'eshell + (use-package esh-buf-stack + :init (progn (add-hook 'eshell-load-hook (lambda () - (bind-key "M-q" #'eshell-push-command eshell-mode-map))))) + (setup-eshell-buf-stack) + (bind-key "M-q" #'eshell-push-command eshell-mode-map)))))) #+END_SRC *** Shells #+BEGIN_SRC emacs-lisp - (req-package shell + (use-package shell :defer t :config (define-key shell-mode-map (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer)) - (req-package comint + (use-package comint :defer t :config (bind-key "C-c C-l" #'helm-comint-input-ring comint-mode-map)) @@ -2139,7 +2128,7 @@ Emacs has an editor within. The most important one for me is JSON property alignment. #+BEGIN_SRC emacs-lisp - (req-package align + (use-package align :defer 10 :config (progn (add-to-list 'align-rules-list @@ -2192,7 +2181,7 @@ symbol, not word, as I need this for programming the most." Sub-word movement is really nice for camel- and Pascal-case #+BEGIN_SRC emacs-lisp -(req-package subword +(use-package subword :init (global-subword-mode t)) #+END_SRC @@ -2200,7 +2189,7 @@ I find that =zap-up-to-char= normally makes more sense to me than =zap-to-char=. #+BEGIN_SRC emacs-lisp -(req-package misc +(use-package misc :bind (("M-z" . zap-up-to-char) ("M-Z" . zap-to-char))) #+END_SRC @@ -2209,7 +2198,7 @@ Expanding the region by semantic units was something I quite liked from Sublime Text. As always, there’s a mode for that. #+BEGIN_SRC emacs-lisp -(req-package expand-region +(use-package expand-region :bind ("C-M-SPC" . er/expand-region)) #+END_SRC @@ -2219,7 +2208,7 @@ I like using typographic symbols, but I don’t always remember (how) to type them. #+BEGIN_SRC emacs-lisp - (req-package typo + (use-package typo :config (progn (typo-global-mode 1)) :init (progn @@ -2232,7 +2221,7 @@ Avy is a really nice way to move around files, like ace-jump-mode, but somehow I prefer it. #+BEGIN_SRC emacs-lisp -(req-package avy +(use-package avy :bind* (("M-g g" . avy-goto-line) ("M-g M-g" . avy-goto-line) ("C-|" . avy-goto-line) @@ -2248,7 +2237,7 @@ This is like popping the mark, only it filters to only change areas and doesn’t go back to the same place more than once. #+BEGIN_SRC emacs-lisp -(req-package goto-chg +(use-package goto-chg :bind ("C-x SPC" . goto-last-change)) #+END_SRC @@ -2259,7 +2248,7 @@ cursors was one of my favourite features, so I was really happy when I saw that multiple-cursors was released for Emacs. #+BEGIN_SRC emacs-lisp -(req-package multiple-cursors +(use-package multiple-cursors :defer 1 :config (progn (bind-key "C-." #'mc/mark-next-like-this) @@ -2275,7 +2264,7 @@ Balanced parentheses in lisps are nice, but all the refactoring and movement commands are much more interesting. #+BEGIN_SRC emacs-lisp -(req-package paredit +(use-package paredit :diminish "()" :commands (paredit-mode) :init (progn @@ -2296,7 +2285,8 @@ I didn’t find smartparens’ implementation of paredit style to be as nice as the real version #+BEGIN_SRC emacs-lisp - (req-package smartparens-config + (eval-when-compile (require 'smartparens)) + (use-package smartparens-config :ensure smartparens :config (progn (sp-use-smartparens-bindings) @@ -2327,7 +2317,7 @@ nice as the real version Transposing lines, made easier. #+BEGIN_SRC emacs-lisp -(req-package move-text +(use-package move-text :config (move-text-default-bindings)) #+END_SRC @@ -2337,7 +2327,7 @@ Emacs’ default handling of undo is a bit confusing. Undo-tree makes it much clearer. It’s especially helpful for protoyping and refactoring. #+BEGIN_SRC emacs-lisp -(req-package undo-tree +(use-package undo-tree :config (progn (global-undo-tree-mode) ;; Keep region when undoing in region @@ -2361,7 +2351,7 @@ so this package is pretty useful because it highlights everything in the buffer for me. #+BEGIN_SRC emacs-lisp -(req-package visual-regexp +(use-package visual-regexp :bind (("C-c r" . vr/replace) ("C-c q" . vr/query-replace) ("C-c m" . vc/mc-mark))) @@ -2381,7 +2371,7 @@ to the =after-save-hook= ensuring to always tangle and byte-compile the =org=-document after changes. #+BEGIN_SRC emacs-lisp - (req-package async + (use-package async :commands (async-start) :defer 2) @@ -2413,10 +2403,6 @@ the =org=-document after changes. # End: * End -#+BEGIN_SRC emacs-lisp -(req-package-finish) -#+END_SRC - Start a server if possible. A daemon is already a server. #+BEGIN_SRC emacs-lisp (unless (daemonp) -- cgit 1.4.1