From 3f44e3b41c8f3174ceea5e810119e28dab9c6aaa Mon Sep 17 00:00:00 2001 From: rearman Date: Thu, 13 Jun 2024 15:34:23 -0400 Subject: [PATCH] Change initialization meta Avoid issues when doing a git pull that is not the first clone, having to play games with --[no]-assume-unchanged, etc. 1. Change init.org to config.org, and set up init.el to tangle that file. 2. Track early-init.el, so that it gets run on first startup. a. Keep the tangling section for this file in config.org for central editing. --- .gitignore | 2 +- README.org | 2 +- init.org => config.org | 83 +++++++++++------------------------------- early-init.el | 26 +++++++++++++ init.el | 18 ++++----- 5 files changed, 59 insertions(+), 72 deletions(-) rename init.org => config.org (95%) create mode 100644 early-init.el diff --git a/.gitignore b/.gitignore index e54eec0..2ef0788 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,8 @@ auto-save-list/ abbrev_defs bookmarks +config.el custom.el -early-init.el eln-cache/ elpa/ eshell/ diff --git a/README.org b/README.org index 4e5814b..60bfc2c 100644 --- a/README.org +++ b/README.org @@ -1,2 +1,2 @@ * README -This is my emacs init. See init.org for more. +This is my emacs init. See [[file:~/.emacs.d/config.org][config.org]] for more. diff --git a/init.org b/config.org similarity index 95% rename from init.org rename to config.org index f5b919d..ca79e6d 100644 --- a/init.org +++ b/config.org @@ -14,38 +14,9 @@ I keep my emacs installs at the latest release, so I don't worry about checking ** Latinization I believe that all scientific knowledge, and by extension computational knowledge, should be shared in Latin. That is to say I intend to facilitate Latin's return as the default language for global knowledge sharing. To be consistent, I will soon be translating as much of this file as possible into Latin. Monitus es. * Meta Configuration -I have taken this mostly whole-hog from [[https://github.com/larstvei/dot-emacs][github.com/larstvei/dot-emacs]]. The idea is that this bare-bones init.el is available when the repo is pulled in, but gets overwritten on emacs' first run. Emacs will need to be re-started after that initial run, since =early-init.el= will be created, and some packages will be installed. -** Init.el -This is the repo's =init.el= file, which bootstraps the real =init.el=. -#+BEGIN_SRC emacs-lisp :tangle no -;;; This file replaces itself with the real config at first run -;; We Can't tangle without org! -(require 'org) -;; Open the config... -(find-file (concat user-emacs-directory "init.org")) -;; Tangle it... -(org-babel-tangle) -;; Load it. -(load-file (concat user-emacs-directory "early-init.el")) -(load-file (concat user-emacs-directory "init.el")) -#+END_SRC - -** Git init.el tracking -*** Disable Tracking -There is no reason to track the =init.el= that is generated. Run the following command to make git ignore the generated file, but keep the dummy init. -#+BEGIN_SRC sh :tangle no -git update-index --assume-unchanged init.el -#+END_SRC - -*** Enable Tracking -If changes to the dummy-init are needed, track those by running -#+BEGIN_SRC sh :tangle no -git update-index --no-assume-unchanged init.el -#+END_SRC - +I have changed the meta. I no longer overwrite the init.el, instead opting to have the init.el tangle this file. * Early init This file was introduced in Emacs 27. I use it for speeding up init, removing all the UI stuff I don't want, etc. Maybe superfluous, but I do get startup times on the order of /0.015/ seconds on Windows. - ** The normal header There are no GNU Police (yet), but I feel nicer by adding this in. #+BEGIN_SRC emacs-lisp :tangle ./early-init.el @@ -97,9 +68,8 @@ Avoid a weird issue on windows where opening emacs via an [[https://www.autohotk * Main init ** Header - #+BEGIN_SRC emacs-lisp -;;; init.el --- Quae configurare -*- lexical-binding: t; -*- +;;; config.el --- Quae configurare -*- lexical-binding: t; -*- ;; Haec pars Emacs non est. @@ -115,23 +85,14 @@ Non-gnu is in the defaults now, so I only need to add melpa. (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) #+END_SRC -*** almost-mono-themes -Exactly what they say they are! +*** Ledger-mode +Accounting #+BEGIN_SRC emacs-lisp -(use-package almost-mono-themes +(use-package ledger-mode :ensure t - :config - (load-theme 'almost-mono-white t)) -#+END_SRC - -*** Packages I don't want on my work computers -I don't need these on a windows PC. -#+BEGIN_SRC emacs-lisp -(unless (equal system-type 'windows-nt) - (use-package ledger-mode - :ensure t - :bind - ((:map ledger-mode-map ("C-c s" . ledger-sort-buffer))))) + :defer t + :bind + ((:map ledger-mode-map ("C-c s" . ledger-sort-buffer)))) #+END_SRC *** visual-fill-column @@ -222,19 +183,19 @@ I need to open binary files with their own editor. Disgusting. #+BEGIN_SRC emacs-lisp (use-package openwith :ensure t + :custom + (openwith-associations (list + (list (openwith-make-extension-regexp + '("xls" "xlsx" "doc" "docx" + "ppt" "odt" "ods" "odg" "odp")) + "LibreOffice" + '(file)) + (list (openwith-make-extension-regexp + '("adpro")) + "ProductivitySuite" + '(file)))) :config (openwith-mode t)) - -(setq openwith-associations (list - (list (openwith-make-extension-regexp - '("xls" "xlsx" "doc" "docx" - "ppt" "odt" "ods" "odg" "odp")) - "LibreOffice" - '(file)) - (list (openwith-make-extension-regexp - '("adpro")) - "ProductivitySuite" - '(file)))) #+END_SRC *** acme-mouse @@ -1373,14 +1334,14 @@ Don't make a new window for source-code edits, and keep indentation consistent. org-src-fontify-natively t) #+END_SRC -**** Auto-tangle init.org +**** Auto-tangle this file Make a function to tangle this file, and run it on save. #+BEGIN_SRC emacs-lisp (defun re/tangle-init () "Tangle and compile init.org. Stolen from https://github.com/larstvei/dot-emacs." (when (equal (buffer-file-name) - (expand-file-name (concat user-emacs-directory "init.org"))) + (expand-file-name (concat user-emacs-directory "config.org"))) (let ((prog-mode-hook nil)) (org-babel-tangle)))) @@ -1535,5 +1496,5 @@ I do not use the customize system. I don't want to see it if I don't have to. ** Footer #+BEGIN_SRC emacs-lisp -;;; hic terminatur init.el +;;; hic terminatur config.el #+END_SRC diff --git a/early-init.el b/early-init.el new file mode 100644 index 0000000..fd4d732 --- /dev/null +++ b/early-init.el @@ -0,0 +1,26 @@ +;;; early-init.el -*- lexical-binding: t; -*- + +;; Haec pars Emacs non est. + +;; Code: + +(setq gc-cons-threshold most-positive-fixnum + gc-cons-percentage 0.6) + +(add-hook 'after-init-hook #'(lambda () (setq gc-cons-threshold (* 1024 1024 25) + gc-cons-percentage 0.1))) + +(menu-bar-mode -1) +(tool-bar-mode -1) +(blink-cursor-mode -1) + +(setq inhibit-startup-screen t + inhibit-startup-buffer-menu t + server-client-instructions nil + frame-resize-pixelwise t + initial-scratch-message (message ";;; Emacs loaded in %s.\n\n" (emacs-init-time))) + +(setq default-directory "~/") + +(provide 'early-init) +;;; hic terminatur early-init.el diff --git a/init.el b/init.el index af7613b..2af87ae 100644 --- a/init.el +++ b/init.el @@ -1,10 +1,10 @@ -;;; This file replaces itself with the real config at first run -;; We Can't tangle without org! +;;; init.el --- Quae configurare -*- lexical-binding: t; -*- + +;; Haec pars Emacs non est. + +;; Code: + (require 'org) -;; Open the config... -(find-file (concat user-emacs-directory "init.org")) -;; Tangle it... -(org-babel-tangle) -;; Load it. -(load-file (concat user-emacs-directory "early-init.el")) -(load-file (concat user-emacs-directory "init.el")) + +(org-babel-load-file (concat user-emacs-directory "config.org")) +;;; hic terminatur init.el -- 2.39.5