Anonymous Functions in Thread Macros

While adding the live reload feature to Clay, I encountered a problem of applying anonymous functions to thread macros. For example, below is a simple snippet trying to wrap the input directory as a vector with the help of thread macro, but surprisingly, it errors out. After some searching, I figured out that I need to put the anonymous function into another pair of parentheses: (-> "/tmp/" #(if (vector? %) % [%])) ;; => Syntax error (ClassCastException) compiling fn* at (simple4all. [Read More]

Starting a Clojure nREPL Manually for Cider

While troubleshooting and fixing a live reload bug in Clay today, which required to start a minimal Clojure environment, I figured out how to start a nREPL from the command line. Instead of using M-x cider-jack-in-clj directly from Emacs, actually we can manully bring up an nREPL with this: clj -Sdeps "{:deps {org.scicloj/clay {:mvn/version \"2-beta21\"} cider/cider-nrepl {:mvn/version \"0.50.2\"}}}" -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" (The clay part is only necessary for this debugging), and then connect to this nREPL using the Emacs command M-x cider-connect-clj. [Read More]

Join Every N Lines By A Separator in Emacs

It has been some time since I came along the idea of the w/join-lines command to join lines. After that, sometimes I found that it would be even better to join every a few lines. Let's see the example below, suppose we've copies some data from somewhere, and now we want to yank it into an Emacs buffer and slightly modify it to be like an matrix. That is, make it from: [Read More]
Emacs 

Restoring Emacs' Window Layouts

If you've been using Emacs for a while, I bet you must have encountered the annoying problem that your Emacs window layout gets messed up after some operations, such as looking for a help (e.g. C-h k), or checking things in the magit status buffer. Photo by R Mo on Unsplash I'm happy if I can just get back to the previous layout that I had before, and guess what? [Read More]
Emacs  hydra 

Emphasize Text By Dragging Mouse in Org-mode

Long story short, I came up with an idea to emphasize content while I was reviewing an org-mode document a few months ago after I was tired of typing tedious * around the content repeatedly. And I've been longing for this feature since then, because I was unfamiliar with mouse-based key bindings, and neither did I have the time to investigate it. Today I finally nailed it down while I was attending a boring meeting, and it turned out to be quite simple. [Read More]

Join Lines By A Separator in Emacs

So sometimes I need to join a few lines by a separator while I'm coding, for example, turn the below lines, foo bar baz into foo + bar + baz. (This is a silly example, I will update if I come up with a better one :-P ) When I was in a rush in the past, I usually baked a keyboard macro temporarily and then applied it to achieve this goal, thought reliable, it's a little bit cumbersome to record it. [Read More]
Emacs 

Hugo Blogging in Emacs

When I started to use Hugo to write this blog last year, I noticed that there is an easy-hugo package of Emacs many people use. So I installed it at that time, but I didn't use many of its features since then. In fact, the only command I used was easy-hugo-current-time. I used it to update the Hugo timestamps manually as in the format of 2022-10-15T09:45:35+08:00. My most desirable feature is to use it to select tags easily when I start to write a new post, but I never got it to work. [Read More]

Auto-complete Accounts From Other Beancount Files in Emacs

Auto-complete accounts from another accounts.bean file If you're using Beancount with Emacs, you may be using beancount-mode. It can auto-complete the accounts defined in the current buffer when we are typing in new transactions so that we can do it more efficiently. But it can only auto-complete the accounts from the current buffer, which makes it less useful when we have a stand-alone file or a few files of beancount accounts. [Read More]

A Bookmarklet for Copying a Link as an Org-mode Link

In this blog post, I'd like to share a bookmarklet for copying a web page's URL as an org-mode link on Firefox, Chrome, or whatever web browsers support bookmarklets. It's handy when the URL isn't SEO-friendly, which means you can't tell what its content is about at first glance of the URL. So a little description text on the link would help. Here is the bookmarklet: javascript:window.prompt("Copy to clipboard: Ctrl+C, Esc", "[[" + document. [Read More]

Emacs Debugging Techniques

If you are new to Emacs, you may run into some errors, especially after you copied some elisp snippets from the Internet or elsewhere. Don't panic! It happens, it's just part of the learning process. Even an experienced Emacs user could run into there issues from time to time. Photo by Mike Newbry on Unsplash But in order to ease the pain, I will introduce a bunch of Emacs built-in features to help you troubleshoot and eventually solve the problems by yourself in this post. [Read More]