How to Kill a "Visible" Buffer Quickly in Emacs

Selecting Emacs windows using ace-window Recently I've been building a simple Emacs config for myself, along the way I re-discovered some fantastic packages, for example, I found that ace-window is a simple yet powerful package to enhance the default other-window command to select other windows quickly when it has more than two windows in a frame. I replaced the key binding of other-window to ace-window by simply doing (global-set-key (kbd "C-x o") #'ace-window), then when there are >2 windows, it will show a white-in-red number at the top-left corner for every window, hit the number (1, 2, 3, …) and then Emacs will select the corresponding window (as demonstrated in the above screenshot). [Read More]
Emacs 

Eglot for Better Programming Experience in Emacs

LSP, or Language Server Protocol, makes programming easier by introducing features like more precise auto-completion and definition lookup. It may have scratched your itches, and you may wonder what the experience is like in Emacs. Emacs has mainly two LSP clients out there, eglot and lsp-mode. Eglot is lightweight, and it could almost run out of the box. So in this post I will briefly show you how to use eglot. [Read More]

Language Shadowing with subed in Emacs

So I'm trying to improve my English speaking skill by shadowing while watching TV episodes. The workflow before was to loop over video clips using mpv: hit l to mark the start of the loop play the video and wait for it to be at the end of the loop hit l again to mark the end Then mpv will loop over the clip, it basically works, but it's a bit hard and tedious to set the start and end precisely. [Read More]

Writing a Python Script in Emacs in 45 Minutes!

Note: watch my live coding session of this article: Intro If you've heard some rumors of Emacs that it has a very steep learning curve (or that Emacs makes a computer slow), you may be too scared to look at it. It indeed has some learning curve (learning anything does have one), but it isn't very steep. I learned this after getting my hands dirty with Emacs a few years ago. [Read More]

Send Notifications from Emacs with i3wm and Dunst

I barely use notifications, but recently I think it's a valuable way to remind me things like helping me nurture habits, or to notify me of emergencies like a critically low laptop battery. So I try to integrate notifications to org-mode and Emacs today. The org-notify package from org-contrib (install it by (package-install 'org-contrib) ) could do this job easily before, so I first test it in the minibuffer with (org-notify "test"). [Read More]

Generate Call Graphs Using Doxygen in Emacs

Doxygen is a nice tool for generating documentations for well-annotated C/C++ projects, the one feature that I like most is generating call graphs and class diagrams, so that I can learn a project quickly by browsing the diagrams from a higher point of view. I take the following steps to generate call graphs for a project on terminals on Linux: cd /path/to/a/project/, and generate a template config file by doxygen -s -g doxygen. [Read More]
Emacs 

A Trick to Troubleshoot Emacs Subprocess Creating

There are many packages of Emacs that leverage subprocesses to do their jobs, Magit, eglot, elpy, to name a few. And there are times that a subprocess doesn't work as expected, for example, Magit is slow, and you're sure that it's ok when running git commands on shell. So how to spot these problems effectively and quickly? The problem is that we don't know what's going on exactly, so here I want to share a few Elisp advices to make the subprocess creating visible, and print the exact program and its arguments to the *Message* buffer. [Read More]

ppcompile: An Emacs Package to Help Coding Locally

If you are a C/C++ programmer like me, you may experience jumping around different machines to write and compile your code, or you may write code on different machines for different projects, and scp/rsync/ftp the projects around. It works, but it's a bit tedious and takes too much burden on our brains. For example, say I have two projects that should be compiled on their compiling machines respectively. There are two obvious workflows for writing code for them "simultaneously": [Read More]
Emacs 

How To Revert a Series of Git Commits?

Sometimes, I need to revert a series of commits that I've already pushed, doing a git hard reset (git reset --hard) is not an option, as someone may already have new commits based on mine. For example, assume that I've made a few commits like below: 65a2c62 * commit 10 25cad43 * commit 9 72ad583 * commit 8 ceebf9a * commit 7 acf8a11 * commit 6 28d526f * commit 5 63af1e2 * commit 4 982c71c * commit 3 0fb4c2d * commit 2 acf9da1 * commit 1 b5f9933 * commit 0 For whatever reason, I need to "drop" the changes made by commit 6 to commit 10, that is, go back to "commit 5" without deleting these commits. [Read More]

Generating org-mode Outlines for wikiHow Articles

Recently I found some great articles on wikiHow, then I want to keep notes of them in org-mode files. At first, I manually copied the ToC of articles, but soon I found it's tedious and takes a lot of time. Today I wrote a requests-based Python script to help me extract the ToCs (Table of Content) into org-mode outlines. It takes two arguments, the first one is the URL, the second one is the containing heading's level for the generated ToC in org-mode. [Read More]