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
|
2023-10-03 07:26:59 +02:00
|
|
|
|
;; Version: 2023.1002.222641
|
2023-04-16 09:30:50 +02:00
|
|
|
|
;; Package-Requires: (oni-data-dir oni-embrace oni-hydra expand-region multiple-cursors gcmh diminish ws-butler which-key insert-char-preview mixed-pitch ace-window vertico marginalia orderless consult embark docstr mini-frame)
|
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:
|
|
|
|
|
|
2021-08-08 04:53:41 +02:00
|
|
|
|
(require 'auth-source)
|
2020-10-15 19:09:47 +02:00
|
|
|
|
(require 'diminish)
|
2020-05-01 07:40:45 +02:00
|
|
|
|
(require 'gcmh)
|
2022-02-28 09:57:24 +01:00
|
|
|
|
(require 'generic-x)
|
2021-02-01 06:59:47 +01:00
|
|
|
|
(require 'hydra)
|
2021-08-08 04:53:41 +02:00
|
|
|
|
(require 'package)
|
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-08-08 04:53:41 +02:00
|
|
|
|
|
|
|
|
|
(require 'oni-data-dir)
|
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))
|
2022-02-24 10:55:05 +01:00
|
|
|
|
(condition-case _
|
|
|
|
|
(progn
|
|
|
|
|
(search-backward-regexp (concat "[^ \t" comment-start "]"))
|
|
|
|
|
(forward-char)
|
|
|
|
|
(when (or (bolp)
|
|
|
|
|
(= start (point)))
|
|
|
|
|
(end-of-line)))
|
|
|
|
|
(search-failed (end-of-line)))
|
2020-04-07 11:09:43 +02:00
|
|
|
|
(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))))
|
|
|
|
|
|
2023-09-12 06:04:34 +02:00
|
|
|
|
(defhydra oni-core-applications-hydra (:color teal :hint nil)
|
|
|
|
|
"
|
|
|
|
|
^^^Applications^^^
|
|
|
|
|
^^--------------------^^-----------------^^--------------
|
|
|
|
|
_m_: Email (notmuch) _r_: RSS (elfeed) _i_: IRC (circe) "
|
|
|
|
|
("m" notmuch)
|
|
|
|
|
("r" elfeed)
|
|
|
|
|
("i" circe))
|
|
|
|
|
|
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)
|
2022-11-14 01:58:38 +01:00
|
|
|
|
;; Discovered through
|
|
|
|
|
;; https://github.com/novoid/dot-emacs/blob/23c28944f1991c636ea71ec7d5c3d266e6dbeb8a/config.org#deletes-duplicate-entries-of-the-history-of-the-minibuffer
|
|
|
|
|
(setq history-delete-duplicates t)
|
2023-08-06 09:19:18 +02:00
|
|
|
|
;; Save what's in the clipboard into the kill-ring before killing or copying
|
|
|
|
|
;; another string.
|
|
|
|
|
(setq save-interprogram-paste-before-kill t)
|
2019-03-04 00:03:21 +01: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)
|
|
|
|
|
|
2021-09-16 18:00:05 +02:00
|
|
|
|
(add-hook 'Info-mode-hook 'mixed-pitch-mode)
|
|
|
|
|
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
|
|
|
|
|
(add-hook 'auto-save-hook #'oni-core--ensure-autosave-directory-exists)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(add-hook 'before-save-hook 'time-stamp)
|
|
|
|
|
(add-hook 'electric-indent-local-mode-hook #'oni-core--switch-newline-keys)
|
2019-03-05 08:54:16 +01:00
|
|
|
|
(add-hook 'prog-mode-hook 'goto-address-prog-mode)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
2023-10-03 07:26:59 +02:00
|
|
|
|
(defun oni-core-set-ace-link-goto-addr-binding ()
|
|
|
|
|
"Set a key locally to open links using ‘ace-link’."
|
|
|
|
|
(local-set-key (kbd "C-c C-o") 'ace-link-addr))
|
|
|
|
|
|
|
|
|
|
(add-hook 'goto-address-prog-mode-hook #'oni-core-set-ace-link-goto-addr-binding)
|
|
|
|
|
|
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)
|
2022-12-13 16:11:36 +01:00
|
|
|
|
(global-set-key (kbd "C-c (") '("Embrace Commander" . embrace-commander))
|
|
|
|
|
(global-set-key (kbd "C-c q") '("Unfill Paragraph" . oni-core-unfill-paragraph))
|
|
|
|
|
(global-set-key (kbd "C-c s") '("Sort and Align Commands" . oni-sort-and-align-hydra/body))
|
2023-09-12 06:04:34 +02:00
|
|
|
|
(global-set-key (kbd "C-c a") '("Applications" . oni-core-applications-hydra/body))
|
2021-07-06 08:33:32 +02:00
|
|
|
|
(global-set-key (kbd "C-c l") 'imenu)
|
2022-12-13 16:11:36 +01:00
|
|
|
|
(global-set-key (kbd "C-x C-b") '("List Buffers" . 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)
|
2022-02-08 18:44:59 +01:00
|
|
|
|
(global-set-key [remap upcase-word] #'upcase-dwim)
|
|
|
|
|
(global-set-key [remap downcase-word] #'downcase-dwim)
|
|
|
|
|
(global-set-key [remap capitalize-word] #'capitalize-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)
|
|
|
|
|
|
2021-12-08 05:48:18 +01:00
|
|
|
|
(global-set-key (kbd "M-o") 'ace-window)
|
2022-01-06 18:16:47 +01:00
|
|
|
|
(global-unset-key (kbd "C-x o"))
|
2021-12-08 05:48:18 +01:00
|
|
|
|
|
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-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")
|
2022-03-02 08:54:18 +01:00
|
|
|
|
(add-to-list 'exec-path "c:/cygwin64/bin" t)
|
2019-03-04 00:03:21 +01:00
|
|
|
|
|
|
|
|
|
(setq delete-by-moving-to-trash t)
|
|
|
|
|
|
|
|
|
|
(setq-default buffer-file-coding-system 'utf-8-unix))
|
|
|
|
|
|
2021-07-27 06:25:57 +02:00
|
|
|
|
;; Set up autoloads for all of my configuration files so that when they get
|
|
|
|
|
;; installed they get loaded automatically, but don’t require them to be
|
|
|
|
|
;; installed.
|
|
|
|
|
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'ahk-mode (require 'oni-autohotkey))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'alert (require 'oni-alert))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'bat-mode (require 'oni-bat))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'bats (require 'oni-bats))
|
|
|
|
|
(with-eval-after-load 'bookmark (require 'oni-bookmark))
|
2021-07-28 06:06:46 +02:00
|
|
|
|
(with-eval-after-load 'browse-url (require 'oni-browse-url))
|
2021-11-17 05:28:56 +01:00
|
|
|
|
(with-eval-after-load 'cc-mode (require 'oni-c nil t))
|
|
|
|
|
(with-eval-after-load 'cc-mode (require 'oni-cpp nil t))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'cc-mode (require 'oni-java nil t))
|
2021-07-28 06:06:46 +02:00
|
|
|
|
(with-eval-after-load 'cider (require 'oni-clojure))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'circe (require 'oni-circe))
|
2021-07-28 06:06:46 +02:00
|
|
|
|
(with-eval-after-load 'clojure-mode (require 'oni-clojure))
|
2021-07-31 08:13:18 +02:00
|
|
|
|
(with-eval-after-load 'cmake-mode (require 'oni-cmake))
|
2021-07-28 06:06:46 +02:00
|
|
|
|
(with-eval-after-load 'company (require 'oni-company))
|
2021-09-20 08:07:55 +02:00
|
|
|
|
(with-eval-after-load 'compile (require 'oni-compilation))
|
2021-09-20 08:22:09 +02:00
|
|
|
|
(with-eval-after-load 'conf-mode (require 'oni-conf))
|
2021-09-20 08:41:08 +02:00
|
|
|
|
(with-eval-after-load 'counsel (require 'oni-counsel))
|
2021-09-21 05:18:47 +02:00
|
|
|
|
(with-eval-after-load 'csharp-mode (require 'oni-csharp))
|
2021-09-21 05:28:32 +02:00
|
|
|
|
(with-eval-after-load 'css-mode (require 'oni-css))
|
2021-09-22 08:29:06 +02:00
|
|
|
|
(with-eval-after-load 'diff-hl (require 'oni-diff-hl))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'dired (require 'oni-dired))
|
|
|
|
|
(with-eval-after-load 'ediff (require 'oni-ediff))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'elfeed (require 'oni-elfeed))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'elisp-mode (require 'oni-elisp))
|
|
|
|
|
(with-eval-after-load 'elm-mode (require 'oni-elm))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'embrace (require 'oni-embrace))
|
2022-08-17 23:50:25 +02:00
|
|
|
|
(with-eval-after-load 'emms (require 'oni-emms))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'eshell (require 'oni-eshell))
|
|
|
|
|
(with-eval-after-load 'fish-mode (require 'oni-fish))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'flycheck (require 'oni-flycheck))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'git-commit (require 'oni-git-commit))
|
|
|
|
|
(with-eval-after-load 'gnus (require 'oni-gnus))
|
|
|
|
|
(with-eval-after-load 'grep (require 'oni-grep))
|
|
|
|
|
(with-eval-after-load 'groovy-mode (require 'oni-groovy))
|
|
|
|
|
(with-eval-after-load 'haskell-mode (require 'oni-haskell))
|
|
|
|
|
(with-eval-after-load 'highlight-indent-guides (require 'oni-highlight-indent-guides))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'hydra (require 'oni-hydra))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'ielm (require 'oni-elisp))
|
2023-04-02 08:01:35 +02:00
|
|
|
|
;; (with-eval-after-load 'ivy (require 'oni-ivy))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'jabber (require 'oni-jabber))
|
|
|
|
|
(with-eval-after-load 'js2-mode (require 'oni-js))
|
|
|
|
|
(with-eval-after-load 'json-mode (require 'oni-json))
|
|
|
|
|
(with-eval-after-load 'lisp-mode (require 'oni-common-lisp))
|
|
|
|
|
(with-eval-after-load 'log-edit (require 'oni-log-edit))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'lsp (require 'oni-lsp))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'lua-mode (require 'oni-lua))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'lui (require 'oni-lui))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'magit (require 'oni-magit))
|
|
|
|
|
(with-eval-after-load 'make-mode (require 'oni-makefile))
|
2022-05-27 08:12:37 +02:00
|
|
|
|
(with-eval-after-load 'notmuch (require 'oni-notmuch))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'nov (require 'oni-epub))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'org (require 'oni-org))
|
|
|
|
|
(with-eval-after-load 'org-roam (require 'oni-org-roam))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'package (require 'oni-package))
|
|
|
|
|
(with-eval-after-load 'package-x (require 'oni-package))
|
2021-07-28 06:06:46 +02:00
|
|
|
|
(with-eval-after-load 'paredit (require 'oni-paredit))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'php-mode (require 'oni-php))
|
2021-07-28 06:06:46 +02:00
|
|
|
|
(with-eval-after-load 'prescient (require 'oni-prescient))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'projectile (require 'oni-projectile))
|
|
|
|
|
(with-eval-after-load 'python (require 'oni-python))
|
|
|
|
|
(with-eval-after-load 'ruby-mode (require 'oni-ruby))
|
|
|
|
|
(with-eval-after-load 'rust-mode (require 'oni-rust))
|
|
|
|
|
(with-eval-after-load 'scheme (require 'oni-scheme))
|
|
|
|
|
(with-eval-after-load 'sgml-mode (require 'oni-html))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'sh (require 'oni-sh))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'shr (require 'oni-shr))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'smartparens (require 'oni-smartparens))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'sort (require 'oni-sort))
|
|
|
|
|
(with-eval-after-load 'tramp (require 'oni-tramp))
|
|
|
|
|
(with-eval-after-load 'vc (require 'oni-vc))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
(with-eval-after-load 'vterm (require 'oni-vterm))
|
2021-11-23 09:38:09 +01:00
|
|
|
|
(with-eval-after-load 'web-mode (require 'oni-web))
|
|
|
|
|
(with-eval-after-load 'yaml-mode (require 'oni-yaml))
|
2021-08-13 07:02:17 +02:00
|
|
|
|
|
|
|
|
|
(with-eval-after-load 'yasnippet
|
|
|
|
|
(require 'oni-yasnippet)
|
|
|
|
|
(when (and (package-installed-p 'oni-yasnippet)
|
|
|
|
|
(not yas-global-mode))
|
|
|
|
|
(yas-global-mode)))
|
2021-07-27 06:25:57 +02:00
|
|
|
|
|
2021-08-24 06:45:41 +02:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'calendar))
|
|
|
|
|
|
|
|
|
|
(with-eval-after-load 'calendar
|
|
|
|
|
;; I’m used to working with Monday as the starting day.
|
2022-11-02 09:49:10 +01:00
|
|
|
|
(setq calendar-week-start-day 1
|
|
|
|
|
calendar-date-style 'iso))
|
|
|
|
|
|
|
|
|
|
(eval-when-compile (require 'solar))
|
|
|
|
|
(with-eval-after-load 'solar
|
|
|
|
|
(setq calendar-latitude 49.2127205
|
|
|
|
|
calendar-longitude -122.9267927))
|
2021-08-24 06:45:41 +02:00
|
|
|
|
|
2021-11-11 06:32:14 +01:00
|
|
|
|
(defun oni-core-in-word-p ()
|
|
|
|
|
"Check whether the character just typed was part of a word."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(backward-char)
|
|
|
|
|
(looking-back (rx word) (1- (point)))))
|
|
|
|
|
|
2023-05-25 08:51:09 +02:00
|
|
|
|
(defun oni-core-ace-window-select-other-window ()
|
|
|
|
|
"Use ‘ace-window’ to select which window is considered “other”."
|
|
|
|
|
(interactive)
|
|
|
|
|
(setq other-window-scroll-buffer (ace-select-window)))
|
|
|
|
|
|
2021-11-11 06:32:14 +01:00
|
|
|
|
(with-eval-after-load 'electric
|
|
|
|
|
(add-hook 'electric-quote-inhibit-functions #'oni-core-in-word-p))
|
|
|
|
|
|
|
|
|
|
(eval-when-compile (require 'ispell))
|
|
|
|
|
(with-eval-after-load 'ispell
|
|
|
|
|
(setq ispell-program-name "hunspell"
|
|
|
|
|
ispell-really-hunspell t))
|
|
|
|
|
|
2021-07-27 06:29:13 +02:00
|
|
|
|
;; Enable any modes that I want to have turned on right away.
|
|
|
|
|
|
|
|
|
|
(electric-indent-mode -1)
|
|
|
|
|
(winner-mode)
|
|
|
|
|
(recentf-mode)
|
|
|
|
|
(gcmh-mode)
|
|
|
|
|
(ws-butler-global-mode)
|
|
|
|
|
(which-key-mode)
|
|
|
|
|
(auto-insert-mode)
|
2021-09-22 08:29:06 +02:00
|
|
|
|
(global-diff-hl-mode)
|
2022-02-24 10:54:34 +01:00
|
|
|
|
;;; Remember minibuffer history across sessions.
|
|
|
|
|
(savehist-mode)
|
|
|
|
|
;;; Remember the place I left at in files when closing them.
|
|
|
|
|
(save-place-mode)
|
2023-08-06 09:23:29 +02:00
|
|
|
|
;;; Mitigate performance issues with files with _really_ long lines.
|
|
|
|
|
(global-so-long-mode)
|
2021-07-27 06:29:13 +02:00
|
|
|
|
|
2023-08-06 09:04:05 +02:00
|
|
|
|
;;; Minibuffer
|
|
|
|
|
|
|
|
|
|
(add-hook 'minibuffer-setup-hook 'electric-pair-local-mode)
|
|
|
|
|
(add-hook 'minibuffer-setup-hook 'cursor-intangible-mode)
|
|
|
|
|
|
|
|
|
|
(setq minibuffer-prompt-properties
|
|
|
|
|
(append '(cursor-intangible t) minibuffer-prompt-properties))
|
|
|
|
|
|
2023-08-06 09:11:17 +02:00
|
|
|
|
(setq read-extended-command-predicate 'command-completion-default-include-p)
|
|
|
|
|
|
2022-03-02 08:52:56 +01:00
|
|
|
|
;;; Vertico
|
|
|
|
|
|
|
|
|
|
(vertico-mode)
|
|
|
|
|
|
2023-08-06 09:15:26 +02:00
|
|
|
|
(define-key vertico-map (kbd "<return>") 'vertico-directory-enter)
|
|
|
|
|
(define-key vertico-map (kbd "<backspace>") 'vertico-directory-delete-char)
|
|
|
|
|
(define-key vertico-map (kbd "M-<backspace>") 'vertico-directory-delete-word)
|
|
|
|
|
|
2022-03-02 08:52:56 +01:00
|
|
|
|
;;; Marginalia
|
|
|
|
|
|
|
|
|
|
(define-key minibuffer-local-map (kbd "M-A") 'marginalia-cycle)
|
|
|
|
|
|
|
|
|
|
(marginalia-mode)
|
|
|
|
|
|
|
|
|
|
;;; Orderless
|
|
|
|
|
|
|
|
|
|
(setq completion-styles '(basic partial-completion orderless))
|
|
|
|
|
|
2023-08-06 08:58:20 +02:00
|
|
|
|
(with-eval-after-load 'orderless
|
|
|
|
|
(add-to-list 'orderless-matching-styles 'orderless-initialism))
|
|
|
|
|
|
2022-03-02 08:52:56 +01:00
|
|
|
|
;;; Consult
|
|
|
|
|
|
2023-01-24 19:04:39 +01:00
|
|
|
|
(global-set-key (kbd "C-c w d") '("Delete a window" . ace-delete-window))
|
|
|
|
|
(global-set-key (kbd "C-c w k") '("Keep a single window" . ace-delete-other-windows))
|
2023-05-25 08:51:09 +02:00
|
|
|
|
(global-set-key (kbd "C-c w o") '("Select other window" . oni-core-ace-window-select-other-window))
|
2023-01-24 19:04:39 +01:00
|
|
|
|
(global-set-key (kbd "M-g M") '("Jump to a mark anywhere" . consult-global-mark))
|
|
|
|
|
(global-set-key (kbd "M-g m") '("Jump to a mark" . consult-mark))
|
2022-03-02 08:52:56 +01:00
|
|
|
|
(global-set-key [remap bookmark-jump] 'consult-bookmark)
|
|
|
|
|
(global-set-key [remap goto-line] 'consult-goto-line)
|
|
|
|
|
(global-set-key [remap imenu] 'consult-imenu)
|
2023-01-24 19:04:39 +01:00
|
|
|
|
(global-set-key [remap project-switch-to-buffer] 'consult-project-buffer)
|
|
|
|
|
(global-set-key [remap projectile-switch-to-buffer] 'consult-project-buffer)
|
|
|
|
|
(global-set-key [remap switch-to-buffer] 'consult-buffer)
|
|
|
|
|
(global-set-key [remap yank-pop] 'consult-yank-pop)
|
2022-03-02 08:52:56 +01:00
|
|
|
|
|
2023-05-25 08:52:39 +02:00
|
|
|
|
(global-set-key (kbd "M-0") #'delete-window)
|
|
|
|
|
(global-set-key (kbd "C-x 0") (lambda () (interactive) (error "Use M-0 instead")))
|
|
|
|
|
(global-set-key (kbd "M-1") #'delete-other-windows)
|
|
|
|
|
(global-set-key (kbd "C-x 1") (lambda () (interactive) (error "Use M-1 instead")))
|
|
|
|
|
(global-set-key (kbd "M-2") #'split-window-below)
|
|
|
|
|
(global-set-key (kbd "C-x 2") (lambda () (interactive) (error "Use M-2 instead")))
|
|
|
|
|
(global-set-key (kbd "M-3") #'split-window-right)
|
|
|
|
|
(global-set-key (kbd "C-x 3") (lambda () (interactive) (error "Use M-3 instead")))
|
|
|
|
|
(global-set-key (kbd "M-4") #'ctl-x-4-prefix)
|
|
|
|
|
(global-set-key (kbd "C-x 4") (lambda () (interactive) (error "Use M-4 instead")))
|
|
|
|
|
(global-set-key (kbd "M-5") #'ctl-x-5-prefix)
|
|
|
|
|
(global-set-key (kbd "C-x 5") (lambda () (interactive) (error "Use M-5 instead")))
|
|
|
|
|
(global-set-key (kbd "M-6") #'2C-command)
|
|
|
|
|
(global-set-key (kbd "C-x 6") (lambda () (interactive) (error "Use M-6 instead")))
|
|
|
|
|
(global-set-key (kbd "M-8") (keymap-lookup global-map "C-x 8"))
|
|
|
|
|
(global-set-key (kbd "C-x 8") (lambda () (interactive) (error "Use M-8 instead")))
|
|
|
|
|
|
2023-06-16 08:34:57 +02:00
|
|
|
|
(global-set-key (kbd "M-8 l") "λ")
|
|
|
|
|
|
2022-12-13 16:14:06 +01:00
|
|
|
|
(defun oni-core-related-files ()
|
|
|
|
|
"Return a list of files related to the current buffer."
|
|
|
|
|
(let* ((jumpers related-files-jumpers)
|
|
|
|
|
(current-place (buffer-file-name)))
|
|
|
|
|
(cond ((not jumpers)
|
|
|
|
|
(user-error "No jumpers. Consider configuring `related-files-jumpers'"))
|
|
|
|
|
((not current-place)
|
|
|
|
|
(user-error "Related-Files only works from file-based buffers"))
|
|
|
|
|
(t
|
2023-03-31 07:28:24 +02:00
|
|
|
|
(related-files--collect-existing-places jumpers (list current-place))))))
|
2022-12-13 16:14:06 +01:00
|
|
|
|
|
|
|
|
|
(defvar oni-core-related-places-source
|
|
|
|
|
'(:name "Related File"
|
|
|
|
|
:category file
|
2023-03-21 06:28:06 +01:00
|
|
|
|
:items oni-core-related-files
|
2022-12-13 16:14:06 +01:00
|
|
|
|
:enabled buffer-file-name
|
|
|
|
|
:action find-file))
|
|
|
|
|
|
2023-05-26 00:29:42 +02:00
|
|
|
|
(eval-when-compile
|
|
|
|
|
(require 'consult))
|
2023-05-25 08:57:26 +02:00
|
|
|
|
|
2022-12-13 16:14:06 +01:00
|
|
|
|
(with-eval-after-load 'consult
|
|
|
|
|
(with-eval-after-load 'related-files
|
2023-05-25 23:09:45 +02:00
|
|
|
|
(add-to-list 'consult-buffer-sources 'oni-core-related-places-source))
|
|
|
|
|
|
2023-07-26 09:35:49 +02:00
|
|
|
|
(consult-customize consult-buffer consult-bookmark :preview-key nil))
|
2022-12-13 16:14:06 +01:00
|
|
|
|
|
2022-03-02 08:52:56 +01:00
|
|
|
|
;;; Embark
|
|
|
|
|
|
|
|
|
|
(global-set-key (kbd "C-.") 'embark-act)
|
|
|
|
|
(global-set-key (kbd "C-;") 'embark-dwim)
|
|
|
|
|
(global-set-key [remap describe-bindings] 'embark-bindings)
|
|
|
|
|
|
|
|
|
|
(defun oni-core-fit-window-to-buffer (window)
|
|
|
|
|
(fit-window-to-buffer window)
|
|
|
|
|
(with-selected-window window
|
|
|
|
|
(enlarge-window-horizontally 1)))
|
|
|
|
|
|
|
|
|
|
(add-to-list 'display-buffer-alist
|
|
|
|
|
`(,(rx string-start " *Embark Actions*")
|
|
|
|
|
display-buffer-in-side-window
|
|
|
|
|
(window-parameter (mode-line-format . none))
|
|
|
|
|
(side . right)
|
|
|
|
|
(slot . 0)
|
|
|
|
|
(window-width . oni-core-fit-window-to-buffer)))
|
|
|
|
|
|
2023-04-16 05:45:15 +02:00
|
|
|
|
;;; Extra debugging
|
|
|
|
|
|
|
|
|
|
;;; From https://gist.github.com/jdtsmith/1fbcacfe677d74bbe510aec80ac0050c
|
|
|
|
|
(defun oni-core-reraise-error (func &rest args)
|
|
|
|
|
"Call function FUNC with ARGS and re-raise any error which occurs.
|
|
|
|
|
Useful for debugging post-command hooks and filter functions,
|
|
|
|
|
which normally have their errors suppressed."
|
|
|
|
|
(condition-case err
|
|
|
|
|
(apply func args)
|
|
|
|
|
((debug error) (signal (car err) (cdr err)))))
|
|
|
|
|
|
|
|
|
|
(defun toggle-debug-on-hidden-errors (func)
|
|
|
|
|
"Toggle hidden error debugging for function FUNC."
|
|
|
|
|
(interactive "a")
|
|
|
|
|
(cond
|
|
|
|
|
((advice-member-p #'oni-core-reraise-error func)
|
|
|
|
|
(advice-remove func #'oni-core-reraise-error)
|
|
|
|
|
(message "Debug on hidden errors disabled for %s" func))
|
|
|
|
|
(t
|
|
|
|
|
(advice-add func :around #'oni-core-reraise-error)
|
|
|
|
|
(message "Debug on hidden errors enabled for %s" func))))
|
|
|
|
|
|
2023-01-24 19:05:31 +01:00
|
|
|
|
;;; Native Compilation
|
|
|
|
|
|
|
|
|
|
(setq native-comp-async-report-warnings-errors 'silent)
|
|
|
|
|
|
2023-07-07 01:48:57 +02:00
|
|
|
|
;;; Lazy counting
|
|
|
|
|
|
|
|
|
|
(with-eval-after-load 'isearch
|
|
|
|
|
(setq isearch-lazy-count t))
|
|
|
|
|
|
2023-07-15 10:08:26 +02:00
|
|
|
|
;;; Tree sitter
|
|
|
|
|
|
|
|
|
|
(when (treesit-available-p)
|
|
|
|
|
(add-to-list 'interpreter-mode-alist '("bash" . bash-ts-mode)))
|
|
|
|
|
|
2023-09-12 06:05:41 +02:00
|
|
|
|
(defun oni-core-copy-guix-build-hash ()
|
|
|
|
|
"Try and find the last actual hash in the compilation buffer and insert it."
|
|
|
|
|
(interactive)
|
|
|
|
|
(insert
|
2023-09-19 08:36:45 +02:00
|
|
|
|
(with-current-buffer next-error-last-buffer
|
2023-09-12 06:05:41 +02:00
|
|
|
|
(save-excursion
|
|
|
|
|
(save-match-data
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(re-search-backward (rx bol (zero-or-more whitespace) "actual hash:" (one-or-more whitespace)))
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(buffer-substring-no-properties (point) (line-end-position)))))))
|
|
|
|
|
|
2023-09-12 06:06:09 +02:00
|
|
|
|
(if (boundp 'safe-local-variable-directories)
|
|
|
|
|
(setq safe-local-variable-directories
|
|
|
|
|
(cl-delete-if
|
|
|
|
|
(lambda (d) (string-match-p (rx "/" (or "." ".." "foreign") eos) d))
|
|
|
|
|
(directory-files "~/projects/" t))))
|
|
|
|
|
|
2019-03-04 00:03:21 +01:00
|
|
|
|
(provide 'oni-core)
|
|
|
|
|
;;; oni-core.el ends here
|