From 32f7510f448e3ce64dc5a79b5adc490959dc30fa Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Thu, 14 Jul 2016 09:14:49 -0700 Subject: [emacs] remove "use-package". Stop using the "use-package" module, and rewrite the configuration without it. --- emacs.d/init.el | 326 +++++++++++++++++++++++++------------------------------- 1 file changed, 145 insertions(+), 181 deletions(-) diff --git a/emacs.d/init.el b/emacs.d/init.el index 090695a..5914c0f 100644 --- a/emacs.d/init.el +++ b/emacs.d/init.el @@ -1,7 +1,6 @@ (require 'package) (setq package-user-dir "~/.emacs.d/var/elpa") -;;; Code: (setq package-archives (append package-archives '(("melpa" . "https://melpa.milkbox.net/packages/")))) @@ -13,13 +12,34 @@ (message "Refreshing ELPA package archives...") (package-refresh-contents)) -(unless (package-installed-p 'use-package) - (message "`use-package' not found. Installing...") - (package-install 'use-package)) - -(require 'use-package) -(setq use-package-minimum-reported-time 0 - use-package-verbose t) +(defvar package-list) +(setq package-list + '( + ag + ansible + ansible-doc + counsel + exec-path-from-shell + flycheck + flycheck-pos-tip + flyspell + geiser + go-eldoc + go-mode + helm + magit + markdown-mode + material-theme + projectile + puppet-mode + swiper + thrift + )) + +;; Install any missing packages +(dolist (package package-list) + (unless (package-installed-p package) + (package-install package))) ;; alias yes-or-no to y-or-n (fset 'yes-or-no-p 'y-or-n-p) @@ -43,10 +63,10 @@ (setq-default indent-tabs-mode nil) ;; nice font -(set-face-attribute 'default nil :font "Source Code Pro" :height 130) -(set-background-color "#FFFFE4") -(set-face-attribute 'fringe nil :background "#FFFFE5") -(set-face-background 'mode-line "#E5FFFF") +(set-face-attribute 'default nil :font "Source Code Pro" :height 150) +(set-background-color "#FFFFD3") +(set-face-attribute 'fringe nil :background "#FFFFD3") +(set-face-background 'mode-line "#D8E6F3") ;; no menu (menu-bar-mode -1) @@ -72,86 +92,65 @@ (scroll-bar-mode 0) ;;hide scroll-bar (menu-bar-mode -1)) ;;hide menu-bar -;; no frindge -(set-fringe-mode 0) +;; no frindge on the right +(fringe-mode '(4 . 0)) ;; auto close bracket insertion (electric-pair-mode 1) ;; if running in macos, load environment variables (when (memq window-system '(mac ns x)) - (use-package exec-path-from-shell - :ensure t - :init (setq exec-path-from-shell-debug +1) - :config - (exec-path-from-shell-initialize) - (exec-path-from-shell-copy-envs '("TMPDIR")))) - -;; I want dired -(use-package dired - :commands dired - :init - (setq dired-listing-switches "-laGhv")) - -;; install recentf -(use-package recentf - :config - (setq recentf-save-file "~/.emacs.d/var/recentf")) - -;; get counsel and swiper -(use-package swiper - :ensure t - :bind (("C-s" . swiper)) - :config - (setq ivy-use-virtual-buffers t) - (ivy-mode)) - -(use-package counsel - :ensure t - :config - (setq counsel-find-file-at-point t)) - -;; I need helm -(use-package helm - :ensure t) - -;; interface to ag -(use-package ag - :ensure t - :defer t) - -;; get projectile -(use-package projectile - :ensure t - :init - (setq projectile-enable-caching t) - (setq projectile-completion-system 'ivy) - (setq projectile-known-projects-file "~/.emacs.d/var/projectile-bookmarks.eld") - (setq projectile-cache-file "~/.emacs.d/var/projectile.cache") - :config - (projectile-global-mode)) + (exec-path-from-shell-initialize) + (exec-path-from-shell-copy-envs '("TMPDIR"))) + +;; use dired and set default switches +(require 'dired) +(setq dired-listing-switches "-laGhv") + +;; configure default path to save recent files +(require 'recentf) +(setq recentf-save-file "~/.emacs.d/var/recentf") + +;; swiper +(require 'swiper) +(setq ivy-use-virtual-buffers t) +(global-set-key (kbd "C-s") 'swiper) +(ivy-mode) + +;; counsel +(require 'counsel) +(setq counsel-find-file-at-point t) + +;; helm +(require 'helm) + +;; interface to ag (the silver surfer) +(require 'ag) + +;; projectile (great for project management!) +(require 'projectile) +(setq projectile-enable-caching t) +(setq projectile-completion-system 'ivy) +(setq projectile-known-projects-file "~/.emacs.d/var/projectile-bookmarks.eld") +(setq projectile-cache-file "~/.emacs.d/var/projectile.cache") +(projectile-global-mode) ;; check my spelling, it can only help -(use-package flyspell - :ensure t - :init - (progn - (setq ispell-program-name "aspell" - ispell-list-command "--list") - (add-hook 'prog-mode-hook 'flyspell-prog-mode) - (add-hook 'text-mode-hook 'turn-on-flyspell) - (add-hook 'org-mode-hook 'turn-on-flyspell))) +(require 'flyspell) +(setq ispell-program-name "aspell" + ispell-list-command "--list") +(add-hook 'prog-mode-hook 'flyspell-prog-mode) +(add-hook 'text-mode-hook 'turn-on-flyspell) +(add-hook 'org-mode-hook 'turn-on-flyspell) ;; this makes emacs slow to work with source (delete 'Git vc-handled-backends) -(use-package magit - :ensure t - :bind ("C-x g" . magit-status) - :config - (progn - (setq magit-completing-read-function 'ivy-completing-read) - (setq magit-item-highlight-face 'bold))) +;; magit! +(require 'magit) +(setq magit-completing-read-function 'ivy-completing-read + magit-item-highlight-face 'bold) +(global-set-key (kbd "C-x g") 'magit-status) ;; run magit in full screen ;; http://www.lunaryorn.com/2016/04/28/fullscreen-magit-status.html @@ -173,32 +172,24 @@ Return the new window for BUFFER." ;; pants related stuff (load-file "~/src/pants.el/pants.el") - -(use-package pants - :bind (("C-c b" . pants-find-build-file) - ("C-c r" . pants-run-binary) - ("C-c t" . pants-run-test)) - :config - (progn - (setq pants-source-tree-root "/Users/fcuny/src/source" - pants-bury-compilation-buffer t))) +(require 'pants) +(setq pants-source-tree-root "/Users/fcuny/src/source" + pants-bury-compilation-buffer t) +(global-set-key (kbd "C-c b") 'pants-find-build-file) +(global-set-key (kbd "C-c r") 'pants-run-binary) +(global-set-key (kbd "C-c t") 'pants-run-test) ;; validate the syntax on the fly -(use-package flycheck - :ensure t - :defer t - :preface (progn - (defun check-source-predicate () - (and (executable-find "check.pex") - (buffer-file-name) - (string-match "src/source/.*\.py$" (buffer-file-name))))) - :init - (progn - (add-hook 'prog-mode-hook 'flycheck-mode) - (setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc))) - :config - (progn - (setq flycheck-mode-line +(require 'flycheck) +(defun check-source-predicate () + (and (executable-find "check.pex") + (buffer-file-name) + (string-match "src/source/.*\.py$" (buffer-file-name)))) + +(add-hook 'prog-mode-hook 'flycheck-mode) +(setq-default flycheck-disabled-checkers '(emacs-lisp-checkdoc)) + +(setq flycheck-mode-line '(:eval (pcase flycheck-last-status-change (`not-checked nil) @@ -217,33 +208,24 @@ Return the new window for BUFFER." (`interrupted " -") (`suspicious '(propertize " ?" 'face 'warning))))) - (setq flycheck-puppet-lint-rc "/Users/fcuny/src/twitter-ops/utilities/puppet/.puppet-lint.rc") - - (flycheck-define-checker source-check - "A syntax checker for python source code in Source, using `check.pex'" - :command ("check.pex" source) - ;;; errors are reported like this: - ;;; E241:ERROR : - :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end) - (warning line-start (id (1+ nonl)) ":WARNING" (1+ nonl) ":" line (message) line-end)) - :predicate check-source-predicate - :modes (python-mode)) - (add-to-list 'flycheck-checkers 'source-check))) - -(use-package flycheck-pos-tip - :defer t - :init - (progn - (eval-after-load 'feature-flycheck - '(setq-default flycheck-display-errors-function #'flycheck-pos-tip-error-messages))) - :ensure t) +(flycheck-define-checker source-check + "A syntax checker for python source code in Source, using `check.pex'" + :command ("check.pex" source) + ;;; errors are reported like this: + ;;; E241:ERROR : + :error-patterns ((error line-start (id (1+ nonl)) ":ERROR" (1+ nonl) ":" line (message) line-end) + (warning line-start (id (1+ nonl)) ":WARNING" (1+ nonl) ":" line (message) line-end)) + :predicate check-source-predicate + :modes (python-mode)) +(add-to-list 'flycheck-checkers 'source-check) + +(require 'flycheck-pos-tip) +(eval-after-load 'feature-flycheck + '(setq-default flycheck-display-errors-function #'flycheck-pos-tip-error-messages)) ;; configuration for ansible -(use-package ansible - :ensure t) - -(use-package ansible-doc - :ensure t) +(require 'ansible) +(require 'ansible-doc) ;; configuration for puppet (when (memq window-system '(mac ns x)) @@ -251,23 +233,16 @@ Return the new window for BUFFER." (unless (getenv var) (exec-path-from-shell-copy-env var)))) -(use-package puppet-mode - :ensure t - :mode ("\\.pp$" . puppet-mode) - :init - (progn - (add-hook 'puppet-mode-hook 'flycheck-mode))) +(setq flycheck-puppet-lint-rc "/Users/fcuny/src/twitter-ops/utilities/puppet/.puppet-lint.rc") + +(require 'puppet-mode) +(add-hook 'puppet-mode-hook 'flycheck-mode) ;; configuration for thrift -(use-package thrift - :ensure t - :defer t) +(require 'thrift) ;; configuration for yaml -(use-package yaml-mode - :mode ("\\.\\(yml\\|yaml\\)\\'" . yaml-mode) - :ensure t - :defer t) +(require 'yaml-mode) ;; configuration for go (when (memq window-system '(mac ns x)) @@ -275,47 +250,37 @@ Return the new window for BUFFER." (unless (getenv var) (exec-path-from-shell-copy-env var)))) -(use-package go-mode - :ensure t - :defer t - :config - (progn - (bind-key "C-c C-f" 'gofmt go-mode-map) - (bind-key "C-c h" 'godoc go-mode-map) - (bind-key "C-c C-g" 'go-goto-imports go-mode-map) - (bind-key "C-c C-r" 'go-remove-unused-imports go-mode-map)) - :init - (progn (add-hook 'go-mode-hook (lambda () - (go-eldoc-setup) - (add-hook 'before-save-hook 'gofmt-before-save))))) - -(use-package go-eldoc - :ensure t - :defer t - :init (add-hook 'go-mode-hook 'go-eldoc-setup)) +(require 'go-mode) +(add-hook 'go-mode-hook (lambda () + (go-eldoc-setup) + (add-hook 'before-save-hook 'gofmt-before-save))) + + ;; (bind-key "C-c C-f" 'gofmt go-mode-map) + ;; (bind-key "C-c h" 'godoc go-mode-map) + + ;; (bind-key "C-c C-g" 'go-goto-imports go-mode-map) + ;; (bind-key "C-c C-r" 'go-remove-unused-imports go-mode-map)) + +(require 'go-eldoc) +(add-hook 'go-mode-hook 'go-eldoc-setup) ;; configuration for markdown -(use-package markdown-mode - :ensure t - :mode ("\\.\\(m\\(ark\\)?down\\|md\\)$" . markdown-mode) - :config - (progn - (let ((preferred-markdown-impl "peg-markdown")) - (when (executable-find preferred-markdown-impl) - (setq markdown-command preferred-markdown-impl))))) +(require 'markdown-mode) +(let ((preferred-markdown-impl "peg-markdown")) + (when (executable-find preferred-markdown-impl) + (setq markdown-command preferred-markdown-impl))) ;; configuration for python -(use-package python - :mode ("BUILD\\|\\(\\.\\(py\\|aurora\\)\\)$" . python-mode) - :config - (progn - (setq python-indent-offset 2))) +(require 'python) +(setq python-indent-offset 2) + +;; (use-package python + ;; :mode ("BUILD\\|\\(\\.\\(py\\|aurora\\)\\)$" . python-mode) + ;; configuration for racket -(use-package geiser - :config - (setq geiser-active-implementations '(racket)) - :ensure t) +(require 'geiser) +(setq geiser-active-implementations '(racket)) ;; configuration for shell (setq-default @@ -363,7 +328,6 @@ Return the new window for BUFFER." (message "File '%s' successfully renamed to '%s'" name (file-name-nondirectory new-name)))))))) ;; start the server if not already running -(use-package server - :config - (unless (server-running-p) - (server-start))) +(require 'server) +(unless (server-running-p) + (server-start)) -- cgit 1.4.1