dotfiles/emacs/.emacs.d/init.el

161 lines
4.6 KiB
EmacsLisp
Raw Normal View History

2018-05-28 18:23:25 +02:00
;;; init.el --- Tom-Emacs Interface -*- lexical-binding: t; -*-
;; Copyright (C) 2018 Tom Willemse
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This is my Emacs configuration. It has gone through many iterations
;; before and may yet go through many more iterations.
;;; Code:
2018-07-20 09:24:41 +02:00
;;;; Load path and autoloads
(eval-and-compile
(let ((load-directory
(file-name-directory
(or load-file-name byte-compile-current-file))))
2019-03-03 21:06:45 +01:00
(add-to-list 'load-path (format "%sos-lisp/" load-directory))))
2018-06-19 19:43:05 +02:00
(require 'package)
2018-05-28 18:23:25 +02:00
(eval-and-compile (package-initialize))
2018-07-20 09:24:41 +02:00
;;;; Dependencies
(require 'diminish)
;;;; Settings
;;; Put backup and auto save files in their own directories so they
;;; don't clutter the rest of the filesystem.
(setq backup-directory-alist
`((".*" . ,(concat user-emacs-directory "data/backup-files"))))
(add-to-list
'auto-save-file-name-transforms
`(".*" ,(concat user-emacs-directory "data/auto-save-files/") t)
:append)
(setq auto-save-list-file-prefix
(concat user-emacs-directory "data/" "auto-save-list/.saves-"))
(setq abbrev-file-name
(concat user-emacs-directory "data/abbrev_defs"))
(with-eval-after-load 'forge
(setq forge-database-file
(concat user-emacs-directory "data/forge-database.sqlite")))
(with-eval-after-load 'tramp-cache
(setq tramp-persistency-file-name
(concat user-emacs-directory "data/tramp")))
(setq delete-old-versions t)
(setq kept-new-versions 20)
(setq kept-old-versions 20)
(setq vc-make-backup-files t)
(setq version-control t)
2018-05-28 18:23:25 +02:00
(global-set-key (kbd "C-M-SPC") 'er/expand-region)
(global-set-key (kbd "M-+") 'mc/mark-next-like-this)
(global-set-key (kbd "C-c (") 'embrace-commander)
2018-07-10 04:04:15 +02:00
(global-set-key (kbd "C-x f") 'ffap)
2018-07-10 04:42:56 +02:00
(global-set-key (kbd "C-x C-b") 'ibuffer)
2018-05-28 18:23:25 +02:00
(setq require-final-newline t)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq sentence-end-double-space nil)
(setq inhibit-startup-screen t)
(setq-default truncate-lines t)
2019-02-01 09:50:04 +01:00
(setq-default fill-column 80)
2018-05-28 18:23:25 +02:00
(global-unset-key (kbd "C-z"))
(defalias 'yes-or-no-p 'y-or-n-p)
(setq user-full-name "Tom Willemse"
user-mail-address "tom@ryuslash.org")
(eval-when-compile (require 'browse-url))
(with-eval-after-load 'browse-url
(setq browse-url-browser-function 'browse-url-firefox))
(defun init--destroy-trailing-whitespace ()
"Delete trailing whitespace everywhere, except in Markdown buffers."
(if (not (eq major-mode 'markdown-mode))
(delete-trailing-whitespace)))
(add-hook 'before-save-hook #'init--destroy-trailing-whitespace)
(add-hook 'minibuffer-setup-hook 'electric-pair-local-mode)
(with-eval-after-load 'paredit
(diminish 'paredit-mode))
(electric-indent-mode -1)
(defun oni:switch-newline-keys ()
"Switch the C-j and RET keys in the local buffer."
(if electric-indent-mode
(progn
(local-set-key (kbd "C-j") 'newline)
(local-set-key (kbd "RET") 'electric-newline-and-maybe-indent))
(local-unset-key (kbd "C-j"))
(local-unset-key (kbd "RET"))))
(add-hook 'electric-indent-local-mode-hook #'oni:switch-newline-keys)
(setq electric-pair-skip-whitespace 'chomp)
;; (with-eval-after-load 'server
;; (diminish 'server-buffer-clients
;; (propertize (concat " " (char-to-string #xf233))
;; 'face '(:family "Font Awesome" :height 0.75))))
(add-hook 'ielm-mode-hook 'paredit-mode)
2018-09-12 07:24:54 +02:00
(add-hook 'prog-mode-hook 'goto-address-prog-mode)
2018-11-14 22:56:46 +01:00
(add-to-list 'auto-mode-alist '("\\.targets\\'" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.proj\\'" . nxml-mode))
(add-hook 'git-commit-mode-hook 'electric-quote-local-mode)
(add-hook 'html-mode-hook 'electric-pair-local-mode)
2018-11-15 20:04:33 +01:00
(add-to-list 'grep-files-aliases '("msbuild" . "*.targets *.proj"))
2018-05-28 18:23:25 +02:00
(add-hook 'before-save-hook 'time-stamp)
2018-07-20 09:24:41 +02:00
(if (eq system-type 'windows-nt)
(require 'oni-windows-nt))
(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file t)
2018-05-28 18:23:25 +02:00
(provide 'init)
;;; init.el ends here