hamacs/bootstrap.org
Howard Abrams f4a69065fc Integrate Mail into Emacs
The mail system connects to my Gmail account with isync and notmuch,
and allows me to interact with with it, like hey.com ... oh, and I can
compose email messsage in org format.

Pretty slick. Now, if I just used mail.
2021-11-14 22:08:09 -08:00

167 lines
6.4 KiB
Org Mode

#+TITLE: My Emacs Bootstrap
#+AUTHOR: Howard X. Abrams
#+EMAIL: howard.abrams@gmail.com
#+DATE: 2021-10-08
#+FILETAGS: :emacs:
A literate programming file for bootstraping my Emacs Configuration.
#+BEGIN_SRC emacs-lisp :exports none
;;; bootstrap.el --- file for bootstraping my Emacs Configuration
;;
;; Copyright (C) 2021 Howard X. Abrams
;;
;; Author: Howard X. Abrams <http://gitlab.com/howardabrams>
;; Maintainer: Howard X. Abrams <howard.abrams@gmail.com>
;; Created: October 8, 2021
;;
;; This file is not part of GNU Emacs.
;;
;; *NB:* Do not edit this file. Instead, edit the original literate file at:
;; ~/other/hamacs/bootstrap.org
;; And tangle the file to recreate this one.
;;
;;; Code:
#+END_SRC
* Introduction
This file contains all the variable definitions and library loading for the other files in my project.
** Straight Package Installer
I'm going to be installing everything using the [[https://github.com/raxod502/straight.el#getting-started][straight.el]] for package installation and management. Here is the initialization/installation for it:
#+BEGIN_SRC emacs-lisp
(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))
#+END_SRC
Let's get the Straight project working with =use-package=:
#+BEGIN_SRC emacs-lisp
(straight-use-package 'use-package)
#+END_SRC
While that enables the =:straight t= extension to =use-package=, let's just have that be the default:
#+BEGIN_SRC emacs-lisp
(use-package straight
:custom (straight-use-package-by-default t
straight-default-vc 'git))
#+END_SRC
See the details in [[https://dev.to/jkreeftmeijer/emacs-package-management-with-straight-el-and-use-package-3oc8][this essay]].
** Basic Libraries
The following packages come with Emacs, but seems like they still need loading:
#+BEGIN_SRC emacs-lisp
(require 'subr-x)
#+END_SRC
Ugh. Why am I getting this error?
#+BEGIN_SRC emacs-lisp
(defun first (elt) (car elt))
#+END_SRC
While most libraries will take care of their dependencies, I want to install /my dependent libraries/. Especially, [[https://github.com/magnars/.emacs.d/][Magnar Sveen]]'s Clojure-inspired [[https://github.com/magnars/dash.el][dash.el]] project:
#+BEGIN_SRC emacs-lisp
(use-package dash)
#+END_SRC
The [[https://github.com/magnars/s.el][s.el]] project is a simpler string manipulation library that I (and other projects) use:
#+BEGIN_SRC emacs-lisp
(use-package s)
#+END_SRC
Manipulate file paths with the [[https://github.com/rejeep/f.el][f.el]] project:
#+BEGIN_SRC emacs-lisp
(use-package f)
#+END_SRC
** My Code Location
Much of my more complicated code comes from my website essays and other projects. The destination, however, shows up here:
#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path (f-expand "~/.emacs.d/elisp"))
#+END_SRC
Hopefully, this will tie me over while I transition.
** Emacs Server Control
Sure the Emacs application will almost always have the =server-start= going, however, I need to control it just a bit (because I often have two instances running on some of my machines). What /defines/ the Emacs instance for work changes ... often:
#+BEGIN_SRC emacs-lisp
(defun ha-emacs-for-work? ()
"Return non-nil when the Emacs application's location matches as one for work.
Currently, this is the `emacs-plus' app that I have built with
the native-comp model, but I reserve the right to change this."
(->> Info-default-directory-list
(first)
(s-split "/")
(--filter (s-starts-with? "emacs-plus" it))
(first)))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(if (ha-emacs-for-work?)
(setq server-name "work")
(setq server-name "personal"))
(server-start)
#+END_SRC
* Load the Rest
The following loads the rest of my org-mode literate files. I add them as they are /ready/, but eventually, I'll trim this up into a nicer pattern.
#+BEGIN_SRC emacs-lisp
(defvar ha-hamacs-files `("ha-config.org"
,(when (display-graphic-p)
"ha-display.org")
"ha-org.org"
,(when (display-graphic-p)
"ha-org-word-processor.org")
"ha-org-clipboard.org"
"ha-org-journaling.org"
"ha-org-publishing.org"
"ha-org-sprint.org"
"ha-capturing-notes.org"
"ha-programming.org"
"ha-agendas.org"
"ha-email.org"
;; "ha-irc.org"
;; "ha-passwords.org"
"ha-remoting.org"
"ha-feed-reader.org"
,(when (ha-emacs-for-work?)
"ha-work.org"))
"List of org files that complete the hamacs project.")
#+END_SRC
We can test/debug/reload any individual file, via:
#+BEGIN_SRC emacs-lisp
(defun ha-hamacs-load (file)
"Load or reload an org-mode FILE containing literate Emacs configuration code."
(interactive (list (completing-read "Org file: " ha-hamacs-files)))
(org-babel-load-file (f-join hamacs-source-dir file)))
#+END_SRC
And we can now load everything:
#+BEGIN_SRC emacs-lisp
(dolist (file ha-hamacs-files)
(ha-hamacs-load file))
#+END_SRC
* Technical Artifacts :noexport:
Let's provide a name so that the file can be required:
#+BEGIN_SRC emacs-lisp :exports none
(provide 'bootstrap)
;;; bootstrap.el ends here
#+END_SRC
Before you can build this on a new system, make sure that you put the cursor over any of these properties, and hit: ~C-c C-c~
#+DESCRIPTION: A literate programming file for bootstrapping my environment.
#+PROPERTY: header-args:sh :tangle no
#+PROPERTY: header-args:emacs-lisp :tangle yes
#+PROPERTY: header-args :results none :eval no-export :comments no mkdirp yes
#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil date:nil
#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js