From 4adb945a518f61229e76c1ab7924c435f0c7c366 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Fri, 21 Aug 2020 13:11:52 -0400 Subject: [PATCH] Contain emacs config entirely within .emacs.d to enable Chemacs --- emacs/.emacs.d/init.el | 51 ++++++++++++++++++----------------- emacs/{ => .emacs.d}/init.org | 13 ++++----- 2 files changed, 32 insertions(+), 32 deletions(-) rename emacs/{ => .emacs.d}/init.org (99%) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 4e48521..4086221 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -1,29 +1,32 @@ ;;; -*- lexical-binding: t; -*- -;; This file is meant to bootstrap ~/init.org, which tangles itself to ~/.emacs.el. -;; Once init.org has been tangled for the first time, ~/.emacs.el should take -;; precedence over this file so it will no longer get loaded. +;; If ~/.emacs.d/jdormit-init.el, just load it. Otherwise, first +;; bootstrap Straight and load Org to make sure we end up with the +;; right Org version, then tangle ~/.emacs.d/init.org to +;; ~/.emacs.d/jdormit-init.el -(message "Bootstrapping init file...") +(when (not (file-exists-p + (expand-file-name "~/.emacs.d/jdormit-init.el"))) + (message "Bootstrapping init file...") + (defvar bootstrapping-init t) + (defvar bootstrap-version) + (let ((bootstrap-file + (expand-file-name "straight/repos/straight.el/bootstrap.el" + user-emacs-directory)) + (bootstrap-version 5)) + (unless (file-exists-p bootstrap-file) + (with-current-buffer + (url-retrieve-synchronously + "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" + 'silent 'inhibit-cookies) + (goto-char (point-max)) + (eval-print-last-sexp))) + (load bootstrap-file nil 'nomessage)) -(defvar bootstrapping-init t) -(defvar bootstrap-version) -(let ((bootstrap-file - (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) - (bootstrap-version 5)) - (unless (file-exists-p bootstrap-file) - (with-current-buffer - (url-retrieve-synchronously - "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file nil 'nomessage)) + (straight-use-package 'org-plus-contrib) + (require 'org) + (org-babel-tangle-file + (expand-file-name "~/.emacs.d/init.org") + (expand-file-name "~/.emacs.d/jdormit-init.el"))) -(straight-use-package 'org-plus-contrib) -(require 'org) - -(org-babel-tangle-file - (expand-file-name "~/init.org") - (expand-file-name "~/.emacs.el")) -(load-file (expand-file-name "~/.emacs.el")) +(load-file (expand-file-name "~/.emacs.d/jdormit-init.el")) diff --git a/emacs/init.org b/emacs/.emacs.d/init.org similarity index 99% rename from emacs/init.org rename to emacs/.emacs.d/init.org index 1a569e6..5c7ffef 100755 --- a/emacs/init.org +++ b/emacs/.emacs.d/init.org @@ -1,9 +1,9 @@ -*- eval: (add-hook 'after-save-hook 'org-babel-tangle 0 t) -*- #+PROPERTY: header-args :results silent -#+PROPERTY: header-args:emacs-lisp :lexical t :tangle ~/.emacs.el +#+PROPERTY: header-args:emacs-lisp :lexical t :tangle ~/.emacs.d/jdormit-init.el This is a literate init file holding my Emacs configuration. It is -initially loaded by a [[file:.emacs.d/init.el::;;; -*- lexical-binding: t; -*-][bootstrap file]] that lives at ~/.emacs.d/init.el; +initially loaded by a [[file:init.el][bootstrap file]] that lives at ~/.emacs.d/init.el; after the initial bootstrapping it writes itself to ~/.emacs.el. Since ~/.emacs.el takes priority over ~/.emacs.d/init.el, after the initial bootstrapping process the tangled ~/.emacs.el file will get loaded @@ -853,7 +853,7 @@ A function to reload my init file. It reloads the major mode after the init file #+BEGIN_SRC emacs-lisp (defun reload-init-file () (interactive) - (load-file "~/.emacs.el") + (load-file "~/.emacs.d/jdormit-init.el") (funcall major-mode)) #+END_SRC @@ -861,7 +861,7 @@ And another one to edit it: #+BEGIN_SRC emacs-lisp (defun find-init-file () (interactive) - (find-file "~/init.org")) + (find-file "~/.emacs.d/init.org")) #+END_SRC * Keybindings @@ -4717,13 +4717,10 @@ Or Gnus can read RSS feeds directly: * Dired ** Dired-X #+BEGIN_SRC emacs-lisp - (defun dired-x-load-setup () - (require "dired-x")) - (defun dired-x-setup () + (require 'dired-x) (dired-omit-mode 1)) - (add-hook 'dired-load-hook #'dired-x-load-setup) (add-hook 'dired-mode-hook #'dired-x-setup) #+END_SRC