2019-03-04 00:03:21 +01:00
|
|
|
|
;;; oni-core.el --- Core Emacs configuration -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
|
|
;; Copyright (C) 2019 Tom Willemse
|
|
|
|
|
|
|
|
|
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
|
|
|
|
;; Keywords: local
|
2021-07-16 07:34:08 +02:00
|
|
|
|
;; Version: 2021.0715.222725
|
2021-06-22 08:03:56 +02:00
|
|
|
|
;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview dashboard)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
|
|
|
|
;; 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
|
2021-07-16 07:34:08 +02:00
|
|
|
|
;; Emacs. These settings don't seem to go anywhere else. Add the following to
|
|
|
|
|
;; your init file in case you want to use this configuration:
|
|
|
|
|
;;
|
|
|
|
|
;; (require 'oni-core)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2020-10-15 19:09:47 +02:00
|
|
|
|
(require 'diminish)
|
2020-05-01 07:40:45 +02:00
|
|
|
|
(require 'gcmh)
|
2021-02-01 06:59:47 +01:00
|
|
|
|
(require 'hydra)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(require 'oni-data-dir)
|
2020-02-25 07:02:35 +01:00
|
|
|
|
(require 'recentf)
|
2020-12-03 04:06:58 +01:00
|
|
|
|
(require 'which-key)
|
2021-02-01 06:59:47 +01:00
|
|
|
|
(require 'ws-butler)
|
2021-06-22 08:36:20 +02:00
|
|
|
|
(require 'auth-source)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
2019-03-30 20:06:56 +01:00
|
|
|
|
(defconst oni-core--auto-save-directory (oni-data-dir-locate "auto-save-files/")
|
|
|
|
|
"Directory where auto-saves go.")
|
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
|
|
|
|
2020-04-08 06:30:12 +02:00
|
|
|
|
(defvar oni-core--recentf-idle-timer nil
|
|
|
|
|
"Internal variable keeping track of a timer started for ‘recentf-save-list’.")
|
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(defun oni-core--switch-newline-keys ()
|
2019-09-18 20:09:58 +02:00
|
|
|
|
"Switch the ‘C-j’ and ‘RET’ keys in the local buffer."
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(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"))))
|
2019-03-30 20:06:56 +01:00
|
|
|
|
|
|
|
|
|
(defun oni-core--ensure-autosave-directory-exists ()
|
|
|
|
|
"Create the autosave directory if doesn't exist."
|
|
|
|
|
(mkdir oni-core--auto-save-directory t))
|
|
|
|
|
|
2020-04-07 11:09:43 +02:00
|
|
|
|
(defun oni-core-move-beginning-of-dwim ()
|
|
|
|
|
"Move to beginning of line either after indentation or before."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((start (point)))
|
|
|
|
|
(back-to-indentation)
|
|
|
|
|
(unless (/= start (point))
|
|
|
|
|
(move-beginning-of-line 1))))
|
|
|
|
|
|
|
|
|
|
(defun oni-core-move-end-of-dwim ()
|
|
|
|
|
"Move to end of line, either before any comments or after."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((start (point))
|
|
|
|
|
(eolpos (line-end-position)))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(if (and comment-start
|
|
|
|
|
(not (looking-at (regexp-quote comment-start)))
|
|
|
|
|
(comment-search-forward eolpos t))
|
|
|
|
|
(progn
|
|
|
|
|
(search-backward-regexp (concat "[^ \t" comment-start "]"))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(when (or (bolp)
|
|
|
|
|
(= start (point)))
|
|
|
|
|
(end-of-line)))
|
|
|
|
|
(end-of-line))))
|
|
|
|
|
|
2021-04-26 02:57:46 +02:00
|
|
|
|
;;; From Bastien Guerry’s Emacs configuraiton:
|
|
|
|
|
;;; https://github.com/bzg/dotemacs/blob/master/emacs.org
|
|
|
|
|
(defun oni-core-unfill-paragraph ()
|
|
|
|
|
"Make a multi-line paragraph into a single line of text."
|
|
|
|
|
(interactive)
|
|
|
|
|
(let ((fill-column (point-max)))
|
|
|
|
|
(fill-paragraph nil)))
|
|
|
|
|
|
2020-04-27 06:45:30 +02:00
|
|
|
|
(defun oni-core-recentf-save-list-silently ()
|
|
|
|
|
"Call ‘recentf-save-list’ but without showing a message about it."
|
|
|
|
|
(let ((inhibit-message t))
|
|
|
|
|
(recentf-save-list)))
|
|
|
|
|
|
2021-02-01 06:59:47 +01:00
|
|
|
|
(defhydra oni-sort-and-align-hydra (:color teal :hint nil)
|
|
|
|
|
"
|
|
|
|
|
^Sort^
|
|
|
|
|
^^--------------
|
|
|
|
|
_l_: Lines
|
2021-02-28 00:37:09 +01:00
|
|
|
|
_p_: Paragraph
|
2021-02-01 06:59:47 +01:00
|
|
|
|
_s_: String list"
|
|
|
|
|
("l" sort-lines)
|
2021-02-28 00:37:09 +01:00
|
|
|
|
("p" (save-excursion
|
|
|
|
|
(sort-lines
|
|
|
|
|
nil
|
|
|
|
|
(progn (start-of-paragraph-text) (point))
|
|
|
|
|
(progn (end-of-paragraph-text) (point)))))
|
2021-02-01 06:59:47 +01:00
|
|
|
|
("s" (sort-regexp-fields
|
|
|
|
|
nil
|
|
|
|
|
(rx "\"" (one-or-more (not "\"")) "\"")
|
|
|
|
|
(rx (one-or-more (not "\"")))
|
|
|
|
|
(region-beginning)
|
|
|
|
|
(region-end))))
|
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(add-to-list 'auto-save-file-name-transforms
|
2019-03-30 20:06:56 +01:00
|
|
|
|
`(".*" ,oni-core--auto-save-directory t)
|
|
|
|
|
:append)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
|
|
|
|
(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"))
|
|
|
|
|
|
2020-02-25 07:02:35 +01:00
|
|
|
|
(setq recentf-save-file (oni-data-dir-locate "recentf"))
|
|
|
|
|
|
2020-01-11 07:46:54 +01:00
|
|
|
|
;;; Get rid of the default help tooltip on the mode-line.
|
|
|
|
|
(setq mode-line-default-help-echo nil)
|
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(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)
|
2019-09-20 02:40:16 +02:00
|
|
|
|
(setq fit-window-to-buffer-horizontally t)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
2021-06-22 08:03:56 +02:00
|
|
|
|
(require 'dashboard)
|
2021-07-08 11:27:40 +02:00
|
|
|
|
(setq dashboard-footer-messages
|
|
|
|
|
'("Play more in order to learn more"
|
|
|
|
|
"Learn from similarities, unlearn from differences"
|
|
|
|
|
"Explore, invent, and apply in your environment - safely"
|
|
|
|
|
"See without judging and then act"
|
|
|
|
|
"Give yourself permission to fail; it’s the path to success"
|
|
|
|
|
"Groove your mind for success"
|
|
|
|
|
"Learn to focus"
|
|
|
|
|
"Make thinking time"
|
|
|
|
|
"Use a wiki to manage information and knowledge"
|
|
|
|
|
"Establish rules of engagement to manage interruptions"
|
|
|
|
|
"Send less email, and you’ll receive less email"
|
|
|
|
|
"Choose your own tempo for an email conversation"
|
|
|
|
|
"Mask interrupts to maintain focus"
|
|
|
|
|
"Use multiple monitors to avoid context switching"
|
|
|
|
|
"Optimize your personal workflow to maximize context"
|
|
|
|
|
"Grab the wheel. You can’t steer on autopilot"))
|
2021-06-22 08:03:56 +02:00
|
|
|
|
(dashboard-setup-startup-hook)
|
2021-06-22 08:39:58 +02:00
|
|
|
|
(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))
|
2021-04-26 02:53:21 +02:00
|
|
|
|
|
2020-02-25 19:17:32 +01:00
|
|
|
|
;; Increase the threshold for garbage collection for increased performance.
|
|
|
|
|
;; Apparently there are some (lsp-mode for example) packages that generate a lot
|
|
|
|
|
;; of garbage.
|
|
|
|
|
(setq gc-cons-threshold 100000000)
|
|
|
|
|
|
2021-04-26 02:42:36 +02:00
|
|
|
|
;;; Remove ~/.authinfo from the auth sources since it’s an unencripted file and
|
|
|
|
|
;;; I don’t want to accidentally store anything in there.
|
2021-07-02 03:00:13 +02:00
|
|
|
|
(setq auth-sources
|
|
|
|
|
(cons "secrets:Login"
|
|
|
|
|
(remove "~/.netrc"
|
|
|
|
|
(remove "~/.authinfo" auth-sources))))
|
2020-02-04 07:02:10 +01:00
|
|
|
|
|
2021-04-26 02:42:36 +02:00
|
|
|
|
(setq read-mail-command 'gnus)
|
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(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 'time-stamp)
|
|
|
|
|
(add-hook 'electric-indent-local-mode-hook #'oni-core--switch-newline-keys)
|
|
|
|
|
(add-hook 'minibuffer-setup-hook 'electric-pair-local-mode)
|
2019-03-05 08:54:16 +01:00
|
|
|
|
(add-hook 'prog-mode-hook 'goto-address-prog-mode)
|
2019-03-30 20:06:56 +01:00
|
|
|
|
(add-hook 'auto-save-hook #'oni-core--ensure-autosave-directory-exists)
|
2020-05-01 03:27:40 +02:00
|
|
|
|
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
|
|
|
|
(global-set-key (kbd "C-M-SPC") 'er/expand-region)
|
2021-02-01 06:59:47 +01:00
|
|
|
|
(global-set-key (kbd "C-S-b") 'windmove-left)
|
|
|
|
|
(global-set-key (kbd "C-S-f") 'windmove-right)
|
|
|
|
|
(global-set-key (kbd "C-S-n") 'windmove-down)
|
|
|
|
|
(global-set-key (kbd "C-S-p") 'windmove-up)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(global-set-key (kbd "C-c (") 'embrace-commander)
|
2021-04-26 02:57:46 +02:00
|
|
|
|
(global-set-key (kbd "C-c q") #'oni-core-unfill-paragraph)
|
2021-02-01 06:59:47 +01:00
|
|
|
|
(global-set-key (kbd "C-c s") #'oni-sort-and-align-hydra/body)
|
2021-07-06 08:33:32 +02:00
|
|
|
|
(global-set-key (kbd "C-c l") 'imenu)
|
2019-12-11 07:11:10 +01:00
|
|
|
|
(global-set-key (kbd "C-x C-b") 'ibuffer-jump)
|
2021-02-01 06:59:47 +01:00
|
|
|
|
(global-set-key (kbd "C-x M-f") 'ffap)
|
|
|
|
|
(global-set-key (kbd "M-+") 'mc/mark-next-like-this)
|
2021-02-28 00:41:20 +01:00
|
|
|
|
(global-set-key [remap insert-char] 'insert-char-preview)
|
2020-04-07 11:09:43 +02:00
|
|
|
|
(global-set-key [remap move-beginning-of-line] #'oni-core-move-beginning-of-dwim)
|
|
|
|
|
(global-set-key [remap move-end-of-line] #'oni-core-move-end-of-dwim)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
2019-09-18 20:07:46 +02:00
|
|
|
|
(global-set-key (kbd "C-<left>") 'winner-undo)
|
|
|
|
|
(global-set-key (kbd "C-<right>") 'winner-redo)
|
|
|
|
|
|
2020-04-08 06:30:12 +02:00
|
|
|
|
(unless oni-core--recentf-idle-timer
|
|
|
|
|
(setq oni-core--recentf-idle-timer
|
2020-04-27 06:45:30 +02:00
|
|
|
|
(run-with-idle-timer 10 t #'oni-core-recentf-save-list-silently)))
|
2020-02-25 07:02:35 +01:00
|
|
|
|
|
2020-12-18 09:05:25 +01:00
|
|
|
|
(with-eval-after-load 'gcmh (diminish 'gcmh-mode))
|
|
|
|
|
(with-eval-after-load 'ws-butler (diminish 'ws-butler-mode))
|
2020-12-18 09:07:13 +01:00
|
|
|
|
(with-eval-after-load 'which-key (diminish 'which-key-mode))
|
2020-10-15 19:09:47 +02:00
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(electric-indent-mode -1)
|
2019-09-18 20:07:46 +02:00
|
|
|
|
(winner-mode)
|
2020-02-25 07:02:35 +01:00
|
|
|
|
(recentf-mode)
|
2020-05-01 07:40:45 +02:00
|
|
|
|
(gcmh-mode)
|
2020-10-15 19:30:02 +02:00
|
|
|
|
(ws-butler-global-mode)
|
2020-12-03 04:06:58 +01:00
|
|
|
|
(which-key-mode)
|
2021-04-26 02:50:22 +02:00
|
|
|
|
(auto-insert-mode)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
2019-09-09 02:26:05 +02:00
|
|
|
|
(add-to-list 'display-buffer-alist
|
2019-09-20 02:39:42 +02:00
|
|
|
|
`(,(rx string-start
|
|
|
|
|
"*" (any ?h ?H) "elp")
|
|
|
|
|
display-buffer-in-side-window
|
2019-09-09 02:26:05 +02:00
|
|
|
|
(side . bottom)
|
|
|
|
|
(slot . 0)
|
|
|
|
|
(window-height . 0.33)))
|
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(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 delete-by-moving-to-trash t)
|
|
|
|
|
|
|
|
|
|
(setq-default buffer-file-coding-system 'utf-8-unix))
|
|
|
|
|
|
|
|
|
|
(provide 'oni-core)
|
|
|
|
|
;;; oni-core.el ends here
|