dotfiles/.config/emacs/core/earnemacs-main.el

85 lines
2.4 KiB
EmacsLisp

;;; earnemacs-main.el --- earnemacs -*- lexical-binding: t; -*-
;; Copyright (C) 2020-2021 earnest ma
;; SPDX-License-Identifier: MIT
;; Author: earnest ma <me@earne.link>
;;; Commentary:
;; The main earnemacs file.
;;; Code:
;; Windows - $HOME folder if not set
(when (and *sys-windows* (null (getenv-internal "HOME")))
(setenv "HOME" (getenv "USERPROFILE"))
(setq abbreviated-home-dir nil))
;; UTF-8, LF by default
(setq-default buffer-file-coding-system 'utf-8-unix)
(setq-default default-buffer-file-coding-system 'utf-8-unix)
(set-default-coding-systems 'utf-8-unix)
(prefer-coding-system 'utf-8-unix)
;; Less noise on startup
(unless (daemonp)
(advice-add #'display-startup-echo-area-message :override #'ignore)) ; message
(setq inhibit-startup-screen t) ; startup buffer
(setq ad-redefinition-action 'accept) ; silence redefined warnings
(setq server-use-tcp t) ; daemon: use tcp sockets file
;; Add default modules to load path (modules/ recursively)
;; Taken with <3 from siren emacs: https://github.com/jimeh/.emacs.d
(defun siren-recursive-add-to-load-path (dir)
"Add DIR and all its sub-directories to `load-path'."
(add-to-list 'load-path dir)
(dolist (f (directory-files dir))
(let ((name (expand-file-name f dir)))
(when (and (file-directory-p name)
(not (string-prefix-p "." f)))
(siren-recursive-add-to-load-path name)))))
(siren-recursive-add-to-load-path earnemacs-modules-dir)
;;; -
(defun earnemacs+load ()
"Function to finish loading earnemacs.
earnemacs has already loaded earnemacs-var, -main, and -packages.
This function will load:
- core modules (prefixed with `earnecore-')
- `pre-load.el' if it exists
- `load.el'
- `config.el'"
(let* ((prel (concat earnemacs-root-dir "pre-load.el")))
(if (file-exists-p prel)
(load-file prel)))
;; Load core modules
(require 'earnecore-theme)
(require 'earnecore-keybinds)
(require 'earnecore-display)
(require 'earnecore-pkg)
(require 'earnecore-projects)
(require 'earnecore-editing)
(let* ((modules (concat earnemacs-root-dir "load.el")))
(load modules nil t)
(dolist (module earnemacs-modules)
(require module)))
(let* ((config (concat earnemacs-root-dir "config.el")))
(load config nil t))
(setq earnemacs-initialized-p t))
;; Load everything!
(earnemacs+load)
(provide 'earnemacs-main)
;;; earnemacs-main.el ends here