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 winner-mode to restore your 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 by some operations, such as looking for a help (e.g. C-h k), or checking things in magit.
It's ok to me if I can get back to a previous used layout. Emacs has built in a package for this package: winner-mode. It's very simple, it only has three commands:
[Read More]
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]
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 that there are many people use it. So I installed it that time, but I didn't use many of its features along the way. 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 Basics
If you are new to Emacs, you may run into some errors, especially after you absorb elisp snippets from the Internet or elsewhere.
Don't panic. It happens. To ease your pain, in this post I will introduce some Emacs built-in features to help you solve the problems yourself.
Start Emacs Without Any Configurations When you have some problems/errors with built-in features, the first thing you should do is to run emacs -Q to start another Emacs instance without any configurations from your emacs.
[Read More]
Duplicate the current line in Emacs
Duplicate the current in Emacs Duplicating the current line is frequent editing for me when I am coding. Initially, I copied a snippet as a command in Emacs from the Internet:
(defun w/duplicate-line() "Duplicate the current line." (interactive) (move-beginning-of-line 1) (kill-line) (yank) (open-line 1) (next-line 1) (yank)) Most of the time, I was happy with it, but it has mainly two drawbacks:
It cannot keep the column position when moving to the next line It messes up with the yank ring as it yanks the text under the hood So today, I took some time to fix these two problems, and I also want it to be capable of commenting the current line out if I prefix the command.
[Read More]
Adjust the laptop's screen brightness in Emacs
Adjust the screen brightness in Emacs If you're using i3wm on Linux, how do you adjust the laptop's screen brightness?
Most of the time, I use the laptop with an external monitor. But when I am out, I have no monitors. And it seems no easy way to adjust the brightness in i3wm. Being too bright or dim is terrible for the eyes.
Recently, I found a command-line tool called brightnessctl, which can adjust the brightness in a terminal.
[Read More]