aboutsummaryrefslogtreecommitdiffstats
path: root/oni-core.el
blob: dfc8aa90bdf79ecf0ba8a67d4195b7c360f9bd69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
;;; oni-core.el --- Core Emacs configuration         -*- lexical-binding: t; -*-

;; Copyright (C) 2019  Tom Willemse

;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 20190303150119
;; Package-Requires: (oni-data-dir expand-region multiple-cursors embrace)

;; 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 <https://www.gnu.org/licenses/>.

;;; Commentary:

;; Core Emacs configuration, doesn't need any requires from within
;; Emacs. These settings don't seem to go anywhere else.

;;; Code:

(require 'oni-data-dir)

(defalias 'yes-or-no-p 'y-or-n-p)

(defun oni-core--destroy-trailing-whitespace ()
  "Delete trailing whitespace everywhere, except in Markdown buffers."
  (if (not (eq major-mode 'markdown-mode))
      (delete-trailing-whitespace)))

(defun oni-core--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-to-list 'auto-save-file-name-transforms
	     `(".*" ,(oni-data-dir-locate "auto-save-files/") t)
	     :append)

(setq backup-directory-alist
      `((".*" . ,(oni-data-dir-locate "backup-files"))))

(setq auto-save-list-file-prefix
      (oni-data-dir-locate "auto-save-list/.saves-"))

(setq abbrev-file-name (oni-data-dir-locate "abbrev_defs"))

(setq user-full-name "Tom Willemse"
      user-mail-address "tom@ryuslash.org")

(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)
(setq require-final-newline t)
(setq sentence-end-double-space nil)
(setq inhibit-startup-screen t)
(setq electric-pair-skip-whitespace 'chomp)

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq-default truncate-lines t)
(setq-default fill-column 80)

(add-hook 'before-save-hook #'oni-core--destroy-trailing-whitespace)
(add-hook 'before-save-hook 'time-stamp)
(add-hook 'electric-indent-local-mode-hook #'oni-core--switch-newline-keys)
(add-hook 'minibuffer-setup-hook 'electric-pair-local-mode)

(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)
(global-set-key (kbd "C-x f") 'ffap)
(global-set-key (kbd "C-x C-b") 'ibuffer)

(electric-indent-mode -1)

(when (eql system-type 'windows-nt)
  (add-to-list 'load-path (locate-user-emacs-file "vendor/p4-vc"))
  (add-to-list 'exec-path "c:/Program Files/Git/bin")
  (add-to-list 'exec-path "C:/Program Files/Git/usr/bin")
  (add-to-list 'exec-path "c:/cygwin64/bin")

  (setq find-program (shell-quote-argument "c:/cygwin64/bin/find.exe"))
  (setq grep-program (shell-quote-argument "c:/cygwin64/bin/grep.exe"))
  (setq grep-use-null-device nil)
  (setq delete-by-moving-to-trash t)

  (setq-default buffer-file-coding-system 'utf-8-unix))

;;;###autoload(require 'oni-core)

(provide 'oni-core)
;;; oni-core.el ends here