Why yes, this will look like it sprung, like Athena, fully grown and in armor from my head, but this is really just the mid-point of a new endeavor.
11 KiB
Emacs Graphical Display Configuration
A literate programming file to configure the Emacs UI.
Dashboard
The emacs-dashboard project makes a nicer startup screen.
(use-package dashboard
:init
(setq dashboard-banner-logo-title "Welcome to Emacs"
dashboard-startup-banner "~/other/hamacs/support/levitating-gnu.png"
dashboard-center-content t
dashboard-set-init-info t
dashboard-projects-switch-function 'projectile-persp-switch-project
dashboard-items '((projects . 5)
;; (agenda . 5)
(bookmarks . 5)))
:config
(dashboard-setup-startup-hook)
(setq dashboard-footer-messages (list (ha--dad-joke))))
Mode Line
Let's install and load some of packages from the Doom Emacs project, like doom-modeline and maybe the themes:
(use-package doom-modeline
:init
(setq doom-modeline-minor-modes nil
doom-modeline-buffer-encoding nil
doom-modeline-percent-position nil)
:config
(doom-modeline-mode +1))
(use-package doom-themes)
Themes
One does get used to a particular collection of colors. Mine is Tomorrow:
(use-package color-theme-sanityinc-tomorrow)
Most of the time, Emacs is on my desk is a darkened room, so I choose the dark theme:
(defun laptop-inside ()
(interactive)
(load-theme 'sanityinc-tomorrow-night t)
(set-face-attribute 'region nil :background "#000096")
;; font-lock-comment-face #8a8b8a
(set-face-attribute 'mode-line nil :background "black")
(set-face-attribute 'mode-line-inactive nil :background "#333333"))
But, when feeling adventurous, I sometimes take my laptop outside:
(defun laptop-in-the-sun ()
(interactive)
(load-theme 'sanityinc-tomorrow-day t)
(set-face-attribute 'region nil :background "orange1")
;; font-lock-comment-face #8a8b8a
(set-face-attribute 'mode-line nil :background "#cccccc")
(set-face-attribute 'mode-line-inactive nil :background "#888888"))
Oh, and turn off the line highlighting:
(global-hl-line-mode -1)
And of course, the default is inside where it is dark and safe:
(laptop-inside)
Full Size Frame
Taken from this essay, I figured I would start the initial frame automatically in fullscreen, but not any subsequent frames (as this could be part of the capturing system).
(add-to-list 'initial-frame-alist '(fullscreen . maximized))
Font Configuration
Am I ever really ever satisfied with any font? I regularly change my font based on the monospace du jour… Source Code Pro is attractive, and has been a staple on every programmers' screen. However, we all want ligatures, Hasklig is a nice font that is thinner and easier to read than Fira, but Iosevka seems to have it all. Oh, Microsoft just gave us Cascadia and that seems shiny. However, the Nerd Font project adds the ligatures as well as all the other niceties to a font.
Choosing a Font
I stole the following idea from Protesilaos Stavrou's dotfile configuration, and the following should minimally be readable:
Similarities | Regular | |
---|---|---|
()[]{}<>«»‹› | ABCDEFGHIJKLMNOPQRSTUVWXYZ | |
6bB8& | abcdefghijklmnopqrstuvwxyz | |
0ODdoaoOQGC | 0123456789 | |
I1tilIJL | ~!@#$%^&*+ | |
!¡ij | `'"‘’“”.,;:… | |
5$§SsS5 | ()[]{}—-_=<>/\ | |
17ZzZ2 | ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ | |
9gqpG6 | αβγδεζηθικλμνξοπρστυφχψω | |
hnmMN | ||
uvvwWuuwvy | ||
x×X | #include <stdio.h> // <= quickly. | |
.,·°% | int main(int argc, char **argv) { | |
¡!¿? | long il1[]={1-2/3.4,5+6==7/8}; | |
:; | int OxFaced=0xBAD | "[{(CQUINE"; |
`''"‘’“” | unsigned O0,l1,Z2,S5,G6,B8__XY; | |
—-~≈=≠+*_ | printf("@$Hamburgefo%c`",'\n'); | |
…⋯ | return ~7&8^9?0:l1 | !"j->k+=*w"; |
… |
The following is from Hack's website:
// The four boxing wizards jump
#include <stdio.h> // <= quickly.
int main(int argc, char **argv) {
long il1[]={1-2/3.4,5+6==7/8};
int OxFaced=0xBAD||"[{(CQUINE";
unsigned O0,l1,Z2,S5,G6,B8__XY;
printf("@$Hamburgefo%c`",'\n');
return ~7&8^9?0:l1|!"j->k+=*w";
}
To install a font, I use the following command on my Mac:
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
Specifying a Font
My current favorite font is actually the top list of fonts that may be installed on my system (they usually are):
(defvar ha/fixed-font
(when window-system
(cond ((x-list-fonts "Hack Nerd Font") "Hack Nerd Font")
((x-list-fonts "Cousine Nerd Font") "Cousine Nerd Font")
((x-list-fonts "Iosevka Nerd Font") "Iosevka Nerd Font")
((x-list-fonts "Iosevka") "Iosevka")
((x-list-fonts "FantasqueSansMono Nerd Font") "FantasqueSansMono Nerd Font")
((x-list-fonts "Monoid Nerd Font") "Monoid Nerd Font")
((x-list-fonts "Hasklig") "Hasklig")
((x-list-fonts "Cascadia Code PL") "Cascadia Code PL")
((x-list-fonts "Source Code Pro") "Source Code Pro")
((x-list-fonts "Anonymous Pro") "Anonymous Pro")
(t "monospaced")))
"My fixed width font based on what is installed, `nil' if not defined.")
Force something as well:
(setq ha/fixed-font "Hack Nerd Font")
I probably don't need to have such a ranking system, as chances are really good that I'll have all of them installed. Still.
(defvar ha/variable-font
(when window-system
(cond ((x-list-fonts "Overpass") "Overpass")
((x-list-fonts "Source Sans Pro") "Source Sans Pro")
((x-list-fonts "Lucida Grande") "Lucida Grande")
((x-list-fonts "Verdana") "Verdana")
((x-family-fonts "Sans Serif") "Sans Serif")
(nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro."))))
"My variable width font available to org-mode files and whatnot.")
Simple function that gives me the font information based on the size I need.
This calls set-frame-font
, but also sets the monospaced font for org code blocks.
(defun ha/set-favorite-font-size (size)
(let ((fav-font (format "%s-%d" ha/fixed-font size)))
(set-frame-font fav-font nil t)
;; When using variable-pitch in org, we need to specifically set the
;; fixed-pitch as my default fixed-pitched font.
(custom-theme-set-faces
'user
`(variable-pitch ((t (:family ,ha/variable-font :slant normal :weight normal :height 1.1 :width normal))))
`(fixed-pitch ((t (:family ,ha/fixed-font :slant normal :weight normal :height 1.0 :width normal)))))))
Define a few interactive functions to quickly adjusting the font size based on my computing scenario:
(defun ha/mac-monitor-fontsize ()
"Quickly set reset my font size when I connect my laptop to a monitor on a Mac."
(interactive)
(ha/set-favorite-font-size 13))
(defun ha/linux-monitor-fontsize ()
"Quickly set reset my font size when I connect my laptop to a monitor on Linux."
(interactive)
(ha/set-favorite-font-size 12))
(defun ha/mac-laptop-fontsize ()
"Quickly set reset my font size when I disconnect my laptop to a monitor from a Mac."
(interactive)
(ha/set-favorite-font-size 32))
(defun ha/linux-laptop-fontsize ()
"Quickly set reset my font size when I disconnect my laptop to a monitor from Linux."
(interactive)
(ha/set-favorite-font-size 14))
Which font to choose?
(if (eq system-type 'gnu/linux)
(ha/linux-laptop-fontsize)
(ha/mac-monitor-fontsize))
Ligatures
Seems like getting ligatures to work in Emacs has been a Holy Grail. On Mac, I've used special builds that have hacks, but now with Emacs 27 and Harfbuzz, I should be able to get –> to look like it should.
(setq prettify-symbols-unprettify-at-point 'right-edge)
(global-prettify-symbols-mode +1)
(prettify-symbols-mode +1)
Note, in Doom, is appears we have a ligatures
module.
We'll start using that instead, but changing it in general-programming file.