Using Djblue's portal for tap in Babashka
It’s often the case one has to deal with a repl-crashing amount of data via Babashka. In clojure I reach for hashp but this time I thought I’d try out Chris Badahdah’s Portal which describes itself as the following: “A clojure tool to navigate through your data”. Amazingly, you can even try it out online!
Hydra for evil-mc
At least in Doom Emacs the default keybindings for evil-mc are really cumbersome, here’s a Hydra that makes things much easier:
Naming a timer in Babashka
(defmacro named-time
"Evaluates expr and prints the `nme` and the time it took. Returns the value of
expr."
[nme# expr]
`(let [start# (. System (nanoTime))
ret# ~expr]
(prn (str "Elapsed time (" ~nme# ") "
(/ (double (- (. System (nanoTime)) start#)) 1000000.0)
" msecs"))
ret#))
Like the time
function that Babashka/Clojure has in core, but accepts a name so that it’s easier to identify stuff in a busy console:
(named-time :plus (+ 1 1)) => 2
, prints "Elapsed time (:plus) 0.022612 msecs"
Keeping backups of every edited file
I recently ran rm -rf *
in my home directory, which apart from being very foolish, reminded me that I have backups of basically every file I’ve edited:
Delta for Git and Magit
I was just introduced to a tool called Delta which is a pager you can use with Git to give you Github-esque diffs.
Save all mu4e attachments
To save all attachments from an mu4e email to a particular directory, you can use this handy snippet for older versions of the client. For more modern mu4e versions, use the elisp by @sj30.
condev - like cond but different
Hopefully the docstring explains this well enough:
Export an environment variable to Emacs
Handy function to export environment variables to Emacs from the command line:
Using yadm via magit
Yadm’s an amazing dotfile manager that’s basically a thin wrapper around git and a bare repo. With it being a bare repo, you’ll not be able to manage it directly with Magit so here’s a really smart tip I found that will let you access it via Tramp:
Load a random emacs theme on startup
To load a random emacs theme on startup (I restart daily) you can use the following snippet. Just add your theme as a new function to funs
. If you don’t restart often, you could add a timer to change themes while you’re going.
Start evil substitution on selection
Here’s a little evil operator that will fill in the first part of an evil/ex substitution with the region / visual / object. This allows you to replace objects quickly without having to type out the ex command in full.
Search specific extensions with counsel-projectile-rg
If you’re in a monorepo searching through stuff can be a bit chaotic. Here’s a way of narrowing down to specific file extensions with counsel-projectile-rg
:
Using the CIDER debugger in Evil
When using evil and CIDER together, you might find that rebinding the keys required to control the debugger is a pain. Luckily, you don’t actually have to, you can just enter insert mode instead:
Keeping a constant record of text written
If ever I’m writing a chunk of text that will change a lot over time, I like to use this script to make sure I have a constant record of what has changed over time. Combined with your equivelent of git-timemachine, it’s really handy for looking back at progression or finding where you might have gone wrong. 🙂
Widescreen emacs and vertical splits
On a widescreen monitor, especially the really wide ones, it’s nice to have only vertical splits. This snippet will give bias to vertical splits:
Having Smartparens commands work with Evil-mc
As described here, when using evil-mc, it’s very frustrating when a Smartparens command works on only the first of the multiple cursors. Here’s how to fix that: