Skip to content

meshelton/emacs-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Emacs Initialization File

Bootstrapping

The endgoal here is to have an easily shareable, readable, and reproducable emacs setup. When you clone this repository you'll have two main files: init.el and README.org.

This is the entry point to the entire configuration process. When you first clone this repo init.el should look like this:

;;; .emacs --- Emacs initialization file -*- lexical-binding: t; -*-

;; This file replaces itself with the actual configuration at first run.

;; We can't tangle without org!
(require 'org)
;; Open the configuration
(find-file (concat user-emacs-directory "README.org"))
;; tangle it
(org-babel-tangle)
;; load it
(load-file (concat user-emacs-directory "init.el"))
;; finally byte-compile it
(byte-compile-file (concat user-emacs-directory "init.el"))

This code will load org mode, move specified code blocks from README.org to init.el and then byte compile it.

This is where the main configuration goes. Any code blocks that have the :tangle ./init.el will be used to construct the final init.el file through the function (org-babel-tangle). The initial processesing of README.org will be triggered by init.el.

Then we load up a couple packages:

  1. use-package :: A nicer package configuration framework
  2. org-mode :: A package for literate programming and so much more
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
                         ("marmalade" . "https://marmalade-repo.org/packages/")
                         ("melpa" . "https://melpa.org/packages/")
                         ("org" . "https://orgmode.org/elpa/")))
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(require 'use-package)
(setq use-package-always-ensure t)
(use-package org
             :bind ("C-c l" . 'org-store-link))

Subsequent init.el generations are through this after-save-hook on README.org

(defun tangle-init ()
  "If the current buffer is 'README.org' the code-blocks are
tangled, and the tangled file is compiled."
  (when (equal (buffer-file-name)
               (expand-file-name (concat user-emacs-directory "README.org")))
    ;; Avoid running hooks when tangling.
    (let ((prog-mode-hook nil))
      (org-babel-tangle)
      (byte-compile-file (concat user-emacs-directory "init.el")))))

(add-hook 'after-save-hook 'tangle-init)

We also add an after save hook to automatically generate a new README.md

(require 'ox-md)
(use-package ox-gfm)
(defun export-readme ()
  "If the current buffer is 'README.org' export it to 'README.md'"
  (when (equal (buffer-file-name)
               (expand-file-name (concat user-emacs-directory "README.org")))
    (org-gfm-export-to-markdown)))
(add-hook 'after-save-hook 'export-readme)

Configuration

Per System Configuration

(defun system-is-home-desktop ()
  (interactive)
  "Return true if the system we are running is my personal desktop"
  (string-equal (system-name) "DESKTOP-C2EK1OP"))
(defun system-is-home-desktop-wsl ()
  (interactive)
  "Return true if the system we are running is my personal desktop"
  (string-equal (system-name) "DESKTOP-6PNIEF5"))

Personal Information

(setq user-full-name "Michael Shelton"
      user-mail-address "michael.e.shelton@gmail.com")

Backup

(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq delete-old-versions -1)
(setq version-control t)
(setq vc-make-backup-files t)
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))
(setq backup-by-copying t)

Appearance

(load-theme 'wombat 1)
(global-linum-mode 0)
(column-number-mode 1)
(line-number-mode 1)
(setq inhibit-startup-screen 1)
(show-paren-mode 1)
(tool-bar-mode -1)
(setq-default indent-tabs-mode nil)
(setq tab-width 2)
(setq compilation-scroll-output 'first-error)

Multiple Cursors

(use-package multiple-cursors
  :bind (("C->" . 'mc/mark-next-like-this)
         ("C-<" . 'mc/mark-previous-like-this)
         ("C-^" . 'mc/mark-all-like-this)))

Visual Regular Expressions

(use-package visual-regexp
  :bind (("C-M-r" . 'vr/replace)
         ("C-M-q" . 'vr/query-replace)))
(use-package visual-regexp-steroids
  :bind ("C-M-m" . 'vr/mc-mark))

Magit

(use-package magit
  :bind ("C-x g" . 'magit-status))

string-inflection

(use-package string-inflection
  :bind ("C-c i" . 'string-inflection-cycle))

TODOs

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages