Posted on 2025-04-29
(Last modified on 2025-05-17)
| 1 minutes
| 82 words
Sometimes, we may want a few examples of a Clojure API for inspiration while developing, especially when reading other people's or open source code.
With Cider in Emacs, we can run M-x cider-doc to see the docstring for the symbol. We can even use M-x cider-clojuredocs for some examples if the symbol is from the language core.
Running M-x cider-clojuredocs
I happened to find this command recently. I bet I was not the only one who didn't know it, thus I'm sharing.
Here is the outline for my cider tutorial on YouTube, covering basic things you need to know to get started with cider, and starting exploring the fun of clojure programming with the REPL-driven programming approach.
Jack In to a REPL
C-c M-j (cider-jack-in-clj)
start a nREPL and jack in.
It works in a project or with a sole .clj file.
M-x cider-connect-clj
run the command and then fill in hostname and port.
It could be useful in some cases. e.g. on Windows, I can start the nREPL manually and then connect to it separately.
Evaluate Things
C-M-x (cider-eval-defun-at-point)
evaluate current top-level form.
C-x C-e (cider-eval-last-sexp)
evaluate the preceding form.
C-c C-k (cider-load-buffer)
evaluate/load the current buffer.
C-c C-p (cider-pprint-eval-last-sexp)
Pprint the result in a dedicated buffer.
Great thing to do when the result is too large to fit in the echo area.
Note: I prefer to use the same key bindings as for Elisp, given that
cider might bind a few keys to a single command!
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.
Posted on 2023-11-19
(Last modified on 2025-02-26)
| 2 minutes
| 332 words
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? Emacs happens to have that capability built in – the winner-mode package, what a surprise!
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. The exploration journey was not much different than before. First, I managed to find out how to bind a command to a mouse event, taking advantage of the good-old C-h k and (info "emacs") (or here at gnu.org). And then wrote a few lines of code to perform the task standing on the shoulder of Advice.
Posted on 2023-06-12
(Last modified on 2023-11-25)
| 2 minutes
| 399 words
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. So I wonder maybe it would be a good idea to have a command for it.
Posted on 2022-10-10
(Last modified on 2025-02-26)
| 6 minutes
| 1245 words
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.
Posted on 2022-09-10
(Last modified on 2025-10-17)
| 2 minutes
| 268 words
• Other languages: (in "中文")
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.
Posted on 2022-08-08
(Last modified on 2025-02-26)
| 2 minutes
| 408 words
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.location.href+"]["+document.title+" - "+document.location.hostname+"]]");// Don't know why the page becomes blank after using it on Firefox, so use alert instead.
javascript:alert("[["+document.location.href+"]["+document.title+" - "+document.location.hostname+"]]");
Add a new bookmark on the browser, give it a name, such as (org-link), and then copy and paste the content as URL, just like below on Firefox:
Posted on 2022-07-17
(Last modified on 2025-10-17)
| 6 minutes
| 1169 words
• Other languages: (in "中文")
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.
BTW, I'm improving my English by watching YouTube videos every single day; If you're also learning English, or any languages, LanguagePuppy can definitely help you. It's a Chrome extension I developed using Clojure. Check it out: