# 2020-07-16 Emacs everything

These days I mostly use Emacs on my laptop. Sure, there’s all that stuff in the background. But in terms of applications I actually launch, I’d say I mostly use just Emacs.

I use Firefox for some websites, but I don’t actually do a lot of surfing. I spend a lot of time using Mastodon but with Bitlbee and the Mastodon plugin, I get the gist of things on IRC, and my IRC client is rcirc, in Emacs.

My Gemini client is Elpher, in Emacs. When I follow links in Elpher or IRC, they open in my default web browser, and my web browser is EWW, in Emacs.

(set browse-url-browser-function 'eww-browse-url)

Actually, there’s a little more customizing I do. First, I don’t need cookies:

(setq url-cookie-trusted-urls '()
url-cookie-untrusted-urls '(".*"))

Cookies were invented for shopping carts and that’s where they should remain.

And I like to follow Gemini and Gopher links from my browser, so here’s how to handle them:

(advice-add 'eww-browse-url :around 'asc:eww-browse-url)

(defun asc:eww-browse-url (original url &optional new-window)
(cond ((string-match-p "\\\$$gemini\\|gopher\$$://" url)
(require 'elpher)
(elpher-go url))
(t (funcall original url new-window))))

Did you know about Readability in EWW? Use R. 😀

I work a lot on the command line, but a lot of my work on the command line is actually just making directories, using git, and running tests, and all of that is better done in Emacs. Dired is my file manager, Magit is my git interface most of the time, Eshell is my shell.

I remember the days thirty years ago when I used Norton Commander on a 286. It was so much better than MS DOS 3.3 or whatever I used back then. But when I try to use Midnight Commander in a terminal, or Sunrise Commander in Emacs, soon enough I end up back in Dired.

I think there are some important things you need to do for Dired, though:

(eval-after-load "dired"
'(require 'dired-x))

(setq dired-recursive-deletes 'always
dired-recursive-copies 'always
dired-deletion-confirmer 'y-or-n-p
dired-clean-up-buffers-too nil
delete-by-moving-to-trash t
;; trash-directory "~/.Trash/emacs"
dired-dwim-target t
dired-guess-shell-alist-user
'(("\\.pdf\\'" "evince")
("\\.jpg\\'" "feh"))
dired-listing-switches "-alv")

Let’s go through them:

• Some of the stuff I’m going to customise is actually part of the Dired extensions, so make sure those get loaded as well (but only when actually using Dired)
• When deleting or copying directories, I always want to do this recursively.
• When confirming things, I hate typing y e s and hitting the Return key. A simple y should be enough.
• The buffer cleanup is another annoying question it likes to ask.
• Very important: switching from rm to trash on the command line has been good for me a few times and so I was happy to see that Dired can also use the system trash.
• Do-what-I-mean (DWIM) target means that whenever you have two dired buffers, the other buffer is suggested as a destination for commands that require one. Instant Norton Commander feelings: C-x 2 to split the window, change the directory in the current window, then copy or rename from one to the other.
• When using ! on a file, Dired will suggest a command, but for JPG files the suggested command is xloadimage (where as for PNG files it is display), and for PDF files the suggested command is xpdf. I was interested in learning more about feh and my PDF reader is Evince, so that’s where these two settings come from.
• The switches use -v in addition to the default switches, and that stands for natural numbers. Thus, foo-10 comes after foo-9, finally.

But there’s more:

(add-hook 'dired-mode-hook
(lambda ()
(local-set-key "E" 'emms-play-dired)
(local-set-key (kbd "C-c w") 'wdired-change-to-wdired-mode)))

Writable Dired (WDired) mode is cool because you can edit the buffer and rename a bunch of files all at the same time, using Emacs commands. In these situations using the rectangle commands come in super handy: C-x r k to kill a rectangle, and C-x r t to insert text on every line are my favourites.

EMMS is my music player, in Emacs. At home I don’t use it often, but at work I often need to listen to music. Fuck those open office plans. Project managers love it because they love to hear the buzz, get a feel for what the team is working on. For the team itself, however, it’s hell. We get to wear headphones almost the entire time because we can’t focus if we don’t. What a shitty way to program.

Back to EMMS... I usually use Dired to navigate to my music collection and then just hit E on a folder to play all of it. Perfect.

As loading EMMS can take a while because of the cache, I try to delay doing it. It’s only when nothing happens for a few seconds that I proceed. As you can see, my music player setup is super simple: I just use mpg321 or mpg123 or ogg123... As I said, it’s not fancy, can’t hit pause, don’t get lyrics, but it’s good enough for what I need: playing some music while I try to avoid the endless chatter of the people around me in the open plan office, GAAAAAAH!

(run-with-idle-timer
10 nil
(lambda ()
(require 'emms-setup)
(emms-standard)
(if (executable-find "mpg321")
(setq emms-player-list '(emms-player-mpg321))
(define-emms-simple-player mpg123 '(file url)
(emms-player-simple-regexp "mp3" "mp2")
"mpg123")
(setq emms-player-list '(emms-player-mpg123)))
(when (executable-find "ogg123")
(add-to-list 'emms-player-list 'emms-player-ogg123))))

Anyway, a small window into my Emacs life.

As you can see in the screenshot below, I use a big font, run Emacs maximised. I use them all maximised: Emacs, Tilix, Firefox, Evince... I don’t have time for tiling.

(cond ((find-font (font-spec :name "Iosevka"))
;; on windows, this defaults to a different font?
(dolist (face '(default fixed-pitch))
(set-face-attribute
face nil
:family "Iosevka"
:height (if (eq (window-system) 'w32) 180 220))))
((find-font (font-spec :name "Noto Mono"))
(set-face-attribute 'default nil :family "Noto Mono" :height 200)))

In the mode-line you can see my IRC setup. The theme I use is brutalist-dark. Thanks, @algernon.

I also deactivate the blinking cursor, the tool-bar, the menu-bar, and the scroll-bar...

;; deactivate some bling
tool-bar-mode
scroll-bar-mode))
(when (fboundp mode)
(funcall mode -1)))

And some stuff I need:

Matching parenthesis are important for programming languages with lots of parenthesis, hehe.

Winner mode lets me go back to particular window configurations. Let’s say I have used a bunch of C-x 2 and C-x 3 and C-x + to get a few buffers to show in just the right way, and then a few uses of C-h i or C-h f or C-h v or M-x man to get help and it gets all messed up? Use C-c <left> to get back to that old layout.

Windmove allows me to use shift and the arrow keys to move from window to window Which is important if you have more than one in Emacs. If you have just two, C-x o is probably good enough.

Showing the column is sometimes important, I guess? Now I can’t remember when it ever was important. Something to be removed soon, I guess.

I also like my Emacs to not beep. I like completion to ignore case, and I don’t use double space to end sentences. When this is really important I use non-breaking spaces after abbreviations. I’ve changed my Caps Lock key to be the Compose Key. Very useful!

;; active some other bling
(show-paren-mode 1)
(winner-mode 1)
(windmove-default-keybindings)
(column-number-mode 1)

(setq visible-bell t
completion-ignore-case t
(setq sentence-end-double-space nil)`

And here’s the screenshot...

Tags: