Hugo Readdir Error with Emacs
emacs

Hugo Readdir Error with Emacs

Every now and then when previewing Hugo (via hugo serve) as I'm editing it in Emacs I'll get a strange error like: ERROR 2021/10/18 19:36:03 process: readAndProcessContent: walk: Readdir: decorate: lstat /home/user/skeptric/content/user@machine.2139:12345 no such file or directory Often I can work around it by editing and saving the file I've been editing again, but I'll have to restart the Hugo process. However the underlying cause is lockfiles in Emacs, and the easiest fix is to run the elisp (in 24.

Pasting text from long ago in Emacs and Vim
emacs

Pasting text from long ago in Emacs and Vim

I use Vim keybindings in Emacs through Evil Mode and Evil Collection. Often I'll copy something, make some edits, and then want to paste the text. The problem is that the edits changed what was on the register and I want to recover that text. In Vim (and Evil mode) I can type :reg to see what's in the registers, find the value I want to paste, commit the register to memory (for example 8), exit and then paste that register ("8p from normal mode, C-r 8 from insert mode).

Taking Screenshots in Firefox
firefox

Taking Screenshots in Firefox

I find taking screenshots in Linux a bit painful. My current way is to use GIMP to create an image from a screenshot, but it's a bit slow to startup and interrupts my flow. I've had trouble installing Shutter which I haven't worked through yet. However I've just found out that Firefox has a way to take screenshots. All you need to do is press Control-Shift-S and then it brings up a selector where you can pick an element, or a region (like an improved version of Windows Snipping tool).

Offline SQL Formatting with sqlformat
sql

Offline SQL Formatting with sqlformat

It's polite to format your SQL before you share it around. You want to be able to do it in context, and not upload your private SQL to some random website. The sqlformat command of the Python package sqlparse is a great tool for the job. You can install sqlformat in Debian derivatives such as Ubuntu with sudo apt install sqlformat. Alternatively with any system with Python you can install it via pip install sqlparse, just make sure you have the binary in your path (e.

Customising Portable Dotfiles
git

Customising Portable Dotfiles

I keep my personal configuration files in a public dotfiles repository. This means that whenever I'm on a new machine it's very easy to get comfortable in a new environment. However I find I often need machine specific configuration, so I provide ways to override them with local configuration. When I get to a new machine I'll pretty quickly want some of my usual configuration (although I don't need it). I can clone or download a zipfile of my dotfiles and then install it via some symlinks via a bootstrap bash script.

Pipetable to CSV
emacs

Pipetable to CSV

Sometimes I get out pipe tables in Emacs that I want to convert into a CSVto put somewhere else. This is really easy with regular expressions. I often get data output from an SQL query like this text | num | value --------------+------+------------- Some text | 0.3 | 0.2 Rah rah | 7 | 0.00123(2 rows) Running sed 's/\(^ *\| *|\|(.*\) */,/g' gives: ,text,num,value --------------+------+------------- ,Some text,0.3,0.2 ,Rah rah,7,0.00123, I can delete the divider and then use as a CSV.

Using Emacs under WSL
emacs

Using Emacs under WSL

Getting Emacs to work nicely on a Windows system can be a challenge. You can install it natively (although getting all the dependencies is a challenge), but many packages require libraries or utilities that are hard to install or don't exist on Windows. The best solution I have found is using Emacs under the Windows Subsystem for Linux (WSL) with Xming. However if you run Emacs 26 or greater after starting Xming with XLaunch you're faced with a blank screen and can't see any writing on Emacs

Don't manage work email with Emacs
email

Don't manage work email with Emacs

I do a lot of work in Emacs and at the command line, and I get quite a few emails so it would be great if I could handle my emails there too. Email in Emacs can be surprisingly featureful and handles HTML markup, images and can even send org markup with images and equations all from the comfort of an Emacs buffer. However it can be a whole heap of work, and as you get deeper into the features your mail client provides the amount of custom integration required grows very rapidly.

Using emacs dumb-jump with evil
emacs

Using emacs dumb-jump with evil

Dumb-jump is a fantastic emacs package for code navigation. It jumps to the definition of a function/class/variable by searching for regular expressions that look like a definition using ag, ripgrep or git-grep/grep. Because it is so simple it works in over 40 languages (including oddities like SQL, LaTeX and Bash) and is easy to extend. While it is slower and less accurate than ctags, for medium sized projects it's fast enough and requiring no setup makes it much more useful in practice.