By Susam Pal on 02 Apr 2023
Tiny Book Club
We have a tiny book
club that meets every weekend to read and discuss the
book Mastering
Emacs, 2022 edition written by Mickey Petersen. We go
through a few pages of the book every time we meet, do some demos,
and talk about the concepts we learn from the book. In the 36
meetings that we have had so far, we have spent approximately 26
hours together carefully reading every line of the book, trying out
the lessons on an actual editor, and experimenting with the new
concepts. In the last 3½ months, we have completed four
chapters of the book. We are currently reading the fifth chapter. In
this post, I’ll share what the journey has been like so far and a
few interesting things we have learnt.
A big thanks to Mickey Petersen who very graciously granted me the
permission to share his book on screen while we discuss the lessons
from the book and try out the examples on the editor.
This is the second series of such meetings I have been hosting. The
first one was about
analytic number theory that
began in March 2021. It ran for seven months and
finally concluded in October
2021 after 120 meetings. I chose Emacs as the topic for the next
series. The book Mastering Emacs by Mickey Petersen seemed
like a great choice for it.
Our new discussion group for Emacs began on 16 Dec 2022. We have
been meeting over Jitsi during the weekends. Each meeting is
approximately 40 minutes long. With my desktop shared via Jitsi, I
demonstrate all the concepts we find in the book in my Emacs editor.
On an average, we see about 7 participants in each meeting. Some
participants are regulars who join the meetings every weekend,
follow the lessons, share their comments, etc. It has been a fun
experience so far.
Variety of Professions
Most members of our discussion group come from
the #emacs
channels of Libera and Matrix networks. An
interesting thing I noticed in our Emacs book discussion group is
that we have a good mix of members from diverse backgrounds. In the
previous series of meetings on analytic number theory, almost every
participant had a career in software engineering. But in this
discussion group about Emacs, we have members from various types of
professions such as physics, molecular biology, finance, literature,
etc. It is interesting how we had mostly software engineers in a
mathematics discussion group but a variety of professionals in a
software discussion group!
Some participants of our meetings have several years of experience
with Emacs. Others are beginners. However, even those who are quite
experienced with Emacs have found that they learnt many new
techniques and concepts from the book. In the next few sections,
I’ll present some of those Emacs functions that were initially not
known to some of the experienced Emacs users of our group but were
found to be very useful after having learnt them from the book.
Lunar Phases
Yes, we can see the lunar phases calendar right within Emacs! I
don’t know if this was interesting to other members of our group, so
I can only speak for myself here. As someone who has been interested
in astronomy since my childhood
days, I found this very exciting. Type M-x lunar-phases
in your Emacs and a new buffer appears with an output
RET
like this:
Tuesday, March 7, 2023: Full Moon 12:39pm (UTC)
Wednesday, March 15, 2023: Last Quarter Moon 2:14am (UTC)
Tuesday, March 21, 2023: New Moon 5:27pm (UTC)
Wednesday, March 29, 2023: First Quarter Moon 2:33am (UTC)
Thursday, April 6, 2023: Full Moon 4:33am (UTC)
Thursday, April 13, 2023: Last Quarter Moon 9:17am (UTC)
Thursday, April 20, 2023: New Moon 4:16am (UTC) ** Solar Eclipse **
Thursday, April 27, 2023: First Quarter Moon 9:21pm (UTC)
Friday, May 5, 2023: Full Moon 5:32pm (UTC) ** Lunar Eclipse **
Friday, May 12, 2023: Last Quarter Moon 2:34pm (UTC)
Friday, May 19, 2023: New Moon 3:56pm (UTC)
Saturday, May 27, 2023: First Quarter Moon 3:24pm (UTC)
It also shows the upcoming eclipses! In fact, there is one coming up
this month! Isn’t this nice? I knew that Emacs has all sorts of fun
stuff like M-x zone RET
to zone out with a built-in
screensaver, M-x tetris RET
to play a clone of the
famous puzzle game, M-: (animate-string "hello" 0) RET
to display a string in a fun manner starting off as scattered pieces
spread randomly across the buffer that then slide and come together
to join and form the string. But to have something as obscure as
lunar phases and eclipses available within the editor was a nice
surprise! Thanks to the book, I now use this function often.
For people who are not familiar with Emacs notation for key binding,
note that M-x lunar-phases RET
means
typing alt+x followed by
typing lunar-phases
and then pressing enter.
The notation M-
represents the meta modifier key which
is mapped to alt on modern systems.
Returning to Mark
Most members knew that we can set a mark with C-SPC
(i.e., ctrl+space) and then move around in the
buffer with motion keys to highlight a region that we can cut
with C-w
or copy with M-w
and paste it
elsewhere with C-y
. However, what was new to some
members is the fact that we can also return to a mark just as
easily. The key sequence to return to mark is C-u
. But there is a problem.
C-SPC
When we set a mark with C-SPC
and start moving
around with motion keys, the text between the mark and the current
position of the cursor (known as point in Emacs) becomes a
highlighted region in modern Emacs. This highlighted region can be
annoying while browsing some code. So how do we use the mark as a
place to return to? Barring unusual workarounds like
disabling transient-mark-mode
, is there a simple way?
Yes, there is a simple trick. Type C-SPC C-SPC
to set
the mark! Typing C-SPC
the first time sets the mark and
activates the region. Typing it the second time deactivates the
region. But Emacs remembers the mark that was set. Now continue with
normal editing. Finally, type C-u C-SPC
to return to
mark.
The key sequences involved are pretty convenient. Typing C-SPC
involves holding down the ctrl key, then
C-SPC
typing space twice, and finally releasing
the ctrl key. Similarly, typing C-u C-SPC
involves holding down the ctrl key, typing u,
then space, and then releasing the ctrl key.
Three keystrokes for each command. They become muscle memory in no
tim