Reorganise a bunch of elisp file

Set package priority manually rather than using
crafted-early-init-config

Copy crafted-defaults-config to custom-defaults-config instead

Move some things out of init.el into relevant custom config files

Add some new packages (to be configured)
This commit is contained in:
Evie Litherland-Smith 2023-10-27 08:03:51 +01:00
parent 25d87b600a
commit 5c959f8bf5
7 changed files with 303 additions and 113 deletions

View file

@ -1,11 +1,16 @@
;;; early-init.el --- Emacs early initialization for Crafted Emacs (optional) -*- lexical-binding: t; -*-
;;; early-init.el --- Emac s early initialization for Crafted Emacs (optional) -*- lexical-binding: t; -*-
;;; Commentary:
;;
;;; Code:
(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;; Configures `package.el'
;; (load "~/crafted-emacs/modules/crafted-early-init-config")
(load (expand-file-name "crafted-emacs/modules/crafted-early-init-config" user-emacs-directory))
(setq package-archive-priorities '(("gnu" . 99)
("nongnu" . 80)
("stable" . 70)
("melpa" . 0)))
(when (require 'package nil :noerror) (package-refresh-contents))
(provide 'early-init)

View file

@ -19,13 +19,11 @@
(add-to-list 'load-path (expand-file-name "modules" crafted-emacs-home))
;;; Configuration phase
(require 'crafted-completion-config)
(require 'crafted-defaults-config)
(require 'crafted-ide-config)
(require 'crafted-org-config)
(require 'crafted-workspaces-packages)
(require 'crafted-writing-packages)
(setq user-full-name "Evie Litherland-Smith"
user-mail-address "evie@xenia.me.uk")
(require 'custom-defaults-config)
(require 'custom-email-config)
(require 'custom-feed-config)
(require 'custom-ide-config)
@ -35,51 +33,13 @@
(require 'custom-project-config)
(require 'custom-ui-config)
;;; Optional configuration
(setq user-full-name "Evie Litherland-Smith"
user-mail-address "evie@xenia.me.uk"
sendmail-program (executable-find "msmtp")
send-mail-function #'smtpmail-send-it
message-sendmail-f-is-evil t
message-sendmail-extra-arguments '("--read-envelope-from")
message-send-mail-function #'message-send-mail-with-sendmail
message-kill-buffer-on-exit t
use-dialog-box nil
display-line-numbers 'relative
fill-column 80)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(add-to-list 'default-frame-alist '(font . "FiraCode Nerd Font-12"))
(global-prettify-symbols-mode)
(set-frame-parameter nil 'alpha-background 80)
(add-to-list 'default-frame-alist '(alpha-background . 80))
(when (require 'doom-themes nil :noerror) (load-theme 'doom-tokyo-night t))
;; Extra minor-modes
(which-key-mode)
;; Extra functions
(defun my/org-move-done-tasks-to-bottom ()
"Sort all tasks in the topmost heading by TODO state."
(interactive)
(save-excursion
(while (org-up-heading-safe))
(org-sort-entries nil ?o))
;; Reset the view of TODO items
(org-overview)
(org-show-entry)
(org-show-children))
(require 'crafted-completion-config)
(require 'crafted-ide-config)
(require 'crafted-org-config)
(require 'crafted-workspaces-config)
(require 'crafted-writing-config)
;; Set default coding system (especially for Windows)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
;; TRAMP settings
(setq tramp-default-method "sshx"
tramp-default-remote-shell "/bin/sh"
tramp-remote-path '(tramp-own-remote-path tramp-default-remote-path))

View file

@ -0,0 +1,240 @@
;;; custom-defaults.el -*- lexical-binding: t; -*-
;; Copyright (C) 2023
;; SPDX-License-Identifier: MIT
;; Author: System Crafters Community
;; Commentary
;; General Crafted Emacs endorsed defaults
;;
;; Some of these settings were inspired by the following:
;; - Charles Choi: "Surprise and Emacs Defaults"
;; http://yummymelon.com/devnull/surprise-and-emacs-defaults.html
;; - Mickey Petersen: "Mastering Emacs",
;; especially "Demystifying Emacss Window Manager"
;; https://www.masteringemacs.org/article/demystifying-emacs-window-manager
;;; Code:
;;; Buffers
;; Revert Dired and other buffers
(customize-set-variable 'global-auto-revert-non-file-buffers t)
;; Revert buffers when the underlying file has changed
(global-auto-revert-mode 1)
;; Make dired do something intelligent when two directories are shown
;; in separate dired buffers. Makes copying or moving files between
;; directories easier. The value `t' means to guess the default
;; target directory.
(customize-set-variable 'dired-dwim-target t)
;; automatically update dired buffers on revisiting their directory
(customize-set-variable 'dired-auto-revert-buffer t)
;; scroll eshell buffer to the bottom on input, but only in "this"
;; window.
(customize-set-variable 'eshell-scroll-to-bottom-on-input 'this)
;; pop up dedicated buffers in a different window.
(customize-set-variable 'switch-to-buffer-in-dedicated-window 'pop)
;; treat manual buffer switching (C-x b for example) the same as
;; programmatic buffer switching.
(customize-set-variable 'switch-to-buffer-obey-display-actions t)
;; prefer the more full-featured built-in ibuffer for managing
;; buffers.
(keymap-global-set "<remap> <list-buffers>" #'ibuffer-list-buffers)
;; turn off forward and backward movement cycling
(customize-set-variable 'ibuffer-movement-cycle nil)
;; the number of hours before a buffer is considered "old" by
;; ibuffer.
(customize-set-variable 'ibuffer-old-time 24)
;;; Completion settings
;; Turn on the best completion-mode available:
;; - in version 28 or later, turn on `fido-vertical-mode'
;; - in earlier versions, if the additional package `icomplete-vertical' is
;; present, turn it on.
;; - otherwise turn on `icomplete-mode'
;;
;; Note: If you also use `custom-completion-config' and have `vertico'
;; installed, all of these modes will be turned off in favour of
;; `vertico'.
(if (version< emacs-version "28")
(if (locate-library "icomplete-vertical")
(icomplete-vertical-mode 1)
(icomplete-mode 1))
(fido-vertical-mode 1))
;; No matter which completion mode is used:
(customize-set-variable 'tab-always-indent 'complete)
(customize-set-variable 'completion-cycle-threshold 3)
(customize-set-variable 'completion-category-overrides
'((file (styles . (partial-completion)))))
(customize-set-variable 'completions-detailed t)
;; use completion system instead of popup window
(customize-set-variable 'xref-show-definitions-function
#'xref-show-definitions-completing-read)
;;; Editing
;; Typed text replaces the selection if the selection is active,
;; pressing delete or backspace deletes the selection.
(delete-selection-mode)
;; Use spaces instead of tabs
(setq-default indent-tabs-mode nil)
;; Do not save duplicates in kill-ring
(customize-set-variable 'kill-do-not-save-duplicates t)
;; Better support for files with long lines
(setq-default bidi-paragraph-direction 'left-to-right)
(setq-default bidi-inhibit-bpa t)
(global-so-long-mode 1)
;; define a key to define the word at point.
(keymap-set global-map "M-#" #'dictionary-lookup-definition)
;; Show dictionary definition on the left
(add-to-list 'display-buffer-alist
'("^\\*Dictionary\\*"
(display-buffer-in-side-window)
(side . left)
(window-width . 70)))
;; turn on spell checking, if available.
(with-eval-after-load 'ispell
(when (executable-find ispell-program-name)
(add-hook 'text-mode-hook #'flyspell-mode)
(add-hook 'prog-mode-hook #'flyspell-prog-mode)))
;;; Navigation
;; add hydra to facilitate remembering the keys and actions for dumb-jump
(when (and (require 'hydra nil :noerror)
(require 'dumb-jump nil :noerror))
(defhydra dumb-jump-hydra (:color blue :columns 3)
"Dumb Jump"
("j" dumb-jump-go "Go")
("o" dumb-jump-go-other-window "Other window")
("e" dumb-jump-go-prefer-external "Go external")
("x" dumb-jump-go-prefer-external-other-window "Go external other window")
("i" dumb-jump-go-prompt "Prompt")
("l" dumb-jump-quick-look "Quick look")
("b" dumb-jump-back "Back"))
;; not a great key as a mnemonic, but easy to press quickly
(keymap-set dumb-jump-mode-map "C-M-y" #'dumb-jump-hydra/body))
;; use xref
(with-eval-after-load 'dumb-jump
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
;;; Persistence between sessions
;; Turn on recentf mode
(add-hook 'after-init-hook #'recentf-mode)
;; Enable savehist-mode for command history
(savehist-mode 1)
;; save the bookmarks file every time a bookmark is made or deleted
;; rather than waiting for Emacs to be killed. Useful especially when
;; Emacs is a long running process.
(customize-set-variable 'bookmark-save-flag 1)
;;; Window management
(defgroup custom-windows '()
"Window related configuration for Crafted Emacs."
:tag "Crafted Windows"
:group 'crafted)
(defcustom custom-windows-prefix-key "C-c w"
"Configure the prefix key for window movement bindings.
Movement commands provided by `windmove' package, `winner-mode'
also enables undo functionality if the window layout changes."
:group 'custom-windows
:type 'string)
;; Turning on `winner-mode' provides an "undo" function for resetting
;; your window layout. We bind this to `C-c w u' for winner-undo and
;; `C-c w r' for winner-redo (see below).
(winner-mode 1)
(define-prefix-command 'custom-windows-key-map)
(keymap-set 'custom-windows-key-map "u" 'winner-undo)
(keymap-set 'custom-windows-key-map "r" 'winner-redo)
(keymap-set 'custom-windows-key-map "n" 'windmove-down)
(keymap-set 'custom-windows-key-map "p" 'windmove-up)
(keymap-set 'custom-windows-key-map "b" 'windmove-left)
(keymap-set 'custom-windows-key-map "f" 'windmove-right)
(keymap-global-set custom-windows-prefix-key 'custom-windows-key-map)
;; Make scrolling less stuttered
(setq auto-window-vscroll nil)
(customize-set-variable 'fast-but-imprecise-scrolling t)
(customize-set-variable 'scroll-conservatively 101)
(customize-set-variable 'scroll-margin 0)
(customize-set-variable 'scroll-preserve-screen-position t)
;; open man pages in their own window, and switch to that window to
;; facilitate reading and closing the man page.
(customize-set-variable 'Man-notify-method 'aggressive)
;; keep the Ediff control panel in the same frame
(customize-set-variable 'ediff-window-setup-function
'ediff-setup-windows-plain)
;; Window configuration for special windows.
(add-to-list 'display-buffer-alist
'("\\*Help\\*"
(display-buffer-reuse-window display-buffer-pop-up-window)
(inhibit-same-window . t)))
(add-to-list 'display-buffer-alist
'("\\*Completions\\*"
(display-buffer-reuse-window display-buffer-pop-up-window)
(inhibit-same-window . t)
(window-height . 10)))
;;; Miscellaneous
;; Load source (.el) or the compiled (.elc or .eln) file whichever is
;; newest
(customize-set-variable 'load-prefer-newer t)
;; Make shebang (#!) file executable when saved
(add-hook 'after-save-hook
#'executable-make-buffer-file-executable-if-script-p)
;; Turn on repeat mode to allow certain keys to repeat on the last
;; keystroke. For example, C-x [ to page backward, after pressing this
;; keystroke once, pressing repeated [ keys will continue paging
;; backward. `repeat-mode' is exited with the normal C-g, by movement
;; keys, typing, or pressing ESC three times.
(unless (version< emacs-version "28")
(repeat-mode 1))
(provide 'custom-defaults-config)
;;; custom-defaults-config.el ends here

View file

@ -1,4 +1,10 @@
(setq mail-user-agent 'notmuch-user-agent
sendmail-program (executable-find "msmtp")
send-mail-function #'smtpmail-send-it
message-sendmail-f-is-evil t
message-sendmail-extra-arguments '("--read-envelope-from")
message-send-mail-function #'message-send-mail-with-sendmail
message-kill-buffer-on-exit t
notmuch-search-oldest-first nil
notmuch-show-logo nil
notmuch-hello-thousands-separator ","

View file

@ -13,4 +13,25 @@
org-refile-targets '((nil :maxlevel . 3)
(org-agenda-files :maxlevel . 3)))
(defun my/org-move-done-tasks-to-bottom ()
"Sort all tasks in the topmost heading by TODO state."
(interactive)
(save-excursion
(while (org-up-heading-safe))
(org-sort-entries nil ?o))
;; Reset the view of TODO items
(org-overview)
(org-show-entry)
(org-show-children))
(when (require 'org nil :noerror)
(add-hook
'org-mode-hook
(lambda () (add-hook
'before-save-hook
#'my/org-move-done-tasks-to-bottom
nil
'local))))
(provide 'custom-org-config)

View file

@ -7,6 +7,20 @@
;;; Code:
(setq use-dialog-box nil
display-line-numbers 'relative
fill-column 80)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(add-to-list 'default-frame-alist '(font . "FiraCode Nerd Font-12"))
(global-prettify-symbols-mode +1)
(set-frame-parameter nil 'alpha-background 80)
(add-to-list 'default-frame-alist '(alpha-background . 80))
(when (require 'doom-themes nil :noerror) (load-theme 'doom-tokyo-night t))
;; Extra minor-modes
(when (require 'which-key nil :noerror) (which-key-mode +1))
(when (require 'page-break nil :noerror) (global-page-break-lines-mode +1))
;;;; Help Buffers
@ -24,64 +38,6 @@
;; Bind extra `describe-*' commands
(keymap-global-set "C-h K" #'describe-keymap)
;;;; Line Numbers
(defcustom custom-ui-line-numbers-enabled-modes
'(conf-mode prog-mode)
"Modes which should display line numbers."
:type 'list
:group 'crafted-ui)
(defcustom custom-ui-line-numbers-disabled-modes
'(org-mode)
"Modes which should not display line numbers.
Modes derived from the modes defined in
`custom-ui-line-number-enabled-modes', but should not display line numbers."
:type 'list
:group 'crafted-ui)
(defun custom-ui--enable-line-numbers-mode ()
"Turn on line numbers mode.
Used as hook for modes which should display line numbers."
(display-line-numbers-mode 1))
(defun custom-ui--disable-line-numbers-mode ()
"Turn off line numbers mode.
Used as hook for modes which should not display line numebrs."
(display-line-numbers-mode -1))
(defun custom-ui--update-line-numbers-display ()
"Update configuration for line numbers display."
(if custom-ui-display-line-numbers
(progn
(dolist (mode custom-ui-line-numbers-enabled-modes)
(add-hook (intern (format "%s-hook" mode))
#'custom-ui--enable-line-numbers-mode))
(dolist (mode custom-ui-line-numbers-disabled-modes)
(add-hook (intern (format "%s-hook" mode))
#'custom-ui--disable-line-numbers-mode))
(setq-default
display-line-numbers-grow-only t
display-line-numbers-type t
display-line-numbers-width 2))
(progn
(dolist (mode custom-ui-line-numbers-enabled-modes)
(remove-hook (intern (format "%s-hook" mode))
#'custom-ui--enable-line-numbers-mode))
(dolist (mode custom-ui-line-numbers-disabled-modes)
(remove-hook (intern (format "%s-hook" mode))
#'custom-ui--disable-line-numbers-mode)))))
(defcustom custom-ui-display-line-numbers nil
"Whether line numbers should be enabled."
:type 'boolean
:group 'crafted-ui
:set (lambda (sym val)
(set-default sym val)
(custom-ui--update-line-numbers-display)))
;; add visual pulse when changing focus, like beacon but built-in
;; from from https://karthinks.com/software/batteries-included-with-emacs/
(defun pulse-line (&rest _)

View file

@ -55,13 +55,15 @@
org-journal
# project-packages
projectile
magit
# ui-packages
all-the-icons
elisp-demos
helpful
nerd-icons
page-break-lines
dashboard
helpful
which-key
link-hint