dotfiles/emacs.d/init.el

203 lines
6.0 KiB
EmacsLisp
Raw Normal View History

2017-02-22 21:49:21 -07:00
;; init.el
;;
;; Emacs Configuration
;;
;; Author: Kevin Cotugno git@kevincotugno.com
;; Date: 2/22/17
;; Package
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
2017-10-16 07:39:58 -07:00
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(add-to-list 'exec-path "/usr/local/bin")
2018-02-13 11:48:17 -07:00
(defun directory-files-no-directories (path)
"Return the list of files in PATH excluding and directories"
(seq-filter (lambda (item)
(not (null item)))
(mapcar (lambda (item)
(if (not (eq (nth 1 item) 't))
(car item)))
(directory-files-and-attributes path 't))))
(defun update-env-var (var list)
"Prepend LIST to the specified environment variable"
(mapc (lambda (dir)
(when (not (string-equal dir ""))
(if (or (null (getenv var)) (string-equal (getenv var) ""))
(setenv var dir)
(setenv var (format "%s:%s"
dir
(getenv var))))))
list))
(if (eq system-type 'darwin)
(update-env-var "PATH" (with-temp-buffer
(mapcar (lambda (item)
(insert-file-contents item))
(directory-files-no-directories "/etc/paths.d"))
(insert-file-contents "/etc/paths")
(split-string (buffer-string) "\n" t))))
2017-02-22 21:49:21 -07:00
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure t)
;; Display
(set-default-font "Source Code Pro-12")
(line-number-mode t)
(global-linum-mode t)
(menu-bar-mode -1)
(tool-bar-mode -1)
2017-02-27 21:03:28 -07:00
(setq inhibit-startup-screen t)
2017-05-23 10:37:04 -07:00
(setq-default truncate-lines t)
(setq-default truncate-partial-width-windows nil)
2017-02-22 21:49:21 -07:00
2017-05-23 10:37:04 -07:00
(setq-default scroll-conservatively 100)
2017-03-29 14:55:05 -07:00
2017-05-31 15:43:28 -07:00
(when (display-graphic-p) (progn
2017-06-01 10:07:52 -07:00
(global-hl-line-mode t)
(scroll-bar-mode -1)))
2017-02-23 11:01:34 -07:00
(global-whitespace-mode)
2018-02-17 11:55:57 -07:00
(setq whitespace-style '(face trailing tabs spaces lines-tail empty indentation
2017-02-27 12:42:03 -07:00
space-after-tab space-before-tab space-mark
tab-mark))
2018-02-17 11:55:57 -07:00
(setq-default fill-column 80)
2017-02-22 21:49:21 -07:00
;; End display
;; Auto generated config
(setq custom-file (expand-file-name "auto.el" user-emacs-directory))
(load custom-file 'noerror)
;; End auto generated config
;; Text Formatting
2017-05-23 10:36:30 -07:00
(setq-default standard-indent 8)
2017-02-22 21:49:21 -07:00
(setq-default c-default-style "linux"
c-basic-offset 8
2017-02-23 11:01:34 -07:00
tab-width 8)
2017-05-23 10:36:30 -07:00
2017-05-30 18:11:12 -07:00
(add-hook 'emacs-lisp-mode-hook (lambda ()
(setq indent-tabs-mode nil)))
2017-05-23 10:36:30 -07:00
(add-hook 'ruby-mode-hook (lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 2)))
(add-hook 'js-mode-hook (lambda ()
(setq indent-tabs-mode nil)
(setq js-indent-level 2)))
(add-hook 'css-mode-hook (lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 2)
(setq css-indent-offset 2)))
2017-05-30 18:11:12 -07:00
(add-hook 'org-mode-hook (lambda ()
(setq indent-tabs-mode nil)
2018-02-17 11:58:09 -07:00
(setq tab-width 2)))
2017-02-22 21:49:21 -07:00
;; End text Formatting
2017-02-27 12:41:42 -07:00
;; Backup Files
(setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
;; End Backup Files
2017-02-22 21:49:21 -07:00
;; Plugins
;; Themes
(defun flip-background ()
"Flip the frame and terminal background mode.
useful for alternating between light and dark themes"
(interactive)
(let ((mode (if (or (eq (frame-parameter nil 'background-mode) 'dark)
(eq (terminal-parameter nil 'background-mode) 'dark))
(setq mode 'light)
(setq mode 'dark))))
2018-02-13 11:48:11 -07:00
(set-frame-parameter nil 'background-mode mode)
(set-terminal-parameter nil 'background-mode mode)
(dolist (theme custom-enabled-themes)
(enable-theme theme))))
(global-set-key (kbd "<f5>") 'flip-background)
;; Load directories in the .emacs.d/themes directory to the load path
;; TODO Only add directories
(mapcar (lambda (item)
(add-to-list 'custom-theme-load-path item))
(mapcar (lambda (item)
(format "%s/.emacs.d/themes/%s/" (getenv "HOME") item))
(let (files '())
(dolist (val
(directory-files (format "%s/.emacs.d/themes/"
(getenv "HOME")))
files)
(let ((off (string-match "\\." val)))
(unless (and off (eq off 0))
(setq files (cons val files))))))))
(when (load-theme 'solarized t) (flip-background))
2017-02-22 21:49:21 -07:00
;; End themes
2017-10-16 07:40:09 -07:00
(use-package org
:ensure t)
2017-06-01 10:39:43 -07:00
(use-package org-bullets
2017-10-16 07:40:09 -07:00
:ensure t
:after org
:config
(add-hook 'org-mode-hook (lambda ()
(org-bullets-mode t))))
2017-06-01 10:39:43 -07:00
2017-02-27 10:34:34 -07:00
(use-package company
2017-10-16 07:40:09 -07:00
:ensure t
2017-05-23 10:37:04 -07:00
:config
2017-06-01 10:39:43 -07:00
(add-hook 'after-init-hook 'global-company-mode))
2017-02-27 10:34:34 -07:00
2017-02-22 21:49:21 -07:00
(use-package powerline
2017-10-16 07:39:58 -07:00
:ensure t
2017-05-23 10:37:04 -07:00
:config
(powerline-default-theme))
2017-02-22 21:49:21 -07:00
2017-10-16 07:39:58 -07:00
(use-package magit
:ensure t)
2017-02-22 21:49:21 -07:00
2017-02-27 11:53:01 -07:00
(use-package helm
2017-10-16 07:39:58 -07:00
:ensure t
2017-05-23 10:37:04 -07:00
:config
(helm-mode t))
2017-02-27 11:53:01 -07:00
(use-package helm-projectile
2017-10-16 07:39:58 -07:00
:ensure t
2017-05-23 10:37:04 -07:00
:config
(evil-leader/set-key "p" 'helm-projectile)
(helm-projectile-on))
2017-02-27 11:53:01 -07:00
2017-10-16 07:39:58 -07:00
(require 'mu4e)
(setq mu4e-maildir (concat (getenv "HOME") "/.mail"))
(setq mu4e-drafts-folder "/Drafts")
(setq mu4e-sent-folder "/Sent")
(setq mu4e-trash-folder "/Trash")
(setq mu4e-get-mail-command "offlineimap")
(setq mu4e-compose-reply-to-address "kevin@kevincotugno.com"
user-mail-address "kevin@kevincotugno.com"
user-full-name "Kevin Cotugno")
(setq
message-send-mail-function 'smtpmail-send-it
smtpmail-smtp-server "smtp.cotugno.family"
smtpmail-stream-type 'ssl
smtpmail-smtp-service 587)
(setq message-kill-buffer-on-exit t)
2017-02-22 21:49:21 -07:00
;; End Plugins