Skip to content

Instantly share code, notes, and snippets.

@jhilker98
Last active May 10, 2021 23:49
Show Gist options
  • Save jhilker98/eee037e912e4e23c5bd552b09572fe81 to your computer and use it in GitHub Desktop.
Save jhilker98/eee037e912e4e23c5bd552b09572fe81 to your computer and use it in GitHub Desktop.

Jmacs (Jacob’s Literate Emacs Config)

Welcome to JMacs! This is a my personal configuration of emacs, for solo RPG campaigns like Ironsworn, writing (both prose and code), and for general use. I have organized this file into different sections, such as the functions I use, the UI settings, etc.

Early Initialization

Disabling Package.el

By default, I want to use straight.el as my package manager.

(setq package-enable-at-startup nil)

General Initialization

Setting Up Straight.el

I am using straight.el for my packages.

(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))

Setting Up Use-Package with Straight.el

Use-package provides an easy-to-use macro - I like that, but want the functionality of straight.el.

(straight-use-package 'use-package)

And finally, I always want it to use straight.el.

(setq straight-use-package-by-default t)

Org Mode

I want to use the newest version of org-mode instead of the one built in to emacs.

(straight-use-package '(org-plus-contrib :includes org))

And finally, I want to load the literate config.

(org-babel-load-file "~/.emacs.d/jmacs.org")

Initial Setup

This is where I setup my initial personal information, as well as a minimal UI and enabling the visual bell.

(setq visible-bell t)

Now I want to disable automatic indentation with electric-indent-mode, and disable tabs.

(electric-indent-mode -1)
(setq-default indent-tabs-mode nil)
(setq tab-always-indent 'complete)

Core Functionality

Undo Tree

Undo Tree lets me use more of Evil mode’s redo functionality.

(use-package undo-tree
:config
 (global-undo-tree-mode))

Evil Mode

Evil mode lets me use the (superior) Vim bindings to the Emacs ones. In addition, I don’t want :q to kill emacs, but rather the current buffer I am in (similar to Vim).

Evil-mode Core

This is the core of evil mode.

(use-package evil
  :init
  (setq evil-undo-system 'undo-tree)

  (setq evil-want-integration t) ;; This is optional since it's already set to t by default.
  (setq evil-want-keybinding nil)
  :config
  ;(evil-set-undo-system 'undo-tree)
  ;(setq evil-undo-system 'undo-tree)
  (evil-mode 1)
  :preface
  (defun ian/save-and-kill-this-buffer ()
    (interactive)
    (save-buffer)
    (kill-this-buffer))
  :config
  (with-eval-after-load 'evil-maps ; avoid conflict with company tooltip selection
    (define-key evil-insert-state-map (kbd "C-n") nil)
    (define-key evil-insert-state-map (kbd "C-p") nil))
  (evil-ex-define-cmd "q" #'kill-this-buffer)
  (evil-ex-define-cmd "wq" #'ian/save-and-kill-this-buffer))

Evil-mode Collection

This provides a collection of modules for using evil mode in other emacs programs.

(use-package evil-collection
  :after evil
  :config
  (evil-collection-init))

General

(use-package general)

Which-Key

Which-key lets me see what keybindings I can use.

(use-package which-key
:config
(which-key-mode 1))

Hydra

I want to use hydras for certain things - namely, elfeed filters.

(use-package hydra)

Helpful

Helpful allows me to have a better view of a help buffer.

(use-package helpful
    :config
    (setq counsel-describe-function-function #'helpful-callable)
    (setq counsel-describe-variable-function #'helpful-variable))

IDE Configuration

Completion Frameworks

Counsel

(use-package counsel
  :config
  (counsel-mode 1))

Ivy

(use-package ivy
  :defer 0.1
  :diminish
 :config
 (setq ivy-count-format "(%d/%d) ")
 (ivy-mode 1))

Ivy Posframe

Ivy Posframe makes it much easier to edit the ivy ui.

Ivy Rich

Ivy Rich will allow me to see more about each command

(use-package ivy-rich
  :init
  (ivy-rich-mode 1))

Swiper

 (use-package swiper
:after ivy)

Org Mode

General Customization

Clearer Faces

I like having different colors for faces.

(set-face-attribute 'org-level-1 nil :foreground "#83a598")
(set-face-attribute 'org-level-2 nil :foreground "#d3869b")
(set-face-attribute 'org-level-3 nil :foreground "#fabd2f")
(set-face-attribute 'org-level-4 nil :foreground "#fb4934")
(set-face-attribute 'org-level-5 nil :foreground "#83a598")
(set-face-attribute 'org-level-6 nil :foreground "#d3869b")
(set-face-attribute 'org-level-7 nil :foreground "#fabd2f")
(set-face-attribute 'org-level-8 nil :foreground "#fb4934")

Org Tempo

Org Tempo lets me use <s(tab) to insert blocks into an org-mode document.

(use-package org-tempo
    :straight nil
    :ensure nil)

UI Tweaks

Fonts

I love Iosevka as a font. All the different variants help as well.

(set-face-attribute 'default nil :font "Iosevka Nerd Font" :height 120)
(set-face-attribute 'org-meta-line nil :font "Iosevka Nerd Font" :height 120)
(set-face-attribute 'org-block nil :font "Iosevka Nerd Font" :height 120)

Variable Width

I like Iosevka Aile as a variable width font for content.

(set-face-attribute 'variable-pitch nil :font "Iosevka Aile" :height 120)

Themes

The doom-themes collection has a lot of nice themes - I do overwrite some of the faces, though.

(use-package doom-themes)
(load-theme 'doom-gruvbox t)

Keybindings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment