aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/early-init.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-06-17 17:20:29 +1000
committerYuchen Pei <id@ypei.org>2023-06-17 17:20:29 +1000
commit093ffa5fbf7143f4668bb0a3dc9659a5cc836e12 (patch)
tree1ed4e14b2a43b8e338f4ad6a04d969b99b9239be /emacs/.emacs.d/early-init.el
parentabc686827ae38ee715d9eed1c5c29161c74127e6 (diff)
Moving things one level deeper
To ease gnu stow usage. Now we can do stow -t ~ emacs
Diffstat (limited to 'emacs/.emacs.d/early-init.el')
-rw-r--r--emacs/.emacs.d/early-init.el92
1 files changed, 92 insertions, 0 deletions
diff --git a/emacs/.emacs.d/early-init.el b/emacs/.emacs.d/early-init.el
new file mode 100644
index 0000000..59c9a84
--- /dev/null
+++ b/emacs/.emacs.d/early-init.el
@@ -0,0 +1,92 @@
+;;; early-init.el -- Early init -*- lexical-binding: t -*-
+
+;; Copyright (C) 2023 Free Software Foundation.
+
+;; Author: Yuchen Pei <id@ypei.org>
+;; Protesilaos Stavrou <info@protesilaos.com>
+;; John Wiegley <johnw@newartisans.com>
+;; Maintainer: Yuchen Pei <id@ypei.org>
+;; Package-Requires: ((emacs "28.2"))
+
+;; This file is part of dotfiles.
+
+;; dotfiles is free software: you can redistribute it and/or modify it under
+;; the terms of the GNU Affero General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; dotfiles 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 Affero General
+;; Public License for more details.
+
+;; You should have received a copy of the GNU Affero General Public
+;; License along with dotfiles. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Early init.
+
+;;; Code:
+
+(defconst my-emacs-start-time (current-time))
+
+;; Use this to control what kind of emacs we want to use. For emms,
+;; erc, home, or work etc.
+(defvar my-profile (getenv "EMACS_PROFILE"))
+
+;;; Copied from John Wiegley's .emacs file
+(defun my-report-time-since-load (&optional suffix)
+ (message "Loading init...done (%.3fs)%s"
+ (float-time (time-subtract (current-time) my-emacs-start-time))
+ suffix))
+
+(add-hook 'after-init-hook
+ #'(lambda () (my-report-time-since-load " [after-init]"))
+ t)
+
+;; Much of the following is copied from prot-dotfiles
+;; Disable the damn thing by making it disposable.
+(setq custom-file (make-temp-file "emacs-custom-"))
+
+(menu-bar-mode -1)
+(scroll-bar-mode -1)
+(tool-bar-mode -1)
+
+(setq frame-resize-pixelwise t
+ frame-inhibit-implied-resize t)
+
+(setq use-dialog-box t ; only for mouse events
+ use-file-dialog nil
+ inhibit-splash-screen t
+ inhibit-startup-screen t
+ inhibit-x-resources t
+ inhibit-startup-echo-area-message user-login-name ; read the docstring
+ inhibit-startup-buffer-menu t
+ make-backup-files nil
+ backup-inhibited nil ; Not sure if needed, given `make-backup-files'
+ create-lockfiles nil)
+
+;; Temporarily increase the garbage collection threshold. These
+;; changes help shave off about half a second of startup time.
+(defvar my-emacs--gc-cons-threshold gc-cons-threshold)
+
+(setq gc-cons-threshold most-positive-fixnum)
+
+(add-hook 'emacs-startup-hook
+ (lambda ()
+ (setq gc-cons-threshold my-emacs--gc-cons-threshold)))
+
+;; Initialise installed packages
+(setq package-enable-at-startup t)
+
+(defvar package-quickstart)
+
+;; Allow loading from the package cache
+(setq package-quickstart t)
+
+(when (native-comp-available-p)
+ (setq native-comp-async-report-warnings-errors 'silent) ; emacs28 with native compilation
+ (setq native-compile-prune-cache t)) ; Emacs 29
+
+;;; early-init.el ends here