While still finding my footing making Emacs videos, today I'm sharing my second video.
Bending Emacs Episode 02: From vanilla to your flavor
The video is a little longer than I intended at 14:37, so plan accordingly.
In this video, I show some of my favorite UI customizations, with additional tips and tricks along the way. Like my first video, I'm hoping you find unexpected goodies in there despite being familiar with the general topic.
Read on for all supporting material…
Showcased a handful of ways to evaluate elisp.
M-x eval-last-sexp
M-x eval-expression
M-x eval-buffer
M-x ielm
M-x org-ctrl-c-ctrl-c (Evaluate org source blocks)
Sample snippets:
(set-face-attribute 'default nil :background "DarkSlateGray")
(set-face-attribute 'default nil :background "#212121")
path/to/emacs/nextstep/Emacs.app/Contents/MacOS/Emacs -Q --init-directory /tmp/secondary/.emacs.d --load path/to/other-emacs.el
other-emacs.el (minimal, almost vanilla setup):
; -*- lexical-binding: t; -*-
(server-force-delete)
(make-directory "/tmp/secondary/" t)
(setq server-socket-dir "/tmp/secondary/")
(setq server-name "emacs-server")
(server-start)
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")))
(setq package-archive-priorities
'(("melpa" . 4)))
(require 'package)
(package-initialize)
(mapc #'package-delete (mapcar #'cadr package-alist))
(add-to-list 'custom-theme-load-path "path/to/emacs-materialized-theme")
(defmacro with-other-emacs (&rest body)
"Evaluate BODY in the current buffer of the other Emacs instance."
`(call-process "emacsclient" nil nil nil
"--socket-name=/tmp/secondary/emacs-server"
"--eval"
(prin1-to-string
'(with-current-buffer (window-buffer (selected-window))
,@body))))
We want to extend source blocks to accept the :other-emacs header argument as follows:
#+begin_src emacs-lisp :other-emacs t
(message (propertize "Hello again twin" 'face '(:height 6.0)))
#+end_src
So we advice org-babel-expand-body:emacs-lisp:
(defun adviced:org-babel-expand-body:emacs-lisp:other-emacs (orig-fn body header-args)
(if (map-elt header-args :other-emacs)
(format "(with-other-emacs %s)" (funcall orig-fn body header-args))
(funcall orig-fn body header-args)))
(advice-add #'org-babel-expand-body:emacs-lisp
:around #'adviced:org-babel-expand-body:emacs-lisp:other-emacs)
(set-face-attribute 'default nil
:height 160 ;; 16pt
;; brew tap homebrew/cask-fonts && brew install --cask font-jetbrains-mono
:family "JetBrains Mono")
(load-theme 'materialized t)
(use-package calle24 :ensure t
:config
(calle24-install)
(calle24-refresh-appearance)))
(tool-bar-mode -1)
No text in title bar
(setq-default frame-title-format "")
Transparent titlebar (macOS)
(set-frame-parameter nil 'ns-transparent-titlebar t)
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(scroll-bar-mode -1)
(use-package minions
:ensure t
:custom
(mode-line-modes-delimiters nil)
(minions-mode-line-lighter " …")
:config
(minions-mode +1)
(force-mode-line-update t))
(use-package moody
:ensure t
:config
(setq-default mode-line-format
'(""
mode-line-front-space
mode-line-client
mode-line-frame-identification
mode-line-buffer-identification
" "
mode-line-position
(vc-mode vc-mode)
(multiple-cursors-mode mc/mode-line)
mode-line-modes
mode-line-end-spaces))
(moody-replace-mode-line-buffer-identification)
(moody-replace-vc-mode))
(use-package nyan-mode
:ensure t
:custom
(nyan-bar-length 10)
:config
(nyan-mode +1)))
A little static welcome screen I cooked up.
(defun ar/show-welcome-buffer ()
"Show *Welcome* buffer."
(with-current-buffer (get-buffer-create "*Welcome*")
(setq truncate-lines t)
(setq cursor-type nil)
(read-only-mode +1)
(ar/refresh-welcome-buffer)
(local-set-key (kbd "q") 'kill-this-buffer)
(add-hook 'window-size-change-functions
(lambda (_frame)
(ar/refresh-welcome-buffer)) nil t)
(add-hook 'window-configuration-change-hook
#'ar/refresh-welcome-buffer nil t)
(switch-to-buffer (current-buffer))))
(defun ar/refresh-welcome-buffer ()
"Refresh welcome buffer content for WINDOW."
(when-let* ((inhibit-read-only t)
(welcome-buffer (get-buffer "*Welcome*"))
(window (get-buffer-window welcome-buffer))
(image-path "~/.emacs.d/emacs.png")
(image (create-image image-path nil nil :max-height 300))
(image-height (cdr (image-size image)))
(image-width (car (image-size image)))
(top-margin (floor (/ (- (window-height window) image-height) 2)))
(left-margin (floor (/ (- (window-width window) image-width) 2)))
(title "Welcome to Emacs"))
(with-current-buffer welcome-buffer
(erase-buffer)
(setq mode-line-format nil)
(goto-char (point-min))
(insert (make-string top-margin ?\n))
(insert (make-string left-margin ?\ ))
(insert-image image)
(insert "\n\n\n")
(insert (make-string (- (floor (/ (- (window-width window) (string-width title)) 2)) 1) ?\ ))
(insert (propertize title 'face '(:height 1.2))))))
(ar/show-welcome-buffer)
Liked the video? Please let me know. Got feedback? Leave me some comments.
Please go like my video, share with others, and subscribe to my channel.
If there's enough interest, I'll continue making more videos!
powered by LMNO.lol