Combine various config files into init.el
This commit is contained in:
parent
ea498b169d
commit
58e0b8a4f3
@ -1,8 +1,12 @@
|
||||
;;; early-init.el -*- lexical-binding: t; -*-
|
||||
;;; early-init.el --- Early initialization for Emacs. -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Emacs 27.1 introduced early-init.el, which is run before init.el, before
|
||||
;; package and UI initialization happens, and before site files are loaded.
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; Minimize garbage collection during startup.
|
||||
(setq gc-cons-threshold most-positive-fixnum)
|
||||
|
||||
@ -10,3 +14,6 @@
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(setq gc-cons-threshold (expt 2 23))))
|
||||
|
||||
(provide 'early-init)
|
||||
;;; early-init.el ends here
|
||||
|
32
editor.el
32
editor.el
@ -1,32 +0,0 @@
|
||||
;; Automatically reload files if modified outside of the editor.
|
||||
(global-auto-revert-mode)
|
||||
|
||||
;; Overwrite selected text when typing.
|
||||
(delete-selection-mode)
|
||||
|
||||
;; Display line numbers.
|
||||
(global-display-line-numbers-mode)
|
||||
|
||||
;; Display a ruler in the 80th column.
|
||||
(setq-default display-fill-column-indicator-column 80)
|
||||
(add-hook 'prog-mode-hook #'display-fill-column-indicator-mode)
|
||||
(add-hook 'text-mode-hook #'display-fill-column-indicator-mode)
|
||||
|
||||
;; Whitespace settings:
|
||||
;; - Tabs are 4 space characters (as the gods intended)
|
||||
;; - Ensure a newline character is present at the end files when saving
|
||||
;; - Clean up extraneous whitespace when saving
|
||||
(setq-default indent-tabs-mode nil
|
||||
tab-width 4)
|
||||
(setq require-final-newline t)
|
||||
(add-hook 'before-save-hook 'whitespace-cleanup)
|
||||
|
||||
;; Make sure that UTF-8 is *ALWAYS* the default encoding.
|
||||
(set-charset-priority 'unicode)
|
||||
(prefer-coding-system 'utf-8-unix)
|
||||
|
||||
;; Prettify symbols (eg. lambda -> λ).
|
||||
(global-prettify-symbols-mode)
|
||||
|
||||
;; Enable mouse support.
|
||||
(xterm-mouse-mode +1)
|
159
init.el
159
init.el
@ -1,7 +1,12 @@
|
||||
;;; init.el --- A (reasonably) minimal initialization file for Emacs.
|
||||
;;; init.el --- A (reasonably) minimal init file for Emacs. -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;;; Code:
|
||||
|
||||
|
||||
;; Manage package configuration via `use-package`.
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Manage packages via `use-package`.
|
||||
;; https://github.com/jwiegley/use-package
|
||||
|
||||
(require 'package)
|
||||
@ -17,31 +22,17 @@
|
||||
(package-install 'use-package))
|
||||
|
||||
|
||||
;; Configure how and where backup files are created.
|
||||
|
||||
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
|
||||
backup-by-copying t ; Don't delink hardlinks
|
||||
version-control t ; Use version numbers on backups
|
||||
delete-old-versions t ; Automatically delete excess backups
|
||||
kept-new-versions 20 ; How many of the newest versions to keep
|
||||
kept-old-versions 5 ; How many of the oldest versions to keep
|
||||
)
|
||||
|
||||
|
||||
;; On macOS, `ls` does not support the `--dired` option.
|
||||
(when (string= system-type "darwin")
|
||||
(setq dired-use-ls-dired nil))
|
||||
|
||||
|
||||
;; Define a couple simple helper functions for loading user-defined
|
||||
;; configuration files.
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Define some simple helper functions for loading user-defined configuration
|
||||
;; files. Load all configuration files for third-party packages and language
|
||||
;; support.
|
||||
|
||||
(defconst user-init-dir "~/.emacs.d/")
|
||||
|
||||
(defun load-user-file (file)
|
||||
"Load FILE in the current user's configuration directory.
|
||||
File names which are prefixed with an underscore or which do not have the
|
||||
extension '.el' will be ignored."
|
||||
File names which are prefixed with an underscore and/or which do not have
|
||||
the extension '.el' will be ignored."
|
||||
(interactive "f")
|
||||
(setq file-name (file-name-nondirectory file))
|
||||
(when (and (string-suffix-p ".el" file-name)
|
||||
@ -57,23 +48,130 @@
|
||||
(load-user-file file)))
|
||||
|
||||
|
||||
;; Load all user-defined configuration files.
|
||||
|
||||
(load-user-file "editor.el")
|
||||
(load-user-file "interface.el")
|
||||
(load-user-file "key-bindings.el")
|
||||
(load-user-file "theme.el")
|
||||
|
||||
(load-user-dir "pkg")
|
||||
(load-user-dir "lang")
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Configure how and where backup files are created.
|
||||
|
||||
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
|
||||
backup-by-copying t ; Don't delink hardlinks
|
||||
version-control t ; Use version numbers on backups
|
||||
delete-old-versions t ; Automatically delete excess backups
|
||||
kept-new-versions 20 ; How many of the newest versions to keep
|
||||
kept-old-versions 5 ; How many of the oldest versions to keep
|
||||
)
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Interface settings:
|
||||
;; - Open new windows to the right, not on the bottom
|
||||
;; - Don't use double-spaces after periods
|
||||
;; - Use unicode ellipses
|
||||
;; - Don't require full yes/no answers, allow y/n instead
|
||||
;; - Hide the menu bar
|
||||
;; - Make it easier to move between windows. Windows can be navigated using
|
||||
;; <shift> in combination with the arrow keys
|
||||
|
||||
(setq split-height-threshold nil
|
||||
split-width-threshold 0
|
||||
sentence-end-double-space nil
|
||||
truncate-string-ellipsis "…")
|
||||
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
(menu-bar-mode -1)
|
||||
|
||||
(setq windmove-wrap-around t)
|
||||
(windmove-default-keybindings)
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Mode line configuration:
|
||||
;; - Hide the frame identifier
|
||||
;; - Display the column and line numbers of the cursor
|
||||
;; - Display the file size
|
||||
|
||||
(setq mode-line-frame-identification " ")
|
||||
|
||||
(column-number-mode)
|
||||
(size-indication-mode)
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Editor configuration:
|
||||
;; - Scroll line-by-line, rather than jumping around haphazardly
|
||||
;; - Automatically reload files if modified outside of the editor
|
||||
;; - Overwrite selected text when typing
|
||||
;; - Display line numbers
|
||||
;; - Prettify symbols (eg. lambda -> λ)
|
||||
;; - Enable mouse support
|
||||
;; - Display a ruler in the 80th column
|
||||
;; - Make sure that UTF-8 is *ALWAYS* the default encoding
|
||||
|
||||
(setq scroll-conservatively 10000
|
||||
scroll-margin 0
|
||||
scroll-preserve-screen-position 1)
|
||||
|
||||
(global-auto-revert-mode)
|
||||
(delete-selection-mode)
|
||||
(global-display-line-numbers-mode)
|
||||
(global-prettify-symbols-mode)
|
||||
(xterm-mouse-mode +1)
|
||||
|
||||
(setq-default display-fill-column-indicator-column 80)
|
||||
(add-hook 'prog-mode-hook #'display-fill-column-indicator-mode)
|
||||
(add-hook 'text-mode-hook #'display-fill-column-indicator-mode)
|
||||
|
||||
(set-charset-priority 'unicode)
|
||||
(prefer-coding-system 'utf-8-unix)
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Whitespace settings:
|
||||
;; - Tabs are 4 space characters (as the gods intended)
|
||||
;; - Ensure a newline character is present at the end files when saving
|
||||
;; - Clean up extraneous whitespace when saving
|
||||
|
||||
(setq-default indent-tabs-mode nil
|
||||
tab-width 4
|
||||
require-final-newline t)
|
||||
|
||||
(add-hook 'before-save-hook 'whitespace-cleanup)
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Dired-mode configuration:
|
||||
;; - Show human-readable file sizes in dired mode
|
||||
;; - On macOS, `ls` does not support the `--dired` option
|
||||
|
||||
(setq dired-listing-switches "-alh")
|
||||
|
||||
(when (string= system-type "darwin")
|
||||
(setq dired-use-ls-dired nil))
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Diminish some built-in modes that we don't really care about.
|
||||
|
||||
(add-hook 'eldoc-mode-hook (lambda () (diminish 'eldoc-mode)))
|
||||
(add-hook 'hs-minor-mode-hook (lambda () (diminish 'hs-minor-mode)))
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; Custom key-bindings.
|
||||
|
||||
;; Globally un-set "C-z", which suspends Emacs by default.
|
||||
(global-unset-key (kbd "C-z"))
|
||||
|
||||
;; Enable code folding in programming modes, and set some more reasonable
|
||||
;; shortcuts.
|
||||
(add-hook 'prog-mode-hook #'hs-minor-mode)
|
||||
(global-set-key (kbd "C-c C-h") (kbd "C-c @ C-h")) ; Hide a block
|
||||
(global-set-key (kbd "C-c C-s") (kbd "C-c @ C-s")) ; Show a block
|
||||
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; WARNING: Don't touch anything after this comment!
|
||||
|
||||
(custom-set-variables
|
||||
@ -91,3 +189,6 @@
|
||||
;; Your init file should contain only one such instance.
|
||||
;; If there is more than one, they won't work right.
|
||||
)
|
||||
|
||||
(provide 'init)
|
||||
;;; init.el ends here
|
||||
|
29
interface.el
29
interface.el
@ -1,29 +0,0 @@
|
||||
;; Hide the menu bar.
|
||||
(menu-bar-mode -1)
|
||||
|
||||
;; Don't use double-spaces after periods.
|
||||
(setq sentence-end-double-space nil)
|
||||
|
||||
;; Use unicode ellipses, because they're nicer.
|
||||
(setq truncate-string-ellipsis "…")
|
||||
|
||||
;; Don't require full yes/no answers, allow y/n instead.
|
||||
(fset 'yes-or-no-p 'y-or-n-p)
|
||||
|
||||
;; Open new windows to the right, not on the bottom.
|
||||
(setq split-height-threshold nil
|
||||
split-width-threshold 0)
|
||||
|
||||
;; Scroll line-by-line, rather than jumping around haphazardly.
|
||||
(setq scroll-conservatively 10000
|
||||
scroll-margin 0
|
||||
scroll-preserve-screen-position 1)
|
||||
|
||||
;; Hide the frame identifier in the mode line.
|
||||
(setq mode-line-frame-identification " ")
|
||||
|
||||
;; Display the column and line numbers of the cursor in the mode line.
|
||||
(column-number-mode)
|
||||
|
||||
;; Display the file size in the mode line.
|
||||
(size-indication-mode)
|
@ -1,14 +0,0 @@
|
||||
;; Globally un-set "C-z", which suspends Emacs by default (and is super
|
||||
;; annoying!).
|
||||
(global-unset-key (kbd "C-z"))
|
||||
|
||||
;; Make it easier to move between windows. Windows can be navigated using
|
||||
;; <shift> in combination with the arrow keys.
|
||||
(setq windmove-wrap-around t)
|
||||
(windmove-default-keybindings)
|
||||
|
||||
;; Enable code folding in programming modes, and set some more reasonable
|
||||
;; shortcuts.
|
||||
(add-hook 'prog-mode-hook #'hs-minor-mode)
|
||||
(global-set-key (kbd "C-c C-h") (kbd "C-c @ C-h")) ; Hide a block
|
||||
(global-set-key (kbd "C-c C-s") (kbd "C-c @ C-s")) ; Show a block
|
@ -1,3 +1,4 @@
|
||||
;; Use the `doom-tokyo-night` theme.
|
||||
;; https://github.com/doomemacs/themes
|
||||
(use-package doom-themes
|
||||
:ensure t
|
Loading…
Reference in New Issue
Block a user