<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="../feed.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Susam's Meetup Pages</title>
  <subtitle>Feed for Susam's Meetup Pages</subtitle>
  <link href="https://susam.net/"/>
  <link href="https://susam.net/tag/meetup.xml" rel="self"/>
  <id>https://susam.net/tag/meetup.xml</id>
  <updated>2023-12-30T00:00:00Z</updated>
  <author><name>Susam Pal</name></author>
  <entry>
    <title>From Fill Prefix to TRAMP</title>
    <link href="https://susam.net/from-fill-prefix-to-tramp.html"/>
    <id>urn:uuid:3488c75c-8155-4cc3-bba9-6b236b8ade40</id>
    <updated>2023-12-30T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  Our &lt;a href=&quot;cc/mastering-emacs/&quot;&gt;tiny book club&lt;/a&gt; that
  used to meet during the weekends and holidays and discuss the
  book &lt;a href=&quot;https://www.masteringemacs.org/&quot;&gt;Mastering Emacs&lt;/a&gt;,
  2022 edition concluded today.  In our
  &lt;a href=&quot;cc/mastering-emacs/log.html#72&quot;&gt;final meeting&lt;/a&gt; today,
  we first discussed how to work across multiple directories in the
  same Dired buffer.  Then we did several demos of the various shells
  and terminal modes available in Emacs out of the box.  That
  completed our discussion on Chapter 6.  Then we moved on to Chapter
  7 (the final chapter) that first reiterates the importance of using
  the describe-system to ask Emacs questions about itself and then
  offers some recommendations about third-party packages and online
  Emacs communities.  Completing this chapter brought our book club
  discussions to an end.
&lt;/p&gt;
&lt;p&gt;
  A big thanks to Mickey Petersen for writing the book and also very
  generously granting me the permission to share his book on screen
  while discussing it.
&lt;/p&gt;
&lt;p&gt;
  This book club began on 16 Dec 2022 when we had our first meeting
  over Jitsi.  About 3&amp;half; months after beginning these meetings, I
  posted an update about this book club in another blog post
  titled &lt;a href=&quot;from-lunar-phases-to-yank-pop.html&quot;&gt;From Lunar
  Phases to Yank-Pop&lt;/a&gt;.  If you have not read that post yet, I
  suggest you read it before returning to this post.  Especially if
  you have recently begun learning Emacs, I think you will find that
  post useful.
&lt;/p&gt;
&lt;p&gt;
  Back then, when I posted that last update, we had spent about 26
  hours together across 36 meetings and we were reading Chapter 5 of
  the book.  It took another 36 meetings to complete that chapter and
  the remaining two chapters.  After a total of 72 meetings, we
  completed discussing Chapter 7 of the book today which concluded
  this series of book club meetings.  In total, we have spent a little
  over 52 hours together to discuss this book, trying out every
  concept and command introduced in the book and sharing our insights
  about the material with each other.
&lt;/p&gt;
&lt;p&gt;
  In this post, I will share some highlights from our meetings since
  the &lt;a href=&quot;from-lunar-phases-to-yank-pop.html&quot;&gt;last update&lt;/a&gt;.
  These highlights share some concepts and commands we learnt that
  most members of our book club were not familiar with earlier but
  were found to be very useful after having learnt them.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#fill-prefix&quot;&gt;Fill Prefix&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#elisp-expressions-in-replacement-strings&quot;&gt;Elisp Expressions in Replacement Strings&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#keep-lines-and-flush-lines&quot;&gt;Keep Lines and Flush Lines&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#keyboard-macros&quot;&gt;Keyboard Macros&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#dabbrev&quot;&gt;DAbbrev&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tab-vs-m-i&quot;&gt;TAB vs M-i&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#project-management&quot;&gt;Project Management&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#eshell-with-tramp&quot;&gt;Eshell with TRAMP&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#thanks&quot;&gt;Thanks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;fill-prefix&quot;&gt;Fill Prefix&lt;/h2&gt;
&lt;p&gt;
  Most of us in the book discussion group knew about filling
  paragraphs with &lt;code&gt;M-q&lt;/code&gt;.  Consider the following badly
  formatted paragraphs with very long and very short lines:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore
magna aliqua.  Arcu dui vivamus arcu felis bibendum ut tristique et egestas.
Bibendum arcu vitae
elementum curabitur vitae.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Now put the point (cursor) anywhere on the paragraph and
  type &lt;code&gt;M-q&lt;/code&gt;.  The paragraph gets neatly formatted to
  something like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.  Arcu dui
vivamus arcu felis bibendum ut tristique et egestas.  Bibendum arcu
vitae elementum curabitur vitae.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-q&lt;/code&gt; invokes
  the &lt;code&gt;fill-paragraph&lt;/code&gt; command that reformats the paragraph
  such that each line is as long as possible without exceeding the
  fill width (70 columns by default).  Most of us already used this
  command very often while writing and editing text.  However what
  some of us did not know was that there is such a thing as fill
  prefix which is taken into account while filling paragraphs.  To
  illustrate this concept, we will first consider this badly formatted
  paragraph:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:::: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
:::: incididunt ut labore et dolore
:::: magna aliqua.  Arcu dui vivamus arcu felis bibendum ut tristique et egestas.
:::: Bibendum arcu vitae
:::: elementum curabitur vitae.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Each line has a prefix consisting of four colons and a space.  After
  we reformat this paragraph with &lt;code&gt;M-q&lt;/code&gt;, we get something
  like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:::: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor :::: incididunt ut labore et dolore :::: magna aliqua.
Arcu dui vivamus arcu felis bibendum ut tristique et egestas.  ::::
Bibendum arcu vitae :::: elementum curabitur vitae.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  This is not what we want.  We want the paragraph to be formatted
  such that each line does not exceed 70 characters in length (which
  we have, in fact, accomplished above) and each line contains the
  four colons and a space as the prefix (this is broken above).  Can
  we do this?  Yes, by setting the fill prefix.  Type &lt;code&gt;C-/&lt;/code&gt;
  or &lt;code&gt;C-x u&lt;/code&gt; to undo the bad formatting we did just now and
  let us try again.  This time move the point over to
  the &lt;code&gt;L&lt;/code&gt; of &lt;code&gt;Lorem&lt;/code&gt; and type &lt;code&gt;C-x .&lt;/code&gt;
  to set the fill prefix to the current line up to the point.  A
  confirmation is printed in the echo area that &lt;code&gt;&quot;:::: &quot;&lt;/code&gt;
  has been set as the fill prefix.  Then type &lt;code&gt;M-q&lt;/code&gt; and the
  paragraph is now neatly formatted to look like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:::: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
:::: eiusmod tempor incididunt ut labore et dolore magna aliqua.  Arcu
:::: dui vivamus arcu felis bibendum ut tristique et egestas.
:::: Bibendum arcu vitae elementum curabitur vitae.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Note how every line is as long as possible without exceeding 70
  characters in length and each line has the fill prefix.  Emacs took
  care to remove the fill prefix from each line, subtract the length
  of the fill prefix from the maximum character budget it has for each
  line, reformat the lines and then reinsert the fill prefix on each
  line of the result.
&lt;/p&gt;
&lt;p&gt;
  To turn off the fill prefix, simply set it to an empty prefix by
  typing &lt;code&gt;C-x .&lt;/code&gt; at the beginning of the line.
  Thus &lt;code&gt;C-a C-x .&lt;/code&gt; becomes an idiom for turning off the
  fill prefix.
&lt;/p&gt;
&lt;h2 id=&quot;elisp-expressions-in-replacement-strings&quot;&gt;Elisp Expressions in Replacement Strings&lt;/h2&gt;
&lt;p&gt;
  It was no surprise to anyone in the book discussion group that the
  key sequence &lt;code&gt;C-M-% f.. RET bar RET&lt;/code&gt; starts a
  search-and-replace operation for strings that match the regular
  expression pattern &lt;code&gt;f..&lt;/code&gt; to be replaced with the
  text &lt;code&gt;bar&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  The concept of backreferences was also known to most.  For
  example, &lt;code&gt;C-M-% \(f..\)-\(b..\) RET \2-\1 RET&lt;/code&gt; searches
  for strings matching the given regular expression pattern and
  replaces it with a new string that swaps the positions of the first
  capturing group and the second capturing group.  The
  backreference &lt;code&gt;\1&lt;/code&gt; refers to the string matched by the
  first capturing group &lt;code&gt;\(f..\)&lt;/code&gt; and
  similarly &lt;code&gt;\2&lt;/code&gt; refers to the string matched by the second
  capturing group &lt;code&gt;\(b..\)&lt;/code&gt;.  In this example, a string
  like &lt;code&gt;foo-bar&lt;/code&gt; is replaced with &lt;code&gt;bar-foo&lt;/code&gt;
  or &lt;code&gt;playful-banter&lt;/code&gt; with &lt;code&gt;playban-fulter&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  However what came as a surprise to some of us was that we could also
  use Elisp expressions in the replacement strings.  The syntax to do
  so is to write &lt;code&gt;\,&lt;/code&gt; followed by the Elisp expression in
  the replacement string.  For example, consider the key
  sequence &lt;code&gt;C-M-% f.. RET \,(upcase \&amp;amp;) RET&lt;/code&gt;.  Note how
  we are using the backreference &lt;code&gt;\&amp;amp;&lt;/code&gt; that refers to
  the whole match as the argument to the Elisp function
  &lt;code&gt;upcase&lt;/code&gt; that converts its argument to upper-case.  This
  example searches for strings that match the pattern &lt;code&gt;f..&lt;/code&gt;
  and replaces them with the upper-case form of the match.  A string
  like &lt;code&gt;foo-bar&lt;/code&gt; is replaced with &lt;code&gt;FOO-bar&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  Here is another slightly more sophisticated example: &lt;code&gt;C-M-%
  port-\([0-9]+\) RET port-\,(+ 1000 \#1)&lt;/code&gt;.  The
  backreference &lt;code&gt;\#1&lt;/code&gt; refers to the string matched by the
  first capturing group &lt;code&gt;\([0-9]+\)&lt;/code&gt; as &lt;em&gt;number&lt;/em&gt;.
  The Elisp expression in the replacement pattern simply adds 1000 to
  that number and replaces the matched string with the result.  A
  string like &lt;code&gt;port-80&lt;/code&gt; becomes &lt;code&gt;port-1080&lt;/code&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;keep-lines-and-flush-lines&quot;&gt;Keep Lines and Flush Lines&lt;/h2&gt;
&lt;p&gt;
  A nifty set of commands that our group members enjoyed learning were
  the commands for keeping and flushing lines.  These commands can be
  incredibly useful while filtering large log files.  Here is a brief
  illustration of a couple of these commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x keep-lines RET f.. RET&lt;/code&gt;: Keep lines in region
      that match the regular expression &lt;code&gt;f..&lt;/code&gt; and delete
      the rest.  If no region is active, then keep matching lines
      between the point and end of buffer; delete the rest.  The
      deleted lines are not copied to kill ring.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x flush-lines RET f.. RET&lt;/code&gt;: Delete lines in the
      region that match the regular expression &lt;code&gt;f..&lt;/code&gt;.  If
      no region is active, then delete matching lines between the
      point and end of buffer.  The deleted lines are not copied to
      kill ring.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note how each point above mentions that the deleted lines are not
  copied to the kill ring.  This can be an inconvenience if we want to
  quickly yank the deleted lines to another buffer.  Emacs 28.1
  introduces a couple of more commands that remedy this situation to
  an extent.  Here they are:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x copy-matching-lines RET f.. RET&lt;/code&gt;: Copy lines in
      the region that match the regular expression &lt;code&gt;f..&lt;/code&gt;.
      If no region is active, then copy matching lines between the
      point and end of buffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x kill-matching-lines RET f.. RET&lt;/code&gt;: Kill lines in
      region that match the regular expression &lt;code&gt;f..&lt;/code&gt; to the
      kill ring.  If no region is active, then kill matching lines
      between the point and end of buffer.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;keyboard-macros&quot;&gt;Keyboard Macros&lt;/h2&gt;
&lt;p&gt;
  Most experienced Emacs users in our group were aware of keyboard
  macros.  However, some people did learn this wonderful automation
  feature for the first time in our meetings, so I thought this
  deserves its own section in this post.
&lt;/p&gt;
&lt;p&gt;
  Keyboard macros is a large topic on its own which is best learnt
  from
  section &lt;a href=&quot;https://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macros.html&quot;&gt;Keyboard
  Macros&lt;/a&gt; of the manual.  On Emacs, type &lt;code&gt;M-: (info &quot;(emacs)
  Keyboard Macros&quot;) RET&lt;/code&gt; to open this section using the Info
  documentation browser.  In this blog post though, we will very
  briefly talk about keyboard macros that should be enough to get
  someone very new to it started with them quickly.
&lt;/p&gt;
&lt;p&gt;
  Say, we have a buffer that looks like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;foo:bar:baz
bar:baz:qux
quux:corge:grault
garply:waldo:fred&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Now suppose we want to swap the first two fields separated by colon
  in each line.  Of course, we could do it using regular expressions,
  for example, with the key sequence
  &lt;code&gt;C-M-% ^\(.+?:\)\(.+?:\) RET \2\1 RET&lt;/code&gt;.  But we can also
  solve this problem in a &quot;dumb&quot; way by simply performing the edits
  necessary to do the swap on one line and then asking Emacs to repeat
  what we did on the other lines.  Here are the steps:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      First move the point to somewhere on the first line.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Then type &lt;code&gt;C-x (&lt;/code&gt; to start recording a keyboard
      macro.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Then type &lt;code&gt;C-a M-d C-d M-f : C-y C-n&lt;/code&gt; to swap the
      first and second fields on the first line and move the point to
      the next line.  This is just one way to achieve the swap.  You
      may use any editing commands you are comfortable with to make
      the swap happen and move the point to the next line.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Now type &lt;code&gt;C-x )&lt;/code&gt; to stop macro recording.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now type &lt;code&gt;C-x e&lt;/code&gt; to replay the macro in the second
      line.  As soon as we type this key sequence, the swap occurs in
      the second line and the cursor moves to the third line.  Keep
      repeating this key sequence to keep repeating the swap operation
      on subsequent lines.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  To summarise, &lt;code&gt;C-x (&lt;/code&gt; starts recording a new keyboard
  macro, &lt;code&gt;C-x )&lt;/code&gt; stops recording the keyboard macro
  and &lt;code&gt;C-x e&lt;/code&gt; replays the last keyboard macro.
  Alternatively, we could also use the function keys &lt;code&gt;F3&lt;/code&gt;
  and &lt;code&gt;F4&lt;/code&gt;.  To start recording a keyboard macro,
  type &lt;code&gt;F3&lt;/code&gt;.  Type &lt;code&gt;F4&lt;/code&gt; to stop recording a
  keyboard macro.  Then type &lt;code&gt;F4&lt;/code&gt; again to replay the last
  macro.
&lt;/p&gt;
&lt;p&gt;
  Pay close attention to step 3 above.  We start the key sequence
  with &lt;code&gt;C-a&lt;/code&gt; to move the point to the first column.  This
  may feel redundant when the cursor is already at the first column.
  However in our meetings, I used to emphasise often about the
  importance of doing this.  Typing &lt;code&gt;C-a&lt;/code&gt; at the beginning
  ensures that we do not carry over any assumption about where the
  cursor is on the line into the rest of the keyboard macro definition
  we are going to record.  By typing &lt;code&gt;C-a&lt;/code&gt;, we ensure that
  no matter where the cursor is on the line, when we replay the macro,
  the cursor would first move to the beginning of the line.  This
  guarantee allows us to confidently define the rest of the editing
  operations necessary to perform the swap.
&lt;/p&gt;
&lt;p&gt;
  Similarly, at the end we type &lt;code&gt;C-n&lt;/code&gt; to move the point to
  the next line.  I used to emphasise the importance of doing this too
  in our meetings.  Moving the cursor to the next line ensures that
  the cursor is in a good place to allow repeating the keyboard macro
  again immediately.  This is why we could type &lt;code&gt;C-x e&lt;/code&gt; (or
  alternatively, &lt;code&gt;F4&lt;/code&gt;) over and over again to replay the
  macro on subsequent lines.  In fact, if we feel confident about the
  keyboard macro, we can repeat it several times automatically using
  the digit argument.  For example, type &lt;code&gt;C-3 C-x e&lt;/code&gt; (or
  alternatively &lt;code&gt;C-3 F4&lt;/code&gt;) to repeat the keyboard macro 3
  times.  We could also type &lt;code&gt;C-0 C-x e&lt;/code&gt; (or
  alternatively &lt;code&gt;C-0 F4&lt;/code&gt;) to repeat the keyboard macro
  until there is an error (e.g. reaching the end of the buffer).
&lt;/p&gt;
&lt;h2 id=&quot;dabbrev&quot;&gt;DAbbrev&lt;/h2&gt;
&lt;p&gt;
  DAbbrev stands for &lt;em&gt;dynamic abbrevation&lt;/em&gt;.  This is a pretty
  useful package that many of us learnt only from our book club
  meetings.  We discussed two simple key sequences supported by this
  package:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-/&lt;/code&gt;: Expand the word before the point to the
      nearest preceding word for which the current word is a prefix.
      If no suitable preceding word is found, then expand the current
      word to the nearest succeeding word for which the current word
      is a prefix.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-M-/&lt;/code&gt;: Find all words in the buffer that has the
      current word before the cursor as the prefix and expand the
      current word to the longest common prefix of all these matching
      words.  However, if the longest common prefix of the matching
      words is same as the word before the cursor, then present them
      as suggestions for completion.  If there is exactly one matching
      word, expand the word before the cursor to that word.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Let us look at some examples.  Suppose there is a buffer with the
  following one line of text:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;abacus apple appliance application&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Now if we type &lt;code&gt;ap&lt;/code&gt; on the next line and
  type &lt;code&gt;M-/&lt;/code&gt;, DAbbrev automatically expands the partially
  written word to &lt;code&gt;application&lt;/code&gt; because that is the nearest
  word that has &lt;code&gt;ap&lt;/code&gt; as the prefix.
&lt;/p&gt;
&lt;p&gt;
  But if we type &lt;code&gt;ap&lt;/code&gt; and type &lt;code&gt;C-M-/&lt;/code&gt;, the word
  expands to &lt;code&gt;appl&lt;/code&gt; since that is the longest common prefix
  among all the matching words.  If we type &lt;code&gt;C-M-/&lt;/code&gt; again
  then &lt;code&gt;apple&lt;/code&gt;, &lt;code&gt;appliance&lt;/code&gt;
  and &lt;code&gt;application&lt;/code&gt; are presented as possible completions
  in a temporary buffer named &lt;code&gt;*Completions*&lt;/code&gt;.  If we
  type &lt;code&gt;ic&lt;/code&gt;, so that the word before the cursor
  becomes &lt;code&gt;applic&lt;/code&gt; and type &lt;code&gt;C-M-/&lt;/code&gt;, it is
  expanded to &lt;code&gt;application&lt;/code&gt; because that is the only
  possible completion now.
&lt;/p&gt;
&lt;p&gt;
  These two commands are simpler than it sounds from the verbose
  descriptions of these commands presented in the above paragraphs.
  When we actually begin to use them, they become intuitive in no
  time.  Roughly speaking, while &lt;code&gt;M-/&lt;/code&gt; expands the word
  before the point to the nearest preceding word, &lt;code&gt;C-M-/&lt;/code&gt;
  considers all matching words in the file for expansion and presents
  completion options to the user when it finds multiple of them.
&lt;/p&gt;
&lt;h2 id=&quot;tab-vs-m-i&quot;&gt;TAB vs M-i&lt;/h2&gt;
&lt;p&gt;
  The behaviour of Emacs when we type &lt;code&gt;TAB&lt;/code&gt; can be
  surprising to beginners.  In most other mainstream editors, this key
  either inserts a tab character or it inserts enough number of spaces
  so that the cursor moves to the next tab stop.  But in
  Emacs, &lt;code&gt;TAB&lt;/code&gt; most often indents the current line
  according to the syntax rules implemented by the major mode enabled
  in the buffer.
&lt;/p&gt;
&lt;p&gt;
  What is a simple key on other editors happens to be a complex
  feature in Emacs.  The exact behaviour of &lt;code&gt;TAB&lt;/code&gt; is
  controlled by variables
  like &lt;code&gt;tab-always-indent&lt;/code&gt;, &lt;code&gt;indent-line-function&lt;/code&gt;,
  etc.  Some major modes may refer to other such special variables to
  decide what &lt;code&gt;TAB&lt;/code&gt; should do.  However, as a user of Emacs
  this is not something we normally have to worry about.  Most major
  modes set up all these variables appropriately, so that
  &lt;code&gt;TAB&lt;/code&gt; almost always does what an experienced Emacs user
  expects, i.e. indent the current line of code correctly.
&lt;/p&gt;
&lt;p&gt;
  But what if we really do want to just insert a tab or enough number
  of spaces to move the point to the next tab stop column?  That is
  done with &lt;code&gt;M-i&lt;/code&gt;.  If the
  variable &lt;code&gt;indent-tabs-mode&lt;/code&gt; is set to &lt;code&gt;t&lt;/code&gt;,
  then &lt;code&gt;M-i&lt;/code&gt; inserts a literal tab character.  If it is set
  to &lt;code&gt;nil&lt;/code&gt;, then &lt;code&gt;M-i&lt;/code&gt; inserts enough number of
  spaces to move the point to the next tab stop column.
&lt;/p&gt;
&lt;p&gt;
  To summarise, the behaviour of &lt;code&gt;M-i&lt;/code&gt; is similar to
  the &lt;code&gt;TAB&lt;/code&gt; behaviour we observe in other editors.  In
  practice though, the key sequence &lt;code&gt;M-i&lt;/code&gt; is rarely
  required.  Most people just type &lt;code&gt;TAB&lt;/code&gt; to automatically
  indent code.  In fact, we can also select a region of code and
  type &lt;code&gt;TAB&lt;/code&gt; to reindent the whole region.
&lt;/p&gt;
&lt;h2 id=&quot;project-management&quot;&gt;Project Management&lt;/h2&gt;
&lt;p&gt;
  The project management commands that come out of the box (from the
  package named &lt;code&gt;project.el&lt;/code&gt;) came as a surprise to some.
  In fact, some members of our group who never used the project
  management commands earlier happen to use them regularly now after
  learning about them in our meetings.
&lt;/p&gt;
&lt;p&gt;
 When we use a project command like &lt;code&gt;C-x p f&lt;/code&gt; to visit a
 file in the current project, the command automatically detects the
 top-level directory of the project by checking parent directories for
 version control system artefacts (e.g. &lt;code&gt;.git&lt;/code&gt; directory)
 and presents files within that top-level directory as autocomplete
 options.
&lt;/p&gt;
&lt;p&gt;
  There is a lot that can be written about the project management
  features that come out of the box in Emacs.  The following list
  introduces only the very simple ones to get someone started with
  them:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p f logger RET&lt;/code&gt;: Find file with name that
      matches &lt;code&gt;logger&lt;/code&gt; in the current project.  This
      searches all subdirectories recursively.  If there is only one
      matching file (say, &lt;code&gt;src/logger.cc&lt;/code&gt;), that file is
      opened.  If there are multiple matching files, they are
      presented as completion options.  Running this command or, in
      fact, running any project command leads to discovering the
      current project and adding an entry for the discovered project
      to &lt;code&gt;~/.emacs.d/projects&lt;/code&gt;.  This is useful for a
      command like the one presented in the next point.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p f foo TAB RET logger TAB RET&lt;/code&gt;: When we
      type &lt;code&gt;C-x p f&lt;/code&gt; while visiting a file that does not
      belong to any project, then its prompts for a project path
      first.  In this example, we type &lt;code&gt;foo TAB RET&lt;/code&gt; to
      automatically expand it to a known project path such
      as &lt;code&gt;~/git/foo/&lt;/code&gt; and enter it.  Then we
      type &lt;code&gt;logger TAB RET&lt;/code&gt; to automatically expand it to a
      file name such as &lt;code&gt;src/logger.cc&lt;/code&gt; and visit it.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p p bar TAB RET f logger TAB RET&lt;/code&gt;: Say we are in
      project &lt;code&gt;~/git/foo/&lt;/code&gt; but we want to switch to another
      previously discovered project &lt;code&gt;~/git/bar/&lt;/code&gt; and find a
      file there.  To do so, we first type &lt;code&gt;C-x p p&lt;/code&gt; to
      switch project.  At the project selection prompt, we
      type &lt;code&gt;bar TAB&lt;/code&gt; to automatically complete the
      directory path of the known project &lt;code&gt;~/git/bar/&lt;/code&gt;.
      Then another prompt is presented to choose an action from a
      number of actions.  In this case, we type &lt;code&gt;f&lt;/code&gt; to find
      a file in the project we have switched to.  Finally, we
      type &lt;code&gt;logger TAB RET&lt;/code&gt; to automatically expand the
      partially entered name to a path like &lt;code&gt;src/logger.cc&lt;/code&gt;
      and visit it.  The key sequence &lt;code&gt;C-x p p&lt;/code&gt; is very
      useful when the current file belongs to one project but we want
      to run a project command on another project.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p p ... RET ~/git/baz/ RET f logger TAB RET&lt;/code&gt;:
      This awkward key sequence discovers a new project directory
      at &lt;code&gt;~/git/baz/&lt;/code&gt; and then finds a file in it.  The key
      sequence &lt;code&gt;C-x p p ... RET&lt;/code&gt; is rarely required though.
      See the notes after the end of this list to read why.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p g ^key\&amp;gt; RET&lt;/code&gt;: Find all matches for the
      regular expression &lt;code&gt;^key\&amp;gt;&lt;/code&gt; in the current
      project.  The results are displayed in &lt;code&gt;*xref*&lt;/code&gt;
      buffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p s&lt;/code&gt;: Start a shell in the current project&apos;s
      root directory.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p d&lt;/code&gt;: Start Dired in the current project&apos;s root
      directory.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p k yes RET&lt;/code&gt;: Kill all buffers belonging to the
      current project.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  There are several more project commands but we will end the above
  list here for the sake of brevity.  Do pay attention to the second
  point that mentions that if the current file does not belong to any
  project, we are first prompted to enter the project name.  This is a
  common theme for all project commands.  Anytime we invoke a project
  command, it works on the current project.  However if there is no
  current project, then it automatically prompts us to enter a project
  name before executing the command.
&lt;/p&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;C-x p p ... RET&lt;/code&gt; is very rarely
  required during day-to-day editing activities.  Once a project has
  been discovered (say, due to having run a project command on that
  project earlier) and added to the list of known projects
  at &lt;code&gt;~/.emacs.d/projects&lt;/code&gt;, we never have to discover it
  again.  We can use the other key sequences to switch to or work on a
  known project.  Most day-to-day project activities involve working
  on known projects.
&lt;/p&gt;
&lt;p&gt;
  Further, even when we do want to discover a new project and add it
  to the list of known projects, a much more natural way to do it is
  to run a project command while we are visiting a file in the project
  directory.  In most cases, we already have a file from some project
  open in the current buffer.  Therefore it makes more sense to just
  go ahead with a project command, say, with &lt;code&gt;C-x p
  f&lt;/code&gt;, &lt;code&gt;C-x p g&lt;/code&gt;, etc. directly instead of explicitly
  discovering the project with &lt;code&gt;C-x p p ... RET&lt;/code&gt;.  Merely
  running a project command while we have a file from a project open
  ends up discovering the current project automatically.  Explicitly
  discovering projects with &lt;code&gt;C-x p p ... RET&lt;/code&gt; is almost
  never necessary.
&lt;/p&gt;
&lt;h2 id=&quot;eshell-with-tramp&quot;&gt;Eshell with TRAMP&lt;/h2&gt;
&lt;p&gt;
  Many members of our group knew about Eshell and TRAMP separately.
  For example, &lt;code&gt;M-x eshell RET&lt;/code&gt; starts Eshell.  Eshell is
  implemented purely in Elisp and we can use it much like a regular
  shell.  Here is an example session:
&lt;/p&gt;
&lt;pre&gt;&lt;samp&gt;~ $ &lt;kbd&gt;cd /tmp/&lt;/kbd&gt;
/tmp $ &lt;kbd&gt;echo hello &amp;gt; hello.txt&lt;/kbd&gt;
/tmp $ &lt;kbd&gt;cat hello.txt&lt;/kbd&gt;
hello
/tmp $ &lt;kbd&gt;python3 --version&lt;/kbd&gt;
Python 3.11.5
/tmp $ &lt;kbd&gt;which cd echo cat python3 which&lt;/kbd&gt;
eshell/cd is a byte-compiled Lisp function in &amp;lsquo;em-dirs.el&amp;rsquo;.
eshell/echo is a byte-compiled Lisp function in &amp;lsquo;em-basic.el&amp;rsquo;.
eshell/cat is a byte-compiled Lisp function in &amp;lsquo;em-unix.el&amp;rsquo;.
/usr/bin/python3
eshell/which is a byte-compiled Lisp function in &amp;lsquo;esh-cmd.el&amp;rsquo;.&lt;/samp&gt;&lt;/pre&gt;
&lt;p&gt;
  We also knew about TRAMP.  For example, when we type the key
  sequence &lt;code&gt;C-x C-f /ssh:alice@box:/tmp/foo.txt RET&lt;/code&gt;, TRAMP
  notices that we intend to connect to a remote system
  named &lt;code&gt;box&lt;/code&gt; as the user &lt;code&gt;alice&lt;/code&gt; via SSH and
  edit a file named &lt;code&gt;/tmp/foo.txt&lt;/code&gt; on the remote system.
  TRAMP then transparently establishes the SSH connection for us.  If
  public key authentication is already set up, then the connection is
  successfully established immediately.  Otherwise it prompts for a
  password.  In the end, we get a buffer to edit the remote
  file &lt;code&gt;/tmp/foo.txt&lt;/code&gt;.  Once we have this buffer, we never
  have to do anything special to work on the remote file.  All Emacs
  commands work seamlessly on this buffer for the remote file.  For
  example, when we type &lt;code&gt;C-x C-s&lt;/code&gt; TRAMP would go ahead and
  save the file to the remote system using the established SSH
  connection.  If we type &lt;code&gt;C-x d&lt;/code&gt;, TRAMP would create a
  Dired buffer for the remote directory &lt;code&gt;/tmp/&lt;/code&gt;.  All the
  Emacs commands for working with files and directories we know just
  work fine with the remote file or directory.
&lt;/p&gt;
&lt;p&gt;
  So we knew about Eshell and we knew about TRAMP.  However what many
  of us found pleasantly surprising was how remarkably well Eshell and
  TRAMP work together.  Here is an example Eshell session that
  illustrates this point:
&lt;/p&gt;
&lt;pre&gt;&lt;samp&gt;~ $ &lt;kbd&gt;cd /ssh:alice@box:/tmp/&lt;/kbd&gt;
/ssh:alice@box:/tmp $ &lt;kbd&gt;echo foo &amp;gt; foo.txt&lt;/kbd&gt;
/ssh:alice@box:/tmp $ &lt;kbd&gt;ls&lt;/kbd&gt;
foo.txt
/ssh:alice@box:/tmp $ &lt;kbd&gt;cd /tmp/&lt;/kbd&gt;
/tmp $ &lt;kbd&gt;echo bar &amp;gt; bar.txt&lt;/kbd&gt;
/tmp $ &lt;kbd&gt;ls&lt;/kbd&gt;
bar.txt
/tmp $ &lt;kbd&gt;cp /ssh:alice@box:/tmp/foo.txt .&lt;/kbd&gt;
/tmp $ &lt;kbd&gt;ls&lt;/kbd&gt;
bar.txt  foo.txt
/tmp $&lt;/samp&gt;&lt;/pre&gt;
&lt;p&gt;
  Look at how the command &lt;code&gt;cd /ssh:alice@box:/tmp/&lt;/code&gt; above
  has seamlessly and transparently set the current directory of the
  shell to the remote directory.  When we create a file after that, it
  gets created on the remote directory!  We can work across
  directories opened with multiple TRAMP methods too.  For example
  first consider this session where the current local user does not
  have the permissions to write to the local &lt;code&gt;/etc/&lt;/code&gt;
  directory:
&lt;/p&gt;
&lt;pre&gt;&lt;samp&gt;~ $ &lt;kbd&gt;cp /ssh:alice@box:/etc/wgetrc /etc/&lt;/kbd&gt;
Opening output file Permission denied /etc/wgetrc&lt;/samp&gt;&lt;/pre&gt;
&lt;p&gt;
  But if the current user has &lt;code&gt;sudo&lt;/code&gt; privilege, we can do
  something like this:
&lt;/p&gt;
&lt;pre&gt;&lt;samp&gt;~ $ &lt;kbd&gt;cp /ssh:alice@box:/etc/wgetrc /sudo::/etc/&lt;/kbd&gt;
~ $ &lt;kbd&gt;ls /etc/wgetrc&lt;/kbd&gt;
/etc/wgetrc&lt;/samp&gt;&lt;/pre&gt;
&lt;p&gt;
  We copied a file from a remote system and wrote it to a protected
  directory on the local system by using the &lt;code&gt;sudo&lt;/code&gt;
  privilege.  We used the &lt;code&gt;ssh&lt;/code&gt; method to read a remote
  file and the &lt;code&gt;sudo&lt;/code&gt; method to write the file to a
  protected local directory.  TRAMP really does live up to its
  name: &lt;em&gt;Transparent Remote Access, Multiple Protocol&lt;/em&gt;!
&lt;/p&gt;
&lt;h2 id=&quot;thanks&quot;&gt;Thanks&lt;/h2&gt;
&lt;p&gt;
  It has been a pleasure hosting these Emacs book club meetings
  throughout this year.  I have really enjoyed discussing the book in
  great detail, examining each new concept introduced in the book
  carefully and performing demos to illustrate the concepts.  A big
  thank you to the Emacs communities on Libera and Matrix networks who
  showed interest in these meetings, joined these meetings,
  participated in the discussions and helped make these meetings
  successful!
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/from-fill-prefix-to-tramp.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Mastering Emacs: Chapter 7: Conclusion</title>
    <link href="https://susam.net/cc/mastering-emacs/ch07.html"/>
    <id>urn:uuid:9909faf4-c481-46bf-9f48-508bc49cbada</id>
    <updated>2023-12-29T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  The following notes were taken while discussing Chapter 6 of the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  An index of notes for all chapters are available
  at &lt;a href=&quot;notes.html&quot;&gt;notes.html&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#third-party-packages-and-tools&quot;&gt;Third-Party Packages and Tools&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#communities&quot;&gt;Communities&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;third-party-packages-and-tools&quot;&gt;Third-Party Packages and Tools&lt;/h2&gt;
&lt;p&gt;
  Here is a list of third-party packages and tools this chapter
  introduces to the reader:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;nov, an EPUB reader&lt;/li&gt;
  &lt;li&gt;Magit, a Git UI system with a chord-based key system&lt;/li&gt;
  &lt;li&gt;Multiple Cursors&lt;/li&gt;
  &lt;li&gt;LSP Mode, a language server interface for Emacs&lt;/li&gt;
  &lt;li&gt;Eglot, another language server interface for Emacs&lt;/li&gt;
  &lt;li&gt;Helm, a powerful completion framework&lt;/li&gt;
  &lt;li&gt;Flycheck, a generic framework for linting and syntax error checking&lt;/li&gt;
  &lt;li&gt;Org mode, an organiser for notes, agenda, literate programming, etc.&lt;/li&gt;
  &lt;li&gt;YASnippet, a text snippet expansion tool&lt;/li&gt;
  &lt;li&gt;Hydra, a package to build flexible popup UIs for key bindings&lt;/li&gt;
  &lt;li&gt;dumb-jump, a package to jump to definitions from symbols&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note that Eglot comes out of the box since Emacs version 29.1.
&lt;/p&gt;
&lt;h2 id=&quot;communities&quot;&gt;Communities&lt;/h2&gt;
&lt;p&gt;
  Some of the communities recommended by this chapter are:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://old.reddit.com/r/emacs/&quot;&gt;Reddit r/emacs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://emacs.stackexchange.com/&quot;&gt;Emacs Stack Exchange&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://planet.emacslife.com/&quot;&gt;Planet Emacslife&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/ch07.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Mastering Emacs: Chapter 6: The Practicals of Emacs</title>
    <link href="https://susam.net/cc/mastering-emacs/ch06.html"/>
    <id>urn:uuid:b0bdfa9a-4e48-4c66-8f34-39418ca744a3</id>
    <updated>2023-12-28T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  The following notes were taken while discussing Chapter 6 of the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  An index of notes for all chapters are available
  at &lt;a href=&quot;notes.html&quot;&gt;notes.html&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#exploring-emacs&quot;&gt;Exploring Emacs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#project-management&quot;&gt;Project Management&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#xref&quot;&gt;Xref&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#xref-setup&quot;&gt;Xref Setup&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#search-tools-for-xref&quot;&gt;Search Tools for Xref&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#four-most-common-xref-commands&quot;&gt;Four Most Common Xref Commands&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#xref-and-dired&quot;&gt;Xref and Dired&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#working-with-log-files&quot;&gt;Working with Log Files&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#highlighting&quot;&gt;Highlighting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#auto-revert-mode&quot;&gt;Auto-Revert Mode&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#auto-revert-tail-mode&quot;&gt;Auto Revert Tail Mode&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#browsing-tarballs&quot;&gt;Browsing Tarballs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#dired-thumbnail-image-browser&quot;&gt;Dired: Thumbnail Image Browser&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#preview-buffer-quirks&quot;&gt;Preview Buffer Quirks&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#working-on-marked-files&quot;&gt;Working on Marked Files&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#deleting-images&quot;&gt;Deleting Images&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tagging-and-untagging&quot;&gt;Tagging and Untagging&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#using-tags&quot;&gt;Using Tags&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#display-buffer&quot;&gt;Display Buffer&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#docview&quot;&gt;DocView&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#docview-resolution&quot;&gt;DocView Resolution&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tramp&quot;&gt;TRAMP&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#default-directory&quot;&gt;Default Directory&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#multi-hops&quot;&gt;Multi-Hops&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#eww&quot;&gt;EWW: Emacs Web Wowser&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#invoking-external-browser&quot;&gt;Invoking External Browser&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#dired&quot;&gt;Dired&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-getting-started&quot;&gt;Dired: Getting Started&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-navigation&quot;&gt;Dired: Navigation&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-marking-and-unmarking&quot;&gt;Dired: Marking and Unmarking&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-operations&quot;&gt;Dired: Operations&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-copying-or-renaming-between-buffers&quot;&gt;Dired: Copying or Renaming Between Buffers&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-more-keys&quot;&gt;Dired: More Keys&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-x&quot;&gt;Dired-X&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dired-working-across-directories&quot;&gt;Dired: Working Across Directories&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#shell-commands&quot;&gt;Shell Commands&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#compiling-in-emacs&quot;&gt;Compiling in Emacs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#shells-in-emacs&quot;&gt;Shells in Emacs&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#m-x-shell&quot;&gt;M-x shell&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#m-x-ansi-term&quot;&gt;M-x ansi-term&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#m-x-eshell&quot;&gt;M-x eshell&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;exploring-emacs&quot;&gt;Exploring Emacs&lt;/h2&gt;
&lt;p&gt;
  The book suggests the following techniques to explore Emacs:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      Reading the manual.  For example, type &lt;code&gt;M-x info RET&lt;/code&gt;
      or &lt;code&gt;C-h i&lt;/code&gt;, then navigate to the &lt;code&gt;Emacs&lt;/code&gt;
      hyperlink, then type &lt;code&gt;C-s version control RET&lt;/code&gt; and
      then navigate to the node named &lt;code&gt;Version Control&lt;/code&gt; to
      read the corresponding manual.
    &lt;/p&gt;
    &lt;p&gt;
      Note that the section named &lt;em&gt;The Info Manual&lt;/em&gt; in Chapter
      3 offers more alternatives to reach a specific node in a more
      straightforward manner.  For example, &lt;code&gt;C-h i m emacs RET m
      Version Control RET&lt;/code&gt; accomplishes the same result.
      Alternatively, &lt;code&gt;C-h R emacs RET m Version Control
      RET&lt;/code&gt; also accomplishes the same result.  Yet another way
      to accomplish the same result is to evaluate the Elisp
      expression &lt;code&gt;(info &quot;(emacs)Version Control&quot;)&lt;/code&gt;.  See
      section &lt;a href=&quot;ch03.html#info&quot;&gt;Info&lt;/a&gt; in chapter 3 notes for
      more details.
    &lt;/p&gt;
    &lt;p&gt;
      Yet another way to explore the manual is to use
      the &lt;code&gt;info-apropos&lt;/code&gt; command.  For example,
      type &lt;code&gt;M-x info-apropos RET version control RET&lt;/code&gt; to
      find manuals which have the string &quot;version control&quot; in them.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Using apropos.  For example, type &lt;code&gt;C-h d version control
      RET&lt;/code&gt; to search for all symbols whose documentation string
      contains the specified pattern.  Then type &lt;code&gt;C-h a ^vc-
      RET&lt;/code&gt; to search for all commands that match this pattern.
      This is a convenient way to list the vc commands.  Also, see
      section &lt;a href=&quot;ch03.html#apropos&quot;&gt;Apropos&lt;/a&gt; in chapter 3
      notes for more details.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Exploring prefix keys.  For example, type &lt;code&gt;C-x v C-h&lt;/code&gt;
      to list all key sequences bound to the prefix key &lt;code&gt;C-x
      v&lt;/code&gt;.  This is in fact a convenient way to list all the vc
      key bindings.  Also, see section
      &lt;a href=&quot;ch03.html#discovering-and-remembering-keys&quot;&gt;Discovering
      and Remembering Keys&lt;/a&gt; in chapter 3 notes for more details.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Describe what a key does.  For example, type &lt;code&gt;C-h k&lt;/code&gt;
      followed by &lt;code&gt;C-x v v&lt;/code&gt; to see the command that is
      bound to the latter key sequence as well as its documentation
      string along with other details like the keymap where the key
      binding is found, the file where the command is defined, other
      key bindings for the same command, etc.  See
      section &lt;a href=&quot;ch03.html#describe&quot;&gt;Describe&lt;/a&gt; in chapter 3
      notes for some more details.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Describe commands.  For example, type &lt;code&gt;C-h f vc-dir
      RET&lt;/code&gt; to see information about the &lt;code&gt;vc-dir&lt;/code&gt;
      command.  See section &lt;a href=&quot;ch03.html#describe&quot;&gt;Describe&lt;/a&gt;
      in chapter 3 notes for some more details.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Find mode commands.  Type &lt;code&gt;C-h m&lt;/code&gt; to see the
      documentation strings of the current major mode and minor modes.
      A brief summary of the minor modes is shown first, followed by
      the major mode description.  This is followed by documentation
      strings of the minor modes separated by page breaks (the form
      feed character that is rendered as &lt;code&gt;^L&lt;/code&gt; in Emacs).
      See section &lt;a href=&quot;ch03.html#describe&quot;&gt;Describe&lt;/a&gt; in chapter
      3 notes for some more details.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-X&lt;/code&gt; to run
      &lt;code&gt;execute-extended-command-for-buffer&lt;/code&gt; which executes
      commands that are relevant to the current buffer.  While
      offering completions, it limits the completions to commands
      relevant to the current buffer.  See
      section &lt;a href=&quot;ch03.html#m-x-execute-extended-command-for-buffer&quot;&gt;M-X:
      Execute Extended Command for Buffer&lt;/a&gt; of chapter 3 notes for
      more details.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;project-management&quot;&gt;Project Management&lt;/h2&gt;
&lt;p&gt;
  Emacs comes with a project management package
  named &lt;code&gt;project.el&lt;/code&gt; which offers commands to operate on
  projects.  When we use a project management command like &lt;code&gt;C-x p
  f&lt;/code&gt; to visit a file in the current project, this package
  automatically detects the top-level directory of the project by
  checking parent directories for version control system artifacts
  (e.g. &lt;code&gt;.git&lt;/code&gt; directory) and presents files within that
  top-level directory as autocomplete options.
&lt;/p&gt;
&lt;p&gt;
  The following complete key sequences demonstrate the package
  management commands mentioned in the book:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p p ... TAB RET ~/git/foo/ RET f README.md&lt;/code&gt;:
      This awkward key sequence discovers a new project directory
      at &lt;code&gt;~/git/foo/&lt;/code&gt; and then finds the file
      named &lt;code&gt;README.md&lt;/code&gt; in it.  As soon as the key
      sequence &lt;code&gt;f&lt;/code&gt; is typed above, the new project
      directory is discovered and added
      to &lt;code&gt;~/.emacs.d/projects&lt;/code&gt; which is where the list of
      known projects is saved.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p p bar TAB RET f Makefile&lt;/code&gt;: Assuming there is
      already a known project with &lt;code&gt;bar&lt;/code&gt; in its name
      (say, &lt;code&gt;~/git/bar/&lt;/code&gt;) that was discovered earlier, this
      key sequence switches to that project and finds the file named
      in &lt;code&gt;Makefile&lt;/code&gt; in it.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p f dev/build.sh RET&lt;/code&gt;: Find file
      named &lt;code&gt;dev/build.sh&lt;/code&gt; in the current project.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p f build TAB RET&lt;/code&gt;: Same as above
      if &lt;code&gt;dev/build.sh&lt;/code&gt; is the only match
      for &lt;code&gt;build&lt;/code&gt;.  Otherwise, it presents all files in the
      current project containing &lt;code&gt;build&lt;/code&gt; anywhere in its
      path name as autocomplete options.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p f bar TAB RET build TAB RET&lt;/code&gt;: When we
      type &lt;code&gt;C-x p f&lt;/code&gt; while visiting a file that does not
      belong to any project, then its prompts for a project name.  In
      this example, we type &lt;code&gt;bar TAB RET&lt;/code&gt; to automatically
      expand it to a known project name such
      as &lt;code&gt;~/git/bar/&lt;/code&gt; and enter it.  Then we
      type &lt;code&gt;build TAB RET&lt;/code&gt; to automatically expand it to a
      file name such as &lt;code&gt;dev/build.sh&lt;/code&gt; and enter it.
    &lt;/p&gt;
    &lt;p&gt;
      It is worth noting a general point that whenever we invoke a
      project command while visiting a file that does not belong to a
      project, the project command prompts for the project name.
      After we enter the project name, the project command runs on our
      chosen project.  This general point applies to other project
      commands that come later in this list.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p b Makefile RET&lt;/code&gt;: Switch to a buffer
      named &lt;code&gt;Makefile&lt;/code&gt; in the current project.  While
      entering the buffer name when &lt;code&gt;TAB&lt;/code&gt; is typed,
      completion options present buffer names from the current project
      only.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p k yes RET&lt;/code&gt;: Kill all buffers belonging to the
      current project.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p g ^key\&amp;gt; RET&lt;/code&gt;: Find all matches for the
      regular expression &lt;code&gt;^key\&amp;gt;&lt;/code&gt; in the current
      project.  The matches are found in all files in the project
      regardless of whether they are currently open in Emacs or not.
      The matches are displayed in a buffer named &lt;code&gt;*xref*&lt;/code&gt;.
      We can navigate this buffer using key sequences
      like &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt;, etc.  Type
      &lt;code&gt;C-h m&lt;/code&gt; in this buffer to see a list of key sequences
      supported in this buffer.  As we navigate this buffer and go
      from one match to another using &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt;,
      etc. the files containing the match are loaded in a split window
      automatically with the matching lines automatically centred in
      that window.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p r ^key\&amp;gt; RET =key= RET&lt;/code&gt;: Find all matches
      for the regular expression pattern &lt;code&gt;^key\&amp;gt;&lt;/code&gt; in the
      current project and replace them with &lt;code&gt;=key=&lt;/code&gt;.  The
      modified files are not automatically saved though.  They needed
      to be saved later explicitly.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p c RET&lt;/code&gt;: Compiles the current project.  By
      default, it offers as &lt;code&gt;make -f&lt;/code&gt; as the command to be
      run in the project root.  If a specific &lt;code&gt;make&lt;/code&gt; target
      needs to be executed or if another command needs to be executed,
      then the default command offered may be edited before
      typing &lt;code&gt;RET&lt;/code&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p v&lt;/code&gt;: Runs VC-Dir in the current project&apos;s root
      which in turn shows version control status for the project root.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p s&lt;/code&gt;: Start shell in the current project&apos;s root
      directory.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p d RET&lt;/code&gt;: Start Dired in the current project&apos;s
      root directory.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p D&lt;/code&gt;: Same as above.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-x p d doc/tutorial/ RET&lt;/code&gt;: Start Dired in
      the &lt;code&gt;doc/tutorial/&lt;/code&gt; subdirectory in the current
      project.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  There are several more project management key bindings.
  Type &lt;code&gt;C-x p C-h&lt;/code&gt; to see a complete list of them.
&lt;/p&gt;
&lt;h2 id=&quot;xref&quot;&gt;Xref&lt;/h2&gt;
&lt;p&gt;
  Xref provides a generic framework to support commands for
  cross-referencing in Emacs.  While there are several ways to set it
  up and configure it, the book mentions a particular way to set it up
  using a couple of external tools.  The next two subsections discuss
  the setup work involved before we can use Xref in a modern way.  The
  remaining subsections discuss how to use Xref.
&lt;/p&gt;
&lt;h3 id=&quot;xref-setup&quot;&gt;Xref Setup&lt;/h3&gt;
&lt;p&gt;
  By default when we try to look up a definition of an identifier in,
  say, a C file or Python file, by typing &lt;code&gt;M-.&lt;/code&gt;, it
  presents a minibuffer for us to select a tags table file (typically
  named &lt;code&gt;TAGS&lt;/code&gt;).  This requires setting up
  a &lt;code&gt;TAGS&lt;/code&gt; file with a tool like &lt;code&gt;ctags&lt;/code&gt;.  The
  book, however, does not explore this method for good reason.
  Typically the &lt;code&gt;TAGS&lt;/code&gt; file needs to be created with a tool
  like &lt;code&gt;ctags&lt;/code&gt; or &lt;code&gt;etags&lt;/code&gt; for every project we
  work on.  This file contains an index of names found in source code
  files.  We need to periodically update it as the code of our
  projects evolve, so that this index remains up-to-date.  For a long
  time, this was the only way to maintain an index of the names found
  in a source code, so that we could perform cross-referencing in
  editors like Vim and Emacs.  Relying on a tool
  like &lt;code&gt;grep&lt;/code&gt; to search the code on the fly was deemed to
  be quite slow.  However, with modern, fast hardware we do not have
  to work like this anymore.  Further, there are search tools
  like &lt;code&gt;ag&lt;/code&gt; and &lt;code&gt;rg&lt;/code&gt; which are extremely fast.
  Given these modern developments, there are simpler ways to set up
  cross-referencing in Emacs.
&lt;/p&gt;
&lt;p&gt;
  The book suggets installing an external package
  named &lt;code&gt;dumb-jump&lt;/code&gt;.  It can be installed from MELPA with
  the key sequence &lt;code&gt;M-x package-install dumb-jump RET&lt;/code&gt;.
  See &lt;a href=&quot;https://github.com/jacktasia/dumb-jump&quot;&gt;github.com/jacktasia/dumb-jump&lt;/a&gt;
  for more details about this package.  After installing this package,
  add the following code to the Emacs initialisation file:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(add-hook &apos;xref-backend-functions #&apos;dumb-jump-xref-activate)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Here is a minimal Elisp code that sets up &lt;code&gt;dumb-jump&lt;/code&gt;
  from scratch and configures it as mentioned above:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(require &apos;package)
(add-to-list &apos;package-archives &apos;(&quot;melpa&quot; . &quot;https://melpa.org/packages/&quot;) t)
(package-initialize)
(unless package-archive-contents
  (package-refresh-contents))
(dolist (package &apos;(dumb-jump))
  (unless (package-installed-p package)
    (package-install package)))
(add-hook &apos;xref-backend-functions #&apos;dumb-jump-xref-activate)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The above code configures Emacs to use MELPA, retrieve the latest
  list of packages available there, install &lt;code&gt;dumb-jump&lt;/code&gt;
  from it, as well as set up a hook to activate it automatically when
  we use certain Xref commands.
&lt;/p&gt;
&lt;h3 id=&quot;search-tools-for-xref&quot;&gt;Search Tools for Xref&lt;/h3&gt;
&lt;p&gt;
  Once Xref is set up with &lt;code&gt;dumb-jump&lt;/code&gt; as explained in the
  previous section, open a source code file (say, a C file or a Python
  file), move the cursor over to some identifier and
  type &lt;code&gt;M-.&lt;/code&gt; to search that identifier in your environment.
  By default, it searches for the identifier in files of the same type
  found under the home directory with a tool like &lt;code&gt;ag&lt;/code&gt;,
  &lt;code&gt;rg&lt;/code&gt; or &lt;code&gt;grep&lt;/code&gt; (the first one it finds).
  There is an exception to this rule though.  If
  neither &lt;code&gt;ag&lt;/code&gt; nor &lt;code&gt;rg&lt;/code&gt; is found and only GNU
  grep is found, then typing &lt;code&gt;M-.&lt;/code&gt; on an indentifier
  searches the identifier in all files in the home directory (as
  opposed to searching for files of a specific type).  If BSD grep is
  found instead, then this is not a problem and only files of the
  current type is searched for the identifier.
&lt;/p&gt;
&lt;p&gt;
  Further, while looking up definitions within a Git repository, this
  package invokes the &lt;code&gt;git grep&lt;/code&gt; command to restrict
  searches to the repository directory.
&lt;/p&gt;
&lt;p&gt;
  Let us now look at a few examples of the actual search commands that
  are executed under the hood when we type &lt;code&gt;M-.&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  If neither &lt;code&gt;ag&lt;/code&gt; nor &lt;code&gt;rg&lt;/code&gt; is installed and we
  only have &lt;code&gt;grep&lt;/code&gt; on our system, typing &lt;code&gt;M-.&lt;/code&gt;
  while the cursor is on an identifier named &lt;code&gt;foo&lt;/code&gt; in a
  Python file leads to the execution of a command like this when BSD
  grep is found:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep -REn --include &apos;*.py&apos; -e &apos;\s*\bfoo\s*=[^=\n]+&apos; -e &apos;def\s*foo\b\s*\(&apos; -e &apos;class\s*foo\b\s*\(?&apos; /Users/susam&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  If GNU grep is found instead, then all files (not
  just &lt;code&gt;*.py&lt;/code&gt; files) are searched with a command like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grep -rEn -e &apos;[[:space:]]*\bfoo[[:space:]]*=[^=\n]+&apos; -e &apos;def[[:space:]]*foo\b[[:space:]]*\(&apos; -e &apos;class[[:space:]]*foo\b[[:space:]]*\(?&apos; /home/susam&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  If &lt;code&gt;rg&lt;/code&gt; is the only additional search tool installed,
  then the following command is executed:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rg --color never --no-heading --line-number -U --pcre2 --type py &apos;\s*\bfoo\s*=[^=\n]+|def\s*foo\b\s*\(|class\s*foo\b\s*\(?&apos; /home/susam&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  If &lt;code&gt;ag&lt;/code&gt; is installed, then the following command is
  executed:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ag --nocolor --nogroup --python &apos;\s*\bfoo\s*=[^=\n]+|def\s*foo\b\s*\(|class\s*foo\b\s*\(?&apos; /home/susam&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  When we type &lt;code&gt;M-.&lt;/code&gt; in a file that belongs to a Git
  repository, only the repository directory is searched with a command
  like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git grep --color=never --line-number --untracked -E &apos;\s*\bfoo\s*=[^=\n]+|def\s*foo\b\s*\(|class\s*foo\b\s*\(?&apos; -- /home/susam/repo/*.py&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The book makes a mention of &lt;code&gt;rg&lt;/code&gt; and remarks about the
  impressive speed with which it searches the file system.  I
  recommend it too.  Since the &lt;code&gt;M-.&lt;/code&gt; command may search the
  whole home directory, if the home directory is very large, having a
  fast search tool like &lt;code&gt;rg&lt;/code&gt; or &lt;code&gt;ag&lt;/code&gt; makes a
  significant difference.  For example what could normally take 10 to
  20 seconds to search using &lt;code&gt;grep&lt;/code&gt; might only take a
  second or two with &lt;code&gt;rg&lt;/code&gt; or &lt;code&gt;ag&lt;/code&gt;.  I
  use &lt;code&gt;M-.&lt;/code&gt; with &lt;code&gt;rg&lt;/code&gt;.
&lt;/p&gt;
&lt;h3 id=&quot;four-most-common-xref-commands&quot;&gt;Four Most Common Xref Commands&lt;/h3&gt;
&lt;p&gt;
  The book mentions the following commands as the four most common
  commands we should know about:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-.&lt;/code&gt;: Find definitions of the identifier at point.
      If a unique definition is found, then the file containing the
      definition is automatically opened and the definition is centred
      in the window.  If multiple possible candidates are found, then
      they are displayed in an Xref buffer that we can navigate using
      key sequences like &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;p&lt;/code&gt;.  As we
      navigate the Xref buffer, the source of each match is
      automatically opened in a split window and the matching line is
      centred.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-,&lt;/code&gt;: Go back to where &lt;code&gt;M-.&lt;/code&gt; was last
      invoked.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-? foo RET ~/git/foo/ RET&lt;/code&gt;: Find all occurrences of
      the word &lt;code&gt;foo&lt;/code&gt; in files of the same type as the
      current file in the project directory &lt;code&gt;~/git/foo/&lt;/code&gt;.
      It does not restrict the search to definitions only.  If the
      current file belongs to a project already, then we could simply
      type &lt;code&gt;M-? foo RET&lt;/code&gt;.  In fact, since the input to the
      minibuffer prompt is the identifier at the point by default, we
      could simply type &lt;code&gt;M-? RET&lt;/code&gt; to search for the current
      identifier in the current project.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-M-. foo RET&lt;/code&gt;: Find symbols matching the given
      pattern.  Although the documentation mentions that this supports
      regular expressions, it seemed to treat the given pattern as an
      identifier and searched for that identifier literally.  In fact,
      the &lt;code&gt;rg&lt;/code&gt; commands that were executed under the hood
      were exactly the same as the ones executed by &lt;code&gt;M-.&lt;/code&gt;.
      Thus with &lt;code&gt;dumb-jump&lt;/code&gt; enabled, both &lt;code&gt;M-.&lt;/code&gt;
      and &lt;code&gt;C-M-.&lt;/code&gt; behave similarly.  The only difference is
      that &lt;code&gt;M-.&lt;/code&gt; searches for the identifier at the point
      whereas &lt;code&gt;C-M-.&lt;/code&gt; searches for the identifier we enter
      at the minibuffer as input.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  When multiple cross-references are displayed in the Xref buffer, we
  can use the following key sequences to work with the Xref buffer.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;n&lt;/code&gt;: Move to the next cross-reference.  The source of
      the cross-reference is automatically displayed in another
      window.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;n&lt;/code&gt;: Move to the previous cross-reference.  The source
      of the cross-reference is automatically displayed in another
      window.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;.&lt;/code&gt;: Same as &lt;code&gt;n&lt;/code&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;,&lt;/code&gt;: Same as &lt;code&gt;p&lt;/code&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;RET&lt;/code&gt;: Jump to the source of the current
      cross-reference.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;TAB&lt;/code&gt;: Hide Xref buffer and jump to the source.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;C-o&lt;/code&gt;: Show the source of the cross-reference at
      point in a separate window but keep the point in the Xref
      window.  This is useful when we navigate the Xref buffer using
      normal Emacs commands like &lt;code&gt;C-p&lt;/code&gt;, &lt;code&gt;C-n&lt;/code&gt;,
      &lt;code&gt;C-s&lt;/code&gt;, etc.  While navigating the Xref buffer with
      these normal Emacs commands, the source of the cross-references at
      the point is not automatically displayed.  The key
      sequence &lt;code&gt;C-o&lt;/code&gt; helps us to display the cross-reference
      at the point in this case.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;r&lt;/code&gt;: Perform search and replace in the names of the
      references displayed in the Xref buffer.  However, I did not
      find this to be working successfully
      with &lt;code&gt;dumb-jump&lt;/code&gt;.  Any attempt to use this command
      with &lt;code&gt;dumb-jump&lt;/code&gt; always led me to the following
      error: &lt;code&gt;No suitable matches here&lt;/code&gt;.  This key sequence
      does work as expected when Xref is invoked from Dired as going
      to be explained in the next section.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;xref-and-dired&quot;&gt;Xref and Dired&lt;/h3&gt;
&lt;p&gt;
  Here are some key sequences that demonstrate how we can use Xref
  with Dired.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x d RET&lt;/code&gt;: Edit current directory using Dired.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;n&lt;/code&gt;: Move to the next line.  &lt;code&gt;C-n&lt;/code&gt; also
    works.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;p&lt;/code&gt;: Move to the previous line.  &lt;code&gt;C-p&lt;/code&gt; also
    works.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;m&lt;/code&gt;: Mark the file or subdirectory at the point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;u&lt;/code&gt;: Unmark the file or subdirectory at the point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;A f.. RET&lt;/code&gt;: Find all matches for the regular
    expression &lt;code&gt;f..&lt;/code&gt; in the marked files and
    subdirectories.  The matches are always displayed in an Xref
    buffer, even when a single match is found.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;Q f.. RET bar RET&lt;/code&gt;: Find all matches for the regular
    expression &lt;code&gt;f..&lt;/code&gt; in the marked files and subdirectories
    and replace them with &lt;code&gt;bar&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;working-with-log-files&quot;&gt;Working with Log Files&lt;/h2&gt;
&lt;p&gt;
  In this section of the book, it discusses a set of commands that are
  useful for working with log files.  Note that some of these commands
  have been already introduced in the previous chapters.  The
  following list presents the commands discussed in this section of
  the book:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f&lt;/code&gt;: Find a file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-r&lt;/code&gt;: Find file and open in read-only mode.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-q&lt;/code&gt;: Toggle read-only mode.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x flush-lines RET b.. RET&lt;/code&gt;: Delete lines in region
    that match the regular expression &lt;code&gt;b..&lt;/code&gt;.  If no region
    is active, then delete matching lines between the point and end of
    buffer.  The deleted lines are not copied to kill ring.  See
    section &lt;a href=&quot;ch05.html#deleting-and-keeping-lines&quot;&gt;Deleting
    and Keeping Lines&lt;/a&gt; of chapter 5 notes for more details.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x keep-lines RET b.. RET&lt;/code&gt;: Keep lines in region that
    match the regular expression &lt;code&gt;b..&lt;/code&gt; and delete the rest.
    If no region is active, then keep matching lines between the point
    and end of buffer and delete the rest.  The deleted lines are not
    copied to kill ring.  See section
    &lt;a href=&quot;ch05.html#deleting-and-keeping-lines&quot;&gt;Deleting and
    Keeping Lines&lt;/a&gt; of chapter 5 notes for more details.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-s o b.. RET&lt;/code&gt;: Show all lines in the current buffer
    matching the regular expression &lt;code&gt;b..&lt;/code&gt;.  If the region
    is active, then show matching lines from the region only.  The
    matches are shown in a new Occur mode buffer.  The book makes a
    special mention that we can run &lt;code&gt;M-s o&lt;/code&gt; on an Occur
    mode buffer to filter it further and get the results in another
    Occur mode buffer.  See section
    &lt;a href=&quot;ch04.html#occur-mode&quot;&gt;Occur Mode&lt;/a&gt; in chapter 4 notes
    for more details.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;highlighting&quot;&gt;Highlighting&lt;/h2&gt;
&lt;p&gt;
  Section &lt;em&gt;Working with Log Files&lt;/em&gt; of Chapter 6 of the book
  also introduces highlighting commands that can be very useful for
  highlighting certain strings in the log file.  The highlighting
  commands are demonstrated below with an example.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      First create a buffer with the following content.
    &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;foo bar baz
Foo Bar Baz
FOO BAR BAZ
foo  bar  baz
Foo  Bar  Baz
FOO  BAR  BAZ&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now type &lt;code&gt;M-s h p f.. SPC b.. RET RET&lt;/code&gt; to highlight
      the phrases matching the regular expression &lt;code&gt;f.. b..&lt;/code&gt;
      in a case-insensitive and whitespace-insensitive manner.  A
      total of six matches will be highlighted because the first two
      words and the whitespace between them in all lines match this
      phrase pattern when we ignore the case of the words and the
      amount of whitespace.  The second &lt;code&gt;RET&lt;/code&gt; is meant to
      accept the default face offered to us for highlighting.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now type &lt;code&gt;M-s h p b.z RET RET&lt;/code&gt; to highlight the
      phrases matching the regular expression &lt;code&gt;b.z&lt;/code&gt;.  Again
      we select the default face offered to us for highlighting.  At
      this point, we should see two sets of highlighting in two
      different faces.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now move the cursor to one of the first set of highlights and
      type &lt;code&gt;M-s h u RET&lt;/code&gt;.  Those highlights will be
      unhighlighted.  The &lt;code&gt;RET&lt;/code&gt; key accepts the default
      unhighlighting pattern offered to us.  It happens to be the
      pattern with which the highlight under the cursor was
      highlighted.  That is why this key sequence ends up
      unhighlighting the highlight under the cursor.
    &lt;/p&gt;
    &lt;p&gt;
      If the cursor were not over a highlgiht, then the default
      unhighlighting pattern offered to us would have been the pattern
      we used for the last highlight.  In that case, we could
      type &lt;code&gt;M-s h u f.. b.. RET&lt;/code&gt; to explicitly specify the
      unhighlighting pattern.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now type &lt;code&gt;M-s h u RET&lt;/code&gt; again to remove the second set
      of highlights too.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-s h p F.. SPC B.. RET RET&lt;/code&gt; to perform a
      case-sensitive but whitespace-insensitive highlighting.  When
      there is an uppercase letter in the pattern, the highlighting
      becomes case-sensitive.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-s h u RET&lt;/code&gt; to remove the previous
      highlighting.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-s h r f.. SPC b.. RET RET&lt;/code&gt; to perform a
      case-insensitive but whitespace-sensitive highlighting.  This
      time, there are only three matches from the first three lines.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-s h u RET&lt;/code&gt; to remove the previous
      highlighting.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-s h r F.. SPC B.. RET RET&lt;/code&gt; to perform a
      case-sensitive and whitespace-sensitive highlighting.  The
      matching strings are found in the second and third lines.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Move the cursor to lowercase &lt;code&gt;bar&lt;/code&gt; and type &lt;code&gt;M-s
      h .&lt;/code&gt; to highlight symbol at point.  All six occurrences of
      this symbol are highlighted in a case-insensitive manner because
      the symbol at point is written in all lowercase.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Move the cursor to &lt;code&gt;Baz&lt;/code&gt; and type &lt;code&gt;M-s h
      .&lt;/code&gt; to highlight symbol at point.  Only two occurrences of
      this symbol get highlighted.  The highlighted symbols match the
      symbol &lt;code&gt;Baz&lt;/code&gt; exactly (case-sensitive match).  The
      highlighting is done in case-sensitive manner because the symbol
      at point has at least one uppercase letter.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;auto-revert-mode&quot;&gt;Auto-Revert Mode&lt;/h2&gt;
&lt;p&gt;
  The following steps demonstrate how to use
  the &lt;code&gt;revert-buffer&lt;/code&gt; command and then how to
  use &lt;code&gt;auto-revert-mode&lt;/code&gt;.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      In a terminal, run the following command:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;: &amp;gt; /tmp/log.txt &amp;amp;&amp;amp; while true; do date &amp;gt;&amp;gt; /tmp/log.txt; sleep 1; done&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      You could use &lt;code&gt;ansi-term&lt;/code&gt; within Emacs too as the
      terminal if you are familiar with it.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now within Emacs, type &lt;code&gt;C-x C-f /tmp/log.txt RET&lt;/code&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Wait for a few seconds and type &lt;code&gt;M-x revert-buffer RET yes
      RET&lt;/code&gt; to update the buffer with the latest content of the
      file from the file system.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x auto-revert-mode RET&lt;/code&gt; to enable automatic
      update of the buffer as the file changes on the file system.
      Note that this reloads the entire file whenever a change is
      detected, so this could be inefficient while working with very
      large files.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-&amp;gt;&lt;/code&gt; to go to the end of the buffer.  This
      moves the cursor to the end of the buffer.  Doing this ensures
      that as the buffer is automatically updated, the cursor
      automatically keeps moving to the end of the file.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Terminate the command of step 1 and run this command in a
      terminal:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;echo hello &amp;gt; /tmp/log.txt&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      The content of the buffer should now automatically truncate and
      update to just the text &lt;code&gt;hello&lt;/code&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Run the command in step 1 again and confirm that the content of
      the buffer in Emacs gets updated automatically.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x auto-revert-mode RET&lt;/code&gt; to disable automatic
      update of the buffer.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;auto-revert-tail-mode&quot;&gt;Auto Revert Tail Mode&lt;/h2&gt;
&lt;p&gt;
  The mode named &lt;code&gt;auto-revert-tail-mode&lt;/code&gt; is similar
  to &lt;code&gt;auto-revert-mode&lt;/code&gt;.  However,
  unlike &lt;code&gt;auto-revert-mode&lt;/code&gt; which reloads the entire file
  on every update, the &lt;code&gt;auto-revert-tail-mode&lt;/code&gt; only follows
  the tail of the buffer and appends any new text found to the buffer.
  The following steps demonstrate this:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Like in the previous section, run the following command:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;: &amp;gt; /tmp/log.txt &amp;amp;&amp;amp; while true; do date &amp;gt;&amp;gt; /tmp/log.txt; sleep 1; done&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x auto-revert-tail-mode RET&lt;/code&gt;.  Note that this
      command follows the tail of the file only.  It does not reload
      the entire file.  This can be confirmed with the next step.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Terminate the command of step 1 and run this command in a
      terminal:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;echo hello &amp;gt; /tmp/log.txt&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      The buffer for this file in Emacs should automatically update to
      show the text &lt;code&gt;hello&lt;/code&gt; at the bottom.  But notice all
      the earlier text remains intact.  The earlier text does not
      disappear from the buffer because Emacs does not reload the
      entire file when &lt;code&gt;auto-revert-tail-mode&lt;/code&gt; is enabled.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Run the command in step 1 again and confirm that the content of
      the buffer begins to get updated automatically again.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      As of Emacs 28.2, unfortunately running &lt;code&gt;M-x
      auto-revert-tail-mode RET&lt;/code&gt; is not sufficient to disable
      automatic updates in the buffer.  This command does disable the
      mode but the buffer continues to be updated everytime the file
      changes.  This is very likely a bug in this mode.
    &lt;/p&gt;
    &lt;p&gt;
      As a workaround, disabling &lt;code&gt;auto-revert-mode&lt;/code&gt; ends up
      stopping the auto-update behaviour.  There are two ways to do
      this.  You could type &lt;code&gt;M-x auto-revert-mode RET&lt;/code&gt;
      twice: once to enable it and a second time to disable it.
      Alternatively, just simply type &lt;code&gt;C-0 M-x auto-revert-mode
      RET&lt;/code&gt; which invokes the mode with a prefix argument of zero
      which ends up disabling the mode.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;browsing-tarballs&quot;&gt;Browsing Tarballs&lt;/h2&gt;
&lt;p&gt;
  The following steps demonstrate how we can not only browse a tarball
  but also edit files in it and save them back to the tarball.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      First, create a directory of text files with the following shell
      commands:
    &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mkdir -p foo/bar/baz/
echo hello foo &amp;gt; foo/foo.txt
echo hello bar &amp;gt; foo/bar/bar.txt
echo hello baz &amp;gt; foo/bar/baz/baz.txt
tar -caf /tmp/foo.tgz foo/&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Confirm that the tarball looks good with these shell commands:
    &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;tar -tf /tmp/foo.tgz
tar -xOf /tmp/foo.tgz&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Within Emacs, type &lt;code&gt;C-x C-f /tmp/foo.tgz RET&lt;/code&gt; to open
      the tarball.  A list of all entries in the tarball is displayed
      in a Tar buffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;n&lt;/code&gt; and &lt;code&gt;p&lt;/code&gt; to navigate the Tar
      buffer down and up respectively.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      With the cursor on the line
      containing &lt;code&gt;foo/bar/baz/baz.txt&lt;/code&gt;,
      type &lt;code&gt;RET&lt;/code&gt;.  The content of this entry is now
      displayed in a new buffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now in the buffer that displays the content
      of &lt;code&gt;baz.txt&lt;/code&gt;, edit its content.  Say, type &lt;code&gt;C-a
      !&lt;/code&gt; to append an exclamation point to this buffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-x C-s&lt;/code&gt; to save this buffer.  This updates the
      entry of &lt;code&gt;foo/bar/baz/baz.txt&lt;/code&gt; within the buffer
      for &lt;code&gt;foo.tgz&lt;/code&gt;.  However, the updated tarball is not
      written to the file system yet.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-x b foo.tgz RET&lt;/code&gt; to go back to the buffer
      with the tarball entry listing.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Finally, type &lt;code&gt;C-x C-s&lt;/code&gt; to save the tarball to the
      file system.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now repeat step 2.  The updated content
      of &lt;code&gt;foo/bar/baz/baz.txt&lt;/code&gt; should now appear in the
      output.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;dired-thumbnail-image-browser&quot;&gt;Dired: Thumbnail Image Browser&lt;/h2&gt;
&lt;p&gt;
  Assuming there is a directory &lt;code&gt;~/foo/&lt;/code&gt; that contains
  several image files as well as files of other types, the
  command &lt;code&gt;M-x image-dired RET ~/foo/ RET&lt;/code&gt; creates a
  preview buffer of all images in the directory and displays it along
  with a normal dired buffer showing the directory listing.  Both
  buffers are displayed in two separate windows.
&lt;/p&gt;
&lt;p&gt;
  When the preview buffer is first launched, all image files found in
  the directory are automatically &lt;em&gt;marked&lt;/em&gt;.  This can be seen
  in the Dired buffer.  However the preview buffer does not reflect
  this immediately.  Type &lt;code&gt;m&lt;/code&gt; in the preview buffer to
  force it to pick the current list of marked images and highlight
  them.
&lt;/p&gt;
&lt;p&gt;
  As a best practice, remember to type &lt;code&gt;m&lt;/code&gt; soon after
  launching &lt;code&gt;image-dired&lt;/code&gt; so that the marked images are
  accurately displayed in the preview buffer.
&lt;/p&gt;
&lt;p&gt;
  Within the preview buffer, the following key sequences are
  supported:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-f&lt;/code&gt;: Move to next image.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-b&lt;/code&gt;: Move to the previous image.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-n&lt;/code&gt;: Move to next row of images.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-p&lt;/code&gt;: Move to previous row of images.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;RET&lt;/code&gt;: Display the original image in a display buffer.
  &lt;li&gt;
    &lt;code&gt;m&lt;/code&gt;: Mark an image file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;u&lt;/code&gt;: Unmark an image file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;d&lt;/code&gt;: Flag an image file for deletion.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;t t&lt;/code&gt;: Tag marked thumbnails.  If no thumbnails are
    marked, tag the current thumbnail.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;t r&lt;/code&gt;: Remove tag from marked thumbnails.  If no
    thumbnails are marked, remove tag from the current thumbnail.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;l&lt;/code&gt;: Rotate thumbnail left.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;r&lt;/code&gt;: Rotate thumbnail right.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;preview-buffer-quirks&quot;&gt;Preview Buffer Quirks&lt;/h3&gt;
&lt;p&gt;
  The &lt;code&gt;m&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt; or &lt;code&gt;d&lt;/code&gt; commands in the
  preview buffer are actually meant to mark, unmark or flag the
  corresponding files in the Dired buffer.  The highlighting or
  unhighlighting that occurs in the preview buffer is merely a
  convenience feature.  The preview buffer may not always accurately
  reflect the most recent list of all marked and flagged files.
  Always keep an eye on the Dired buffer to check the most recent
  state of the files.
&lt;/p&gt;
&lt;p&gt;
  Especially, if we go back to the Dired buffer and mark, unmark or
  flag files, the preview buffer does not reflect it automatically.
  We need to go to the preview buffer again and perform at least one
  similar operation (&lt;code&gt;m&lt;/code&gt;, &lt;code&gt;u&lt;/code&gt; or
  &lt;code&gt;d&lt;/code&gt;) in the preview buffer for it to be updated again.
  This is why it is important to keep an eye on the Dired buffer to
  get an accurate account of which files are marked or flagged.
&lt;/p&gt;
&lt;h3 id=&quot;working-on-marked-files&quot;&gt;Working on Marked Files&lt;/h3&gt;
&lt;p&gt;
  Say we have marked some image files using the key
  sequence &lt;code&gt;m&lt;/code&gt; in the preview buffer.  Now we can perform
  various operations on these marked files.  For example, to copy the
  marked files to &lt;code&gt;/tmp/&lt;/code&gt; directory, in a Dired buffer,
  type &lt;code&gt;C /tmp/ RET&lt;/code&gt;.  To move them instead, type &lt;code&gt;R
  /tmp/&lt;/code&gt;.
&lt;/p&gt;
&lt;h3 id=&quot;deleting-images&quot;&gt;Deleting Images&lt;/h3&gt;
&lt;p&gt;
  When we flag thumbnails by typing &lt;code&gt;d&lt;/code&gt; in the preview
  buffer, the corresponding files are flagged for deletion in the
  Dired buffer.  The first column of the flagged file entries contain
  the letter &lt;code&gt;D&lt;/code&gt; in the Dired buffer.  Type &lt;code&gt;x&lt;/code&gt;
  in the Dired buffer to permanently delete (expunge) the flagged
  files.
&lt;/p&gt;
&lt;h3 id=&quot;tagging-and-untagging&quot;&gt;Tagging and Untagging&lt;/h3&gt;
&lt;p&gt;
  If there are marked images, then the tagging and untagging commands
  executed in the preview buffer work on those marked images.
  Otherwise, they work on image corresponding to the current
  thumbnail.  We will refer to these images that the tagging or
  untagging commands work on as &lt;em&gt;target&lt;/em&gt; images in the next few
  paragraphs..
&lt;/p&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;t t trip;oxford;uk RET&lt;/code&gt; tags the target
  images with the tags &lt;code&gt;trip&lt;/code&gt;, &lt;code&gt;oxford&lt;/code&gt;
  and &lt;code&gt;uk&lt;/code&gt;.  The tags must be separated by semicolon as
  shown in the preceding example.  The tags are saved in a path set in
  the &lt;code&gt;image-dired-db-file&lt;/code&gt; variable.  Type &lt;code&gt;C-h v
  image-dired-db-file&lt;/code&gt; to read this path.  Typically, it is
  something like &lt;code&gt;~/.emacs.d/image-dired/.image-dired_db&lt;/code&gt;.
  We will call this the DB file.  This file may be manually inspected
  to see how this command and the next command affect the tags for
  each thumbnail.  Alternatively, type &lt;code&gt;C-t e&lt;/code&gt; in a Dired
  buffer to view and edit the tags of the target files.
&lt;/p&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;t r trip RET&lt;/code&gt; removes the
  tag &lt;code&gt;trip&lt;/code&gt; from the target images.  By virtue of how this
  functionality is implemented, a key sequence like &lt;code&gt;t r
  t.*d&lt;/code&gt; removes the tags &lt;code&gt;trip;oxford&lt;/code&gt;
  and &lt;code&gt;trip;salford&lt;/code&gt; (if present) from the DB file but it
  does not remove a tag like &lt;code&gt;trip;cambridge&lt;/code&gt; (if present).
&lt;/p&gt;
&lt;h3 id=&quot;using-tags&quot;&gt;Using Tags&lt;/h3&gt;
&lt;p&gt;
  Tagging thumbnails could be useful if we want to later mark files by
  tags.  In a Dired buffer, the key sequence &lt;code&gt;C-t f t.*d&lt;/code&gt;
  will mark all files whose thumbnails have tags (as they appear in
  the tags file) matching the regular expression &lt;code&gt;t.*d&lt;/code&gt;.
  For example, images that have with tags &lt;code&gt;trip;oxford;uk&lt;/code&gt;
  as well as &lt;code&gt;trip;london;uk&lt;/code&gt; will be marked but images
  with tags &lt;code&gt;trip;bath;uk&lt;/code&gt;
  and &lt;code&gt;trip;liverpool;uk&lt;/code&gt; will not be marked.
&lt;/p&gt;
&lt;h3 id=&quot;display-buffer&quot;&gt;Display Buffer&lt;/h3&gt;
&lt;p&gt;
  When we type &lt;code&gt;RET&lt;/code&gt; in the preview buffer, the original
  image is displayed in a display buffer.  The following key sequences
  are supported in the display buffer:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;s&lt;/code&gt;: Resize image to fit window.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;f&lt;/code&gt;: Display current image in full size.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;q&lt;/code&gt;: Quit window.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The book makes a note that when we open an image file directly from
  a Dired buffer, the image is opened in &lt;code&gt;image-mode&lt;/code&gt; which
  is more powerful than the display buffer we get when we open an
  image from the thumbnail preview window.
&lt;/p&gt;
&lt;h2 id=&quot;docview&quot;&gt;DocView&lt;/h2&gt;
&lt;p&gt;
  When a PDF or another document of a supported format is opened in
  Emacs, they are converted to images on the fly and displayed in
  Emacs.  In this section, we will discuss working with PDFs only.
  The converted images are cached at the directory set in
  the &lt;code&gt;doc-view-cache-directory&lt;/code&gt; variable.
&lt;/p&gt;
&lt;p&gt;
  Type &lt;code&gt;C-h v auto-mode-alist RET&lt;/code&gt; and search
  for &lt;code&gt;doc-view&lt;/code&gt; in the help buffer to see the list of file
  formats that Emacs tries to open in DocView.
&lt;/p&gt;
&lt;p&gt;
  Ghostscript needs to be installed so that DocView can convert the
  PDF into images.  Further, for some commands where we perform
  text-based operations on the PDF, we need the &lt;code&gt;pdftotext&lt;/code&gt;
  command so that DocView can extract text from the PDF.
  Type &lt;code&gt;C-h v doc-view-ghostscript-program RET&lt;/code&gt;
  and &lt;code&gt;C-h v doc-view-pdftotext-program RET&lt;/code&gt; to see the
  external programs that DocView depends on.  These programs can be
  installed with the following command on a Debian or Debian-based
  Linux distribution:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;apt-get install ghostscript poppler-utils&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  On a macOS system, run the following command instead:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;brew install ghostscript poppler&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The following list presents some of the key bindings supported by
  DocView:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;n&lt;/code&gt;: Go to next page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;p&lt;/code&gt;: Go to previous page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x ]&lt;/code&gt;: Same as &lt;code&gt;n&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x [&lt;/code&gt;: Same as &lt;code&gt;p&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;SPC&lt;/code&gt;: Scroll up if possible or go to next page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;DEL&lt;/code&gt;: Scroll down if possible or go to the previous page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;S-SPC&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-&amp;lt;&lt;/code&gt;: View the first page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-&amp;gt;&lt;/code&gt;: View the last page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;+&lt;/code&gt;: Enlarge the document.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;-&lt;/code&gt;: Shrink the document.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;0&lt;/code&gt;: Reset the document size to the initial one.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;W&lt;/code&gt;: Fit the image width to the window width.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;H&lt;/code&gt;: Fit the image height to the window height.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;P&lt;/code&gt;: Fit the image to the window such that neither the
    document width nor the document height exceed the window width or
    height respectively.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;F&lt;/code&gt;: Resize the window so it just fits the page.  When
    there is only window in the frame, the window cannot be resized
    independently of the frame, so the frame is resized instead.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x doc-view-presentation RET&lt;/code&gt;: Display document in
    presentation mode, i.e. as a full screen slide show.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Although not mentioned in the book, here are some commands that show
  how to perform text-based operations on the PDF.  These commands
  need &lt;code&gt;pdftotext&lt;/code&gt; to be installed.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-s ^f..\&amp;gt; RET&lt;/code&gt;: Initiate a new search for lines
    that begin with a three-lettered word beginning with the
    letter &lt;code&gt;f&lt;/code&gt;.  The cursor does not move to the first
    match automatically.  To make the cursor move to the first match,
    type &lt;code&gt;C-s&lt;/code&gt;.  This is also explained in the next point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-s&lt;/code&gt;: When a search has been initiated, jump to the
    next match for the last search that was initiated.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u C-s ^b..\&amp;gt; RET&lt;/code&gt;: Initiate a new search.  This
    is useful when a search was already initiated and we want to
    abandon that search and start another new search.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-r&lt;/code&gt;: Similar to &lt;code&gt;C-s&lt;/code&gt; but works in reverse
    direction.  All three commands mentioned above work
    with &lt;code&gt;C-r&lt;/code&gt; too.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-t&lt;/code&gt;: Show tooltip for the current location.
    Normally, this shows a tooltip like &quot;Page 100 of 314&quot; to describe
    the current page.  When a search is in progress, the tooltip
    includes all the matches from the current page too.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-t&lt;/code&gt;: Show the current document&apos;s content as text.
    Then type the key sequence &lt;code&gt;C-c C-c&lt;/code&gt; to switch to
    editing the document and &lt;code&gt;C-c C-c&lt;/code&gt; again to switch to
    viewing the document.  The key sequence &lt;code&gt;C-c C-c&lt;/code&gt; is
    elaborated a little more in the next point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-c&lt;/code&gt;: Toggle between editing or viewing the
    document.  In case of PDF, switching to editing the document may
    not be very helpful because the binary code of the document is
    opened for editing in this mode which is quite non-trivial to edit
    directly.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;docview-resolution&quot;&gt;DocView Resolution&lt;/h3&gt;
&lt;p&gt;
  If the text in the document looks pixelated in Emacs, set
  the &lt;code&gt;doc-view-resolution&lt;/code&gt; variable to 300 as follows:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(setq doc-view-resolution 300)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  This sets the dots per inch resolution used to render the documents
  to 300.  This offers a good trade-off between high quality rendering
  and fast rendering.  After setting this variable, type the following
  key sequences:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x doc-view-clear-cache RET&lt;/code&gt; to delete the cache
    directory.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x k&lt;/code&gt; to kill the existing DocView buffer (if any).
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f document.pdf RET&lt;/code&gt; to open the document
    (say &lt;code&gt;document.pdf&lt;/code&gt;) again!
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Clearing the cache directory and reopening the document in this
  manner regenerates the images from the documents with the updated
  resolution.
&lt;/p&gt;
&lt;h2 id=&quot;tramp&quot;&gt;TRAMP&lt;/h2&gt;
&lt;p&gt;
  TRAMP stands for Transparent Remote Access, Multiple Protocol.  The
  general syntax of paths supported by TRAMP is:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/method:[user@][hostname[#port]]:[path]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Here
  are some complete key sequences that demonstrate various ways to
  open a remote file using TRAMP:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box:~/foo.txt RET&lt;/code&gt;: Edit file in a
    remote host via SSH.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:susam@box#22:~/foo.txt RET&lt;/code&gt;: Same as
    above.  However the port is explicitly specified this time.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /scp:alice@box:~/foo.txt RET&lt;/code&gt;: Edit file in a
    remote host via SCP.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:box:~/foo.txt RET&lt;/code&gt;: Edit file in a
    remote host via SSH after logging into it with the username of the
    current user in the current shell.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@:~/foo.txt RET&lt;/code&gt;: Edit file in
    localhost via SSH after logging into it as a specific user.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh::~/foo.txt RET&lt;/code&gt;: Edit file in localhost
    via SSH after logging into it with the username of the current
    user in current shell.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /sudo::/etc/hosts&lt;/code&gt;: Edit file as superuser.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x c-f /sudo:alice@:~/foo.txt RET&lt;/code&gt;: Edit file as
    a specific user.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /sudoedit::/etc/hosts&lt;/code&gt;: Edit file as superuser
    but do not keep an open session running in the background for
    security reasons.  This method has worse performance than
    the &lt;code&gt;sudo&lt;/code&gt; method.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /su::/etc/hosts&lt;/code&gt;: Edit file as
    the &lt;code&gt;root&lt;/code&gt; user.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;/su:alice@:~/foo.txt&lt;/code&gt;: Edit file as a specific user.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;/su:alice@localhost:~/foo.txt&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /sudo:: RET&lt;/code&gt;: Browse the &lt;code&gt;root&lt;/code&gt;
    user&apos;s home directory as superuser.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /su:: RET&lt;/code&gt;: Browse the &lt;code&gt;root&lt;/code&gt;
    user&apos;s home directory with Dired.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /-:: RET&lt;/code&gt;:
    Use &lt;code&gt;tramp-default-method&lt;/code&gt; (&lt;code&gt;scp&lt;/code&gt; by
    default) to connect to &lt;code&gt;tramp-default-host&lt;/code&gt;
    (current &lt;code&gt;hostname&lt;/code&gt; by default).  With the default
    values of these variables, this leads to connecting to the local
    system as the current user via SCP and browsing the current user&apos;s
    home directory in Dired.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  This chapter recommends looking up the info manual
  page &lt;code&gt;(tramp) Internal methods&lt;/code&gt; but this is very likely
  an error.  For example, evaluating &lt;code&gt;(info &quot;(tramp)Internal
  methods&quot;)&lt;/code&gt; leads to the following error:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user-error: No such node or anchor: Internal methods&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Instead evaluate &lt;code&gt;(info &quot;(tramp)Inline methods&quot;)&lt;/code&gt; to
  reach the correct node that describes the various connection
  methods.
&lt;/p&gt;
&lt;h3 id=&quot;default-directory&quot;&gt;Default Directory&lt;/h3&gt;
&lt;p&gt;
  The variable &lt;code&gt;default-directory&lt;/code&gt; is buffer local.
  Typically, this is automatically set to the directory where Emacs
  was launched or to the directory of the currently visited file.
  Commands like &lt;code&gt;C-x C-f&lt;/code&gt; defaults to looking up files in
  this directory.
&lt;/p&gt;
&lt;p&gt;
  While editing a remote file via TRAMP, the value for this variable
  may look something like &lt;code&gt;/ssh:alice@box:/home/alice/&lt;/code&gt;.
  The &lt;code&gt;@&lt;/code&gt; character is displayed in the mode line while
  editng a remote file.
&lt;/p&gt;
&lt;p&gt;
  The chapter presents the following examples of commands that work
  seamlessly on a remote machine:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x d&lt;/code&gt;: Manage remote files and directories.  We can
    even copy files (using the key sequence &lt;code&gt;C&lt;/code&gt;) between
    remote and local dired sessions.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x compile RET RET&lt;/code&gt;: Run &lt;code&gt;make -k&lt;/code&gt; (the
    default) or an arbitrary command remotely.  The result is shown in
    the &lt;code&gt;*compilation*&lt;/code&gt; buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x rgrep RET f.. RET *.txt RET RET&lt;/code&gt;:
    Use &lt;code&gt;find&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt; together to search for
    the pattern &lt;code&gt;f..&lt;/code&gt; in files matching the
    pattern &lt;code&gt;*.txt&lt;/code&gt; in the current remote directory.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x shell RET&lt;/code&gt;: Open shell on the remote system in the
    current remote directory.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x eshell RET&lt;/code&gt;: Open Eshell on the remote system in
    the current remote directory.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  With Eshell we can go directly into remote directories seamlessly.
  The following Eshell session illustrates this:
&lt;/p&gt;
&lt;pre&gt;&lt;samp&gt;Welcome to the Emacs shell

~ $ &lt;kbd&gt;uname&lt;/kbd&gt;
Darwin
~ $ &lt;kbd&gt;cd /ssh:alice@box:~/foo/&lt;/kbd&gt;
/ssh:alice@box:/home/alice/foo $ &lt;kbd&gt;hostname&lt;/kbd&gt;
debian
/ssh:alice@box:/home/alice/foo $&lt;/samp&gt;&lt;/pre&gt;
&lt;h3 id=&quot;multi-hops&quot;&gt;Multi-Hops&lt;/h3&gt;
&lt;p&gt;
  Here are some commands that illustrate how multi-hops work:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box|ssh:bob@localhost:~/foo.txt
    RET&lt;/code&gt;: First log in as &lt;code&gt;alice&lt;/code&gt;
    into &lt;code&gt;box&lt;/code&gt; and then from there log in
    as &lt;code&gt;bob&lt;/code&gt; into the same system.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box|sudo:box:/etc/hosts RET&lt;/code&gt;: First
    log in as &lt;code&gt;alice&lt;/code&gt; into &lt;code&gt;box&lt;/code&gt; and then edit
    file as superuser.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box|sudo::/etc/hosts RET&lt;/code&gt;: Same as
    above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box|sudo:bob@box:~/bar.txt RET&lt;/code&gt;:
    First log in as &lt;code&gt;alice&lt;/code&gt; into &lt;code&gt;box&lt;/code&gt; and then
    use &lt;code&gt;sudo&lt;/code&gt; to edit file as &lt;code&gt;bob&lt;/code&gt; in the
    latter user&apos;s home directory.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box|su::/etc/hosts RET&lt;/code&gt;: First log
    in as &lt;code&gt;alice&lt;/code&gt; into &lt;code&gt;box&lt;/code&gt; and then edit file
    as &lt;code&gt;root&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box|su:bob@:~/bar.txt RET&lt;/code&gt;: First log
    in as &lt;code&gt;alice&lt;/code&gt; into &lt;code&gt;box&lt;/code&gt; and then edit file
    as &lt;code&gt;bob&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box|su:bob@box:~/bar.txt RET&lt;/code&gt;: Same
    as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f /ssh:alice@box1|ssh:bob@box2|ssh:carol@box3:~/foo.txt&lt;/code&gt;:
    An example of two hops.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Bookmarks with key sequences like &lt;code&gt;C-x r m&lt;/code&gt;
  (&lt;code&gt;bookmark-set&lt;/code&gt;), &lt;code&gt;C-x r l&lt;/code&gt;
  (&lt;code&gt;bookmark-bmenu-list&lt;/code&gt;) and &lt;code&gt;C-x r b&lt;/code&gt;
  (&lt;code&gt;bookmark-jump&lt;/code&gt;) work seamlessly for remote files
  (including multi-hops).
&lt;/p&gt;
&lt;p&gt;
  Eshell works seamlessy too across multi-hops.  Here is an Eshell
  session that illustrates it:
&lt;/p&gt;
&lt;pre&gt;&lt;samp&gt;~ $ &lt;kbd&gt;uname&lt;/kbd&gt;
Darwin
~ $ &lt;kbd&gt;cd &apos;/ssh:alice@box1|ssh:bob@box2|ssh:carol@box3:/home/carol/foo/bar/&apos;&lt;/kbd&gt;
/ssh:alice@box1|ssh:bob@box2|ssh:carol@box3:/home/carol/foo/bar $ &lt;kbd&gt;uname&lt;/kbd&gt;
Linux
/ssh:alice@box1|ssh:bob@box2|ssh:carol@box3:/home/carol/foo/bar $&lt;/samp&gt;&lt;/pre&gt;
&lt;h2 id=&quot;eww&quot;&gt;EWW: Emacs Web Wowser&lt;/h2&gt;
&lt;p&gt;
  The following commands are useful to get started with EWW.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x eww RET hello RET&lt;/code&gt;: Search for the word &quot;hello&quot;
    with DuckDuckGo.  If the buffer &lt;code&gt;*eww*&lt;/code&gt; already exists,
    then reuse that buffer, otherwise create such a buffer.  The
    search engine can be customised by setting the
    variable &lt;code&gt;eww-search-prefix&lt;/code&gt; (it
    is &lt;code&gt;&quot;https://duckduckgo.com/html/?q=&quot;&lt;/code&gt; by default).
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-x eww RET hello RET&lt;/code&gt;: Like previous command
    except that it creates a new EWW buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x eww RET example.net RET&lt;/code&gt;: Visit the
    URL &lt;a href=&quot;http://example.net/&quot;&gt;http://example.net&lt;/a&gt;.  Reuses
    the &lt;code&gt;*eww*&lt;/code&gt; buffer if it exists.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x eww RET http://example.net/ RET&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-x eww RET example.net RET&lt;/code&gt;: Like before but
    creates a new EWW buffer.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  In the EWW buffer, the following navigation keys work:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;TAB&lt;/code&gt;: Skip to the next link.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;S-TAB&lt;/code&gt; or &lt;code&gt;C-M-i&lt;/code&gt;: Skip to the previous link.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;RET&lt;/code&gt;: Browse the URL under point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u RET&lt;/code&gt;: Browse the URL under point using an external
    browser.  This is especially useful when we know that the URL we
    want to open does not render well in EWW.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;&amp;amp;&lt;/code&gt;: Open the current page in an external browser.
    Note that unlike the previous command, this command opens
    the &lt;em&gt;current&lt;/em&gt; page.  The previous command opens the URL
    under point instead.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;q&lt;/code&gt;: Quit EWW.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;l&lt;/code&gt;: Go to the previously displayed page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;r&lt;/code&gt;: Go to the next displayed page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;b&lt;/code&gt;: Bookmark the current page.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;B&lt;/code&gt;: Show bookmarks.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;H&lt;/code&gt;: Show history of the current EWW buffer.  The most
    recently visited URLs are displayed on top and the oldest ones are
    shown at the bottom.  The current URL is not displayed in the
    history.  Only the older URLs are shown in the history.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;R&lt;/code&gt;: View the main &quot;readable&quot; parts of the current
    page.  This command uses heuristics to find the parts of the web
    page that contains the main content and omits the non-content part
    like navigation menus etc.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-s M-w&lt;/code&gt;: Search the web for the text in the region.
    If there is no region, then prompt for a search string.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-RET&lt;/code&gt;: Open link in a new EWW buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;s&lt;/code&gt;: Prompt for an EWW buffer to display and switch to
    the selected buffer.  This is similar to changing to tabs in a
    desktop web browser.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;w&lt;/code&gt;: If the point is on a URL or just after a URL, then
    copy that URL to the kill ring.  If the point is at any other
    place, copy the URL of the current page.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Further, EWW supports a few semantic browsing methods.  The
  pertaining commands are presented below.  However note that whether
  these commands would work on a page or not depends on whether the
  page provides the relevant navigation aids required by these
  commands.  Here are the key sequences for such commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;p&lt;/code&gt;: Go to the page marked &lt;em&gt;previous&lt;/em&gt;.  A page
    is marked &lt;em&gt;previous&lt;/em&gt; if there is
    a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tag or an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag
    for it with the attribute &lt;code&gt;rel=&quot;prev&quot;&lt;/code&gt; (a standard
    value for the attribute) or &lt;code&gt;rel=&quot;previous&quot;&lt;/code&gt;
    (non-standard value supported by EWW).
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;n&lt;/code&gt;: Go to the page marked &lt;em&gt;next&lt;/em&gt;.  A page is
    marked &lt;em&gt;next&lt;/em&gt; if there is a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tag
    or an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag for it with the
    attribute &lt;code&gt;rel=&quot;next&quot;&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;u&lt;/code&gt;: Go to the page marked &lt;em&gt;up&lt;/em&gt;.  A page is
    marked &lt;em&gt;up&lt;/em&gt; if there is a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt;
    or an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag for it with the
    attribute &lt;code&gt;rel=&quot;up&quot;&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;t&lt;/code&gt;: Go to the page marked &lt;em&gt;top&lt;/em&gt;.  A page is
    marked &lt;em&gt;top&lt;/em&gt; if there is a &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tag or
    an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tag for it with the
    attribute &lt;code&gt;rel=&quot;start&quot;&lt;/code&gt; or &lt;code&gt;rel=&quot;home&quot;&lt;/code&gt;
    or &lt;code&gt;rel=&quot;contents&quot;&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;invoking-external-browser&quot;&gt;Invoking External Browser&lt;/h2&gt;
&lt;p&gt;
  If we would rather open a URL using our desktop web browser, then we
  can use the &lt;code&gt;browse-url&lt;/code&gt; command like this: &lt;code&gt;M-x
  browse-url RET http://example.net/ RET&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  This command very conveniently picks up the word or domain name at
  the point or just before the point and uses that as the default
  value for the URL input.  Therefore if the cursor is already on a
  URL, then we can simply type &lt;code&gt;M-x browse-url RET RET&lt;/code&gt; to
  visit it.
&lt;/p&gt;
&lt;h2 id=&quot;dired&quot;&gt;Dired&lt;/h2&gt;
&lt;h3 id=&quot;dired-getting-started&quot;&gt;Dired: Getting Started&lt;/h3&gt;
&lt;p&gt;
  There are several ways to start Dired.  Some examples are presented
  below:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f ~/foo/bar/ C-d&lt;/code&gt;: If IDO or FIDO mode is
    enabled, then this key sequence automatically opens Dired in the
    given directory path.  Essentially, while using &lt;code&gt;C-x
    C-f&lt;/code&gt; with IDO/FIDO mode, we can type &lt;code&gt;C-d&lt;/code&gt;
    anytime and Dired is opened in the path entered so far.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x dired RET ~/foo/bar/ RET&lt;/code&gt;: Opens Dired in the
    given directory path.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x dired RET RET&lt;/code&gt;: In the previous command, the
    default input is the path of the current directory
    (&lt;code&gt;default-directory&lt;/code&gt;), so this key sequence
    conveniently opens Dired in the current directory.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x d&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x 4 d&lt;/code&gt;: Like before but open Dired in another
    window.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;dired-navigation&quot;&gt;Dired: Navigation&lt;/h3&gt;
&lt;p&gt;
  The following keys work in a Dired buffer:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;RET&lt;/code&gt;: Visit the file or directory on the current line.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;^&lt;/code&gt;: Go up by one directory.  If the parent directory
    is found in an existing buffer, then switch to that buffer.
    Otherwise create a new buffer to show the parent directory in
    Dired.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;q&lt;/code&gt;: Quit Dired window.  The buffer remains intact,
    i.e. the buffer is only buried, not killed.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u q&lt;/code&gt;: Quit Dired window and kill the buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;p&lt;/code&gt; or &lt;code&gt;C-p&lt;/code&gt;: Move to the previous line and
    position the point on the filename.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;C-n&lt;/code&gt;: Move to the next line and
    position the point on the filename.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note that when we go from one Dired buffer to another (say, by
  typing &lt;code&gt;RET&lt;/code&gt; to enter a subdirectory from a parent
  directory), then typing &lt;code&gt;q&lt;/code&gt; or &lt;code&gt;C-u q&lt;/code&gt; buries
  or kills (respectively) the current buffer and takes us back to the
  last Dired buffer.
&lt;/p&gt;
&lt;h3 id=&quot;dired-marking-and-unmarking&quot;&gt;Dired: Marking and Unmarking&lt;/h3&gt;
&lt;p&gt;
  The following list describes marking and unmarking commands of
  Dired:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;m&lt;/code&gt;: Mark the file or directory at point.  If the
    region is active, mark all files or directories in the region.
    Note that at least one character of the filename or directory name
    must lie within the region for a file to be marked.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;u&lt;/code&gt;: Unmark the file or directory at point.  If the
    region is active, unmark all files or directories in the region.
    Note that this also removes the flag for deletion (introduced
    later in this list).
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;U&lt;/code&gt;: Unmark everything.  Note that this also removes
    flags for deletion.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;d&lt;/code&gt;: Flag the file or directory for deletion.  If the
    region is active, flag all files or directories in the region for
    deletion.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The following key sequences describe the effects of prefix arguments
  with marking, unmarking and flagging commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-5 m&lt;/code&gt;: Mark 5 files from the current line to 4 more
    lines below.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-5 u&lt;/code&gt;: Unmark 5 files from the current line for
    deletion..
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-5 d&lt;/code&gt;: Flag 5 files from the current line for deletion.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-- C-1 m&lt;/code&gt;: Mark the file on the previous line.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-- C-1 u&lt;/code&gt;: Unmark the file on the previous line.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-- C-1 d&lt;/code&gt;: Flag the file on the previous line for deletion.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-- C-5 m&lt;/code&gt;: Mark files in the 5 previous lines.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-- C-5 u&lt;/code&gt;: Unmark files in the 5 previous lines.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-- C-5 d&lt;/code&gt;: Flag files in the 5 previous lines for
    deletion.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Additionally, the chapter mentions the following commands in a
  separate table but on Emacs 28.2, they seem to have the same effect
  as one of the commands discussed earlier:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;* m&lt;/code&gt;: Behaves the same as &lt;code&gt;m&lt;/code&gt; and marks
    files.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;* u&lt;/code&gt;: Behaves the same as &lt;code&gt;u&lt;/code&gt; and unmarks
    files.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  However the following commands (also introduced briefly in the same
  table but illustrated with complete key sequences below) provide
  additional marking and unmarking facilities:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;* % f.. RET&lt;/code&gt;: Mark files with names that match the
    regular expression &lt;code&gt;f..&lt;/code&gt;.  If the region is active,
    then only the files in the region that match the pattern are
    marked.  The directories &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt; are
    never marked.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;% m f.. RET&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u * % f.. RET&lt;/code&gt;: Unmark files with names that match
    the regular expression &lt;code&gt;f..&lt;/code&gt;.  If the region is active,
    then only the files in the region that match the pattern are
    unmarked.  The directories &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt; are
    never unmarked.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u % m f.. RET&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;t&lt;/code&gt; or &lt;code&gt;* t&lt;/code&gt;: Toggle marks.  The marked
    files become unmarked and vice versa.  If the region is active,
    toggle the marks of only the files in the region.  The
    directories &lt;code&gt;.&lt;/code&gt; and &lt;code&gt;..&lt;/code&gt; are never toggled.
    Flagged files are not toggled.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;* c * D&lt;/code&gt;: Change all files marked with &lt;code&gt;*&lt;/code&gt;
    to be now marked with &lt;code&gt;D&lt;/code&gt; (i.e. flagged for deletion).
    Note that unlike the other commands, this command ignores the
    active region.  It performs the change in the whole buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;* c D SPC&lt;/code&gt;: Change all files marked
    with &lt;code&gt;D&lt;/code&gt; to be now unmarked.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The chapter also mentions a key sequence &lt;code&gt;* .&lt;/code&gt; to mark
  files by extension but this requires &lt;code&gt;dired-x&lt;/code&gt;, so this
  is discussed in a later section of this page.
&lt;/p&gt;
&lt;h3 id=&quot;dired-operations&quot;&gt;Dired: Operations&lt;/h3&gt;
&lt;p&gt;
  This section explains some operations we can perform in Dired.  If
  there are one or more items marked in the Dired buffer, then the
  operations work on the marked items.  Otherwise, the operations work
  on the item under the cursor.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C&lt;/code&gt;: Copy marked files or copy the current file.  If
    one file is being copied, this command prompts for the target file
    path.  If multiple files are being copied, this command prompts
    for the target directory path.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;R&lt;/code&gt;: Rename marked files or the current file.  If one
    file is being renamed, this command prompts for the target file
    path.  If multiple file are being renamed, this command prompts
    for the target directory path.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;O&lt;/code&gt;: Change owner of the marked files or the current
    file.  A complete key sequence may look like &lt;code&gt;O root
    RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;G&lt;/code&gt;: Change group of the marked files or the current
    file.  A complete sequence may look like &lt;code&gt;G wheel RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M&lt;/code&gt;: Change the mode of the marked files or the current
    file.  A complete key sequence may look like &lt;code&gt;M u+x
    RET&lt;/code&gt; or &lt;code&gt;M 600 RET&lt;/code&gt;.  Both symbolic modes
    like &lt;code&gt;u+x&lt;/code&gt; and numeric modes like &lt;code&gt;600&lt;/code&gt; are
    supported.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;D&lt;/code&gt;: Delete marked files, i.e. the files that are
    marked with &lt;code&gt;*&lt;/code&gt; on the leftmost column of the Dired
    buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;x&lt;/code&gt;: Delete the files flagged for deletion, i.e. the
    files that are marked with &lt;code&gt;D&lt;/code&gt; on the leftmost column
    of the Dired buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;c&lt;/code&gt;: Compress marked files or current file into an
    archive.  The archive file name is prompted.  The format of the
    archive is automatically deduced from the extension of the file
    name entered at the prompt.  A complete key sequence may look
    like &lt;code&gt;c foo.tar.gz RET&lt;/code&gt; or &lt;code&gt;c foo.zip RET&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note the difference between &lt;code&gt;D&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;.  The
  key &lt;code&gt;D&lt;/code&gt; deletes marked files but the key &lt;code&gt;x&lt;/code&gt;
  deletes flagged files.  Therefore there are two ways of deleting
  files:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    Mark files with &lt;code&gt;m&lt;/code&gt; and delete them with &lt;code&gt;D&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Flag files with &lt;code&gt;d&lt;/code&gt; and delete them with &lt;code&gt;x&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  I normally prefer the second way of deleting files.  Since deleting
  file is a destructive operation which is possibly risky, I like to
  flag them first with &lt;code&gt;d&lt;/code&gt; before deleting them
  with &lt;code&gt;x&lt;/code&gt;.  In other words, I flag files for deletions and
  mark files for everything else.  Since I do not use
  the &lt;code&gt;D&lt;/code&gt; key, I can be confident that my marked files are
  always safe and there is no risk of inadvertently deleting them.
&lt;/p&gt;
&lt;h3 id=&quot;dired-copying-or-renaming-between-buffers&quot;&gt;Dired: Copying or Renaming Between Buffers&lt;/h3&gt;
&lt;p&gt;
  The following steps explain how we can copy or move files from one
  Dired buffer to another.  First we will see the default behaviour
  and then we will customise Dired to copy or move files to a
  particular Dired directory.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-x d /usr/ RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-x 2&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-x d /tmp/ RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-x 2&lt;/code&gt; agian.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-x d /etc/ RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Move the cursor on some file in &lt;code&gt;/etc/&lt;/code&gt; and then
    type &lt;code&gt;C&lt;/code&gt; or &lt;code&gt;R&lt;/code&gt; and we will see that the
    default directory to copy/move the file to is &lt;code&gt;/etc/&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Now type &lt;code&gt;(setq dired-dwim-target t)&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Now type &lt;code&gt;C&lt;/code&gt; or &lt;code&gt;R&lt;/code&gt; again while the cursor
    is on some file in &lt;code&gt;/etc/&lt;/code&gt;.  We will see that the
    default directory to copy/move the file to is &lt;code&gt;/tmp/&lt;/code&gt;
    now.  Since &lt;code&gt;dired-dwim-target&lt;/code&gt; is set to non-nil,
    Dired picks the directory from the next window with a Dired buffer
    and uses that as the target buffer.
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;dired-more-keys&quot;&gt;Dired: More Keys&lt;/h3&gt;
&lt;p&gt;
  Here are some examples of Dired keys that do not act on marked files
  but does other interesting work:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;g&lt;/code&gt;: Refresh the Dired buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;+&lt;/code&gt;: Create directory.  A complete key sequence may
    look like &lt;code&gt;+ bar RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;s&lt;/code&gt;: Toggle sorting by date.  By default, the items in
    the Dired buffer are sorted by file/directory names.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;&amp;lt;&lt;/code&gt;: Jump to the next directory.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;&amp;gt;&lt;/code&gt;: Jump to the previous directory.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;j&lt;/code&gt;: Jump to a file by name.  A complete sequence may
    look like &lt;code&gt;j hosts RET&lt;/code&gt;.  Note that this only moves the
    cursor to the line in Dired buffer with the provided filename.  It
    does not visit the file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-s a C-s&lt;/code&gt;: Perform multi-file incremental search
    through all marked files or the current file.  Marked directories
    are ignored.  Action region is also ignored.  It performs the
    search across all marked files.  A complete key sequence may look
    like &lt;code&gt;M-s a C-s foo&lt;/code&gt; and then repeat &lt;code&gt;C-s&lt;/code&gt;
    over and over again to jump through all the matches.  When the
    search reaches the end of one file, the next &lt;code&gt;C-s&lt;/code&gt;
    automatically jumps to the match in the next file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;Q&lt;/code&gt;: Perform multi-file regex-based search-and-replace
    operation through all marked files or the current file.  For any
    marked directories, the search-and-replace operation is performed
    in all its files recursively.  The active region is ignored.  A
    complete key sequence may look like &lt;code&gt;Q f.. RET \&amp;amp;\&amp;amp;
    RET&lt;/code&gt; which searches for strings matching the
    pattern &lt;code&gt;f..&lt;/code&gt;  and duplicates that string.  The key
    sequences supported by &lt;code&gt;C-M-%&lt;/code&gt;
    (&lt;code&gt;query-replace-regexp&lt;/code&gt;)
    like &lt;code&gt;y&lt;/code&gt;, &lt;code&gt;n&lt;/code&gt;, etc. work here.  See
    section &lt;a href=&quot;ch05.html#search-and-replace&quot;&gt;Search and
    Replace&lt;/a&gt; for an account of the supported key sequences.  The
    search results are also displayed in a
    separate &lt;code&gt;*xref*&lt;/code&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;A&lt;/code&gt;: Find matches for a regular expression pattern in
    all marked files or the current file.  For any marked directories,
    all its files are searched recursively.  The active region is
    ignored.  A complete key sequence may look like &lt;code&gt;A
    f.. RET&lt;/code&gt;.  Note that this does not perform incremental
    search.  Instead the search results are displayed in
    &lt;code&gt;*xref*&lt;/code&gt; buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;!&lt;/code&gt;: Run a shell command on each marked file or
    directory (or the current file or directory if nothing is marked).
    The command is executed synchronously.  The active region is
    ignored or the current file or directory.  The command works on
    all marked files and directories.  The output is displayed in a
    separate buffer.  If &lt;code&gt;*&lt;/code&gt; is present in the command,
    then each &lt;code&gt;*&lt;/code&gt; is replaced with the entire file list and
    the command runs only once (not multiple times, once for each
    file).  If &lt;code&gt;?&lt;/code&gt; is present in the command, then the
    command runs multiple times, once for each marked file, with
    each &lt;code&gt;?&lt;/code&gt; replaced with the name of the file being
    operated on.  It is an error to specify both &lt;code&gt;*&lt;/code&gt;
    and &lt;code&gt;?&lt;/code&gt;.  If neither is present, then the command runs
    multiple times, once for each marked file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;&amp;amp;&lt;/code&gt;: Like the previous command but runs the command
    asynchronously.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  To understand the usefulness of &lt;code&gt;g&lt;/code&gt;, while Dired is open
  create a new file in the current directory with, say, &lt;code&gt;C-x C-f
  foo.txt RET&lt;/code&gt; and save it with &lt;code&gt;C-x s&lt;/code&gt;.  Then kill
  the buffer for the file with &lt;code&gt;C-x k&lt;/code&gt; and return to the
  Dired buffer.  The Dired buffer does not show the new
  file &lt;code&gt;foo.txt&lt;/code&gt;.  Now type &lt;code&gt;g&lt;/code&gt; to refresh the
  Dired buffer.  As soon as &lt;code&gt;g&lt;/code&gt; is typed, the buffer gets
  updated to display the new file.
&lt;/p&gt;
&lt;p&gt;
  To understand the difference between &lt;code&gt;!&lt;/code&gt; and
  &lt;code&gt;&amp;amp;&lt;/code&gt; mark five files and then type the key
  sequence &lt;code&gt;! sleep 1; echo&lt;/code&gt;.  Emacs blocks (i.e. does not
  react to our keystrokes) for 5 seconds while it runs the given
  command for each file.  When the &lt;code&gt;echo&lt;/code&gt; output for all
  files is obtained after 5 seconds, the output appears and Emacs
  unblocks again.  Now type &lt;code&gt;&amp;amp; sleep 1; echo&lt;/code&gt;.  Now
  Emacs remains unblocked while the output of each &lt;code&gt;echo&lt;/code&gt;
  command appears at one second intervals in the output buffer.
&lt;/p&gt;
&lt;h3 id=&quot;dired-x&quot;&gt;Dired-X&lt;/h3&gt;
&lt;p&gt;
  Dired-X provides extra Dired functionality.  It is not enabled by
  default.  To enable it, add the following line to the Emacs
  initialisation file:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(require &apos;dired-x)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The following key sequences are supported by Dired-X:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;F&lt;/code&gt;: Visit the marked files or the current file.  When
    multiple files are visited, they are opened in split windows
    distributed as evenly as possible.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u F&lt;/code&gt;: Visit the marked files or the current file but
    open them in background, i.e. do not show them on any window.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;* .&lt;/code&gt;: Mark files with a certain extension.  If the
    region is active, then mark only the files in the region that have
    the given extension.  A complete key sequence may look
    like &lt;code&gt;* . txt&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;!&lt;/code&gt; and &lt;code&gt;&amp;amp;&lt;/code&gt;: These commands still work
    the way they were described in the previous section.  However with
    Dired-X enabled, when &lt;code&gt;!&lt;/code&gt; or &lt;code&gt;&amp;amp;&lt;/code&gt; is
    invoked on a single file (either a single marked file or no marked
    file in which case it operates on the current file), it
    automatically determines the command to execute for the current
    file type and offers that as the default input.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;dired-working-across-directories&quot;&gt;Dired: Working Across Directories&lt;/h3&gt;
&lt;p&gt;
  The following key sequences offer some support for working across
  multiple directories in the same Dired buffer:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;i&lt;/code&gt;: While the cursor is on a line for a directory, it
    expands the directory listing for that directory in the same Dired
    buffer.  Now we could use the mark, unmark, etc. commands to
    select files that belong to multiple directories and operate on
    them from the same Dired buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;$&lt;/code&gt;: Collapse or expand the current directory listing.
    If there are multiple directory listings (such as the ones created
    with &lt;code&gt;i&lt;/code&gt;), then move to the next directory listing
    after collapsing or expanding the current one.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Using &lt;code&gt;i&lt;/code&gt; to insert the directory listing of a
  subdirectory into the current Dired buffer could feel tedious if we
  want to recursively work on multiple directories.  The commands
  (illustrated with complete key sequences below) may be more suitable
  for such operations:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x find-dired RET RET -name SPC &quot;f*.txt&quot; RET&lt;/code&gt;: Find
      all files and directories in the current directory and its
      subdirectories recursively with name matching the
      pattern &lt;code&gt;f*.txt&lt;/code&gt; and show the results in the buffer
      named &lt;code&gt;*Find*&lt;/code&gt; with Dired mode enabled in it.  Emacs
      runs the following command to get the results:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;find . \( -name &quot;f*.txt&quot; \) -ls&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x find-name-dired RET RET f*.txt RET&lt;/code&gt;: Same as
      above.  Emacs runs the following command to get the results:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;find . \( -name f\*.txt \) -l&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      Further on a system with case-insensitive filenames, Emacs is
      clever enough to use the &lt;code&gt;-iname&lt;/code&gt; argument instead
      of &lt;code&gt;-name&lt;/code&gt; so that case-insensitive search is
      performed.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x find-grep-dired RET RET f.. RET&lt;/code&gt;: Find all files
      in the current directory and its subdirectories recursively and
      list the files where lines matching the regular
      expression &lt;code&gt;..&lt;/code&gt; is found.  The result is shown in a
      the buffer named &lt;code&gt;*Find&lt;/code&gt; with Dired mode enabled in
      it.  Emacs runs the following command to get the results:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;find . \( -type f -exec grep -q -e f.. \{\} \; \) -ls&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      &lt;code&gt;M-x find-lisp-find-dired RET RET f.. RET&lt;/code&gt;: Find all
      files in the current directory and subdirectories recursively
      and list the files with names that match the regular expression
      pattern &lt;code&gt;..&lt;/code&gt;.  Note that this is different from
      both &lt;code&gt;find-name-dired&lt;/code&gt;
      and &lt;code&gt;find-grep-dired&lt;/code&gt;.  The former relies on the
      Unix &lt;code&gt;find&lt;/code&gt; command to match filenames using glob
      patterns.  The latter uses both &lt;code&gt;find&lt;/code&gt;
      and &lt;code&gt;grep&lt;/code&gt; to list files that contain a line with a
      matching regular expression pattern.  However this command lists
      files with names that match a regular expression pattern (not
      glob pattern).  Further this command is implemented purely in
      Elisp and does not have any external dependencies on tools
      like &lt;code&gt;find&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;shell-commands&quot;&gt;Shell Commands&lt;/h2&gt;
&lt;p&gt;
  The following complete key sequences demonstrate how we can invoke
  shell commands from Emacs.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-! uname RET&lt;/code&gt;: Execute shell command and show output.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-! uname RET&lt;/code&gt;: Like above but insert the output
    into the buffer wherever the cursor is.  The cursor remains at the
    same place.  The mark is set to the character just after the last
    character of the output.  Therefore, typing &lt;code&gt;C-x C-x&lt;/code&gt;
    (&lt;code&gt;exchange-point-and-mark&lt;/code&gt;) is a quick way to highlight
    the output just inserted as an active region.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-! ping SPC -c SPC 4 SPC localhost RET&lt;/code&gt;: Execute a
    slightly long running shell command that takes about 4 seconds to
    complete.  Emacs blocks while the command is running because the
    command is executed synchronously.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-! ping SPC -c SPC 4 SPC localhost RET&lt;/code&gt;: Like
    before but the output is inserted into the buffer.  Again, Emacs
    blocks while the command is executed.  The output appears in the
    buffer only after the command completes execution.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-&amp;amp; ping SPC -c SPC 4 SPC localhost RET&lt;/code&gt;:
    Like &lt;code&gt;M-!&lt;/code&gt; but execute shell command asynchronously.
    Emacs remains unblocked and the output appears in the output
    buffer as soon as the output is printed by the command.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-| wc RET&lt;/code&gt;: Pipe region to shell command and show
    output.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-| wc RET&lt;/code&gt;: Pipe region to shell command and
    replace the region with the output.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The book also mentions that &lt;code&gt;C-u M-&amp;amp;&lt;/code&gt; is supposed to
  work like &lt;code&gt;C-u M-!&lt;/code&gt; but asynchronously but I did not find
  this to be true.  For example, &lt;code&gt;C-u M-&amp;amp; uname RET&lt;/code&gt;
  led to the following error &lt;code&gt;Wrong type argument: stringp,
  (4)&lt;/code&gt;.  This may be a bug in Emacs 28.2.
&lt;/p&gt;
&lt;h2 id=&quot;compiling-in-emacs&quot;&gt;Compiling in Emacs&lt;/h2&gt;
&lt;p&gt;
  The following complete key sequences demonstrate this feature:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x compile RET&lt;/code&gt;: Runs &lt;code&gt;make -f&lt;/code&gt; by
    default.  The default command is offered as a minibuffer input
    before we type &lt;code&gt;RET&lt;/code&gt;.  Therefore we can edit the
    command to any arbitrary command before typing &lt;code&gt;RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x recompile RET&lt;/code&gt;: Runs the last compile command
    again.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x p c&lt;/code&gt;: Compile in the current project.  See
    section &lt;a href=&quot;#project-management&quot;&gt;Project Management&lt;/a&gt; for
    more details.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The compile commands display the output in
  the &lt;code&gt;*compilation*&lt;/code&gt; buffer where the following key
  sequences work:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-g M-n&lt;/code&gt;: Jump to the next error.  The cursor jumps to
    the next error line in the &lt;code&gt;*compilation*&lt;/code&gt; and the
    source of the matching error line is opened in a separated window.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-g M-p&lt;/code&gt;: Jump to the previous error.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;g&lt;/code&gt;: Recompile, i.e. run the last compile command
    again.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;shells-in-emacs&quot;&gt;Shells in Emacs&lt;/h2&gt;
&lt;h3 id=&quot;m-x-shell&quot;&gt;M-x shell&lt;/h3&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-x shell RET&lt;/code&gt; starts a shell with
  input/output done via a buffer.  Some important points to keep in
  mind while using this:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    The TAB-completion mechanism of the underlying shell (e.g. Bash,
    Zsh, etc.) does not work.  In fact, &lt;code&gt;TAB&lt;/code&gt; invokes
    Emacs&apos;s own completion mechanism.
  &lt;/li&gt;
  &lt;li&gt;
    Programs like &lt;code&gt;top&lt;/code&gt; and &lt;code&gt;man&lt;/code&gt; that need to
    control the terminal do not work.  Only programs that perform
    input/output via standard input, standard output and standard
    error, etc. work well.
  &lt;/li&gt;
  &lt;li&gt;
    Since the shell buffer is made completely of text, all text
    editing commands of Emacs work seamlessly on the buffer.
  &lt;/li&gt;
  &lt;li&gt;
    We can take the cursor to absolutely anywhere in the buffer and
    type &lt;code&gt;RET&lt;/code&gt; to execute whatever is on that line as a
    shell command.  Shell prompt on the line is automatically excluded
    from the command to be executed.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Here are some key bindings that work in the shell buffer:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-p&lt;/code&gt;: Cycle backwards through input history.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-n&lt;/code&gt;: Cycle forwards through input history.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-&amp;lt;up&amp;gt;&lt;/code&gt;: Same as &lt;code&gt;M-p&lt;/code&gt;.  May not work
    if the desktop environment gobbles up this keystroke.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-&amp;lt;down&amp;gt;&lt;/code&gt;: Same as &lt;code&gt;M-n&lt;/code&gt;.  May not
    work if the desktop environment gobbles up this keystroke.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-r f..&lt;/code&gt;: Search history backwards for all commands
    that match the pattern &lt;code&gt;f..&lt;/code&gt;.  Within the search, we
    can use incremental search key bindings
    like &lt;code&gt;C-r&lt;/code&gt;, &lt;code&gt;C-s&lt;/code&gt;, etc. to search backward,
    forward, etc. respectively.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-p&lt;/code&gt;: Move to the previous prompt.  The cursor
    moves to the place just after the prompt.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-n&lt;/code&gt;: Move to the next prompt.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-s out.txt RET&lt;/code&gt;: Write output since the last
    input to a file.  Any prompt at the end of the output is not
    written.  Note that by default the output on shell contains the
    input command as well.  The input command is echoed back, so our
    input command appears twice in the buffer: once where we typed it
    and once more echoed just before the beginning of the output.
    This echoed input command is also saved to the file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-o&lt;/code&gt;: Delete all output since the last input.  Any
    prompt is of course left intact.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u C-c C-o&lt;/code&gt;: Delete all output since the last input
    and save it to the kill ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-l&lt;/code&gt;: Show the list of recent inputs in
    the &lt;code&gt;*Input History*&lt;/code&gt; buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-d&lt;/code&gt;: If the cursor is at the end of the buffer and
    there is no input, send EOF.  Otherwise delete a character forward.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-z&lt;/code&gt;: Suspend the current job.  This performs the
    same function as &lt;code&gt;C-z&lt;/code&gt; in the underlying shell.  We can
    then use job control commands like &lt;code&gt;bg&lt;/code&gt;
    or &lt;code&gt;fg&lt;/code&gt; to resume the job as a background process or
    foreground process.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;TAB&lt;/code&gt;: Perform completion at point.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;m-x-ansi-term&quot;&gt;M-x ansi-term&lt;/h3&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-x ansi-term RET RET&lt;/code&gt; launches an
  ANSI-capable terminal emulator.  It can run sophisticated programs
  like &lt;code&gt;top&lt;/code&gt;, &lt;code&gt;man&lt;/code&gt;, etc. that require terminal
  capabilities fine.  The following key sequences are useful in this
  terminal emulator:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-j&lt;/code&gt;: Switch to line (&quot;cooked&quot;) sub-mode.  Emacs
    editing key sequences work normally in this mode,
    except &lt;code&gt;RET&lt;/code&gt; which sends the current line as a command
    to the underlying shell.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-k&lt;/code&gt;: Switch to char (&quot;raw&quot;) sub-mode.  By
    default, the terminal starts in this mode.  Each character we type
    in this sub-mode is sent directly to the shell, except for the
    escape character &lt;code&gt;C-c&lt;/code&gt; which is used as the prefix keys
    for the key sequences described in this list.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-c C-c&lt;/code&gt;: Interrupt the current subjob.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;m-x-eshell&quot;&gt;M-x eshell&lt;/h3&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-x eshell RET&lt;/code&gt; creates an interactive
  Eshell buffer if none exists or switches to an existing one.  Eshell
  is implemented in Elisp.  It provides Elisp implementation of Unix
  commands like &lt;code&gt;ls&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt;, etc.
&lt;/p&gt;
&lt;p&gt;
  The list below provides examples of some commands we can enter
  directly into Eshell:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;which ls&lt;/code&gt;: The output should show that &lt;code&gt;ls&lt;/code&gt;
    is an Elisp function.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;which which&lt;/code&gt;: The output should show
    that &lt;code&gt;which&lt;/code&gt; itself is an Elisp function.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;which top&lt;/code&gt;: The output should show the file path of
    the external program &lt;code&gt;top&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;ls -l&lt;/code&gt;: Run Eshell&apos;s implementation of &lt;code&gt;ls&lt;/code&gt;
    written in Elisp.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;find-file /etc/hosts&lt;/code&gt;: Run the Elisp function
    named &lt;code&gt;find-file&lt;/code&gt; with the
    argument &lt;code&gt;/etc/hosts&lt;/code&gt; thus opening the file in a
    buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;/bin/ls -l&lt;/code&gt;: Run the external command &lt;code&gt;ls&lt;/code&gt;
    available provided by the operating system utilities.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;python3 --version&lt;/code&gt;: Run the external
    program &lt;code&gt;python3&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;top&lt;/code&gt;: Start the program &lt;code&gt;top&lt;/code&gt; in a separate
    buffer with &lt;code&gt;term-mode&lt;/code&gt; as the major mode.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  In the last point we see that for programs like &lt;code&gt;top&lt;/code&gt;
  which need terminal capabilities to show output in a visual fashion
  (as opposed to just printing output to standard output or standard
  error), Eshell automatically runs the program in
  a &lt;code&gt;term-mode&lt;/code&gt; buffer, so that the output of the visual
  program can be handled and displayed correctly.  Eshell looks at the
  list in the variable &lt;code&gt;eshell-visual-commands&lt;/code&gt; to
  determine if a command needs terminal support or not.  By default,
  commands like &lt;code&gt;vi&lt;/code&gt;, &lt;code&gt;screen&lt;/code&gt;,
  &lt;code&gt;tmux&lt;/code&gt;, &lt;code&gt;top&lt;/code&gt;, etc. belong to this list.
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/ch06.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Mastering Emacs: Chapter 5: The Theory of Editing</title>
    <link href="https://susam.net/cc/mastering-emacs/ch05.html"/>
    <id>urn:uuid:b4fb79b2-c506-45b0-a516-de50171d4b0c</id>
    <updated>2023-09-16T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  The following notes were taken while discussing Chapter 5 of the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  An index of notes for all chapters are available
  at &lt;a href=&quot;notes.html&quot;&gt;notes.html&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#killing-text&quot;&gt;Killing Text&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#append-kill&quot;&gt;Append Kill&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#digit-and-negative-arguments&quot;&gt;Digit and Negative Arguments&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#yanking-text&quot;&gt;Yanking Text&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#yank-pop&quot;&gt;Yank Pop&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#maximum-length-of-kill-ring&quot;&gt;Maximum Length of Kill Ring&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#killing-lines&quot;&gt;Killing Lines&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#transpose&quot;&gt;Transpose&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#filling&quot;&gt;Filling&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#commenting&quot;&gt;Commenting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#search-and-replace&quot;&gt;Search and Replace&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#regular-expressions&quot;&gt;Regular Expressions&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#changing-case&quot;&gt;Changing Case&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#counting&quot;&gt;Counting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#deleting-and-keeping-lines&quot;&gt;Deleting and Keeping Lines&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#splitting-and-joining-lines&quot;&gt;Splitting and Joining Lines&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#examining-and-fixing-whitespace-issues&quot;&gt;Examining and Fixing Whitespace Issues&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#keyboard-macros&quot;&gt;Keyboard Macros&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#text-expansion&quot;&gt;Text Expansion&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#abbrev&quot;&gt;Abbrev&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dabbrev&quot;&gt;DAbbrev&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#hippie-expand&quot;&gt;Hippie Expand&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#indenting&quot;&gt;Indenting&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#electric-indentation&quot;&gt;Electric Indentation&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#indenting-current-line&quot;&gt;Indenting Current Line&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#use-only-spaces-for-indentation&quot;&gt;Use Only Spaces for Indentation&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab-width&quot;&gt;Tab Width&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#edit-tab-stops&quot;&gt;Edit Tab Stops&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#indent-regions&quot;&gt;Indent Region&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#indent-rigidly&quot;&gt;Indent Rigidly&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#sorting&quot;&gt;Sorting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#aligning&quot;&gt;Aligning&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#zap-to-char&quot;&gt;Zap to Char&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#zap-up-to-char&quot;&gt;Zap up to Char&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#spell-check&quot;&gt;Spell Check&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#dictionary-lookup&quot;&gt;Dictionary Lookup&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#quoted-insert&quot;&gt;Quoted Insert&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;killing-text&quot;&gt;Killing Text&lt;/h2&gt;
&lt;p&gt;
  Killing text is equivalent to what we call as cutting text in other
  editors.  Killing some text removes the text from the buffer and
  adds it to the kill ring.  The kill ring is the clipboard of Emacs.
&lt;/p&gt;
&lt;p&gt;
  To discover kill commands using the apropos functionality,
  type &lt;code&gt;C-h a ^kill-&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  Here is a list of commands introduced in the first section of this
  chapter:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-d&lt;/code&gt;: Delete the next character.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt;: Delete the previous character.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-d&lt;/code&gt;: Kill until the end of a word.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-&amp;lt;backspace&amp;gt;&lt;/code&gt;: Kill backward until the
    beginning of a word.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-k&lt;/code&gt;: Kill the rest of the current line.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-k&lt;/code&gt;: Kill until the end of sentence.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-k&lt;/code&gt;: Kill expression following point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-S-&amp;lt;backspace&amp;gt;&lt;/code&gt;: Kill current line.  Does not
    work in terminal Emacs.  Use &lt;code&gt;C-a C-k&lt;/code&gt; as alternative.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-w&lt;/code&gt;: Kill text between point and mark.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-w&lt;/code&gt;: Copy text between point and mark to kill ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-w&lt;/code&gt;: Cause the following command, if it kills, to
    append to the last stretch of text in the kill ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-y&lt;/code&gt;: Yank (paste) the last stretch of text in the
    kill ring to the buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-y&lt;/code&gt;: Cycle through kill ring.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  I have observed that some Emacs users do not bother
  using &lt;code&gt;M-w&lt;/code&gt; to copy to kill ring.  Instead they
  type &lt;code&gt;C-w C-/&lt;/code&gt; to cut the text and immediately undo the
  cut which effectively leaves the buffer unchanged but inserts a copy
  of the text that was cut into the kill ring.  For example,
  while &lt;code&gt;C-a C-SPC C-n C-n M-w&lt;/code&gt; copies two lines into the
  kill ring, so does &lt;code&gt;C-a C-SPC C-n C-n C-w C-/&lt;/code&gt;.  The
  latter key sequence avoids having to use &lt;code&gt;M-w&lt;/code&gt; but it is
  worth noting that this key sequence does not work in a readonly
  buffer while the former does.  To quickly see the difference,
  open &lt;code&gt;/etc/hosts&lt;/code&gt; as a non-root and non-privileged user
  and try both the key sequences.  The former key sequence does not
  modify the buffer, so it works perfectly in a readonly buffer.  The
  latter key sequence modifies the buffer when we
  type &lt;code&gt;C-w&lt;/code&gt;, so it does not work in a readonly buffer.
&lt;/p&gt;
&lt;p&gt;
  I have also observed that many Emacs users do not bother
  learning &lt;code&gt;C-S-&amp;lt;backspace&amp;gt;&lt;/code&gt; because they can achieve
  the same results using &lt;code&gt;C-a C-k&lt;/code&gt;.
  Further, &lt;code&gt;C-S-&amp;lt;backspace&amp;gt;&lt;/code&gt; does not work in
  terminal Emacs due to terminal limitations.  The key
  sequence &lt;code&gt;C-a&lt;/code&gt; moves the cursor to the beginning of the
  line and &lt;code&gt;C-k&lt;/code&gt; kills everything until the end of the
  line.
&lt;/p&gt;
&lt;p&gt;
  There is a difference between &lt;em&gt;deleting&lt;/em&gt; and
  &lt;em&gt;killing&lt;/em&gt;.  The first two commands &lt;code&gt;C-d&lt;/code&gt;
  and &lt;code&gt;&amp;lt;backspace&amp;gt;&lt;/code&gt; delete characters but the deleted
  characters are not added to the kill ring.  The remaining commands
  in the list above kill text, i.e. remove the text from the buffer
  and add it to the kill ring.  The killed text can be pasted into the
  buffer using &lt;code&gt;C-y&lt;/code&gt;.  For example, &lt;code&gt;M-d M-d M-d C-p
  C-p C-y&lt;/code&gt; kills the next three words and pastes them two lines
  above.
&lt;/p&gt;
&lt;h2 id=&quot;append-kill&quot;&gt;Append Kill&lt;/h2&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;C-M-w&lt;/code&gt; is used to ensure that if the
  next command happens to be a kill command, then the killed text is
  appended to the last stretch of text in the kill ring.
&lt;/p&gt;
&lt;p&gt;
  To understand what this command does we must first understand that
  after a kill command adds a new stretch of text to the kill ring,
  subsequent consecutive kills append to the same stretch of text in
  the kill ring, i.e. consecutive kills form a single large stretch of
  text in the kill ring.  This can be tested by performing consecutive
  kills and then pasting with &lt;code&gt;C-y&lt;/code&gt;.  For example,
  &lt;code&gt;M-d M-d M-d C-p C-p C-y&lt;/code&gt; kills 3 words, creates a single
  stretch of text consisting of those 3 words in the kill ring and
  pastes that text two lines above.
&lt;/p&gt;
&lt;p&gt;
  However, the moment a non-kill command is used, it seals the stretch
  of text in the kill ring.  Any subsequent kill command begins a new
  stretch of text.  For example, &lt;code&gt;M-d M-d M-d C-p M-d M-d C-p
  C-y&lt;/code&gt; kills 3 words at first but then it moves to the previous
  line sealing that kill text consisting of 3 words.  Then it kills 2
  words and creates a new stretch of text in the kill ring.
  Therefore, the final yank command pastes only those 2 words from the
  kill ring.
&lt;/p&gt;
&lt;p&gt;
  This can be a problem if we want to kill text from various parts of
  the buffer and yet create a single stretch of text that we want to
  paste somewhere.  That&apos;s when &lt;code&gt;C-M-w&lt;/code&gt; comes useful.  For
  example, &lt;code&gt;M-d M-d M-d C-p C-M-w M-d M-d C-p C-y&lt;/code&gt; kills 3
  words and creates a single stretch of text in the kill ring
  consisting of those 3 words.  Then it moves one line up and kills 2
  more words but this time it appends those 2 words to the existing
  stretch of text in the kill ring.  Finally, it moves two lines up
  and pastes the entire stretch of text consisting of 5 words into the
  buffer.
&lt;/p&gt;
&lt;h2 id=&quot;digit-and-negative-arguments&quot;&gt;Digit and Negative Arguments&lt;/h2&gt;
&lt;p&gt;
  Here are some complete key sequences that demonstrate digit and
  negative arguments:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-3 M-d&lt;/code&gt;: Kill the next 3 words.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M- M-d &lt;/code&gt;: Kill the previous word.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-- M-3 M-d &lt;/code&gt;: Kill the previous 3 words.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-3 C-M-k&lt;/code&gt;: Kill the next 3 expressions.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-- C-M-k&lt;/code&gt;: Kill the previous expression.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-- C-M-3 C-M-k&lt;/code&gt;: Kill the previous 3 expressions.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;yanking-text&quot;&gt;Yanking Text&lt;/h2&gt;
&lt;p&gt;
  There are two key bindings to learn here.  The key
  sequence &lt;code&gt;C-y&lt;/code&gt; executes the &lt;code&gt;yank&lt;/code&gt; command
  which yanks the last stretch of text from the kill ring.
&lt;/p&gt;
&lt;p&gt;
  In the apropos system, &lt;code&gt;paste&lt;/code&gt; is a synonym
  of &lt;code&gt;yank&lt;/code&gt;.  Type &lt;code&gt;C-h v apropos-synonyms RET&lt;/code&gt;
  to see all the synonyms define for the apropos system.
  Thus &lt;code&gt;C-h a paste RET&lt;/code&gt; includes the results
  for &lt;code&gt;yank&lt;/code&gt; too.
&lt;/p&gt;
&lt;h2 id=&quot;yank-pop&quot;&gt;Yank Pop&lt;/h2&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-y&lt;/code&gt; executes the &lt;code&gt;yank-pop&lt;/code&gt;
  command which replaces a just-yanked kill with an older kill.  This
  key sequence helps us to cycle through the kill ring and fetch older
  and older kills to be pasted into the buffer.
&lt;/p&gt;
&lt;p&gt;
  Here is an experiment to see how we can use &lt;code&gt;C-y&lt;/code&gt;
  and &lt;code&gt;M-y&lt;/code&gt; can be used together:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    Open a new buffer and type these five words in a single
    line: &lt;code&gt;foo bar baz qux quux&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Then type &lt;code&gt;C-a M-d C-g M-d C-g M-d&lt;/code&gt;.  At this point
    three stretches of text have been inserted into the kill ring.
    The &lt;code&gt;C-g&lt;/code&gt; between every &lt;code&gt;M-d&lt;/code&gt; is there to
    avoid appending kills to the existing stretch of text in the kill
    ring.  This ensures that we have three separate stretches of text
    in the kill ring.
  &lt;/li&gt;
  &lt;li&gt;
    Now type &lt;code&gt;C-y&lt;/code&gt;.  The last stretched of kill text, i.e.
    &lt;code&gt;baz&lt;/code&gt; is now pasted into the buffer.
  &lt;/li&gt;
  &lt;li&gt;
    Now without typing any other key sequence, type &lt;code&gt;M-y&lt;/code&gt;.
    The earlier pasted text &lt;code&gt;baz&lt;/code&gt; is now replaced with an
    older stretch of text from the kill ring.  Thus &lt;code&gt;baz&lt;/code&gt;
    is replaced with &lt;code&gt;bar&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Now once again type &lt;code&gt;M-y&lt;/code&gt;.  The earlier pasted
    text &lt;code&gt;bar&lt;/code&gt; is now replaced with a further older stretch
    of text from the kill ring.  Thus &lt;code&gt;bar&lt;/code&gt; is replaced
    with &lt;code&gt;foo&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  Note in the previous steps how we are not supposed to type any other
  key between the first &lt;code&gt;C-y&lt;/code&gt; and &lt;code&gt;M-y&lt;/code&gt;.
  Similarly, while cycling through the kill ring, we must not type any
  other key between the consecutive &lt;code&gt;M-y&lt;/code&gt; key sequences.
  While cycling through the kill ring, when we reach the oldest kill,
  the next &lt;code&gt;M-y&lt;/code&gt; wraps around and brings back the newest
  kill.
&lt;/p&gt;
&lt;p&gt;
  Since Emacs 28, the key sequence &lt;code&gt;M-y&lt;/code&gt; also supports
  browsing the kill ring and yanking any arbitrary entry from the kill
  ring.  For example, after trying the above experiment,
  type &lt;code&gt;C-g&lt;/code&gt; just to make sure that we are breaking any
  existing &lt;code&gt;C-y&lt;/code&gt; or &lt;code&gt;M-y&lt;/code&gt; cycle.  Then
  type &lt;code&gt;M-y&lt;/code&gt; and a minibuffer prompt appears to yank an
  arbitrary kill from the kill ring.  If we remember the previous
  kill, we can type it out partially and type &lt;code&gt;TAB&lt;/code&gt; to
  autocomplete it.  Alternatively, we could also type &lt;code&gt;TAB&lt;/code&gt;
  initially itself to browse all the kills in the kill ring.
&lt;/p&gt;
&lt;h2 id=&quot;maximum-length-of-kill-ring&quot;&gt;Maximum Length of Kill Ring&lt;/h2&gt;
&lt;p&gt;
  Type &lt;code&gt;C-h v kill-ring-max RET&lt;/code&gt; to see the maximum length
  of the kill ring.  It is &lt;code&gt;60&lt;/code&gt; by default.
&lt;/p&gt;
&lt;h2 id=&quot;killing-lines&quot;&gt;Killing Lines&lt;/h2&gt;
&lt;p&gt;
  Since &lt;code&gt;C-S-&amp;lt;backspace&amp;gt;&lt;/code&gt; works only in GUI Emacs and
  not in terminal Emacs due to terminal limitations, in the
  section &lt;em&gt;Killing Lines&lt;/em&gt; the author recommends installing the
  package &lt;code&gt;whole-line-or-region&lt;/code&gt; which modifies the
  behaviour of &lt;code&gt;C-w&lt;/code&gt; to kill the current line if there is
  no active region.
&lt;/p&gt;
&lt;p&gt;
  This package can be installed with the following command:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;M-x package-install whole-line-or-region RET&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Then a mode offered by this package can be enabled by adding this
  line to the Emacs initialisation file:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(whole-line-or-region-global-mode)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  After Emacs is started with the updated initialisation file,
  typing &lt;code&gt;C-w&lt;/code&gt; kills the current line if there is no active
  region.  However, if there is an active region then &lt;code&gt;C-w&lt;/code&gt;
  retains the default behaviour of killing the region.
&lt;/p&gt;
&lt;p&gt;
  Although the author recommends this package, I do not use this
  package.  I have found &lt;code&gt;C-a C-k&lt;/code&gt; to be very effective for
  killing the current line.  However, it is worth noting that for
  non-empty lines, &lt;code&gt;C-k&lt;/code&gt; does not include the newline in
  the kill by default.  If we want to remove the newline too, we must
  type &lt;code&gt;C-k&lt;/code&gt; another time.  Therefore, to faithfully
  reproduce the behaviour of &lt;code&gt;C-w&lt;/code&gt;
  (of &lt;code&gt;whole-line-or-region&lt;/code&gt;) or that
  of &lt;code&gt;C-S-&amp;lt;backspace&amp;gt;&lt;/code&gt;, we need to type &lt;code&gt;C-a C-k
  C-k&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  It is possible to change the default behaviour of &lt;code&gt;C-k&lt;/code&gt;
  such that when we type it at the beginning of a line, the trailing
  newline is included in the kill.  To do so, add this to the Emacs
  initialisation file:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(setq kill-whole-line t)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  After Emacs is started with this initialisation
  file, &lt;code&gt;C-k&lt;/code&gt; kills a whole line along with the trailing
  newline only if cursor is at the start of a line.  In other words,
  with this setting, &lt;code&gt;C-a C-k&lt;/code&gt; always kills a whole line
  along with the trailing newline.
&lt;/p&gt;
&lt;h2 id=&quot;transpose&quot;&gt;Transpose&lt;/h2&gt;
&lt;p&gt;
  Here are some transpose commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-t&lt;/code&gt;: Interchange characters around point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-t&lt;/code&gt;: Interchange words around point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-t&lt;/code&gt;: Interchange expressions around point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-t&lt;/code&gt;: Exchange current line and previous line.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x transpose-paragraphs RET&lt;/code&gt;: Interchange current
    paragraph with next one.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x transpose-sentences RET&lt;/code&gt;: Interchange the current
    sentence with the next one.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  While using &lt;code&gt;C-t&lt;/code&gt; remember that the point is the logical
  place between two characters.  For example if the cursor blinking on
  the letter &lt;code&gt;e&lt;/code&gt; of the word &lt;code&gt;hello&lt;/code&gt;, then the
  point is between the letters &lt;code&gt;h&lt;/code&gt; and &lt;code&gt;e&lt;/code&gt;.
  When we type a new character, the new character is inserted where
  the point is.  The key sequence &lt;code&gt;C-t&lt;/code&gt; interchanges the
  characters on both sides of the point, i.e. it exchanges the
  character the cursor is blinking on with the character just before
  it.
&lt;/p&gt;
&lt;p&gt;
  There is a subtle difference between the way &lt;code&gt;C-x C-t&lt;/code&gt;
  works and the way the other commands work.  The other commands
  exchange the current or previous object with the next one.
  However, &lt;code&gt;C-x C-t&lt;/code&gt; exchanges the current line with the
  previous one.
&lt;/p&gt;
&lt;p&gt;
  Note that the cursor moves to the end of the next object after
  performing an exchange.  This allows the object that moved forward
  to be dragged further forward by repeated application of the same
  command.  Note again that while the other commands drag the thing at
  point forward, &lt;code&gt;C-x C-t&lt;/code&gt; drags the previous line forward.
&lt;/p&gt;
&lt;p&gt;
  If the cursor is on a space between &lt;code&gt;&quot;foo&quot; :: &quot;bar&quot;&lt;/code&gt;,
  note that &lt;code&gt;M-t&lt;/code&gt; will transpose it to &lt;code&gt;&quot;bar&quot; ::
  &quot;foo&quot;&lt;/code&gt; because it ignores symbols.
&lt;/p&gt;
&lt;h2 id=&quot;filling&quot;&gt;Filling&lt;/h2&gt;
&lt;p&gt;
  Here are some complete key sequences that perform paragraph filling:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-q&lt;/code&gt;: Refill paragraph.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-q&lt;/code&gt;: Refill paragraph and justify text too.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x f 40 RET&lt;/code&gt;: Set &lt;code&gt;fill-column&lt;/code&gt; to 40.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x .&lt;/code&gt;: Set the fill prefix to the current line up to
    point.  On performing a fill operation, the fill prefix is
    inserted at the beginning of every new line created.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-a C-x .&lt;/code&gt;: To cancel the fill prefix, type &lt;code&gt;C-x
    .&lt;/code&gt; at the beginning of a line.  Thus &lt;code&gt;C-a C-x .&lt;/code&gt;
    cancels the fill prefix.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x auto-fill-mode RET&lt;/code&gt;: Toggle auto-filling.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;commenting&quot;&gt;Commenting&lt;/h2&gt;
&lt;p&gt;
  Here are some key bindings to add comments to code in various ways:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-;&lt;/code&gt;: Insert or remove comment in a &lt;em&gt;do what I
    mean&lt;/em&gt; (DWIM) fashion.  If the line is empty, a comment is
    inserted at the beginning of the line.  If the line is not empty,
    a comment is inserted at the end of the line and then indented to
    the column numbered &lt;code&gt;comment-column&lt;/code&gt; if it can.  If a
    region is selected, it comments or uncomments that region.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-;&lt;/code&gt;: Comment out or uncomment the current line.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x comment-box RET&lt;/code&gt;: Comment a region by drawing a
    box made of comment characters around the selected region.
    Running this command repeatedly on the same region creates
    multiple nested comment boxes.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-j&lt;/code&gt;: Insert a new line and continue with the comment
    if the current line has an open comment.  If there is no open
    comment in the current line, then create a new line and indent.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-j&lt;/code&gt;: Same as above.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Here are some variables that control the behaviour of
  comment-related commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;comment-style&lt;/code&gt;: The default is &lt;code&gt;indent&lt;/code&gt;
    which ensures that new comments created with the comment commands
    are correctly indented.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;comment-styles&lt;/code&gt;: An association list with all the
    available comment styles.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;comment-start&lt;/code&gt;: String to insert to start a new
    comment.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;comment-end&lt;/code&gt;: String to insert to end a new comment.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;comment-padding&lt;/code&gt;: Extra spacing between the comment
    characters and the comment text.  This is the minimum number of
    spaces (only if the value of this variable is made of spaces) that
    Emacs tries to keep between the comment characters and comment
    text.  No spaces are inserted if &lt;code&gt;comment-start&lt;/code&gt;
    and &lt;code&gt;comment-end&lt;/code&gt; already
    provide &lt;code&gt;comment-padding&lt;/code&gt; number of spaces or more to
    separate the comment text.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  To demonstrate how changing &lt;code&gt;comment-style&lt;/code&gt; changes the
  commenting behaviour try &lt;code&gt;M-x (setq comment-style &apos;indent)
  RET&lt;/code&gt;, then select a region and type &lt;code&gt;M-;&lt;/code&gt;.  The
  selected region will be commented out with a comment box.
&lt;/p&gt;
&lt;p&gt;
  However running &lt;code&gt;M-x (setq comment-style &apos;aligned) RET&lt;/code&gt;,
  selecting a region in a C buffer and typing &lt;code&gt;M-;&lt;/code&gt; does
  not seem to do anything interesting.
&lt;/p&gt;
&lt;h2 id=&quot;search-and-replace&quot;&gt;Search and Replace&lt;/h2&gt;
&lt;p&gt;
  Here are some complete key sequences that demonstrate search and
  replace commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-% foo RET bar RET&lt;/code&gt;: Replace the
    string &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; while prompting for
    instruction at every match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% f.. RET bar RET&lt;/code&gt;: Replace matches for regular
    expression &lt;code&gt;f..&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; while prompting
    for instruction at every match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x query-replace RET foo RET bar RET&lt;/code&gt;: Same
    as &lt;code&gt;M-% foo RET bar RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x query-replace-regexp RET f.. RET bar RET&lt;/code&gt;: Same
    as &lt;code&gt;C-M-% f.. RET bar RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x replace-string RET foo RET bar RET&lt;/code&gt;: Replace the
    string &lt;code&gt;foo&lt;/code&gt; with &lt;code&gt;bar&lt;/code&gt; but do not prompt
    for instruction at every match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x replace-string RET f.. RET bar RET&lt;/code&gt;: Replace
    matches for regular expression &lt;code&gt;f..&lt;/code&gt;
    with &lt;code&gt;bar&lt;/code&gt; but do not prompt for instruction at every
    match.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The following key bindings work while a query replace operation is
  in progress:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;y&lt;/code&gt;: Replace one match and continue.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;SPC&lt;/code&gt;: Same as &lt;code&gt;y&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;n&lt;/code&gt;: Skip to next match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;DEL&lt;/code&gt;: Same as &lt;code&gt;n&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;q&lt;/code&gt;: Exit query replace.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;RET&lt;/code&gt;: Same as &lt;code&gt;q&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;.&lt;/code&gt;: Replace one match and exit.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;,&lt;/code&gt;: Replace and stay at current match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;!&lt;/code&gt;: Replace all remaining matches in the buffer with
    no more questions.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;^&lt;/code&gt;: Move point back to the previous match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;u&lt;/code&gt;: Undo previous replacement.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;U&lt;/code&gt;: Undo all replacements.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;E&lt;/code&gt;: Edit replacement string and replace next match.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Just like incremental search (&lt;code&gt;C-s&lt;/code&gt; or
  &lt;code&gt;C-M-s&lt;/code&gt;), search and replace performs case folding,
  i.e. performs case-insensitive match if the search string is a
  lowercase string.  However, the moment we include an uppercase
  character in the search string, search and replace performs
  case-sensitive search and replace.
&lt;/p&gt;
&lt;h2 id=&quot;regular-expressions&quot;&gt;Regular Expressions&lt;/h2&gt;
&lt;p&gt;
  This section presents some examples of regular-expression-based
  search as well as search-and-replace.  Here is a simple text buffer
  where the commands to be presented later can be tried out.
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;foo-bar-baz
foo-baar-baz
foo-baaar-baz
foo-baaaar-baz
foo-baaaaar-baz
foo-baaaaaar-baz

web
server
webserver
web server
web_server
web-&amp;gt;server
web::server
web.server
securewebserver
secure web server
web server port 80

web-server
web-api-server
secure-web-server
web-server-port-80
web-server-port-http
web-server-port-HTTP-80

(1, 2, 3)
[4, 5, 6]
{7, 8, 9}
((10 + 20) * 30)
&amp;lt;40, 50, 60&amp;gt;

&quot;hello, world&quot;
&apos;hello, world&apos;

; comment
# comment
// comment
/* comment */&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Here are some complete key sequences that demonstrate regular
  expressions in search operations:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s f..&lt;/code&gt;: Search for the letter &lt;code&gt;f&lt;/code&gt;
    followed by two characters.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s foo\|bar&lt;/code&gt;: Search for the
    string &lt;code&gt;foo&lt;/code&gt; or &lt;code&gt;bar&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s ba\{3\}r&lt;/code&gt;: Search for the letter &lt;code&gt;b&lt;/code&gt;
    followed by the string &lt;code&gt;aaa&lt;/code&gt; and the
    letter &lt;code&gt;r&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s ba\{3,5\}r&lt;/code&gt;: Search for the
    letter &lt;code&gt;b&lt;/code&gt; followed by 3 to 5 repetitions of the
    letter &lt;code&gt;a&lt;/code&gt; followed by the letter &lt;code&gt;r&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s port-[0-9]+&lt;/code&gt;: Search for the
    string &lt;code&gt;port-&lt;/code&gt; followed by one or more digits.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s port-[[:digit:]]+&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s port-[[:alnum:]]+&lt;/code&gt;: Search for the
    string &lt;code&gt;port-&lt;/code&gt; followed by one or more alphanumeric
    characters.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s port-[[:upper:][:digit:]-]+&lt;/code&gt;: Search for the
    string &lt;code&gt;port-&lt;/code&gt; followed by consecutive sequence of one
    or more upper-case letters, digits or hyphen.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \&amp;lt;web&lt;/code&gt;: Search for the
    string &lt;code&gt;web&lt;/code&gt; at the beginning of a word.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s web\&amp;gt;&lt;/code&gt;: Search for the
    string &lt;code&gt;web&lt;/code&gt; at the end of a word.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \&amp;lt;web.+server\&amp;gt;&lt;/code&gt;: Search for the
    string &lt;code&gt;web&lt;/code&gt; at the beginning of a word followed by one
    or more characters and the string &lt;code&gt;server&lt;/code&gt; at the end
    of a word.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \_&amp;lt;web.+server\_&amp;gt;&lt;/code&gt;: Search for the
    string &lt;code&gt;web&lt;/code&gt; at the beginning of a symbol followed by
    one or more characters and the string &lt;code&gt;server&lt;/code&gt; at the
    end of a symbol.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s web\s server&lt;/code&gt;: Search for the
    string &lt;code&gt;web&lt;/code&gt; followed by one whitespace character and
    the string &lt;code&gt;server&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s web\s-server&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s &lt;/code&gt;: Search for whitespace character.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s-&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \sw&lt;/code&gt;: Search for word constituent character.
    Typically uppercase letters, lowercase letters and digits are
    considered word constituents.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s_&lt;/code&gt;: Search for a symbol character that is used
    in variable names or command names.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s.&lt;/code&gt;: Search for punctuation character.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s(&lt;/code&gt;: Search for opening pair of a grouping
    character, e.g. &lt;code&gt;(&lt;/code&gt;, &lt;code&gt;[&lt;/code&gt;, &lt;code&gt;{&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s)&lt;/code&gt;: Search for closing pair of a grouping
    character, e.g. &lt;code&gt;)&lt;/code&gt;, &lt;code&gt;]&lt;/code&gt;, &lt;code&gt;}&lt;/code&gt;,
    etc.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s&quot;&lt;/code&gt;: Search for string delimiter.  This does
    not work in text mode but does work in programming modes.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s&amp;lt;&lt;/code&gt;: Search for opening comment delimiter.
    This too does not work in text mode but does work in programming
    modes.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \s&amp;gt;&lt;/code&gt;: Search for closing comment delimiter.
    This too does not work in text mode but does work in programming
    modes.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-s \Sw&lt;/code&gt;: Search for character that is not a word
    constituent.  The pattern &lt;code&gt;\S&lt;/code&gt; matches any character
    whose syntax code is not the given syntax code (&lt;code&gt;w&lt;/code&gt; in
    this example).
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  All examples above that contain the regular
  expression &lt;code&gt;\s&lt;/code&gt; followed by a character matches a
  character that belongs to a specific syntax class.  For
  example &lt;code&gt;\s.&lt;/code&gt; matches characters that belong to the
  punctuation syntax class.  The syntax class for each character is
  decided by the current major mode.  Thus the same character may
  belong to different syntax classes in different modes.  For example,
  while the character &lt;code&gt;#&lt;/code&gt; belongs to the punctuation syntax
  class in text mode, it belongs to the comment syntax class in Python
  mode.
&lt;/p&gt;
&lt;p&gt;
  To find out which syntax class a particular character belongs to,
  place the cursor on the character and type &lt;code&gt;C-u C-x =&lt;/code&gt;.
  The &lt;em&gt;syntax&lt;/em&gt; field in the output buffer shows the syntax
  class of the character.
&lt;/p&gt;
&lt;p&gt;
  Here are some complete key sequences that demonstrate various
  search-and-replace features:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% \(web\)\(\s-\)\(server\) RET \3\2\1 RET&lt;/code&gt;: Search
    for the string &lt;code&gt;web&lt;/code&gt; followed by a whitespace and the
    string &lt;code&gt;server&lt;/code&gt; and swap &lt;code&gt;web&lt;/code&gt;
    with &lt;code&gt;server&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% \(foo-\)\sw+\(-baz\) RET \1\?\2 RET&lt;/code&gt;: Search for
    the string &lt;code&gt;foo-&lt;/code&gt; followed by a word and the
    string &lt;code&gt;baz&lt;/code&gt; and replace the middle word with text
    input provided by the user.  Before each replace operation, Emacs
    will prompt the user to edit the replacement pattern by putting
    the point where &lt;code&gt;\?&lt;/code&gt; was in the original replacement
    string.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% foo RET \# RET&lt;/code&gt;: Search for the
    string &lt;code&gt;foo&lt;/code&gt; and replace each match with an
    autoincrementing number.  The first match is replaced
    with &lt;code&gt;0&lt;/code&gt;, the second one with &lt;code&gt;1&lt;/code&gt;, the third
    one with &lt;code&gt;2&lt;/code&gt; and so on.  Precisely speaking, the
    backreference &lt;code&gt;\#&lt;/code&gt; refers to the count of the
    replacements already made in the current search and replace
    operation.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% foo RET \&amp;amp;\&amp;amp; RET&lt;/code&gt;: Search for the
    string &lt;code&gt;foo&lt;/code&gt; and duplicate it.  The replacement
    pattern &lt;code&gt;\&amp;amp;&lt;/code&gt; stands for the whole match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% f.. RET \,(upcase \&amp;amp;) RET&lt;/code&gt;: Search for the
    letter &lt;code&gt;f&lt;/code&gt; followed by two characters and replace the
    match with an uppercase form of the match.  The
    syntax &lt;code&gt;\,(&lt;em&gt;form&lt;/em&gt;)&lt;/code&gt; is used to evaluate an Elisp
    form and use its result in the replacement string.  The
    backreference &lt;code&gt;\&amp;amp;&lt;/code&gt; refers to the whole match as a
    string in the Elisp expression.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% [0-9]+ RET \,(+ 1000 \#&amp;amp;)&lt;/code&gt;: Search for
    numbers and add 1000 to each match.  The
    backreference &lt;code&gt;\#&amp;amp;&lt;/code&gt; refers to the whole match as a
    number within the Elisp expression.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% \(\sw+\)-\(\sw+\) RET \,(upcase \2)-\1 RET&lt;/code&gt;:
    Search for two words separated by a hyphen and then swap them but
    convert the second word in each match to uppercase.  The
    backreference &lt;code&gt;\2&lt;/code&gt; refers to the string matched by the
    second capturing group as a string within the Elisp expression.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-% port-\([0-9]+\) RET port-\,(+ 1000 \#1) RET&lt;/code&gt;:
    Search for the string &lt;code&gt;port-&lt;/code&gt; followed by a number and
    add 1000 to the number.  The backreference &lt;code&gt;\#1&lt;/code&gt; refers
    to the string matched by the first capturing group as a string
    within the Elisp expression.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;changing-case&quot;&gt;Changing Case&lt;/h2&gt;
&lt;p&gt;
  Here are some commands to change case of text:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-l&lt;/code&gt;: Convert string from point to the end of word to
    lowercase.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-u&lt;/code&gt;: Convert string from point to the end of word to
    uppercase.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-c&lt;/code&gt;: Capitalise string from point to the end of word.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-l&lt;/code&gt;: Convert region to lower case.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-u&lt;/code&gt;: Convert region to upper case.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x upcase-initials-region RET&lt;/code&gt;: Capitalise region.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note that the commands &lt;code&gt;C-x C-l&lt;/code&gt;
  (&lt;code&gt;downcase-region&lt;/code&gt;) and &lt;code&gt;C-x C-u&lt;/code&gt;
  (&lt;code&gt;upcase-region&lt;/code&gt;) are disabled by default.  Follow the
  prompts to try it or enable it.  A quick way to try it is to
  type &lt;code&gt;SPC&lt;/code&gt;.  Also, adding the following to the Emacs
  initialisation file permanently enables it.
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(put &apos;downcase-region &apos;disabled nil)
(put &apos;upcase-region &apos;disabled nil)&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;counting&quot;&gt;Counting&lt;/h2&gt;
&lt;p&gt;
  Here are some commands to count lines, words, characters, patterns,
  etc:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-=&lt;/code&gt;: Count lines, words and characters in region.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x count-words-region RET&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x count-words RET&lt;/code&gt;: Similar to above.  If no region
    is selected, then counts in the entire buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x how-many RET f.. RET&lt;/code&gt;: Show the number of matches
    for the regular expression &lt;code&gt;f..&lt;/code&gt; following point.  If
    region is selected, then show the number of matches in the region.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x count-matches RET f.. RET&lt;/code&gt;: Same as above.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;deleting-and-keeping-lines&quot;&gt;Deleting and Keeping Lines&lt;/h2&gt;
&lt;p&gt;
  The commands that are presented in this section can be tested with a
  buffer like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;foo
bar

foo
bar

foo
foo

bar
foo



baz
baz
baz&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Here are the commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x delete-duplicate-lines RET&lt;/code&gt;: Delete all but one
    copy of duplicate lines in region.  When executed on the whole of
    the example buffer presented above, it leaves us with three
    non-empty lines and one blank line.  When duplicate lines are
    encountered, the first instance of each line is kept intact and
    the others are deleted.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-x delete-duplicate-lines RET&lt;/code&gt;: Like the previous
    command but search backwards.  Thus effectively, the last instance
    of each repeated line is left intact while the other duplicates
    are deleted.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u C-u M-x delete-duplicate-lines RET&lt;/code&gt;: Delete only
    those duplicate lines that are adjacent to each other.  In every
    contiguous group of duplicate lines, the first one is left intact
    and the rest are deleted.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u C-u C-u M-x delete-duplicate-lines RET&lt;/code&gt;: Like the
    first command in this list but repeated blank lines are left
    intact.  When executed on the whole of the example buffer
    presented above, it leaves us with three non-empty lines and six
    blank lines.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x flush-lines RET b.. RET&lt;/code&gt;: Delete lines in region
    that match the regular expression &lt;code&gt;b..&lt;/code&gt;.  If no region
    is active, then delete matching lines between the point and end of
    buffer.  The deleted lines are not copied to kill ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x keep-lines RET b.. RET&lt;/code&gt;: Keep lines in region that
    match the regular expression &lt;code&gt;b..&lt;/code&gt; and delete the rest.
    If no region is active, then keep matching lines between the point
    and end of buffer and delete the rest.  The deleted lines are not
    copied to kill ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x copy-matching-lines RET b.. RET&lt;/code&gt;: Copy lines in
    region that match the regular expression &lt;code&gt;b..&lt;/code&gt; to the
    kill ring.  If no region is active, then copy matching lines
    between the point and end of buffer.  (Available since Emacs 28.1)
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x kill-matching-lines RET b.. RET&lt;/code&gt;: Kill lines in
    region that match the regular expression &lt;code&gt;b..&lt;/code&gt; to the
    kill ring.  If no region is active, then kill matching lines
    between the point and end of buffer.  (Available since Emacs 28.1)
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  To try each command on the entire buffer, first type &lt;code&gt;C-x
  h&lt;/code&gt; to select the entire buffer as the region and then type a
  command mentioned above.
&lt;/p&gt;
&lt;h2 id=&quot;splitting-and-joining-lines&quot;&gt;Splitting and Joining Lines&lt;/h2&gt;
&lt;p&gt;
  Here is a list of commands that help with splitting and joining
  lines:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-o&lt;/code&gt;: Insert a newline after the point but do not move
    the point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-o&lt;/code&gt;: On blank line, delete all surrounding blank
    lines, leaving just one.  On isolated blank line, delete the blank
    line.  On non-blank line, delete all consecutive blank lines that
    follow the non-blank lines.  While deleting blank lines it also
    deletes lines that consist only of whitespaces.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-o&lt;/code&gt;: Split current line at the next non-whitespace
    character after the point while maintaining its indentation.
    Everything from the next non-whitespace character after the point
    to the end of the line moves down by one line but the new line is
    indented so that the column numbers of all the characters that
    moved down remain the same.  If a fill-prefix has been set, say
    with &lt;code&gt;C-x .&lt;/code&gt;, then the fill-prefix is inserted in the
    new line.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-^&lt;/code&gt;: Join current line with previous line and leave
    exactly one space between the joined lines.  If a fill-prefix is
    set, say with &lt;code&gt;C-x .&lt;/code&gt;, then the fill-prefix is removed
    while joining lines.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;C-x C-o&lt;/code&gt; is very useful for removing
  spurious blank lines between paragraphs.
&lt;/p&gt;
&lt;p&gt;
  Note that &lt;code&gt;M-^&lt;/code&gt; also works on a region.  When a region is
  active, it joins all lines in the region.
&lt;/p&gt;
&lt;h2 id=&quot;examining-and-fixing-whitespace-issues&quot;&gt;Examining and Fixing Whitespace Issues&lt;/h2&gt;
&lt;p&gt;
  Here is a list of commands that are useful in examining whitespace
  in the current buffer:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x whitespace-mode RET&lt;/code&gt;: Toggle visualisation of
    spaces, tabs, newlines and lines longer
    than &lt;code&gt;whitespace-line-column&lt;/code&gt; number of columns (80 by
    default) with special glyphs and colour.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x whitespace-newline-mode RET&lt;/code&gt;: Toggle visualisation
    of newlines.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x whitespace-toggle-options RET&lt;/code&gt;: Toggle local
    options for &lt;code&gt;whitespace-mode&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  After typing &lt;code&gt;M-x whitespace-toggle-options RET&lt;/code&gt;, type a
  key to tell it what to do.  For example, type &lt;code&gt;N&lt;/code&gt; and it
  will start or restart &lt;code&gt;whitespace-mode&lt;/code&gt; with the
  visualisation of newline toggled.  Type &lt;code&gt;?&lt;/code&gt; to see the
  list of all key inputs it supports.
&lt;/p&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-x whitespace-toggle-options RET&lt;/code&gt; may
  be typed anytime regardless of whether &lt;code&gt;whitespace-mode&lt;/code&gt;
  is currently enabled or not.  If &lt;code&gt;whitespace-mode&lt;/code&gt; is not
  enabled, running &lt;code&gt;whitespace-toggle-options&lt;/code&gt;
  automatically enables it.  If &lt;code&gt;whitespace-mode&lt;/code&gt; is
  already enabled, then running &lt;code&gt;whitespace-toggle-options&lt;/code&gt;
  and toggling an option, restarts local &lt;code&gt;whitespace-mode&lt;/code&gt;
  with the updated option setting.
&lt;/p&gt;
&lt;p&gt;
  Here are some commands to report and clean up whitespace issues:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x whitespace-report RET&lt;/code&gt;: Shows a report of
    whitespace issues.  The &quot;Current setting&quot; column on left shows the
    current settings found in the
    variable &lt;code&gt;whitespace-style&lt;/code&gt;.  The &quot;Whitespace Problem&quot;
    column on the right shows the whitespace problems found in the
    buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x whitespace-report-region RET&lt;/code&gt;: Like the previous
    command but reports problems in a region.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x whitespace-cleanup RET&lt;/code&gt;: Cleans up whitespace
    issues in the buffer.  This command checks
    the &lt;code&gt;whitespace-style&lt;/code&gt; variable to decide which issues
    to fix.  See &lt;code&gt;C-h f whitespace-cleanup RET&lt;/code&gt; for
    complete details.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x whitespace-cleanup-region RET&lt;/code&gt;: Cleans up
    whitespace issues in a region.  Unlike the previous command, this
    command does not fix empty lines at the beginning or end of
    buffer.  See &lt;code&gt;C-h f whitespace-cleanup-region RET&lt;/code&gt; for
    complete details.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  As mentioned in the list above, the whitespace cleanup functions
  read the variable &lt;code&gt;whitespace-style&lt;/code&gt; to decide which
  whitespace issues to fix.  Say, we do not want to fix trailing
  whitespace issue but do want to fix other whitespace issues selected
  by default (e.g. empty lines at the beginning or end of buffer,
  spaces before tab, etc.), then we need to update
  the &lt;code&gt;whitespace-style&lt;/code&gt; variable as follows:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(setq whitespace-style (delete &apos;trailing whitespace-style))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Now running &lt;code&gt;whitespace-cleanup&lt;/code&gt;
  or &lt;code&gt;whitespace-cleanup-region&lt;/code&gt; is going to skip fixing
  trailing spaces but it will perform the other cleanups determined by
  the value of &lt;code&gt;whitespace-style&lt;/code&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;keyboard-macros&quot;&gt;Keyboard Macros&lt;/h2&gt;
&lt;p&gt;
  The behaviour of keyboard macro key sequences depend on the current
  context.  So they are presented as table below.
&lt;/p&gt;
&lt;table class=&quot;grid&quot;&gt;
  &lt;tr&gt;
    &lt;th&gt;
      Key
    &lt;/th&gt;
    &lt;th&gt;
      Command
    &lt;/th&gt;
    &lt;th&gt;
      While not recording
    &lt;/th&gt;
    &lt;th&gt;
      While recording
    &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;code&gt;F3&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;code&gt;kmacro-start-macro-or-insert-counter&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      Start recording
    &lt;/td&gt;
    &lt;td&gt;
      Insert counter
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;code&gt;F4&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;code&gt;kmacro-end-or-call-macro&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      Call macro
    &lt;/td&gt;
    &lt;td&gt;
      End recording
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;code&gt;C-x&amp;nbsp;(&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;code&gt;kmacro-start-macro&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      Start recording
    &lt;/td&gt;
    &lt;td&gt;
      Do nothing
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;code&gt;C-x&amp;nbsp;)&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;code&gt;kmacro-end-macro&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      End recording
    &lt;/td&gt;
    &lt;td&gt;
      Do nothing
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;code&gt;C-x&amp;nbsp;e&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;code&gt;kmacro-end-and-call-macro&lt;/code&gt;
    &lt;/td&gt;
    &lt;td&gt;
      Call macro
    &lt;/td&gt;
    &lt;td&gt;
      End recording and call macro
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;
  The key sequences in the table above can be divided into three
  groups:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x (&lt;/code&gt; and &lt;code&gt;C-x )&lt;/code&gt;: These invoke simple
    commands that start and stop macro recording.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;F3&lt;/code&gt; and &lt;code&gt;F3&lt;/code&gt;: These are wrappers around the
    simple commands.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x e&lt;/code&gt;: This is a slightly high level command too that
    wraps around simpler macro commands and functions that end
    recording and calls a macro.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Given these details, there are broadly two ways these macro key
  sequences can be used.  They are shown in the table below.
&lt;/p&gt;
&lt;table class=&quot;grid&quot;&gt;
  &lt;tr&gt;
    &lt;th&gt;Operation&lt;/th&gt;
    &lt;th&gt;Using Function Keys&lt;/th&gt;
    &lt;th&gt;Using Control Keys&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Start recording&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;F3&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;C-x (&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Stop recording&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;F4&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;C-x )&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Call macro&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;F4&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;C-x e&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Stop recording and call macro&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;F4 F4&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;C-x e&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;Repeat call macro&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;F4&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;e&lt;/code&gt;&lt;/td&gt;
&lt;/table&gt;
&lt;p&gt;
  If you are comfortable using function keys, you might want to follow
  the second column in the table above.  Otherwise, you might want to
  follow the third column in the table above.
&lt;/p&gt;
&lt;p&gt;
  The last row is not mentioned in the book but the fact
  that &lt;code&gt;e&lt;/code&gt; may be used to repeat a macro call performed
  with &lt;code&gt;C-x e&lt;/code&gt; is documented in the Emacs
  manual: &lt;a href=&quot;https://www.gnu.org/software/emacs/manual/html_node/emacs/Basic-Keyboard-Macro.html&quot;&gt;Keyboard
  Macros: Basic Use&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  Note that &lt;code&gt;F3&lt;/code&gt; inserts a counter value and increments the
  counter value by 1 or by the number specified via a digit argument.
  Here is an example key sequence that may be typed in a buffer with
  multiple lines to demonstrate this:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-x (&lt;/code&gt; to start macro recording.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-a F3 . SPC M-c C-n&lt;/code&gt; to insert macro counter
    which &lt;code&gt;0&lt;/code&gt; by default, followed by dot and space at the
    beginning of the line, capitalise the first word and move to the
    next line.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-x e&lt;/code&gt; to stop macro recording and call the
    recorded macro.  Now &lt;code&gt;1&lt;/code&gt;, dot and space is inserted at
    the beginning of the line.  The first word of the current line is
    capitalised and the cursor moves to the next line.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;e&lt;/code&gt; to repeat the macro call.  Keep
    typing &lt;code&gt;e&lt;/code&gt; to repeat the macro call.
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  The behaviour of the the macro commands change with universal
  arguments and digit arguments as follows:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-u F3&lt;/code&gt;: Execute the last macro, then record new macro
    and append it to the last macro.  Set
    &lt;code&gt;kmacro-execute-before-append&lt;/code&gt; to &lt;code&gt;nil&lt;/code&gt;
    (it is &lt;code&gt;t&lt;/code&gt; by default) to prevent executing the last
    macro before appending a new macro to the last macro.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u C-x (&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-5 F3&lt;/code&gt;: Start recording but set counter to 5, i.e.
    while a macro is being recorded, typing &lt;code&gt;F3&lt;/code&gt; inserts 5
    the first time, 6 the second time and so on.  The numeric prefix
    argument sets the counter value.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-5 C-x (&lt;/code&gt;: Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u F4&lt;/code&gt;: Execute the second macro in the ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-7 F4&lt;/code&gt;: Repeat the last macro 7 times.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-7 C-x e&lt;/code&gt;: Repeat the last macro 7 times.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-0 F3&lt;/code&gt;: Repeat macro until there is an error (e.g.
    reaching the end of a buffer).
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-0 C-x e&lt;/code&gt;: Same as above.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Type &lt;code&gt;C-x C-k C-h&lt;/code&gt; to discover keyboard macro commands
  and their key bindings.  The list below shows some of the
  interesting ones mentioned in the book.  In the list below, complete
  key sequences are used, so that they serve as a demonstration of the
  macro commands.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k C-a 20 RET&lt;/code&gt;: Add 20 value to the counter.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k TAB&lt;/code&gt;: Insert counter.  Note that we saw earlier
    that this can also be done with &lt;code&gt;F3&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k C-c&lt;/code&gt;: Set counter.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k C-f %02x&lt;/code&gt;: Set macro counter format to
    zero-padded two-digit hexadecimal numbers with a minimum width of
    2.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note that all of the above commands work fine even when no macro
  recording is in progress.  For example, earlier we saw
  that &lt;code&gt;F3&lt;/code&gt; inserts the macro counter value only when a
  macro recording is in progress.  However, &lt;code&gt;C-x C-k TAB&lt;/code&gt;
  inserts the macro counter value even when a macro recording is not
  in progress.
&lt;/p&gt;
&lt;p&gt;
  Another interesting feature mentioned in the book is querying for
  user input while recording a keyboard macro.  The key sequence to
  query the user is &lt;code&gt;C-x C-k q&lt;/code&gt; or &lt;code&gt;C-x q&lt;/code&gt;.
  Here are a few complete key sequences that may be used to
  demonstrate this feature:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;F3 C-n C-a foo: C-x q C-e :bar F4&lt;/code&gt;: This defines a
    macro such that when we execute the macro by
    typing &lt;code&gt;F4&lt;/code&gt; one more time, the macro first
    inserts &lt;code&gt;foo&lt;/code&gt; at the beginning of the next line, then
    it prompts us to decide if we want to continue with macro
    execution.  If we type type &lt;code&gt;y&lt;/code&gt;, then it continues with
    the remainder of the macro execution.  If we type &lt;code&gt;n&lt;/code&gt;,
    it skips the rest of the macro iteration and continue with the
    next iteration of the macro (such as when we are replaying the
    macro multiple times with a digit argument).  If we
    type &lt;code&gt;RET&lt;/code&gt;, it skips the rest of the macro execution as
    well as skip any further iterations of the macro (in case we are
    replaying the macro multiple times).
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;F3 C-a foo: C-x C-k q C-e :bar F4&lt;/code&gt;: Same as above but
    slightly longer key sequence.  The key sequence in the previous
    point is easier to remember and type.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  In the above examples, when the macro playback prompts queries for
  user input, we can also type &lt;code&gt;C-l&lt;/code&gt; to recentre the
  screen, &lt;code&gt;C-r&lt;/code&gt; to enter recursive edit or
  &lt;code&gt;C-M-c&lt;/code&gt; to exit recursive edit.
&lt;/p&gt;
&lt;p&gt;
  Note that the key sequence &lt;code&gt;C-l&lt;/code&gt; behaves a little
  differently from the regular &lt;code&gt;C-l&lt;/code&gt;.  Unlike the
  regular &lt;code&gt;C-l&lt;/code&gt;, successive invocations of this key
  sequence during macro query does not cause the window to reposition
  at various places (centre, top and bottom by default) in a cyclical
  order.  Successive invocations of &lt;code&gt;C-l&lt;/code&gt; during macro
  query, leaves the screen centred.
&lt;/p&gt;
&lt;p&gt;
  Here are some key sequences to save and recall macros:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k C-p&lt;/code&gt;: Move to the previous keyboard macro in
    the keyboard macro ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k C-n&lt;/code&gt;: Move to the next keyboard macro in the
    keyboard macro ring.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k n foo RET&lt;/code&gt;: Assign the name &lt;code&gt;foo&lt;/code&gt;
    to the current keyboard macro in the keyboard macro ring.  Now the
    macro can be executed by simply typing &lt;code&gt;M-x foo RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x insert-kbd-macro foo RET&lt;/code&gt;: Insert the definition
    of the named keyboard macro &lt;code&gt;foo&lt;/code&gt; as Elisp code into
    the current buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k b C-c 1&lt;/code&gt;: Assign the key sequence &lt;code&gt;C-c
    1&lt;/code&gt; to the current keyboard macro in the keyboard macro ring.
    Now the macro can be executed by simply typing &lt;code&gt;C-c 1&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Finally, here are some commands to edit keyboard macros:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k e C-x e&lt;/code&gt;: Edit the current keyboard macro.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k e M-x foo RET&lt;/code&gt;: Edit the keyboard macro
    named &lt;code&gt;foo&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k e C-c 1&lt;/code&gt;: Edit the keyboard macro
    bound to &lt;code&gt;C-c 1&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-k l&lt;/code&gt;: View the most recent 300 keystrokes and
    edit it to create a new keyboard macro.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x kmacro-edit-lossage RET&lt;/code&gt;: Same as above.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  A few additional commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-h l&lt;/code&gt;: See the last 300 characters typed (lossage).
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x open-dribble-file foo.txt RET&lt;/code&gt;: Write input events
    to a dribble file named &lt;code&gt;foo.txt&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-: (open-dribble-file nil) RET&lt;/code&gt;: Close the dribble file.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;text-expansion&quot;&gt;Text Expansion&lt;/h2&gt;
&lt;h3 id=&quot;abbrev&quot;&gt;Abbrev&lt;/h3&gt;
&lt;p&gt;
  Here are some Abbrev commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x a l&lt;/code&gt;: Take the word before the cursor and define a
    mode-specific abbreviation for it.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x a g&lt;/code&gt;: Take the word before the cursor and define a
    global abbreviation for it.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x a i l&lt;/code&gt;: Take the abbreviated word before the
    cursor and define a mode-specific expansion for it.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x a i l&lt;/code&gt;: Take the abbreviated word before the
    cursor and define a global expansion for it.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note that for the expansions to work Abbrev mode should be enabled,
  say with &lt;code&gt;M-x abbrev-mode RET&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  Here are some complete key sequences that demonstrate how we can use
  Abbrev to define an abbreviation, i.e. text that automatically gets
  replaced by another text:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;Use SPC Debian C-x a l deb RET&lt;/code&gt;: Define a
    mode-specific abbreviation &lt;code&gt;deb&lt;/code&gt; such that whenever we
    type &lt;code&gt;deb&lt;/code&gt;, it automatically expands
    to &lt;code&gt;Debian&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;Use SPC Linux C-x a g lnx RET&lt;/code&gt;: Define a global
    abbreviation &lt;code&gt;lnx&lt;/code&gt; such that whenever we
    type &lt;code&gt;lin&lt;/code&gt;, it automatically expands
    to &lt;code&gt;Linux&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;Hello SPC wld C-x a i l World RET&lt;/code&gt;: Define a
    mode-specific abbreviation &lt;code&gt;wld&lt;/code&gt; such that whenever we
    type &lt;code&gt;wld&lt;/code&gt;, it automatically expands
    to &lt;code&gt;World&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;Hello SPC evry C-x a i g Everyone RET&lt;/code&gt;: Define a
    global abbreviation &lt;code&gt;evry&lt;/code&gt; such that whenever we
    type &lt;code&gt;evry&lt;/code&gt;, it automatically expands
    to &lt;code&gt;Everyone&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Although not mentioned in the book, these commands can be used with
  a numeric prefix argument to specify the number of words before the
  cursor to be picked for expansion for the abbreviation we are about
  to define.  Here are some complete key sequences that demonstrate
  this:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;I use Debian GNU/Linux C-3 C-x a l dgl&lt;/code&gt;: Define a
    mode-specific abbreviation &lt;code&gt;dgl&lt;/code&gt; such that whenever we
    type &lt;code&gt;dgl&lt;/code&gt;, it automatically expands to &lt;code&gt;Debian
    GNU/Linux&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;I use Debian GNU/Linux C-3 C-x a g dgl&lt;/code&gt;: Similar to
    above but define a global abbreviation.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;dabbrev&quot;&gt;DAbbrev&lt;/h3&gt;
&lt;p&gt;
  There are two key bindings discussed in the book:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-/&lt;/code&gt;: Expand the word just before the cursor to the
    nearest preceding word for which the current word is a prefix.  If
    no suitable preceding word is found, expand it to the nearest
    succeeding word for which the current word is a prefix.  Repeating
    this command cycles between the other matches found.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-/&lt;/code&gt;: Find all words in the buffer that has the
    current word before the cursor as the prefix and expand the
    current word to the longest common prefix of all these matching
    words.  However, if the longest common prefix of the matching
    words is same as the word before the cursor, then present them as
    suggestions for completion.  If there is exactly one matching
    word, expand the word before the cursor to that word.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The last command above takes a little while to get used to it.  The
  following steps demonstrate how it works.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Create a text buffer with the following line:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;abacus apple appliance application&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;ap&lt;/code&gt; followed by &lt;code&gt;C-M-/&lt;/code&gt;, the word
    expands to &lt;code&gt;appl&lt;/code&gt; since that is the longest common
    prefix among the matching words.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;C-M-/&lt;/code&gt; again.  The matching
    words &lt;code&gt;apple&lt;/code&gt;, &lt;code&gt;appliance&lt;/code&gt;
    and &lt;code&gt;application&lt;/code&gt; are presented as possible completions
    in a temporary buffer named &lt;code&gt;*Completions*&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Now type &lt;code&gt;ic&lt;/code&gt;, so that the word before the cursor
    becomes &lt;code&gt;applic&lt;/code&gt; and type &lt;code&gt;C-M-/&lt;/code&gt; again.
    Now the word before the cursor expands to &lt;code&gt;application&lt;/code&gt;
    because that is the only possible completion now.
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  Note that by default DAbbrev looks for matching words in other open
  buffers too and offers them as completions.
&lt;/p&gt;
&lt;h3 id=&quot;hippie-expand&quot;&gt;Hippie Expand&lt;/h3&gt;
&lt;p&gt;
  Unlike DAbbrev, Hippie Expand goes beyond open buffers to look for
  expansions.  The variable
  &lt;code&gt;hippie-expand-try-functions-list&lt;/code&gt; contains a list of
  expansion functions that &lt;code&gt;hippie-expand&lt;/code&gt; uses to look for
  completions.  The book suggests remapping &lt;code&gt;M-/&lt;/code&gt; to
  invoke &lt;code&gt;hippie-expand&lt;/code&gt; with this Elisp code:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(global-set-key [remap dabbrev-expand] &apos;hippie-expand)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  By default, Hippie Expand can complete file names, complete lines,
  etc.  For example, if there is a line for which the current line is
  a prefix (leading whitespace is ignored while checking for matches),
  then the current line is expanded to the other matchine line.
&lt;/p&gt;
&lt;p&gt;
  Repeated invocations of this command cycles between the matches.
&lt;/p&gt;
&lt;p&gt;
  As mentioned earlier, the
  variable &lt;code&gt;hippie-expand-try-functions-list&lt;/code&gt; determines
  which expansion algorithms are used.  Here is an example that
  demonstrates how we can alter this variable:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(setq hippie-expand-try-functions-list &apos;(try-complete-lisp-symbol))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The above rather unrealistic example severely restricts the
  expansions Hippie Expand can perform.  With the above example, word
  expansion, line expansion, file name completion, etc. are disabled.
  Only Elisp symbols are expanded.  For example,
  typing &lt;code&gt;white&lt;/code&gt; followed by &lt;code&gt;M-/&lt;/code&gt; first expands
  the word to &lt;code&gt;whitespace&lt;/code&gt; because all matching Elisp
  symbols have that as the longest common prefix.
  Typing &lt;code&gt;M-/&lt;/code&gt; over and over again, completes the expansion
  further with various Elisp symbols.
&lt;/p&gt;
&lt;p&gt;
  As mentioned before, the above example is highly atypical.  The
  above example is only meant for demonstrating how this variable can
  be set.  Typically, users add more functions to this variable to add
  more expansion capabilities.
&lt;/p&gt;
&lt;h2 id=&quot;indenting&quot;&gt;Indenting&lt;/h2&gt;
&lt;h3 id=&quot;electric-indentation&quot;&gt;Electric Indentation&lt;/h3&gt;
&lt;p&gt;
  Emacs automatically indents code as we type.  The major mode decides
  the automatic indentation behaviour.  The automatic identation is
  provided by a global minor mode named
  &lt;code&gt;electric-indent-mode&lt;/code&gt; which is enabled by default.
&lt;/p&gt;
&lt;h3 id=&quot;indenting-current-line&quot;&gt;Indenting Current Line&lt;/h3&gt;
&lt;p&gt;
  Typing &lt;code&gt;TAB&lt;/code&gt; indents the current line.  In many modes
  like &lt;code&gt;emacs-lisp-mode&lt;/code&gt;, &lt;code&gt;python-mode&lt;/code&gt;,
  &lt;code&gt;text-mode&lt;/code&gt;, etc. the command
  &lt;code&gt;indent-for-tab-command&lt;/code&gt; is bound to it.  But there are
  modes that bind another command to &lt;code&gt;TAB&lt;/code&gt;.  For example,
  in &lt;code&gt;c-mode&lt;/code&gt;, the command
  &lt;code&gt;c-indent-line-or-region&lt;/code&gt; is bound to &lt;code&gt;TAB&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  The behaviour of &lt;code&gt;indent-for-tab-command&lt;/code&gt; is determined
  by the variables &lt;code&gt;tab-always-indent&lt;/code&gt;.  It
  is &lt;code&gt;t&lt;/code&gt; by default which causes &lt;code&gt;TAB&lt;/code&gt; to just
  indent the current line.  If set to &lt;code&gt;nil&lt;/code&gt;,
  hitting &lt;code&gt;TAB&lt;/code&gt; indents the current line only if the point
  is before the first non-whitespace character of the line.  Otherwise
  it inserts tabs or spaces to move the point to the next tab stop
  column.  If set to &lt;code&gt;&apos;complete&lt;/code&gt;, typing &lt;code&gt;TAB&lt;/code&gt;
  first tries to indent the current line but if the line is already
  correctly indented, then it tries to complete the thing at point.
&lt;/p&gt;
&lt;p&gt;
  When &lt;code&gt;indent-for-tab-command&lt;/code&gt; is bound
  to &lt;code&gt;TAB&lt;/code&gt; and when &lt;code&gt;indent-for-tab-command&lt;/code&gt;
  decides to indent the current line, it calls the function in the
  variable &lt;code&gt;indent-line-function&lt;/code&gt; to perform the
  indentation.  Here is a table that shows
  what &lt;code&gt;indent-line-function&lt;/code&gt; contains in a few major modes
  where &lt;code&gt;indent-for-tab-command&lt;/code&gt; command is bound
  to &lt;code&gt;TAB&lt;/code&gt;:
&lt;/p&gt;
&lt;table class=&quot;grid&quot;&gt;
  &lt;tr&gt;
    &lt;th&gt;&lt;code&gt;major-mode&lt;/code&gt;&lt;/th&gt;
    &lt;th&gt;&lt;code&gt;indent-line-function&lt;/code&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;code&gt;emacs-lisp-mode&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;lisp-indent-line&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;code&gt;python-mode&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;python-indent-line-function&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;code&gt;text-mode&lt;/code&gt;&lt;/td&gt;
    &lt;td&gt;&lt;code&gt;indent-relative&lt;/code&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;
  While &lt;code&gt;lisp-indent-line&lt;/code&gt; and
  &lt;code&gt;python-indent-line&lt;/code&gt; attempt to indent the current line
  according to the syntax of the language,
  &lt;code&gt;indent-relative&lt;/code&gt; inserts tabs and spaces to move the
  point to the next indentation point where the indentation point is
  defined as the next non-whitespace character following whitespace.
  This can be useful in aligning the point with words in the previous
  line.  If the previous line has no indentation point (e.g. the
  previous line is an empty line or does not have whitespace),
  then &lt;code&gt;tab-to-tab-stop&lt;/code&gt; is invoked which inserts tabs or
  spaces to move the point to the next tab stop column.
&lt;/p&gt;
&lt;p&gt;
  The command &lt;code&gt;tab-to-tab-stop&lt;/code&gt; command introduced in the
  previous paragraph can also be invoked with &lt;code&gt;M-i&lt;/code&gt;.
&lt;/p&gt;
&lt;h3 id=&quot;use-only-spaces-for-indentation&quot;&gt;Use Only Spaces for Indentation&lt;/h3&gt;
&lt;p&gt;
  By default, Emacs uses a mix of tabs and spaces for indentation and
  alignment.  When it needs to align the first non-whitespace
  character of a line with a certain token in the previous line, it
  would insert as many tabs as it can followed by a few spaces if
  necessary to attain the desired alignment.  To force Emacs to always
  use spaces for indentation and alignment, add the following Elisp
  code to the Emacs initialisation file:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(setq-default indent-tabs-mode nil)&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;tab-width&quot;&gt;Tab Width&lt;/h3&gt;
&lt;p&gt;
  The variable &lt;code&gt;tab-width&lt;/code&gt; is used in various contexts
  while performing indentation and alignment.  For example,
  when &lt;code&gt;indent-tabs-mode&lt;/code&gt; is enabled, for
  every &lt;code&gt;tab-width&lt;/code&gt; columns of indentation required, Emacs
  inserts a tab to indent the code.
&lt;/p&gt;
&lt;p&gt;
  Also, when &lt;code&gt;indent-tabs-mode&lt;/code&gt; is set to &lt;code&gt;nil&lt;/code&gt;,
  typing &lt;code&gt;M-i&lt;/code&gt; inserts as many spaces as necessary to move
  the point to the next tab stop column where the distance between two
  tab stops is assumed to be &lt;code&gt;tab-width&lt;/code&gt;.
&lt;/p&gt;
&lt;h3 id=&quot;edit-tab-stops&quot;&gt;Edit Tab Stops&lt;/h3&gt;
&lt;p&gt;
  The behaviour of &lt;code&gt;M-i&lt;/code&gt; can be customised further by
  manually defining tab stop columns.  Type &lt;code&gt;M-x edit-tab-stops
  RET&lt;/code&gt; first.  A buffer named &lt;code&gt;*Tab Stops*&lt;/code&gt; appears.
  The second and third line of this buffer contains a ruler to
  indicate the column numbers.  Type &lt;code&gt;:&lt;/code&gt; (i.e. colon) in
  the first line whereever you want to define tab stops.  Then
  type &lt;code&gt;C-c C-c&lt;/code&gt; to install the changes.  Now
  when &lt;code&gt;M-i&lt;/code&gt; is typed in a text buffer, each time it
  inserts as many tabs (if &lt;code&gt;indent-tabs-mode&lt;/code&gt;
  is &lt;code&gt;t&lt;/code&gt;) or spaces as necessary to move the point to the
  next tab stop column as defined earlier in the &lt;code&gt;*Tab
  Stops*&lt;/code&gt; buffer.
&lt;/p&gt;
&lt;h3 id=&quot;indent-regions&quot;&gt;Indent Region&lt;/h3&gt;
&lt;p&gt;
  Typing &lt;code&gt;TAB&lt;/code&gt; when a region is active indents the region
  according to the major mode&apos;s indentation rules.  It invokes the
  same command as the one invoked when we type &lt;code&gt;TAB&lt;/code&gt; to
  indent a line.  The command bound to it takes care of indenting
  region.  For example, if &lt;code&gt;TAB&lt;/code&gt; is bound
  to &lt;code&gt;indent-for-tab-command&lt;/code&gt;, the latter checks if a
  region is active and if it is, then it simply
  calls &lt;code&gt;indent-region&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  The &lt;code&gt;indent-region&lt;/code&gt; command can be invoked explicitly
  using &lt;code&gt;C-M-\&lt;/code&gt;.  If &lt;code&gt;fill-prefix&lt;/code&gt; has been set,
  say with &lt;code&gt;C-x .&lt;/code&gt;, then it is added to every line in the
  region being indented.  With a numeric prefix argument, each line in
  the region is indented to the column indicated by the argument.  For
  example, &lt;code&gt;C-M-1 C-M-0 C-M-\&lt;/code&gt; indents each line of the
  region to column 10.
&lt;/p&gt;
&lt;h3 id=&quot;indent-rigidly&quot;&gt;Indent Rigidly&lt;/h3&gt;
&lt;p&gt;
  When we want to rigidly control how a region must be indented, we
  can type &lt;code&gt;C-x TAB&lt;/code&gt; to perform rigid indentation.  Doing
  so allows us to bypass the indentation rules of the major mode.
  Instead we control exactly how the indentation must be done.  The
  following complete key sequences demonstrates a few examples of
  rigid indentation:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x TAB&lt;/code&gt;: Interactively indent region.
    Type &lt;code&gt;&amp;lt;right&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;left&amp;gt;&lt;/code&gt; to
    increase or decrease indentation by one space respectively.
    Type &lt;code&gt;&amp;lt;right&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;left&amp;gt;&lt;/code&gt; to
    increase or decrease indentation by one tab stop respectively.
  &lt;/li&gt;
  &lt;li&gt;
	&lt;code&gt;C-6 C-x TAB&lt;/code&gt;: Indent region by 6 spaces.  Appropriate
	number of tabs and spaces are inserted to achieve an apparent 6
	spaces of indentation.  Whether tabs are inserted or not and how
	many tabs are inserted depend on the values
	of &lt;code&gt;indent-tabs-mode&lt;/code&gt; and &lt;code&gt;tab-width&lt;/code&gt; as
	explained in the previous sections.
  &lt;/li&gt;
  &lt;li&gt;
	&lt;code&gt;C-- C-6 C-x TAB&lt;/code&gt;: Reduce indentation of region by 6
	spaces.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;sorting&quot;&gt;Sorting&lt;/h2&gt;
&lt;p&gt;
  Assuming a region is active, here are some complete key sequences
  for various sorting commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x sort-lines RET&lt;/code&gt;: Sort lines alphabetically.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-x sort-lines RET&lt;/code&gt;: Reverse sort lines
    alphabetically.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x sort-fields RET&lt;/code&gt;: Sort lines alphabetically by the
    first field alphabetically.  Fields are separated by whitespace.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-2 M-x sort-fields RET&lt;/code&gt;: Sort lines alphabetically
    by the second field.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-2 M-x sort-numeric-fields RET&lt;/code&gt;: Sort lines
    numerically by the second field.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x sort-columns RET&lt;/code&gt;: Sort columns between the column
    position of mark and column position of point.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x sort-regexp-fields RET [A-Z]*-&amp;gt;\(.*\) RET \1 RET&lt;/code&gt;:
    Sort the strings in each line matched by the given regular
    expression by the field matched by the first (and the only)
    capturing group in the regular expression.  The part of each line
    that is not matched by the regular expression remains intact.
    They never move.  Only the part of each line that is matched by
    the regular expression moves around during the sorting operation.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x sort-regexp-fields RET&lt;/code&gt;: Sort paragraphs
    alphabetically.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;aligning&quot;&gt;Aligning&lt;/h2&gt;
&lt;p&gt;
  The two simple commands for aligning text introduced first in the
  book are:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x align RET&lt;/code&gt;: Aligns current region.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x align-current RET&lt;/code&gt;: Aligns current section.  A
    section is a group of consecutive lines both below, above and
    including the current line for which the first alignment rule
    (according to the major mode) applies.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Consider the following Elisp buffer:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defvar person &apos;((&quot;name&quot; . &quot;Alice&quot;)
                 (&quot;city&quot; . &quot;London&quot;)
                 (&quot;country&quot; . &quot;UK&quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  If we type &lt;code&gt;C-x h&lt;/code&gt; followed by &lt;code&gt;M-x align RET&lt;/code&gt;
  or if we put the cursor on any line of the above code and
  type &lt;code&gt;M-x align-current RET&lt;/code&gt;, we get the following
  result:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defvar alice &apos;((&quot;name&quot;    . &quot;Alice&quot;)
                (&quot;city&quot;    . &quot;London&quot;)
                (&quot;country&quot; . &quot;UK&quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  There is also an &lt;code&gt;align-regexp&lt;/code&gt; command that allows us to
  parts of lines by regular expressions.  The following experiments
  demonstrate this command.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    First create a buffer with the following text:
&lt;pre&gt;&lt;code&gt;Alice:London:UK
Bob:Paris:France
Carol:Tokyo:Japan&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-x h&lt;/code&gt; followed by &lt;code&gt;C-u M-x align-regexp
        \(\s-*\): RET 1 RET 1 RET y RET&lt;/code&gt;.  The result looks like
        this:
    &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Alice :London :UK
Bob   :Paris  :France
Carol :Tokyo  :Japan&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      Note that the regular expression capturing
      group &lt;code&gt;\(\s-*\)&lt;/code&gt; appears as the default in the
      minibuffer.  We only add &lt;code&gt;:&lt;/code&gt; to it.  Similarly the
      two occurrences of &lt;code&gt;1&lt;/code&gt; appear as default values.  The
      first &lt;code&gt;1&lt;/code&gt; is the default for determining which
      parenthesis group to modify.  The second &lt;code&gt;1&lt;/code&gt; is the
      default for amount of spacing to be used during alignment.
      The &lt;code&gt;y&lt;/code&gt; in the end specifies that we want to repeat
      the alignment throughout the line.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
      Type &lt;code&gt;C-/&lt;/code&gt; to undo the changes done in the last step.
      Then type &lt;code&gt;C-x h&lt;/code&gt; followed by &lt;code&gt;M-x align-regexp
      : RET&lt;/code&gt;.  This is a shorter equivalent to the previous
      command.  The output is same as before.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-/&lt;/code&gt; to undo the changes done in the last step.
      Then type &lt;code&gt;C-x h&lt;/code&gt; followed by &lt;code&gt;C-u M-x
      align-regexp :\(\s-*\) RET 1 RET 1 y RET&lt;/code&gt;.  Note that the
      only difference this time is that we place the colon before the
      parenthesis group.  The result looks like this:
    &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Alice: London: UK
Bob:   Paris:  France
Carol: Tokyo:  Japan&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-/&lt;/code&gt; to undo the changes done in the last step.
      Then type &lt;code&gt;C-x h&lt;/code&gt; followed by &lt;code&gt;C-u M-x
      align-regexp \(\s-*\): RET 1 RET 0 y RET&lt;/code&gt;.  Note that the
      only difference this time is that we place the colon before the
      parenthesis group.  We specify &lt;code&gt;0&lt;/code&gt; as the amount of
      spacing this time, so a minimum of zero spacing is used for
      alignment when possible.  The result looks like the following.
      Notice the lack of space after &lt;code&gt;Alice&lt;/code&gt;
      and &lt;code&gt;Carol&lt;/code&gt;.
    &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Alice:London:UK
Bob  :Paris :France
Carol:Tokyo :Japan&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-/&lt;/code&gt; to undo the changes done in the last step.
      Then type &lt;code&gt;C-x h&lt;/code&gt; followed by &lt;code&gt;C-u M-x
      align-regexp \(\s-*\): RET 1 RET 5 y RET&lt;/code&gt;.  Note that the
      only difference this time is that we place the colon before the
      parenthesis group.  We specify &lt;code&gt;5&lt;/code&gt; as the amount of
      spacing this time, so a minimum of 5 spaces are used for
      alignment.
    &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Alice     :London     :UK
Bob       :Paris      :France
Carol     :Tokyo      :Japan&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;zap-to-char&quot;&gt;Zap to Char&lt;/h2&gt;
&lt;p&gt;
  The steps below demonstrate the &lt;code&gt;zap-to-char&lt;/code&gt; command
  that is bound to the key sequence &lt;code&gt;M-z&lt;/code&gt;.  This command
  kills up to and including the given character.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Create a buffer with the following text:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;foo bar baz qux quux&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-&amp;lt;&lt;/code&gt; to go to the beginning of the buffer
      and then type &lt;code&gt;M-z r&lt;/code&gt; to kill text up to and
      including the first occurrence of the letter &lt;code&gt;r&lt;/code&gt;.
      The buffer now looks like this:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;  baz qux quux&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-&amp;lt;&lt;/code&gt; to go to the beginning of the buffer
      and then type &lt;code&gt;M-z x&lt;/code&gt; to kill text up to and
      including the first occurrence of the letter &lt;code&gt;x&lt;/code&gt;.
      The buffer now looks like this:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt; quux&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now type &lt;code&gt;C-e SPC C-y&lt;/code&gt; to reinsert the killed text at
      the end of the line.  The buffer now looks like this:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt; quux foo bar baz qux&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      Note that the last step yanks both chunks of text that were
      killed in the previous two steps.  This is due to the fact that
      consecutive kills append to the same stretch of text in the kill
      ring.  This fact was discussed earlier in
      section &lt;a href=&quot;#append-kill&quot;&gt;Append Kill&lt;/a&gt;
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now type &lt;code&gt;M-&amp;lt;&lt;/code&gt; to go back to the beginning of the
      buffer again.  Then type &lt;code&gt;M-2 M-z a&lt;/code&gt;.  The numeric
      argument &lt;code&gt;2&lt;/code&gt; specifies that we want to zap up to the
      second occurrence of the letter &lt;code&gt;a&lt;/code&gt;.  The buffer
      looks like this:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;z qux&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-e SPC C-y&lt;/code&gt; to reinsert the text killed in the
      previous step at the end of the line.  The buffer looks like
      this now:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;z qux quux foo bar ba&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-- M-2 M-z x&lt;/code&gt; to zap backward up to the second
      occurrence of the letter &lt;code&gt;x&lt;/code&gt;.  The buffer looks like
      this now:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;z qu&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;zap-up-to-char&quot;&gt;Zap up to Char&lt;/h2&gt;
&lt;p&gt;
  Here are some steps that demonstrate the &lt;code&gt;zap-up-to-char&lt;/code&gt;
  command.  This command kills text up to, but not including, the
  given character.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Create a buffer with the following text:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;foo bar baz qux quux&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-&amp;lt;&lt;/code&gt; to go to the beginning of the buffer.
      Then type &lt;code&gt;M-x zap-up-to-char RET b&lt;/code&gt;.  The result now
      looks like this:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;bar baz qux quux&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-2 M-x zap-up-to-char RET q&lt;/code&gt;.  The result now
      looks like this:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;quux&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-e SPC C-y&lt;/code&gt; to reinsert the killed text at the end
      of the buffer:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;quux foo bar baz qux &lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-- M-2 M-x zap-up-to-char RET b&lt;/code&gt;.  The buffer
      now looks like this:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;quux foo b&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  The author of the book suggests binding this command
  to &lt;code&gt;M-S-z&lt;/code&gt; with the following Elisp code:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(global-set-key (kbd &quot;M-S-z&quot;) &apos;zap-up-to-char)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The above code, however, does not create the binding successfully.
  Therefore, use the following Elisp code instead:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(global-set-key (kbd &quot;M-Z&quot;) &apos;zap-up-to-char)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Now the commands presented in this section above can be typed as
  follows:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;M-Z b&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;M-2 M-Z q&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;M-- M-Z b&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;spell-check&quot;&gt;Spell Check&lt;/h2&gt;
&lt;p&gt;
  The spell checking commands of Emacs require a spell checking
  program to be installed on the system.  Emacs supports the spell
  checking programs &lt;code&gt;aspell&lt;/code&gt;, &lt;code&gt;ispell&lt;/code&gt;,
  &lt;code&gt;hunspell&lt;/code&gt; and &lt;code&gt;enchant-2&lt;/code&gt;.  If multiple
  programs are present, it looks for them one by one in the order
  specified in the previous sentence and picks the first one that is
  found.  The following spell checking commands are introduced in the
  book:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-$&lt;/code&gt;: Check spelling of word under or before the
    cursor.  Possible corrections are offered in a new window.  If the
    word under or before the cursor is already correct, a message
    like &lt;code&gt;APPLE is correct&lt;/code&gt; appears in the echo area.  When
    corrections are offered, each correction is numbered.
    Type &lt;code&gt;SPC&lt;/code&gt; to leave the word unchanged or type a number
    to choose a numbered correction.  Type &lt;code&gt;x&lt;/code&gt; to exit the
    the spelling buffer (the one that shows corrections).
    Type &lt;code&gt;q&lt;/code&gt; to quit the spelling session (kills the
    spelling program process).  To see the list of all key bindings
    supported, type &lt;code&gt;C-h f ispell-help RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x flyspell-mode RET&lt;/code&gt;: Toggle on-the-fly spell
    checking.  Misspelled words are underlined with squiggly lines.
    Type &lt;code&gt;C-M-i&lt;/code&gt; or &lt;code&gt;C-.&lt;/code&gt; to correct a
    misspelled word under or before the cursor.  All possible
    corrections appear in the echo area.  Repeat &lt;code&gt;C-M-i&lt;/code&gt;
    or &lt;code&gt;C-.&lt;/code&gt; to cycle through the possible corrections.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x flyspell-prog-mode RET&lt;/code&gt;: Turns
    on &lt;code&gt;flyspell-mode&lt;/code&gt; for comments and strings only.  This
    is useful while working in a buffer with a programming mode
    enabled.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x ispell-buffer RET&lt;/code&gt;: Check the current buffer for
    spelling errors interactively.  Each misspelled word is
    highlighted and corrections are offered in a new window.  The
    interface and key sequences for making corrections are the same as
    the ones for &lt;code&gt;M-$&lt;/code&gt; introduced above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x ispell-region RET&lt;/code&gt;: Like the previous command but
    checks the current region for spelling errors.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;dictionary-lookup&quot;&gt;Dictionary Lookup&lt;/h2&gt;
&lt;p&gt;
  The following complete key sequences demonstrate some of the
  dictionary commands introduced in the book:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x dictionary-lookup-definition RET&lt;/code&gt;: Look up
    definitions of the word at or before the cursor.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x dictionary-search RET programming RET&lt;/code&gt;: Search
    definitions of the word &lt;code&gt;programming&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x dictionary-select-dictionary RET&lt;/code&gt;: This command
    presents a list of available dictionaries in a new buffer.
    Navigate the buffer and click on a dictionary or
    type &lt;code&gt;RET&lt;/code&gt; while the cursor is on a dictionary entry to
    select it.  For example, move the cursor down to the entry that
    begins with the text &lt;code&gt;jargon:&lt;/code&gt; and
    type &lt;code&gt;RET&lt;/code&gt; and then type &lt;code&gt;M-x dictionary-search
    RET programming RET&lt;/code&gt; to see the definition of the
    word &lt;code&gt;programming&lt;/code&gt; from the Jargon File only.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The dictionary commands first attempt to connect to a locally
  running dictionary server.  If the connection does not succeed, it
  prompts for consent to connect to
  &lt;a href=&quot;https://dict.org/&quot;&gt;dict.org&lt;/a&gt;.  Typing &lt;code&gt;y&lt;/code&gt; at
  the prompt allows the command to proceed and complete the command.
&lt;/p&gt;
&lt;h2 id=&quot;quoted-insert&quot;&gt;Quoted Insert&lt;/h2&gt;
&lt;p&gt;
  Here are some complete key sequences that demonstrate quoted insert:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-q C-l&lt;/code&gt;: Insert form feed character.  This is
    displayed as &lt;samp&gt;^L&lt;/samp&gt; in Emacs using the face
    named &lt;code&gt;escape-glyph&lt;/code&gt;.  Emacs treats each form feed
    character as a page break and we can navigate back and forth
    between pages with &lt;code&gt;C-x [&lt;/code&gt; and &lt;code&gt;C-x ]&lt;/code&gt;
    respectively.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-q (&lt;/code&gt;: Insert a literal open parenthesis.  Useful
    in &lt;code&gt;paredit-mode&lt;/code&gt; where the key sequence &lt;code&gt;(&lt;/code&gt;
    is bound to &lt;code&gt;paredit-open-round&lt;/code&gt; which inserts a
    balanced pair of parentheses.  To insert a single parenthesis
    instead, we can perform a quoted insert with &lt;code&gt;C-q (&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-q TAB&lt;/code&gt;: Insert a literal tab character.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-q C-j&lt;/code&gt;: Insert a literal line feed character, i.e.
    a newline character.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-q RET&lt;/code&gt;: Insert a literal carriage return.  This is
    displayed as &lt;samp&gt;^M&lt;/samp&gt; in Emacs.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-q ESC&lt;/code&gt;: Insert a literal escape character.  This is
    displayed as &lt;samp&gt;^[&lt;/samp&gt; in Emacs.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-q C-[&lt;/code&gt;: Same as above.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;
&lt;p&gt;
  The following list includes some links that were discussed during
  the book discussion group meetings:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://battlepenguin.com/tech/aspell-and-hunspell-a-tale-of-two-spell-checkers/&quot;&gt;Aspell and Hunspell: A Tale of Two Spell Checkers&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://www.reddit.com/r/emacs/comments/fxs92h/&quot;&gt;Spell
      checkers in Emacs in 2020&lt;/a&gt;
  &lt;/li&gt;
&lt;/ul&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/ch05.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>From Lunar Phases to Yank-Pop</title>
    <link href="https://susam.net/from-lunar-phases-to-yank-pop.html"/>
    <id>urn:uuid:9356bef4-d66d-49cc-9878-bc08d08e9489</id>
    <updated>2023-04-02T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;h2 id=&quot;tiny-book-club&quot;&gt;Tiny Book Club&lt;/h2&gt;
&lt;p&gt;
  We have a &lt;a href=&quot;cc/mastering-emacs/&quot;&gt;tiny book
  club&lt;/a&gt; that meets every weekend to read and discuss the
  book &lt;em&gt;&lt;a href=&quot;https://www.masteringemacs.org/&quot;&gt;Mastering
  Emacs&lt;/a&gt;&lt;/em&gt;, 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 &lt;a href=&quot;cc/mastering-emacs/log.html#36&quot;&gt;36 meetings&lt;/a&gt; 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&amp;half; months, we have completed four chapters of the book.
  We are currently reading the fifth chapter.  In this post, I&apos;ll
  share what the journey has been like so far and a few interesting
  things we have learnt.
&lt;/p&gt;
&lt;p&gt;
  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.
&lt;/p&gt;
&lt;p&gt;
  This is the second series of such meetings I have been hosting.  The
  first one was about &lt;a href=&quot;cc/iant/&quot;&gt;analytic number
  theory&lt;/a&gt; that began in March 2021.  It ran for seven months and
  finally &lt;a href=&quot;final-iant-meeting.html&quot;&gt;concluded&lt;/a&gt; in October
  2021 after 120 meetings.  I chose Emacs as the topic for the next
  series.  The book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen seemed
  like a great choice for it.
&lt;/p&gt;
&lt;p&gt;
  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.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#tiny-book-club&quot;&gt;Tiny Book Club&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#variety-of-professions&quot;&gt;Variety of Professions&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#lunar-phases&quot;&gt;Lunar Phases&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#returning-to-mark&quot;&gt;Returning to Mark&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#working-with-other-windows&quot;&gt;Working With Other Windows&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#tab-bars&quot;&gt;Tab Bars&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#back-to-indentation&quot;&gt;Back to Indentation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#exchange-point-and-mark&quot;&gt;Exchange Point and Mark&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#search-toggles&quot;&gt;Search Toggles&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#word-sequence-search&quot;&gt;Word Search Mode&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#occur-mode&quot;&gt;Occur Mode&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#imenu&quot;&gt;Imenu&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#helm&quot;&gt;Helm&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#appending-kills&quot;&gt;Appending Kills&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#yank-pop&quot;&gt;Yank-Pop&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#join-us&quot;&gt;Join Us&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;variety-of-professions&quot;&gt;Variety of Professions&lt;/h2&gt;
&lt;p&gt;
  Most members of our discussion group come from
  the &lt;code&gt;#emacs&lt;/code&gt; 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!
&lt;/p&gt;
&lt;p&gt;
  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&apos;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.
&lt;/p&gt;
&lt;h2 id=&quot;lunar-phases&quot;&gt;Lunar Phases&lt;/h2&gt;
&lt;p&gt;
  Yes, we can see the lunar phases calendar right within Emacs!  I
  don&apos;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 &lt;a href=&quot;dark-night-skies.html&quot;&gt;since my
  childhood days&lt;/a&gt;, I found this very exciting.  Type &lt;code&gt;M-x
  lunar-phases RET&lt;/code&gt; in your Emacs and a new buffer appears with
  an output like this:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;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)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  It also shows the upcoming eclipses!  In fact, there is one coming
  up this month!  Isn&apos;t this nice?  I knew that Emacs has all sorts of
  fun stuff like &lt;code&gt;M-x zone RET&lt;/code&gt; to zone out with a built-in
  screensaver, &lt;code&gt;M-x tetris RET&lt;/code&gt; to play a clone of the
  famous puzzle game, &lt;code&gt;M-: (animate-string &quot;hello&quot; 0) RET&lt;/code&gt;
  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.
&lt;/p&gt;
&lt;p&gt;
  For people who are not familiar with Emacs notation for key binding,
  note that &lt;code&gt;M-x lunar-phases RET&lt;/code&gt; means
  typing &lt;kbd&gt;alt&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; followed by
  typing &lt;code&gt;lunar-phases&lt;/code&gt; and then pressing &lt;kbd&gt;enter&lt;/kbd&gt;.
  The notation &lt;code&gt;M-&lt;/code&gt; represents the meta modifier key which
  is mapped to &lt;kbd&gt;alt&lt;/kbd&gt; on modern systems.
&lt;/p&gt;
&lt;h2 id=&quot;returning-to-mark&quot;&gt;Returning to Mark&lt;/h2&gt;
&lt;p&gt;
  Most members knew that we can set a mark with &lt;code&gt;C-SPC&lt;/code&gt;
  (i.e. &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;space&lt;/kbd&gt;) and then move around in the
  buffer with motion keys to highlight a region that we can cut
  with &lt;code&gt;C-w&lt;/code&gt; or copy with &lt;code&gt;M-w&lt;/code&gt; and paste it
  elsewhere with &lt;code&gt;C-y&lt;/code&gt;.  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 &lt;code&gt;C-u
  C-SPC&lt;/code&gt;.  But there is a problem.
&lt;/p&gt;
&lt;p&gt;
  When we set a &lt;em&gt;mark&lt;/em&gt; with &lt;code&gt;C-SPC&lt;/code&gt; and start moving
  around with motion keys, the text between the mark and the current
  position of the cursor (known as &lt;em&gt;point&lt;/em&gt; 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 &lt;code&gt;transient-mark-mode&lt;/code&gt;, is there a simple way?
  Yes, there is a simple trick.  Type &lt;code&gt;C-SPC C-SPC&lt;/code&gt; to set
  the mark!  Typing &lt;code&gt;C-SPC&lt;/code&gt; 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 &lt;code&gt;C-u C-SPC&lt;/code&gt; to return
  to mark.
&lt;/p&gt;
&lt;p&gt;
  The key sequences involved are pretty convenient.
  Typing &lt;code&gt;C-SPC C-SPC&lt;/code&gt; involves holding down
  the &lt;kbd&gt;ctrl&lt;/kbd&gt; key, then typing &lt;kbd&gt;space&lt;/kbd&gt; twice and
  finally releasing the &lt;kbd&gt;ctrl&lt;/kbd&gt; key.  Similarly,
  typing &lt;code&gt;C-u C-SPC&lt;/code&gt; involves holding down
  the &lt;kbd&gt;ctrl&lt;/kbd&gt; key, typing &lt;kbd&gt;u&lt;/kbd&gt;, then &lt;kbd&gt;space&lt;/kbd&gt;
  and then releasing the &lt;kbd&gt;ctrl&lt;/kbd&gt; key.  Three keystrokes for
  each command.  They become muscle memory in no time!
&lt;/p&gt;
&lt;h2 id=&quot;working-with-other-windows&quot;&gt;Working With Other Windows&lt;/h2&gt;
&lt;p&gt;
  In Chapter 4, &lt;em&gt;The Theory of Movement&lt;/em&gt;, there is a section
  about working with other windows.  There are a number of key
  bindings available under the prefix key &lt;code&gt;C-x 4&lt;/code&gt; that
  perform operations on another window instead of the current window.
  For example, &lt;code&gt;C-x 4 C-f&lt;/code&gt; opens a file in another window.
  This could be a faster alternative to splitting the current window
  with &lt;code&gt;C-x 2&lt;/code&gt; or &lt;code&gt;C-x 3&lt;/code&gt; and then opening a
  file with &lt;code&gt;C-x C-f&lt;/code&gt;.  The single key sequence &lt;code&gt;C-x 4
  C-f&lt;/code&gt; takes care of splitting the current window into two if
  another window does not exist and opening the file there.  Moreover
  if another window does exist, this key sequence just reuses that
  window to open the file there.  Pretty nifty!
&lt;/p&gt;
&lt;p&gt;
  To see all the commands under the &lt;code&gt;C-x 4&lt;/code&gt; prefix key,
  type &lt;code&gt;C-x 4 C-h&lt;/code&gt;.  Yet another such command that I found
  quite convenient is &lt;code&gt;C-x 4 d&lt;/code&gt; which opens Dired in
  another window.  This can be useful when we need to browse a
  directory without hiding the current buffer.
&lt;/p&gt;
&lt;h2 id=&quot;tab-bars&quot;&gt;Tab Bars&lt;/h2&gt;
&lt;p&gt;
  One of the many features of Emacs that most of us did not bother
  paying attention to earlier was the tab bar mode.  Turns out it is
  pretty useful in managing multiple window configurations
  side-by-side.  Each tab can be used as a workspace with a specific
  arrangement of windows that suits our workflow in that workspace.
  For example, we could arrange one tab to have three windows to
  display source code, a debugger and the current directory in Dired
  mode.  Then we could have another tab with two windows beside each
  other, perhaps one to display some source code and another to run
  the terminal.
&lt;/p&gt;
&lt;p&gt;
  The tab management commands are very similar to window management
  commands.  Just like &lt;code&gt;C-x 2&lt;/code&gt; splits a window to create a
  new window, &lt;code&gt;C-x t 2&lt;/code&gt; creates a new tab.  Just
  like &lt;code&gt;C-x 0&lt;/code&gt; deletes a window, &lt;code&gt;C-x t 0&lt;/code&gt;
  deletes a tab.  Similarly, &lt;code&gt;C-x t o&lt;/code&gt; switches to the next
  tab.  Tabs can be renamed and moved too with some more key bindings.
  Chapter 4 has a section called &lt;em&gt;Tab Bar Mode&lt;/em&gt; that introduces
  these operations in detail.
&lt;/p&gt;
&lt;h2 id=&quot;back-to-indentation&quot;&gt;Back to Indentation&lt;/h2&gt;
&lt;p&gt;
  Almost everyone knew that &lt;code&gt;C-a&lt;/code&gt; moves the cursor to the
  beginning of the current line.  But not many of us knew
  about &lt;code&gt;M-m&lt;/code&gt; which invokes the
  command &lt;code&gt;back-to-indentation&lt;/code&gt;.  This command moves the
  cursor to the first non-whitespace character on the current line.
  This is another new thing some of us learnt from the book.  This can
  be quite useful while editing code.
&lt;/p&gt;
&lt;h2 id=&quot;exchange-point-and-mark&quot;&gt;Exchange Point and Mark&lt;/h2&gt;
&lt;p&gt;
  Let us say we set a mark somewhere with &lt;code&gt;C-SPC&lt;/code&gt; and then
  move around to select a region.  However, then we get distracted,
  possibly by some typo in our buffer and we begin fixing that.  At
  this point, the highlighted region disappears.  Say after fixing
  that typo, we want to resume with the region selection again.  What
  do we do now?  Do we go back to set the mark and begin selecting the
  region again?  Not really.  There is an easier way.  We can just
  type &lt;code&gt;C-x C-x&lt;/code&gt; to exchange the point and the mark and
  highlight the region in between.  This has the effect of
  reactivating the region.
&lt;/p&gt;
&lt;p&gt;
  Note that &lt;code&gt;C-x C-x&lt;/code&gt; &lt;em&gt;exchanges&lt;/em&gt; the point and the
  mark, so although it conveniently reactivates the region, the point
  jumps to where the mark was set earlier.  This could be quite far
  from where we want the cursor to be right now.  If you don&apos;t like
  that the cursor moves far way to the mark, just type &lt;code&gt;C-x
  C-x&lt;/code&gt; once again to exchange the point and mark one more time.
  This has the effect of returning the cursor back to wherever it was
  while keeping the region activated.
&lt;/p&gt;
&lt;h2 id=&quot;search-toggles&quot;&gt;Search Toggles&lt;/h2&gt;
&lt;p&gt;
  Say, we begin an incremental search of the literal
  string &lt;code&gt;f..&lt;/code&gt; in the current buffer with &lt;code&gt;C-s
  f..&lt;/code&gt; but then we change our mind and decide that we want to
  perform a regular-expression-based search using the regular
  expression &lt;code&gt;f..&lt;/code&gt;?  Do we cancel the incremental search
  and begin a new regular-expression-based search
  using &lt;code&gt;C-M-s&lt;/code&gt;?  That&apos;s not necessary.  Instead we can
  toggle the currently ongoing incremental search into a
  regular-expression-based search using the toggle key &lt;code&gt;M-s
  r&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  Another such nice toggle is &lt;code&gt;M-%&lt;/code&gt;.  You are likely aware
  of the global key binding &lt;code&gt;M-%&lt;/code&gt; used to invoke
  the &lt;code&gt;query-replace&lt;/code&gt; command that performs
  search-and-replace operation.  However, when typed during an ongoing
  incremental search, &lt;code&gt;M-%&lt;/code&gt; converts the ongoing
  incremental search to a search-and-replace operation.  This is
  really useful sometimes.  If we are searching for a complicated
  string, say, &lt;code&gt;C-s std::vector&amp;lt;int&amp;gt;&lt;/code&gt; but then we
  suddenly realise that we want to perform a search-and-replace
  operation instead with the same string, we don&apos;t really have to quit
  the current incremental search and start a new search-and-replace
  operation.  Instead we can simply change the current incremental
  search to a search-and-replace operation by typing &lt;code&gt;M-%&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  Similarly, we can toggle the case-sensitivity of the search
  using &lt;code&gt;M-s c&lt;/code&gt;.  If we type our search string in all
  lowercase (e.g. &lt;code&gt;C-s foo&lt;/code&gt;), then Emacs performs a
  case-sensitive search by default.  I think this is a reasonable
  default behaviour.  This is what we want most of the time.  When we
  do want case-sensitive search for a lowercase string, we can switch
  from the currently ongoing case-insensitive search to a
  case-sensitive search with the &lt;code&gt;M-s c&lt;/code&gt; toggle.
&lt;/p&gt;
&lt;p&gt;
  The moment we introduce an uppercase character in our search string
  (e.g. &lt;code&gt;C-s Foo&lt;/code&gt;), Emacs switches to case-sensitive mode.
  Although this behaviour may appear peculiar at first, it makes sense
  if you think about it.  If we have bothered to type an uppercase
  character in our search string, we probably care about the case, so
  Emacs switches to case-sensitive search in this case.  Once again,
  if this is not what we want, it is trivial to change the
  case-sensitive search to a case-insensitive one using the &lt;code&gt;M-s
  c&lt;/code&gt; toggle.
&lt;/p&gt;
&lt;p&gt;
 There are a number of other toggles available.  Chapter 4 has a
 pretty long subsection on incremental search.  That section discusses
 these toggles among many other things.
&lt;/p&gt;
&lt;h2 id=&quot;word-sequence-search&quot;&gt;Word Search Mode&lt;/h2&gt;
&lt;p&gt;
  Say, we start searching for the string &lt;code&gt;web_server&lt;/code&gt; in
  some code buffer with the key sequence &lt;code&gt;C-s web_server&lt;/code&gt;.
  But we soon realise that the code has the words &lt;code&gt;web&lt;/code&gt;
  and &lt;code&gt;server&lt;/code&gt; written together in all kinds of notation
  like &lt;code&gt;web-&amp;gt;server&lt;/code&gt;, &lt;code&gt;web::server&lt;/code&gt;,
  &lt;code&gt;web-server&lt;/code&gt; and even &lt;code&gt;web server&lt;/code&gt; (perhaps in
  inline comments).  We now decide that we want to match all of them.
  In most other editors, we&apos;ll probably have to cancel the current
  search and resort to a clever regular-expression-based search.  In
  Emacs, thanks to the toggles available in incremental search, we can
  type &lt;code&gt;M-s w&lt;/code&gt; and the currently ongoing incremental search
  will change itself to word search mode where it now matches all
  these other ways those two words are written.  In word search mode,
  Emacs searches for a sequence of words while ignoring any delimiters
  in between.
&lt;/p&gt;
&lt;h2 id=&quot;occur-mode&quot;&gt;Occur Mode&lt;/h2&gt;
&lt;p&gt;
  A very useful feature that has been in Emacs for a long time and yet
  was unknown to many of us is the occur mode.  Type &lt;code&gt;M-s o foo
  RET&lt;/code&gt; and it will pull up all matches for the regular
  expression &lt;code&gt;foo&lt;/code&gt; in the current buffer and display the
  matches in a new buffer.  Now we can stay in the same buffer where
  we have our text and jump to the places where the matches are found
  using &lt;code&gt;M-g M-n&lt;/code&gt; and &lt;code&gt;M-g M-p&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  It is also possible to convert an ongoing incremental search into an
  occur mode search using the toggle &lt;code&gt;M-s o&lt;/code&gt;.  For example,
  type &lt;code&gt;C-s foo&lt;/code&gt; to start an incremental search for the
  string &lt;code&gt;foo&lt;/code&gt;, then type &lt;code&gt;M-s o&lt;/code&gt; and, lo and
  behold, we are now in occur mode searching for the
  string &lt;code&gt;foo&lt;/code&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;imenu&quot;&gt;Imenu&lt;/h2&gt;
&lt;p&gt;
  Right after the section on occur mode, the book presents a section
  about Imenu which was also new to some of us.  Type &lt;code&gt;M-x imenu
  RET&lt;/code&gt; and then type &lt;code&gt;TAB&lt;/code&gt; to invoke auto-completion
  and it shows a list of all interesting places in the buffer to jump
  too.  For example, if the current buffer is a Python source code
  file, then the output of this command includes all functions in the
  Python file we can jump to.  Use auto-completion to complete a
  function name and Imenu takes us to the place where the function is
  defined.
&lt;/p&gt;
&lt;p&gt;
  After completing the sections on occur mode and Imenu, I remember
  multiple members of our group mentioning that they now want to adopt
  occur mode and Imenu into their workflow.  In fact, it may make
  sense to bind Imenu to a convenient key binding.  The author of the
  book recommends binding it to &lt;code&gt;M-i&lt;/code&gt;.  However, I do
  use &lt;code&gt;M-i&lt;/code&gt; sometimes to insert spaces until the next
  tab-stop column, so I&apos;ll suggest a different key binding that is
  more consistent with Emacs
  &lt;a href=&quot;https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html&quot;&gt;key binding conventions&lt;/a&gt;.
  These conventions suggest that key bindings of the
  form &lt;code&gt;C-c &lt;em&gt;letter&lt;/em&gt;&lt;/code&gt; are reserved for the users.
  Therefore, I suggest the key binding &lt;code&gt;C-c i&lt;/code&gt; to invoke
  Imenu.  Here is some Elisp code to create this key binding:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(global-set-key (kbd &quot;C-c i&quot;) &apos;imenu)&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;helm&quot;&gt;Helm&lt;/h2&gt;
&lt;p&gt;
  Helm is a powerful &lt;em&gt;filter-as-you-type&lt;/em&gt; framework.  Most of
  us already knew about this package.  It does too many things and has
  too many key bindings.  We can barely scratch the surface in a small
  section like this.  But since we discussed Imenu in the previous
  section, I&apos;ll mention here that Helm provides a rather nice
  interface to Imenu.  Helm can be enabled with &lt;code&gt;M-x helm-mode
  RET&lt;/code&gt; or with &lt;code&gt;(helm-mode)&lt;/code&gt; in an Emacs
  initialisation file.  Once enabled, &lt;code&gt;C-x c i&lt;/code&gt; runs
  the &lt;code&gt;helm-imenu&lt;/code&gt; command which provides an interactive
  interface with all options laid out in a vertical format.  We can
  use the motion keys to select an option.  We can then
  type &lt;kbd&gt;enter&lt;/kbd&gt; to activate the selection and jump to the
  corresponding place in the buffer.
&lt;/p&gt;
&lt;p&gt;
  Helm also provides a nice interface for occur mode in the form
  of &lt;code&gt;helm-occur&lt;/code&gt; command.  The key sequence for it
  is &lt;code&gt;C-x c M-s o&lt;/code&gt;, which one might argue is not a very
  convenient key binding.  Nevertheless, the user interface to
  navigate the matches is pretty good.
&lt;/p&gt;
&lt;h2 id=&quot;appending-kills&quot;&gt;Appending Kills&lt;/h2&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;C-M-w&lt;/code&gt; is used to ensure that if the
  next command happens to be a kill command, then the killed text is
  appended to the last stretch of text in the kill ring.  This key
  sequence prevents the next kill from creating a new entry in the
  kill ring.
&lt;/p&gt;
&lt;p&gt;
  To understand what this command does we must first understand that
  after a kill command adds some new text to the kill ring, subsequent
  consecutive kills append to the same stretch of text in the kill
  ring, i.e. consecutive kills form a single large stretch of text in
  the kill ring.  This can be tested by performing consecutive kills
  and then pasting with &lt;code&gt;C-y&lt;/code&gt;.  For example, &lt;code&gt;M-d M-d
  M-d&lt;/code&gt; kills 3 words and creates a single stretch of text
  consisting of those 3 words.  The consecutive kills keep adding to
  the same kill entry in the kill ring.  If we type &lt;code&gt;C-y&lt;/code&gt;
  now, it would yank the newest entry consisting of those 3 words from
  the kill ring and paste it into the buffer.
&lt;/p&gt;
&lt;p&gt;
  However, the moment a non-kill command is used, it seals the current
  entry in the kill ring.  Any subsequent kill command creates a new
  entry in the kill ring.  For example, &lt;code&gt;M-d M-d M-d C-p M-d M-d
  C-p C-p C-y&lt;/code&gt; kills 3 words at first but then it moves to the
  previous line sealing that kill entry consisting of 3 words.  Then
  it kills 2 more words and adds them to a new entry in the kill ring.
  Therefore, the final yank command pastes only those 2 words from the
  kill ring.
&lt;/p&gt;
&lt;p&gt;
  This can be a problem if we want to kill text from various parts of
  the buffer and yet create a single entry in the kill ring.  That&apos;s
  when &lt;code&gt;C-M-w&lt;/code&gt; comes useful.  For example, &lt;code&gt;M-d M-d
  M-d C-p C-M-w M-d M-d C-p C-p C-y&lt;/code&gt; kills 3 words and creates a
  single entry in the kill ring consisting of those 3 words.  Then it
  moves one line up and kills 2 more words but this time it appends
  those 2 words to the existing entry in the kill ring.  Finally, it
  moves two lines up and pastes the entire kill entry consisting of 5
  words into the buffer.
&lt;/p&gt;
&lt;h2 id=&quot;yank-pop&quot;&gt;Yank-Pop&lt;/h2&gt;
&lt;p&gt;
  Although most beginners and experienced users of Emacs know that
  killed text goes into the kill ring and we can yank the last kill
  from kill ring and paste it into the buffer using &lt;code&gt;C-y&lt;/code&gt;,
  for many that&apos;s where the usage of kill ring stops.  The kill ring,
  however, has much more utility than that.  It is a &lt;em&gt;ring&lt;/em&gt;,
  after all!  We can keep killing text as we edit text and all killed
  text gets added to the kill ring.  Now &lt;code&gt;C-y&lt;/code&gt; always yanks
  the newest kill in the kill ring and pastes it in the buffer?  Can
  we recall an older kill?  Yes, using the &lt;code&gt;M-y&lt;/code&gt; key
  sequence.  This key sequence invokes the &lt;code&gt;yank-pop&lt;/code&gt;
  command that replaces a just-yanked stretch of killed text with an
  older kill.  It takes a little bit of getting used to but once this
  becomes muscle memory, the kill ring becomes a very powerful tool.
  We can keep dumping text to the kill ring and keep recalling text
  from it while performing our editing activities.  The following
  exercise shows how &lt;code&gt;C-y&lt;/code&gt; and &lt;code&gt;M-y&lt;/code&gt; can be used
  together.
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    Open a new file, say, with &lt;code&gt;C-x C-f foo.txt RET&lt;/code&gt; and
    type these five words in a single line: &lt;code&gt;foo bar baz qux
    quux&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Then type &lt;code&gt;C-a M-d C-g M-d C-g M-d&lt;/code&gt;.  At this point
    three stretches of text have been inserted into the kill ring.
    The &lt;code&gt;C-g&lt;/code&gt; between every &lt;code&gt;M-d&lt;/code&gt; is there only
    to avoid appending kills to the existing stretch of text in the
    kill ring.  This ensures that we have three separate kills in the
    kill ring.
  &lt;/li&gt;
  &lt;li&gt;
    Now type &lt;code&gt;C-y&lt;/code&gt;.  The last kill, i.e. &lt;code&gt;baz&lt;/code&gt;
    is now pasted into the buffer.
  &lt;/li&gt;
  &lt;li&gt;
    Now without typing any other key sequence, type &lt;code&gt;M-y&lt;/code&gt;.
    The earlier pasted text &lt;code&gt;baz&lt;/code&gt; is now replaced with an
    older stretch of text from the kill ring.  Thus &lt;code&gt;baz&lt;/code&gt;
    is replaced with &lt;code&gt;bar&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Now once again type &lt;code&gt;M-y&lt;/code&gt;.  The earlier pasted
    text &lt;code&gt;bar&lt;/code&gt; is now replaced with a further older stretch
    of text from the kill ring.  Thus &lt;code&gt;bar&lt;/code&gt; is replaced
    with &lt;code&gt;foo&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
  Note in the previous steps how we are not supposed to type any other
  key between the first &lt;code&gt;C-y&lt;/code&gt; and &lt;code&gt;M-y&lt;/code&gt;.
  Similarly, while cycling through the kill ring, we must not type any
  other key between the consecutive &lt;code&gt;M-y&lt;/code&gt; key sequences.
  While cycling through the kill ring, when we reach the oldest kill,
  the next &lt;code&gt;M-y&lt;/code&gt; wraps around and brings back the newest
  kill.
&lt;/p&gt;
&lt;p&gt;
  Since Emacs 28, the key sequence &lt;code&gt;M-y&lt;/code&gt; also supports
  browsing the kill ring and yanking any arbitrary entry from the kill
  ring.  For example, after trying the above experiment,
  type &lt;code&gt;C-g&lt;/code&gt; just to make sure that we are breaking any
  existing &lt;code&gt;C-y&lt;/code&gt; or &lt;code&gt;M-y&lt;/code&gt; cycle.  Then
  type &lt;code&gt;M-y&lt;/code&gt; and a minibuffer prompt appears to yank an
  arbitrary kill from the kill ring.  If we remember the previous
  kill, we can type it out partially and type &lt;code&gt;TAB&lt;/code&gt; to
  autocomplete it.  Alternatively, we could also type &lt;code&gt;TAB&lt;/code&gt;
  initially itself to browse all the kills in the kill ring.
&lt;/p&gt;
&lt;h2 id=&quot;join-us&quot;&gt;Join Us&lt;/h2&gt;
&lt;p&gt;
  That was an account of our Mastering Emacs book club discussions so
  far and a few interesting things we learnt.  We have only recently
  begun reading Chapter 5 that introduces several editing and text
  manipulation commands.  This chapter is 75 pages long and it could
  take a month or two to complete this chapter.  There are two more
  chapters after that which are shorter in their lengths.  They
  discuss some practical aspects of Emacs along with a discussion on
  some popular packages.  We still have a long way to go before we can
  complete this book.
&lt;/p&gt;
&lt;p&gt;
  If all of this sounds like fun, you are very welcome to join our
  meetings.  Just head over to
  &lt;a href=&quot;cc/mastering-emacs/&quot;&gt;cc/mastering-emacs/&lt;/a&gt;
  and there you&apos;ll find everything you need to know in order to be a
  part of our book discussion group and join our meetings.  Looking
  forward to seeing you in our next meeting!
&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;
  &lt;strong&gt;Update on 30 Dec 2023:&lt;/strong&gt; Our discussions of this book
  concluded on 30 Dec 2023 after 72 meetings.  See the post
  &lt;a href=&quot;from-fill-prefix-to-tramp.html&quot;&gt;From Fill Prefix to Tramp&lt;/a&gt;
  for more highlights from these meetings.
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/from-lunar-phases-to-yank-pop.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Mastering Emacs: Chapter 4: The Theory of Movement</title>
    <link href="https://susam.net/cc/mastering-emacs/ch04.html"/>
    <id>urn:uuid:98f60488-e2c0-4cbf-9bb6-f8c10c2394d6</id>
    <updated>2023-03-25T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  The following notes were taken while discussing Chapter 4 of the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  An index of notes for all chapters are available
  at &lt;a href=&quot;notes.html&quot;&gt;notes.html&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#basics&quot;&gt;Basics&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#major-mode-load-order&quot;&gt;Major Mode Load Order&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#file-local-variables&quot;&gt;File-Local Variables&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#occur-mode&quot;&gt;Occur Mode&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;basics&quot;&gt;Basics&lt;/h2&gt;
&lt;p&gt;
  The following complete key sequences illustrate a few basic
  commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f foo.txt RET&lt;/code&gt;: Edit file
    named &lt;code&gt;foo.txt&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-s&lt;/code&gt;: Save current buffer to file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x b *scratch* RET&lt;/code&gt;: Switch to the buffer
    named &lt;code&gt;*scratch*&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x k *scratch* RET&lt;/code&gt;: Kill the buffer
    named &lt;code&gt;*scratch*&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x k RET&lt;/code&gt;: Kill current buffer.  In fact, like the
    previous key sequence above, typing &lt;code&gt;C-x k&lt;/code&gt; first
    prompts for the buffer name.  However, the current buffer name is
    selected as the default value already.  As a result,
    typing &lt;code&gt;RET&lt;/code&gt; kills the current buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-b&lt;/code&gt;: List buffers.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-c&lt;/code&gt;: Exit Emacs.  This command offers to save all
    unsaved buffers before exiting Emacs.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;ESC ESC ESC&lt;/code&gt;: This command exits the current context.
    What that means depends very much on the context.  It performs
    exactly one of the following actions: If there is an active
    region, then it is deactivated; if a minibuffer is open, it gets
    rid of it; if recursive edit is in progress, it quits one level of
    recursive editing; if multiple windows are open, it deletes other
    windows so that the current window becomes the only window in the
    frame.  The aforementioned conditions are tested one by one and as
    soon as one of the conditions is met, the corresponding action is
    executed and the other conditions are skipped.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-/&lt;/code&gt;: Undo changes.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;F10&lt;/code&gt;: Activate the menu bar.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  In my experience, I have found that &lt;code&gt;ESC ESC ESC&lt;/code&gt; is most
  useful when a stray minibuffer is open but the cursor is on some
  other buffer instead of the minibuffer and I need to close the
  minibuffer.  Here are some steps that demonstrate this usage:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x white&lt;/code&gt; and pause.  We now have a partially
      typed command in the minibuffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now pretend that we get distracted by some imperfections in the
      text buffer that was open earlier and we want to fix those
      first.  Type &lt;code&gt;C-x o&lt;/code&gt; to move away from the minibuffer
      and go back to the text buffer to perform some editing tasks.
    &lt;/p&gt;
    &lt;p&gt;
      In this step, we could have typed &lt;code&gt;C-g&lt;/code&gt; to quit the
      minibuffer first but we did not do that.  We pretended to get
      distracted by the text buffer and went straight to it from the
      minibuffer by typing &lt;code&gt;C-x o&lt;/code&gt;.  At this point, the
      cursor is in the text buffer and the minibuffer remains open at
      the bottom.  The open minibuffer can be distracting while
      performing the text editing tasks.  Typing &lt;code&gt;C-g&lt;/code&gt; now
      will not get rid of the minibuffer because the cursor is no
      longer in the minibuffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now one way to close the open minibuffer could be to
      type &lt;code&gt;C-x o&lt;/code&gt; to go back to the minibuffer window and
      type &lt;code&gt;C-g&lt;/code&gt;.  However, there is a more direct way to
      do this as explained in the next point.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;ESC ESC ESC&lt;/code&gt; to get rid of the minibuffer at
      the bottom.  This works even when the cursor is not in the
      minibuffer but is in the text buffer instead.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;major-mode-load-order&quot;&gt;Major Mode Load Order&lt;/h2&gt;
&lt;p&gt;
  The chapter mentions the following order for detecting major mode:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;File-local variables&lt;/li&gt;
  &lt;li&gt;Program loader directives&lt;/li&gt;
  &lt;li&gt;Magic mode detection&lt;/li&gt;
  &lt;li&gt;Automatic mode detection&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Let us start from the bottom of the list and share some experimental
  results that illustrate how the major mode detection works.
&lt;/p&gt;
&lt;h3 id=&quot;file-local-variables&quot;&gt;File-Local Variables&lt;/h3&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Create a text file named &lt;code&gt;foo.txt&lt;/code&gt; with the following
      content:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

int main() {
  std::cout &amp;lt;&amp;lt; &quot;hello, world\n&quot;;
  return 0;
}&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      Then open this file in Emacs (say, with &lt;code&gt;C-x C-f foo.txt
      RET&lt;/code&gt;).  Emacs sets the major mode to &lt;code&gt;Text&lt;/code&gt;
      (i.e. &lt;code&gt;text-mode&lt;/code&gt;).
    &lt;/p&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-: major-mode RET&lt;/code&gt; to confirm that indeed the
      value of &lt;code&gt;major-mode&lt;/code&gt; is &lt;code&gt;text-mode&lt;/code&gt;.
      This happens due to automatic mode detection which determines
      the major mode based on the file name.  In this case it sees
      that the file name ends with &lt;code&gt;.txt&lt;/code&gt; and
      enables &lt;code&gt;text-mode&lt;/code&gt;.  We will discuss automatic mode
      detection further in the
      section &lt;a href=&quot;#automatic-mode-detection&quot;&gt;Automatic Mode
      Detection&lt;/a&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now edit the previous file to add file-local variables in the
      header as follows:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;// -*- mode: c++; c-basic-offset: 4 -*-

#include &amp;lt;iostream&amp;gt;

int main() {
  std::cout &amp;lt;&amp;lt; &quot;hello, world\n&quot;;
  return 0;
}&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      Now reload the buffer.  You could simply kill the buffer
      with &lt;code&gt;C-x k&lt;/code&gt; and reopen the file with &lt;code&gt;C-x C-f
      foo.txt RET&lt;/code&gt; or alternatively, reload the buffer
      with &lt;code&gt;M-x revert-buffer RET yes RET&lt;/code&gt;.
    &lt;/p&gt;
    &lt;p&gt;
      After reloading the buffer, you should see that
      the &lt;code&gt;C++&lt;/code&gt; mode (i.e. &lt;code&gt;c++-mode&lt;/code&gt;) is
      enabled.  As a result, C++ syntax highlighting should be
      visible.  Further &lt;code&gt;C-x h TAB&lt;/code&gt; should reformat the
      code to use 4 spaces for each level of indentation.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      File-local variables may be specified in the footer too as shown
      below:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;#include &amp;lt;iostream&amp;gt;

int main() {
    std::cout &amp;lt;&amp;lt; &quot;hello, world\n&quot;;
    return 0;
}

// Local Variables:
// mode: c++
// c-basic-offset: 6
// End:&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      Now reloading the buffer should show that &lt;code&gt;c++-mode&lt;/code&gt;
      is enabled and typing &lt;code&gt;C-x h TAB&lt;/code&gt; should reformat the
      code to use 6 spaces for each level of indentation.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      What happens if the file-local variables in the header and
      footer contradict each other?  To test this out, edit the buffer
      to have the following content:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;// -*- mode: c++; c-basic-offset: 4 -*-

#include &amp;lt;iostream&amp;gt;

int main() {
      std::cout &amp;lt;&amp;lt; &quot;hello, world\n&quot;;
      return 0;
}

// Local Variables:
// mode: python
// c-basic-offset: 6
// End:&lt;/code&gt;&lt;/pre&gt;
    &lt;p&gt;
      Reloading the buffer should show that &lt;code&gt;c++-mode&lt;/code&gt; is
      active.  Typing &lt;code&gt;C-x h TAB&lt;/code&gt; should reformat the code
      to use 6 spaces for each level of indentation.  Therefore the
      mode specified in the header remains effective.  For other
      variables, the ones specified in the footer have precedence.
    &lt;/p&gt;
    &lt;p&gt;
      Of course, the example above is intended for curiosity and
      exploration.  In practical use, however, it is best to avoid
      assigning conflicting values to file-local variables in both the
      header and footer.  Such inconsistencies can lead to confusion
      and make the effect of the variables difficult to understand.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;occur-mode&quot;&gt;Occur Mode&lt;/h2&gt;
&lt;p&gt;
  TODO: More notes coming up here soon!
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/ch04.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Mastering Emacs: Chapter 3: First Steps</title>
    <link href="https://susam.net/cc/mastering-emacs/ch03.html"/>
    <id>urn:uuid:41ccf675-1e61-4d1a-a0b9-4c097edeaec1</id>
    <updated>2023-01-07T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  The following notes were taken while discussing Chapter 3 of the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  An index of notes for all chapters are available
  at &lt;a href=&quot;notes.html&quot;&gt;notes.html&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#starting-emacs&quot;&gt;Starting Emacs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#emacs-client-server&quot;&gt;Emacs Client-Server&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-emacs-interface&quot;&gt;The Emacs Interface&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#keys&quot;&gt;Keys&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#terminal-limitations&quot;&gt;Terminal Limitations&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#definitions-for-key-sequences&quot;&gt;Definitions for Key Sequences&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#key-examples&quot;&gt;Key Examples&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#ctrl-g&quot;&gt;C-g: Universal Bail Me Out&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#caps-lock-as-control&quot;&gt;Caps Lock as Control&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#M-x-execute-extended-command&quot;&gt;M-x: Execute Extended Command&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#interactive-commands&quot;&gt;Interactive Commands&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#m-x-execute-extended-command-for-buffer&quot;&gt;M-X: Execute Extended Command for Buffer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#universal-arguments&quot;&gt;Universal Arguments&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#discovering-and-remembering-keys&quot;&gt;Discovering and Remembering Keys&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#true-colour&quot;&gt;True Colour&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-customise-interface&quot;&gt;The Customise Interface&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#customise-commands&quot;&gt;Customise Commands&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#evaluating-elisp-code&quot;&gt;Evaluating Elisp Code&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#info&quot;&gt;Info&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#apropos&quot;&gt;Apropos&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#describe&quot;&gt;Describe&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;starting-emacs&quot;&gt;Starting Emacs&lt;/h2&gt;
&lt;p&gt;
  Here are some frequently used commands to start Emacs:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;emacs -nw&lt;/code&gt;: Tell Emacs not to create a graphical
    frame, i.e. run Emacs within a terminal instead.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;emacs -q&lt;/code&gt;: Do not load an init file, i.e. do not
    load &lt;code&gt;~/.emacs&lt;/code&gt;, &lt;code&gt;~/.emacs.d/init.el&lt;/code&gt;, etc.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;emacs -Q&lt;/code&gt;: Do not load init file, site-wide startup
    file or X resources.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;emacs-client-server&quot;&gt;Emacs Client-Server&lt;/h2&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-x server-start RET&lt;/code&gt; turns the current
  instance of Emacs into a server.  If we kill this instance of Emacs,
  it kills the server too.
&lt;/p&gt;
&lt;p&gt;
  Another way to start an Emacs server is to enter the
  command &lt;code&gt;emacs --daemon&lt;/code&gt;.  This too internally
  invokes &lt;code&gt;server-start&lt;/code&gt; to start an Emacs server but this
  command ensures that Emacs runs in background mode.  Therefore,
  killing any particular instance of Emacs window does not end up
  killing the Emacs server.
&lt;/p&gt;
&lt;p&gt;
  To open files, say &lt;code&gt;foo.txt&lt;/code&gt; and &lt;code&gt;bar.txt&lt;/code&gt; in
  an already running Emacs server, enter the command &lt;code&gt;emacsclient
  foo.txt bar.txt&lt;/code&gt;.  This command blocks the terminal and waits
  for us to finish editing the files.  While editing the files, we
  need to type &lt;code&gt;C-x #&lt;/code&gt; to tell Emacs that we are done
  editing the current file.  Emacs then switches to the next file we
  are editing.  When we are done editing all the files
  opened, &lt;code&gt;emacsclient&lt;/code&gt; quits and returns control to the
  terminal.
&lt;/p&gt;
&lt;p&gt;
  The book does not mention how to stop an Emacs daemon.  One of the
  several ways to stop an Emacs daemon is the
  command &lt;code&gt;emacsclient -e &apos;(kill-emacs)&apos;&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  Here are some commands to run &lt;code&gt;emacsclient&lt;/code&gt;:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;emacsclient -c&lt;/code&gt;: Create a frame.  A graphical frame is
    created if graphics is available, otherwise a terminal frame is
    created.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;emacsclient -nw&lt;/code&gt;: Create a terminal frame.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;emacsclient -n&lt;/code&gt;: Client returns immediately without
    waiting for us to finish editing the file.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-emacs-interface&quot;&gt;The Emacs Interface&lt;/h2&gt;
&lt;p&gt;
  The book mentions that many Emacs users disable the menu bar, tool
  bar and the splash screen.  The following Elisp code shows how these
  UI elements can be disabled:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(menu-bar-mode 0)
(when (display-graphic-p)
  (tool-bar-mode 0)
  (scroll-bar-mode 0))
(setq inhibit-startup-screen t)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  After saving the code in the initialisation file (such
  as &lt;code&gt;~/.emacs&lt;/code&gt;, &lt;code&gt;~/.emacs.d/init.el&lt;/code&gt;, etc.) and
  restarting Emacs, these UI elements disappear.
&lt;/p&gt;
&lt;p&gt;
  It is worth mentioning here that disabling the menu bar may not be a
  good idea, especially, for beginners to Emacs.  The menu bar
  contains a lot of helpful shortcuts that could be useful to
  beginners.  Further, the menu bar often displays certain menus that
  are specific to the current buffer.  Therefore, it may be a good
  idea to leave the menu bar enabled.
&lt;/p&gt;
&lt;p&gt;
  Regardless of whether the menu bar is enabled or disabled, the menu
  bar can accessed easily by typing &lt;kbd&gt;F10&lt;/kbd&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;keys&quot;&gt;Keys&lt;/h2&gt;
&lt;p&gt;
  The book mentions the following notation for modifier keys:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;C-&lt;/code&gt;: Control&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;M-&lt;/code&gt;: Meta&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;S-&lt;/code&gt;: Shift&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;s-&lt;/code&gt;: Super&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;H-&lt;/code&gt;: Hyper&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;A-&lt;/code&gt;: Alt&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Although not mentioned in the book, here is a quick way to test out
  all of these modifier keys:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(global-set-key (kbd &quot;C-j&quot;) (lambda () (interactive) (message &quot;You typed C-j&quot;)))
(global-set-key (kbd &quot;M-j&quot;) (lambda () (interactive) (message &quot;You typed M-j&quot;)))
(global-set-key (kbd &quot;C-S-j&quot;) (lambda () (interactive) (message &quot;You typed C-S-j&quot;)))
(global-set-key (kbd &quot;s-j&quot;) (lambda () (interactive) (message &quot;You typed s-j&quot;)))
(global-set-key (kbd &quot;H-j&quot;) (lambda () (interactive) (message &quot;You typed H-j&quot;)))
(global-set-key (kbd &quot;A-j&quot;) (lambda () (interactive) (message &quot;You typed A-j&quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Go to some buffer, say, the scratch buffer with
  &lt;code&gt;C-x b *scratch* RET&lt;/code&gt;, then copy the above code to it,
  then place the cursor at the end of each line of code and
  type &lt;code&gt;C-x e&lt;/code&gt; to evaluate each line.
&lt;/p&gt;
&lt;p&gt;
  Then open a new buffer, say with &lt;code&gt;C-x b foo RET&lt;/code&gt; and
  type &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt;, &lt;kbd&gt;alt&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt;
  and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; to test the first
  three key bindings.
&lt;/p&gt;
&lt;p&gt;
  The fourth key-binding &lt;code&gt;s-j&lt;/code&gt; can usually be invoked by
  typing &lt;kbd&gt;command&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt;
  or &lt;kbd&gt;win&lt;/kbd&gt;+&lt;kbd&gt;j&lt;/kbd&gt; depending on the type of keyboard you
  have.
&lt;/p&gt;
&lt;p&gt;
  The &lt;code&gt;H-&lt;/code&gt; and &lt;code&gt;A-&lt;/code&gt; modifier keys are generally
  not mapped to any actual key in modern systems.  However, it is
  possible to invoke the &lt;code&gt;H-j&lt;/code&gt; and &lt;code&gt;A-j&lt;/code&gt; key
  bindings with the key sequences &lt;code&gt;C-x @ h j&lt;/code&gt; and &lt;code&gt;C-x
  @ a j&lt;/code&gt; respectively, i.e.
  &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;@&lt;/kbd&gt; &lt;kbd&gt;h&lt;/kbd&gt; &lt;kbd&gt;j&lt;/kbd&gt;
  and &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;@&lt;/kbd&gt; &lt;kbd&gt;a&lt;/kbd&gt; &lt;kbd&gt;j&lt;/kbd&gt;
  respectively.
&lt;/p&gt;
&lt;p&gt;
  In fact, similarly, &lt;code&gt;s-j&lt;/code&gt; too can be invoked
  with &lt;code&gt;C-x @ s j&lt;/code&gt;, i.e.
  &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;x&lt;/kbd&gt; &lt;kbd&gt;@&lt;/kbd&gt; &lt;kbd&gt;s&lt;/kbd&gt; &lt;kbd&gt;j&lt;/kbd&gt;
  but that is rarely necessary because &lt;code&gt;s-&lt;/code&gt; is often bound
  to a GUI key like the &lt;kbd&gt;command&lt;/kbd&gt; key on Apple keyboards and
  the &lt;kbd&gt;win&lt;/kbd&gt; key on Windows keyboards.
&lt;/p&gt;
&lt;p&gt;
  A practical example of a real and useful &lt;code&gt;s-&lt;/code&gt; key binding
  from vanilla Emacs is &lt;code&gt;s-u&lt;/code&gt; to invoke
  the &lt;code&gt;revert-buffer&lt;/code&gt; command that reloads a file from the
  disk.
&lt;/p&gt;
&lt;h2 id=&quot;terminal-limitations&quot;&gt;Terminal Limitations&lt;/h2&gt;
&lt;p&gt;
  The book mentions that there are some key bindings that we cannot
  use if we are running Emacs in the terminal.  That is because a
  terminal supports a very limited set of key bindings.  An example
  is &lt;code&gt;C-/&lt;/code&gt; that invokes the &lt;code&gt;undo&lt;/code&gt; command in
  GUI Emacs.  The terminal does not recognise that key sequence.
  However, the &lt;code&gt;undo&lt;/code&gt; command is also bound
  to &lt;code&gt;C-_&lt;/code&gt; and &lt;code&gt;C-x u&lt;/code&gt;, so one of these key
  sequences can be used to undo changes in terminal Emacs.
&lt;/p&gt;
&lt;h2 id=&quot;definitions-for-key-sequences&quot;&gt;Definitions for Key Sequences&lt;/h2&gt;
&lt;p&gt;
  The book provides a few definitions of key sequences that can be
  summarised as follows:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;em&gt;Key sequence&lt;/em&gt; (or just &lt;em&gt;key&lt;/em&gt;): A sequence of
    keyboard or mouse actions, e.g. &lt;code&gt;C-d&lt;/code&gt;,
    &lt;code&gt;C-M-d&lt;/code&gt;, &lt;code&gt;C-x C-f&lt;/code&gt;, &lt;code&gt;C-x 8
    P&lt;/code&gt;, &lt;code&gt;C-x&lt;/code&gt;, &lt;code&gt;C-x 8&lt;/code&gt;, etc.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;em&gt;Complete key&lt;/em&gt;: A key sequence that invokes a command, e.g.
    &lt;code&gt;C-d&lt;/code&gt;, &lt;code&gt;C-M-d&lt;/code&gt;, &lt;code&gt;C-x
    C-f&lt;/code&gt;, &lt;code&gt;C-x 8 P&lt;/code&gt;, etc.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;em&gt;Prefix key&lt;/em&gt;: A key sequence that is not a complete key,
    e.g. &lt;code&gt;C-x&lt;/code&gt;, &lt;code&gt;C-x 8&lt;/code&gt;, etc.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;key-examples&quot;&gt;Key Examples&lt;/h2&gt;
&lt;p&gt;
  The section &lt;em&gt;Keys&lt;/em&gt; presents the following examples of key
  sequences:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-d&lt;/code&gt;: Calls &lt;code&gt;delete-char&lt;/code&gt; which deletes the
    following character.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-d&lt;/code&gt;: Calls &lt;code&gt;down-list&lt;/code&gt; which moves
    forward down one level of parentheses.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-f&lt;/code&gt;: Calls &lt;code&gt;find-file&lt;/code&gt; which is used
    for editing a file.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-x 8 P&lt;/code&gt;: Insersts pilcrow, i.e. the symbol &amp;para;,
    also known as the paragraph symbol.  Here both &lt;code&gt;C-x&lt;/code&gt;
    and &lt;code&gt;8&lt;/code&gt; are prefix keys.  There are many more key
    bindings available under the &lt;code&gt;C-x 8&lt;/code&gt; prefix.  For
    example, &lt;code&gt;C-x 8 C&lt;/code&gt; inserts the copyright symbol, i.e.
    the symbol &amp;copy;.  A set of keys like this that belong to a
    particular prefix key is called a &lt;em&gt;key map&lt;/em&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-%&lt;/code&gt;: Calls &lt;code&gt;query-replace-regexp&lt;/code&gt; to
    replace text with regula-expression based matching.  Since the
    key &lt;kbd&gt;%&lt;/kbd&gt; is normally typed
    as &lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;5&lt;/kbd&gt;, this key sequence involves
    holding down 4 keys together,
    i.e. &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;alt&lt;/kbd&gt;+&lt;kbd&gt;shift&lt;/kbd&gt;+&lt;kbd&gt;5&lt;/kbd&gt;.
    Annoyingly, this happens to be an example of a key sequence that
    does not work in terminal Emacs due to terminal limitations.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;TAB&lt;/code&gt;: Calls &lt;code&gt;indent-for-tab-command&lt;/code&gt; that
    either indents the current line or region or inserts a tab,
    depending on the context.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;&amp;lt;f1&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;f2&amp;gt;&lt;/code&gt;,
    ..., &lt;code&gt;&amp;lt;f10&amp;gt;&lt;/code&gt;: Functions keys that invoke various
    functions.  Some of these are prefix keys while others are
    complete key sequence.  For example, &lt;code&gt;&amp;lt;f1&amp;gt;&lt;/code&gt; is a
    prefix key that is available as an alternative to
    the &lt;code&gt;C-h&lt;/code&gt; prefix key.  The key sequence &lt;code&gt;C-h
    m&lt;/code&gt; shows help for the current major and minor modes and so
    does &lt;code&gt;&amp;lt;f1&amp;gt; m&lt;/code&gt;.  However, &lt;code&gt;&amp;lt;f10&amp;gt;&lt;/code&gt;
    is a complete key sequence that calls the
    command &lt;code&gt;menu-bar-open&lt;/code&gt; that shows the menu bar.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;ctrl-g&quot;&gt;C-g: Universal Bail Me Out&lt;/h2&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;C-g&lt;/code&gt; is used to cancel a partially
  completed command.  For example, normally, the key
  sequence &lt;code&gt;M-x whitespace-mode RET&lt;/code&gt; toggles the visibility
  of whitespace in the current buffer.  However, let us say, we type
  the partial key sequence &lt;code&gt;M-x white&lt;/code&gt; and then we change
  our mind about it and want to cancel entering the command any
  further, we can simply type &lt;code&gt;C-g&lt;/code&gt; to
  run &lt;code&gt;keyboard-quit&lt;/code&gt; that signals a quit condition and
  cancels the input.
&lt;/p&gt;
&lt;p&gt;
  Similarly, say, we type &lt;code&gt;C-x&lt;/code&gt; and then we change our mind
  about it and want to cancel this partially entered key sequence, we
  can simply type &lt;code&gt;C-g&lt;/code&gt;.  The following message appears in
  the echo area but this is by design:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;C-x C-g is undefined&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Don&apos;t let that message make you feel that you did something wrong by
  entering an undefined key sequence.  Key sequences ending
  with &lt;code&gt;C-g&lt;/code&gt; have been intentionally left undefined, so
  that it can be used reliably as the universal &lt;em&gt;bail me out&lt;/em&gt;
  key sequence.
&lt;/p&gt;
&lt;p&gt;
  Now of course, nothing stops us from binding &lt;code&gt;C-x C-g&lt;/code&gt; to
  a command of our choice.  For example, the following Elisp code
  binds it to a command that prints a message:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(global-set-key (kbd &quot;C-x C-g&quot;) (lambda () (interactive) (message &quot;You typed C-x C-g&quot;)))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  However, a key binding like the above one is a very bad idea because
  such a key binding flies against Emacs conventions.  If we were to
  create a key binding like the above one, we can longer rely
  on &lt;code&gt;C-g&lt;/code&gt; to be our universal bail out command.  Key
  sequences ending with &lt;code&gt;C-g&lt;/code&gt; are best left undefined.
&lt;/p&gt;
&lt;h2 id=&quot;caps-lock-as-control&quot;&gt;Caps Lock as Control&lt;/h2&gt;
&lt;p&gt;
  The book recommends configuring our operating system to make
  the &lt;kbd&gt;caps lock&lt;/kbd&gt; key behave like &lt;kbd&gt;ctrl&lt;/kbd&gt;.  Many
  people do find this type of remapping very convenient.  Many
  discussions can be found online where people have claimed that this
  remapping has helped with overcoming repetitive strain injury (RSI).
  However, the
  article &lt;a href=&quot;https://www.emacswiki.org/emacs/MovingTheCtrlKey&quot;&gt;Moving
  the Ctrl Key&lt;/a&gt; on Emacs Wiki claims that for some people this
  remapping &lt;em&gt;causes&lt;/em&gt; RSI.
&lt;/p&gt;
&lt;p&gt;
  I use the original &lt;kbd&gt;ctrl&lt;/kbd&gt; keys as they come with the
  keyboard.  Most keyboards have two &lt;kbd&gt;ctrl&lt;/kbd&gt; keys on either
  side of the keyboard which I find very convenient.  I touch type
  while editing text, so the two &lt;kbd&gt;ctrl&lt;/kbd&gt; keys on either side
  of the keyboard turn out to be really useful.  For example, when I
  need to type &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;a&lt;/kbd&gt;, I can hold
  down &lt;kbd&gt;ctrl&lt;/kbd&gt; with the little finger of the right hand and
  type &lt;kbd&gt;a&lt;/kbd&gt; with the little finger of the left hand.
  Similarly, if I need to type &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;p&lt;/kbd&gt;, I can
  hold down &lt;kbd&gt;ctrl&lt;/kbd&gt; with the little finger of the left hand
  and type &lt;kbd&gt;p&lt;/kbd&gt; with the little finger of the right hand.
  Using the original &lt;kbd&gt;ctrl&lt;/kbd&gt; keys offers this advantage of
  distributing the usage of the &lt;kbd&gt;ctrl&lt;/kbd&gt; to both hands.
  However, some Apple keyboards provide only a single &lt;kbd&gt;ctrl&lt;/kbd&gt;
  key on the left hand side which can be quite annoying to touch
  typists.  In such keyboards, remapping the &lt;kbd&gt;caps lock&lt;/kbd&gt; key
  to behave like &lt;kbd&gt;ctrl&lt;/kbd&gt; key can indeed be more convenient.
&lt;/p&gt;
&lt;h2 id=&quot;M-x-execute-extended-command&quot;&gt;M-x: Execute Extended Command&lt;/h2&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-x&lt;/code&gt; is pronounced &lt;em&gt;mex&lt;/em&gt;, &lt;em&gt;M
  x&lt;/em&gt; or &lt;em&gt;meta x&lt;/em&gt;.  It invokes the
  command &lt;code&gt;execute-extended-command&lt;/code&gt; that brings up a
  minibuffer to read a command name and execute it.
&lt;/p&gt;
&lt;p&gt;
  When &lt;code&gt;M-x&lt;/code&gt; key sequences are presented in written form,
  often they may be written in a precise manner that includes
  the &lt;code&gt;M-x&lt;/code&gt; key sequence, then the command name and finally
  the &lt;code&gt;RET&lt;/code&gt; key in the end, e.g. &lt;code&gt;M-x lunar-phases
  RET&lt;/code&gt;.  But sometimes they may also be written without
  the &lt;code&gt;RET&lt;/code&gt; key, e.g. &lt;code&gt;M-x lunar-phases&lt;/code&gt;.
  The &lt;code&gt;RET&lt;/code&gt; key is automatically implied in the latter
  form.
&lt;/p&gt;
&lt;h2 id=&quot;interactive-commands&quot;&gt;Interactive Commands&lt;/h2&gt;
&lt;p&gt;
  The following function written in Elisp is interactive:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defun hello ()
  (interactive)
  (message &quot;hello&quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  However, the following function is not interactive:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defun hola ()
  (message &quot;hola&quot;))&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  The &lt;code&gt;(interactive)&lt;/code&gt; expression declares a function as
  interactive which allows it to be called interactively
  using &lt;code&gt;M-x&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;
  To see the difference between the two functions, copy both functions
  to some buffer, say, the scratch buffer and then put the cursor
  after the closing parentheses of each function and type &lt;code&gt;C-x
  C-e&lt;/code&gt; to evaluate the &lt;code&gt;defun&lt;/code&gt; expressions thus
  defining the functions.  After doing so, &lt;code&gt;M-x hello RET&lt;/code&gt;
  executes the &lt;code&gt;hello&lt;/code&gt; function and produces the &quot;hello&quot;
  message in the echo area.  However, typing &lt;code&gt;M-x hola RET&lt;/code&gt;
  produces no match for a function named &lt;code&gt;hola&lt;/code&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;m-x-execute-extended-command-for-buffer&quot;&gt;M-X: Execute Extended Command for Buffer&lt;/h2&gt;
&lt;p&gt;
  Emacs 28 introduces &lt;code&gt;M-X&lt;/code&gt; that runs the
  command &lt;code&gt;execute-extended-command-for-buffer&lt;/code&gt;.  The book
  mentions this key binding as &lt;code&gt;M-S-x&lt;/code&gt; which is in
  fact &lt;code&gt;M-X&lt;/code&gt;.  In these notes, we&apos;ll write &lt;code&gt;M-X&lt;/code&gt;
  for consistency with how this key sequence is actually defined and
  represented in Emacs (for example, note that &lt;code&gt;C-h k
  M-S-x&lt;/code&gt; shows the key as &lt;code&gt;M-X&lt;/code&gt;).
&lt;/p&gt;
&lt;p&gt;
  To see how this function works, first open a file,
  say, &lt;code&gt;foo.el&lt;/code&gt; with &lt;code&gt;C-x C-f foo.el RET&lt;/code&gt;, then
  type &lt;code&gt;M-x e RET&lt;/code&gt;.  A large list of function names
  beginning with the letter &quot;e&quot; as choices appears.  Now
  type &lt;code&gt;M-X e RET&lt;/code&gt;.  A much smaller list of choices that
  are relevant for the current Elisp buffer appears.
&lt;/p&gt;
&lt;h2 id=&quot;universal-arguments&quot;&gt;Universal Arguments&lt;/h2&gt;
&lt;p&gt;
  Universal arguments are also called &lt;em&gt;prefix arguments&lt;/em&gt;.  The
  list below presents some examples of complete key sequences where we
  apply various prefix arguments to the key sequence &lt;code&gt;C-n&lt;/code&gt;.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;C-u C-n&lt;/code&gt;: Move cursor down 4 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-u C-u C-n&lt;/code&gt;: Move cursor down 16 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-u C-u C-u C-n&lt;/code&gt;: Move cursor down 64 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-u 5 C-n&lt;/code&gt;: Move cursor down 5 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-u 15 C-n&lt;/code&gt;: Move cursor down 15 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-5 C-n&lt;/code&gt;: Move cursor down 5 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-1 C-5 C-n&lt;/code&gt;: Move cursor down 15 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-- C-n&lt;/code&gt;: Move cursor up 1 line.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-- C-5 C-n&lt;/code&gt;: Move cursor up 5 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-- C-1 C-5 C-n&lt;/code&gt;: Move cursor up 15 lines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Note that negative arguments (the last three examples above)
  reverses the direction of operation.  The digit arguments of the
  form &lt;code&gt;C-&amp;lt;digit&amp;gt;&lt;/code&gt; can also be entered
  using &lt;code&gt;M-&amp;lt;digit&amp;gt;&lt;/code&gt;
  or &lt;code&gt;C-M-&amp;lt;digit&amp;gt;&lt;/code&gt;.  Here are some examples:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;M-5 C-n&lt;/code&gt;: Move cursor down 5 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-M-5 C-n&lt;/code&gt;: Move cursor down 5 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;M-1 M-5 C-n&lt;/code&gt;: Move cursor down 15 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-M-1 C-M-5 C-n&lt;/code&gt;: Move cursor down 15 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;M-- C-n&lt;/code&gt;: Move cursor up 1 line.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;M-- M-5 C-n&lt;/code&gt;: Move cursor up 5 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;M-- M-1 M-5 C-n&lt;/code&gt;: Move cursor up 15 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-M-- C-n&lt;/code&gt;: Move cursor up 1 line.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-M-- C-M-5 C-n&lt;/code&gt;: Move cursor up 5 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-M-- C-M-1 C-M-5 C-n&lt;/code&gt;: Move cursor up 15 lines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  While entering multiple digits in a digit argument, we can also mix
  and match modifier keys as shown below, however doing so would be
  pointless and unwieldy:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;C-1 M-5 C-n&lt;/code&gt;: Move cursor down 15 lines.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-1 C-M-5 C-n&lt;/code&gt;: Move cursor down 15 lines.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  The reason why Emacs supports entering digit arguments or negative
  arguments with all three modifier
  combinations &lt;code&gt;C-&lt;/code&gt;, &lt;code&gt;M-&lt;/code&gt;, &lt;code&gt;C-M-&lt;/code&gt;, is
  so that we can choose a modifier that is convenient.  Usually, this
  would be the modifier we anticipate that we&apos;ll use next for the
  command we are prefixing with the digit or negative argument.  For
  example, if we are going to move forward by 5 words, then &lt;code&gt;M-5
  M-f&lt;/code&gt; is going to be more convenient than &lt;code&gt;C-5 M-f&lt;/code&gt;
  or &lt;code&gt;C-M-5 M-f&lt;/code&gt;.  To type &lt;code&gt;M-5 M-f&lt;/code&gt;, we can
  simply press and hold down &lt;kbd&gt;alt&lt;/kbd&gt;, then type &lt;kbd&gt;5&lt;/kbd&gt;
  followed by &lt;kbd&gt;f&lt;/kbd&gt; and finally release &lt;kbd&gt;alt&lt;/kbd&gt;.
  Similarly, if we are going to move forward by 5 expressions,
  then &lt;code&gt;C-M-5 C-M-f&lt;/code&gt; is going to be more convenient than
  using any other modifier for the digit argument.
&lt;/p&gt;
&lt;p&gt;
  Choosing the modifier combination for a universal argument such that
  it matches the modifier combination for the key sequence coming up
  next helps maintain good &lt;em&gt;tempo&lt;/em&gt; while typing the key
  sequences.  The book often puts emphasis on the subject of tempo in
  various chapters.
&lt;/p&gt;
&lt;p&gt;
  While discussing tempo, the book presents the example of &lt;code&gt;M--
  M-d&lt;/code&gt; which can be used to kill the previous word.  Note
  that &lt;code&gt;M-d&lt;/code&gt; kills one word forward, so &lt;code&gt;M--
  M-d&lt;/code&gt; reverses the direction of the operation and kills one
  word backward.  The book notes that &lt;code&gt;M-- M-d&lt;/code&gt; maintains
  tempo while &lt;code&gt;C-- M-d&lt;/code&gt; which does exactly the same thing
  disrupts tempo.
&lt;/p&gt;
&lt;p&gt;
  Another example that the section &lt;em&gt;Univeral Arguments&lt;/em&gt; briefly
  alludes to but does not provide a concrete example of is changing
  the case of a word that we just typed.  Here are some concrete
  examples for it:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-l&lt;/code&gt;: Convert the text from the point to the end of
    the current or next word to lower case.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-u&lt;/code&gt;: Convert the text from the point to the end of
    the current or next word to upper case.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-c&lt;/code&gt;: Capitalise the text from the point to the end of
    the current or next word.  Capitalisation involves changing only
    the first letter to upper case.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M- M-l&lt;/code&gt;: Convert the text from the point to the
    beginning of the current or previous word to upper case.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M- M-u&lt;/code&gt;: Convert the text from the point to the
    beginning of the current or previous word to upper case.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M- M-c&lt;/code&gt;: Capitalise the text from the point to the
    beginning of the current or previous word.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;discovering-and-remembering-keys&quot;&gt;Discovering and Remembering Keys&lt;/h2&gt;
&lt;p&gt;
  To get help for a prefix key, type the prefix key followed
  by &lt;code&gt;C-h&lt;/code&gt;.  Here are some examples:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;C-x C-h&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-x 8 C-h&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-x 8 &quot; C-h&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-x 8 &apos; C-h&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;C-x 8 * C-h&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Getting help for a prefix key in this manner shows an automatically
  generated list of all keys that belong to the key map associated
  with the prefix key.  Note that a key map for a prefix key may
  itself contain more prefix keys.  For example, in the above
  examples, we see that the key map for &lt;code&gt;C-x 8&lt;/code&gt; contains
  prefix keys &lt;code&gt;C-x 8 &quot;&lt;/code&gt;, &lt;code&gt;C-x 8 &apos;&lt;/code&gt;, etc.  Such
  nested prefix keys are clearly marked in the output as &quot;Prefix
  Command&quot;.
&lt;/p&gt;
&lt;h2 id=&quot;true-colour&quot;&gt;True Colour&lt;/h2&gt;
&lt;p&gt;
  There is a note with the title &lt;em&gt;Supported colors&lt;/em&gt; in the
  section &lt;em&gt;The Customize Interface&lt;/em&gt; that introduces the
  following commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x list-color-display RET&lt;/code&gt;: Display names of defined
    colours and show what they look like.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x info-apropos RET Colors on a TTY RET&lt;/code&gt;: Find an
    info page on the subject of using colours on a TTY.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Since Emacs 28, we can easily enable 24-bit colour in terminal Emacs
  by setting the environment variable
  &lt;code&gt;COLORTERM=truecolor&lt;/code&gt;.  To quickly test it out,
  first enter the following command in the terminal:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;COLORTERM=truecolor emacs -nw&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Then type the following in Emacs:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;M-x list-color-display RET&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-customise-interface&quot;&gt;The Customise Interface&lt;/h2&gt;
&lt;p&gt;
  The customise interface allows us to customise two things: faces and
  options.  Here are some steps to get started with the customise
  interface:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-x 2&lt;/code&gt; to split the current window into two.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-x C-f foo.el RET&lt;/code&gt; to open a new Elisp file.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type some code into the file such that it contains at least one
      string, for example:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;(message &quot;hello&quot;)&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-x o&lt;/code&gt; to go to the other window.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x customize RET&lt;/code&gt;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Move the cursor to the editable text area.  This can be done
      with motion key sequences or with the mouse.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Then type &lt;code&gt;font-lock-string-face&lt;/code&gt; and
      press &lt;kbd&gt;enter&lt;/kbd&gt;.  The customisation interface for the
      chosen face now appears in the buffer.  The message next to the
      &quot;State&quot; button shows &quot;STANDARD.&quot; which indicates that the face
      is set to its default value.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Then move the cursor to the editable text area next to the
      &quot;Foreground:&quot; label, type &lt;code&gt;blue&lt;/code&gt;.  At this point, a
      preview of blue text is shown next to the &quot;Choose&quot; button.
      However, the string in the Elisp buffer still appears in its
      previous colour.  The message next to the &quot;State&quot; button shows
      &quot;EDITED, shown value does not take effect until you set or save
      it.&quot;
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now click the &quot;Apply&quot; button to apply the new string colour.
      Alternatively, move the cursor over to &quot;Apply&quot; and
      press &lt;kbd&gt;enter&lt;/kbd&gt;.  As soon as this button is clicked, the
      string in the Elisp buffer appears blue.  The message next to
      the &quot;State&quot; button says &quot;Set for current session only.&quot;
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now click the &quot;Revert...&quot; button and then click
      &quot;Revert This Session&apos;s Customizations&quot; to revert the customisation.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now change the string colour to blue again and click &quot;Apply and
      Save&quot;.  The message next to the &quot;State&quot; button now changes to
      &quot;SAVED and set.&quot;  Then check Emacs initialisation file (such
      as &lt;code&gt;~/.emacs&lt;/code&gt;, &lt;code&gt;~/.emacs.d/init.el&lt;/code&gt;, etc.)
      and there should be a &lt;code&gt;custom-set-faces&lt;/code&gt; call added
      to the initialisation file to set the string colour to blue.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      To erase the customisation from the initialisation file, click
      &quot;Revert ...&quot; and then click &quot;Erase Customizations&quot;.  At this
      point, the customisation is no longer present in the
      initialisation file.  However, the customise interface shows a
      confusing message next to the &quot;State&quot; button, &quot;EDITED, shown
      value does not take effect until you set or save it.&quot;  Further,
      the face is set to &quot;-- Empty face --&quot; in the customisation
      interface.  To add to the confusion, the &quot;Apply and Save&quot; button
      is enabled!  Beware though!  If &quot;Apply and Save&quot; is clicked now,
      it will set &lt;code&gt;nil&lt;/code&gt; as the value for the face which
      will cause the face to appear black or white (not the default
      colour).
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      To get rid of the confusing state of the customisation buffer
      discussed in the previous point and restore the customisation
      buffer to a sane state, click &quot;Revert ...&quot; and then click either
      &quot;Undo Edits in Customization Buffer&quot; or click
      &quot;Revert This Session&apos;s Customizations&quot;.  Doing so would end up
      showing the default colour of the face in the customise
      interface.  The message next to the &quot;State&quot; button shows
      &quot;STANDARD.&quot; again.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;customise-commands&quot;&gt;Customise Commands&lt;/h2&gt;
&lt;p&gt;
  Here are some examples of complete key sequences that invoke various
  customise commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize RET&lt;/code&gt;: Display customise interface.  We
    can reach a specific item to be customised by navigating the
    groups presented and the subgroups within them.  For example, to
    customise &lt;code&gt;font-lock-string-face&lt;/code&gt;, we can naviage to
    Faces &amp;gt; Font Lock &amp;gt; Font Lock Faces &amp;gt; Font Lock String
    Face.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-browse RET&lt;/code&gt;: Create a tree browser for
    the customise hierarchy.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-option RET global-display-line-numbers
    RET&lt;/code&gt;: Customise a specific option.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-face RET font-lock-string-face RET&lt;/code&gt;:
    Customise a specific face.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-group RET faces RET&lt;/code&gt;: Customise a
    specific group.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-group RET font-lock-faces RET&lt;/code&gt;: Another
    example similar to the previous one.  This one customises
    the &lt;em&gt;Font Lock Faces&lt;/em&gt; subgroup within the &lt;em&gt;Faces&lt;/em&gt;
    group.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-mode RET&lt;/code&gt;: Customise the major mode of
    the current buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-mode RET python-mode RET&lt;/code&gt;: Customise a
    specific mode.  After the first &lt;code&gt;RET&lt;/code&gt;, a prompt to
    enter the mode appears only if the current major mode has no known
    customise group.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-u M-x customize-mode RET python-mode RET&lt;/code&gt;: Yet
    another way to customise a specific mode.  Using the prefix
    argument ensures that we are always prompted for the mode name.
    This can be useful when we want to customise a minor mode or a
    major mode that is different from the current major mode.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-themes RET&lt;/code&gt;: Display a selectable list
    of custom themes.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-customized RET&lt;/code&gt;: Customise all
    customisations set in the session but not saved.  This is very
    useful to see all unsaved customisations together at one place.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-saved RET&lt;/code&gt;: Customise all saved
    customisations.  This is very useful to see all saved
    customisations together at one place.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-changed RET&lt;/code&gt;: Customise all settings
    whose meanings have changed since the previous major Emacs
    release.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x customize-changed RET 26.1 RET&lt;/code&gt;: Customise all
    settings whose meanings have changed since a particular previous
    major Emacs release.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  One thing worth keeping in mind is that when we apply, save or
  revert customisations, only the customisations shown in the current
  buffer are applied, saved or reverted.  Here is an experiment that
  demonstrates what this means:
&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;C-x 2&lt;/code&gt; followed by &lt;code&gt;C-x C-f foo.el
      RET&lt;/code&gt; to split the current window into two and load an
      Elisp file in one window.  Then insert the following code:
    &lt;/p&gt;
    &lt;pre&gt;&lt;code&gt;(defun foo () (message &quot;hello&quot;)) ;; Demo&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x customize RET&lt;/code&gt;, search
      for &lt;code&gt;font-lock-keyword-face&lt;/code&gt;, set its colour
      to &lt;code&gt;red&lt;/code&gt; and click &quot;Apply&quot;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Then search for &lt;code&gt;font-lock-function-name-face&lt;/code&gt;, set
      its colour to &lt;code&gt;green&lt;/code&gt; and click &quot;Apply&quot;.  At this
      point the macro name &lt;code&gt;defun&lt;/code&gt; is coloured red and the
      function name &lt;code&gt;foo&lt;/code&gt; is coloured green in the Elisp
      buffer.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now click &quot;Revert ...&quot; and then click
      &quot;Revert This Session&apos;s Customizations&quot;.  Only the colour of the
      function name reverts to the default colour.  The colour of the
      macro name remains red in the Elisp buffer.  This confirms that
      the revert operation takes only the customisations in the buffer
      into account.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Search for &lt;code&gt;font-lock-string-face&lt;/code&gt;, set its colour
      to &lt;code&gt;blue&lt;/code&gt; and click &quot;Apply and Save&quot;.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Search for &lt;code&gt;font-lock-comment-face&lt;/code&gt;, set its colour
      to &lt;code&gt;magenta&lt;/code&gt; and click &quot;Apply and Save&quot;.  Inspecting
      the Emacs initialisation file shows that only the customisations
      for the string and comment faces have been saved to the file.
      This confirms that only the customisations shown in the current
      buffer are saved.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x customize-customized RET&lt;/code&gt;.  A new buffer
      appears and shows the customisation for keyword because it was
      customised and applied but not saved.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Type &lt;code&gt;M-x customize-saved RET&lt;/code&gt;.  A new buffer appears
      and shows the customisations for string and comment because they
      were customised and saved.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;
      Now search for &lt;code&gt;font-lock-comment-face&lt;/code&gt; so that the
      customise buffer contains only the customisation entry for
      comment.  Click &quot;Revert ...&quot; and then click
      &quot;Erase Customizations&quot;.  Inspecting the Emacs initialisation
      file shows that the customisation for comment is removed but the
      customisation for string is still intact.  This confirms that
      only the customisation shown in the current buffer is erased.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;evaluating-elisp-code&quot;&gt;Evaluating Elisp Code&lt;/h2&gt;
&lt;p&gt;
  The chapter introduces two commands:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x eval-buffer RET&lt;/code&gt;: Evaluate the entire buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x eval-region RET&lt;/code&gt;: Evaluates only the marked
    region.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Here are some additional key sequences that I find very useful:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-x C-e&lt;/code&gt;: Evaluate the expression before the cursor.
    This key binding is available in &lt;code&gt;global-map&lt;/code&gt;, so this
    key sequence works in any buffer.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-M-x&lt;/code&gt;: Evaluate the top-level expression on the
    cursor.  This key binding is not available in the global map.
    Therefore this key sequence works only in those major modes that
    support it.  For example, this key sequence works in Elisp buffers
    because this key binding is available
    in &lt;code&gt;emacs-lisp-mode-map&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;info&quot;&gt;Info&lt;/h2&gt;
&lt;p&gt;
  &lt;em&gt;Info&lt;/em&gt;, also known as the &lt;em&gt;Info Reader&lt;/em&gt;, is the
  documentation browser of Emacs.  Type
  &lt;code&gt;M-x info RET&lt;/code&gt; or &lt;code&gt;C-h i&lt;/code&gt; to enter
  Info.
&lt;/p&gt;
&lt;p&gt;
  The following points explain the navigation commands of Info:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    Type &lt;code&gt;[&lt;/code&gt; or &lt;code&gt;]&lt;/code&gt; to go to the previous or
    next node respectively.  Typing &lt;code&gt;]&lt;/code&gt; repeatedly is a
    nice way to go from one node to the next one without skipping any
    content.  This provides an experience that very close to reading a
    book page by page although &lt;code&gt;SPC&lt;/code&gt; (explained below)
    might be an even better way.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;l&lt;/code&gt; or &lt;code&gt;r&lt;/code&gt; to go back or forward in
    history respectively.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;n&lt;/code&gt; or &lt;code&gt;p&lt;/code&gt; to go to the previous or
    next sibling node.  This is a nice way to go from one chapter to
    next while skipping all the child nodes or to go from one section
    to the next sibling section while skipping all child subsections.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;u&lt;/code&gt; to go up one level to the parent node.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;SPC&lt;/code&gt; to scroll one screen forward at a time.
    Type &lt;code&gt;DEL&lt;/code&gt; or &lt;code&gt;S-SPC&lt;/code&gt; to scroll one screen
    backward at a time.  When a node boundary is reached, these
    commands automatically load the next or previous node.  Thus
    typing &lt;code&gt;SPC&lt;/code&gt; over and over again is a nice way to read
    all the text in a node and then go to the next node.  This
    provides an experience that is closest to reading a book paragraph
    by paragraph and page by page.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;TAB&lt;/code&gt; to go to the next cross-reference or menu
    item, i.e. anything that looks like a link.
    Type &lt;code&gt;S-TAB&lt;/code&gt; or &lt;code&gt;C-M-i&lt;/code&gt; to go back to the
    previous cross-reference or menu item.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;RET&lt;/code&gt; to follow a node reference near point.  This
    behaves like visiting a link.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;m&lt;/code&gt; to prompt for a menu item to go to.  The menu
    item near the point is automatically selected as the default
    answer to the prompt.
  &lt;/li&gt;
  &lt;li&gt;
    Type &lt;code&gt;q&lt;/code&gt; to quit Info.  The Info buffer is not killed.
    Therefore typing &lt;code&gt;C-h i&lt;/code&gt; will switch to the Info buffer
    and we can read the last node we visited again.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  To summarise, the commands &lt;code&gt;[&lt;/code&gt; and &lt;code&gt;]&lt;/code&gt; are
  great for browsing every node.  The command &lt;code&gt;SPC&lt;/code&gt;
  and &lt;code&gt;DEL&lt;/code&gt; are good for reading everything paragraph by
  paragraph and page by page.
&lt;/p&gt;
&lt;p&gt;
  There are several ways to reach a specific node of a specific
  manual.  The following points describe some of them:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    When we open the Info reader with &lt;code&gt;C-h i&lt;/code&gt; for the first
    time, immediately typing &lt;code&gt;m&lt;/code&gt; is a convenient way to
    enter a particular menu item for a manual and jump to that manual,
    e.g. type &lt;code&gt;C-h i m org RET&lt;/code&gt; to go to the Org manual.
  &lt;/li&gt;
  &lt;li&gt;
    Since Emacs 28, we can also use &lt;code&gt;C-h R&lt;/code&gt; to open a
    specific manual from any buffer, i.e. we do not need to
    type &lt;code&gt;C-h i&lt;/code&gt; first to enter Info.  For example,
    type &lt;code&gt;C-h R org RET&lt;/code&gt; to enter the Org manual.
  &lt;/li&gt;
  &lt;li&gt;
    To look up the documentation for a command, type &lt;code&gt;C-h
    F&lt;/code&gt;, e.g. &lt;code&gt;C-h F find-file RET&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    Although not mentioned in the book, a popular way to point others
    to a specific node in the manual is to provide an Elisp expression
    to visit a node.  For example, to read the node
    named &lt;code&gt;Internal Links&lt;/code&gt; in the &lt;code&gt;org&lt;/code&gt; manual,
    evaluate the expression &lt;code&gt;(info &quot;(org)Internal Links&quot;)&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    An alternative to the Elisp expression in the previous point could
    be typing &lt;code&gt;C-h R org RET m Hyperlinks RET m Internal Links
    RET&lt;/code&gt; or even &lt;code&gt;C-h R org RET m Internal Links
    RET&lt;/code&gt;.  However, the Elisp expression in the previous point
    is a convenient way to share a pointer to a specific node in a
    specific manual with other Emacs users.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;apropos&quot;&gt;Apropos&lt;/h2&gt;
&lt;p&gt;
  The following key sequences demonstrate how to use the apropos
  system:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-h a ^whitespace RET&lt;/code&gt;: Find all commands that match
    the regular expression pattern &lt;code&gt;^whitespace&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x apropos-command RET ^whitespace RET&lt;/code&gt;: Same as
    above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x apropos RET ^whitespace RET&lt;/code&gt;: Show all symbols
    that match the given regular expression pattern.  The matches
    include symbols defined as functions, variables and faces.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-h d cleanup-region RET&lt;/code&gt;: Show symbols whose
    documentation strings match the given regular expression pattern.
    Note that this command shows symbols
    like &lt;code&gt;whitespace-cleanup&lt;/code&gt;
    and &lt;code&gt;whitespace-report-region&lt;/code&gt; in the results because
    their documentation strings contain the
    string &lt;code&gt;&quot;cleanup-region&quot;&lt;/code&gt;.  However, it does not show
    the symbol &lt;code&gt;whitespace-cleanup-region&lt;/code&gt; because its
    documentation string does not contain this string.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x apropos-documentation RET cleanup-region RET&lt;/code&gt;:
    Same as above.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x apropos-library RET whitespace RET&lt;/code&gt;: Show all
    variables and functions defined by the library
    &lt;code&gt;whitespace&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x apropos-user-option RET ^whitespace RET&lt;/code&gt;: Show
    user options that match the given pattern.  This includes
    variables that can be customised in the customise interface.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x apropos-value RET ^[^ ]*text RET&lt;/code&gt;: Show all
    symbols which have values whose printed representation matches the
    given pattern.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  By default, the apropos commands show the results in alphabetical
  order.  To sort them by scores, evaluate the following Elisp
  expression:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(setq apropos-sort-by-scores t)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  To sort the matches by score as well as show the scores within
  parentheses next to the matches, evaluate the following Elisp
  expression:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(setq apropos-sort-by-scores &apos;verbose)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Note that sorting by score does not work for &lt;code&gt;C-h d&lt;/code&gt;
  (&lt;code&gt;apropos-documentation&lt;/code&gt;).
&lt;/p&gt;
&lt;h2 id=&quot;describe&quot;&gt;Describe&lt;/h2&gt;
&lt;p&gt;
  The following key sequences demonstrate the describe system:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;C-h m&lt;/code&gt;: Display documentation of current major mode
    and minor modes along with key bindings introduced by the modes.
    Mode-specific commands that are not bound to any key are not
    shown.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-h x calc RET&lt;/code&gt;: Display documentation of
    the &lt;code&gt;calc&lt;/code&gt; command.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-h f calc RET&lt;/code&gt;: Same as above.  However, note that
    while &lt;code&gt;C-h f&lt;/code&gt; can display documentation of any
    function, &lt;code&gt;C-h x&lt;/code&gt; on the other hand can display
    documentation of only those functions that are also commands.  For
    example, &lt;code&gt;C-h f string-join RET&lt;/code&gt; works fine
    but &lt;code&gt;C-h x string-join RET&lt;/code&gt; complains about no match.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-h v tab-width RET&lt;/code&gt;: Display documentation of the
    variable &lt;code&gt;tab-width&lt;/code&gt;.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;C-h k C-x C-f&lt;/code&gt;: Display documentation of the command
    bound to the key sequence &lt;code&gt;C-x C-f&lt;/code&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;
&lt;p&gt;
  The following list includes some links that were discussed during
  the book discussion group meetings:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://commons.wikimedia.org/wiki/File:Space-cadet.jpg&quot;&gt;Picture
      of the space-cadet keyboard with Hyper, Super and Meta keys&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://www.emacswiki.org/emacs/MovingTheCtrlKey&quot;&gt;Moving
    the Ctrl Key&lt;/a&gt;
  &lt;/li&gt;
&lt;/ul&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/ch03.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Mastering Emacs: Chapter 2: The Way of Emacs</title>
    <link href="https://susam.net/cc/mastering-emacs/ch02.html"/>
    <id>urn:uuid:71ff9dcc-499b-42f0-b65f-d12c8b3bf03c</id>
    <updated>2022-12-18T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  The following notes were taken while discussing Chapter 2 of the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  An index of notes for all chapters are available
  at &lt;a href=&quot;notes.html&quot;&gt;notes.html&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#magpie-nest-of-shiny-things&quot;&gt;Magpie&apos;s Nest of Shiny Things&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#cornerstore-of-emacs&quot;&gt;Cornerstone of Emacs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#uptime&quot;&gt;Uptime&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#rpn-calculator&quot;&gt;RPN Calculator&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#point-and-mark&quot;&gt;Point and Mark&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#returning-to-mark&quot;&gt;Returning to Mark&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#font-locking&quot;&gt;Font Locking&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#change-major-mode&quot;&gt;Change Major Mode&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;magpie-nest-of-shiny-things&quot;&gt;Magpie&apos;s Nest of Shiny Things&lt;/h2&gt;
&lt;p&gt;
  The following commands mentioned in the book invoke some interesting
  functions:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;code&gt;M-x zone RET&lt;/code&gt;: Zone out, completely; a built-in screensaver.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x dunnet RET&lt;/code&gt;: Dungeon text adventure game.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x tetris RET&lt;/code&gt;: Tetris clone.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x lunar-phases RET&lt;/code&gt;: Lunar phases calendar.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;code&gt;M-x doctor RET&lt;/code&gt;: ELIZA chatterbot.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;cornerstore-of-emacs&quot;&gt;Cornerstone of Emacs&lt;/h2&gt;
&lt;p&gt;
  The chapter mentions the Elisp interpreter as the cornerstone of
  Emacs.  In fact, Emacs is an editor program that runs in the Elisp
  interpreter.  When we start Emacs, what really starts first is an
  Elisp interpreter.  It executes the Elisp code of an editor program.
  When that program executes, we get Emacs, the editor!
&lt;/p&gt;
&lt;p&gt;
  This behaviour is quite the opposite of how Vim and other editors
  behave.  For example, when we start Vim or Visual Studio Code, first
  the editor runs.  The editor then provides an embedded programming
  language that we can use to write plugins and extend the editor.
  For example, Vim offers VimScript to let us write code using
  VimScript and extend the functionality of Vim.  However, when we
  start Emacs, first the Elisp interpreter runs and this interpreter
  executes a program that results in Emacs, the editor.
&lt;/p&gt;
&lt;h2 id=&quot;uptime&quot;&gt;Uptime&lt;/h2&gt;
&lt;p&gt;
  The key sequence &lt;code&gt;M-x emacs-uptime RET&lt;/code&gt; shows how long
  the current instance of Emacs has been running.  Many users have
  month-long uptimes.
&lt;/p&gt;
&lt;h2 id=&quot;rpn-calculator&quot;&gt;RPN Calculator&lt;/h2&gt;
&lt;p&gt;
  To try out the calculator, type &lt;code&gt;C-x * c&lt;/code&gt; or &lt;code&gt;M-x
  calc RET&lt;/code&gt; to start the calculator.  Then to calculate
  something like, say, 1 + (2 * 3), type &lt;code&gt;1 RET 2 RET 3 RET *
  +&lt;/code&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;point-and-mark&quot;&gt;Point and Mark&lt;/h2&gt;
&lt;p&gt;
  To try out point and mark quickly, first open a buffer with some
  text in it.  For example, open a file, say, &lt;code&gt;foo.txt&lt;/code&gt;
  using the key sequence &lt;code&gt;C-x C-f foo.txt RET&lt;/code&gt;.  Make sure
  there are a few lines of text in the buffer.  If it is a new buffer,
  type some lines of text into it.  Then move the point (cursor) to
  any arbitrary place within the text.  The motion keys
  like &lt;code&gt;C-p&lt;/code&gt;, &lt;code&gt;C-n&lt;/code&gt;, &lt;code&gt;C-b&lt;/code&gt;, &lt;code&gt;C-f&lt;/code&gt;,
  etc. or simply &lt;code&gt;&amp;lt;up&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;down&amp;gt;&lt;/code&gt;,
  &lt;code&gt;&amp;lt;left&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;right&amp;gt;&lt;/code&gt;, etc. may be
  used to do this.
&lt;/p&gt;
&lt;p&gt;
  Then type &lt;code&gt;C-SPC&lt;/code&gt; (i.e. &lt;kbd&gt;ctrl&lt;/kbd&gt;+&lt;kbd&gt;space&lt;/kbd&gt;)
  to set the mark at the current position of the point.  Then move the
  point around.  Emacs should now be highlighting the region between
  the mark (set earlier) and the point.  Then type &lt;code&gt;M-w&lt;/code&gt;
  (i.e. &lt;kbd&gt;alt&lt;/kbd&gt;+&lt;kbd&gt;w&lt;/kbd&gt;) to copy the text in the selected
  region or type &lt;code&gt;C-w&lt;/code&gt; to cut the text instead.  Finally,
  move the point around again and type &lt;code&gt;C-y&lt;/code&gt; to paste the
  copied/cut text.
&lt;/p&gt;
&lt;h2 id=&quot;returning-to-mark&quot;&gt;Returning to Mark&lt;/h2&gt;
&lt;p&gt;
  Marks can also be used to remember a position in the buffer to which
  we may wish to return to later.  To try it out, first move the point
  to some place in the buffer where a mark needs to be set.  Then
  type &lt;code&gt;C-SPC C-SPC&lt;/code&gt; to set the mark without activating it
  (activating a mark causes Emacs to highlight the region as explained
  in the previous section).  Then move the point to some other place
  in the buffer.  Finally, type &lt;code&gt;C-u C-SPC&lt;/code&gt; to return to
  the marked position.
&lt;/p&gt;
&lt;h2 id=&quot;font-locking&quot;&gt;Font Locking&lt;/h2&gt;
&lt;p&gt;
  Font locking (syntax highlighting) in Emacs is made up of faces of
  properties (colour, font, size, etc.).  Type &lt;code&gt;C-u C-x =&lt;/code&gt;
  to describe the current character (the character the cursor is on).
  The output displays the face details as well.  Alternatively,
  type &lt;code&gt;M-x describe-face RET&lt;/code&gt; to describe the face of the
  character the cursor is on.
&lt;/p&gt;
&lt;h2 id=&quot;change-major-mode&quot;&gt;Change Major Mode&lt;/h2&gt;
&lt;p&gt;
  Emacs almost always sets the appropriate major mode by inspecting
  the filename or the content of the buffer.  However, sometimes it
  can be useful to set the major mode manually.  For example, consider
  a file named &lt;code&gt;foo.html&lt;/code&gt; which is open in Emacs and has
  the following text:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Euler&apos;s Identity&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;
  In mathematics, &amp;lt;em&amp;gt;Euler&apos;s identity&amp;lt;/em&amp;gt; is the
  equality

  \[
    e^{i \pi} + 1 = 0.
  \]

  Euler&apos;s identity is a special case of Euler&apos;s formula from complex
  analysis, which states that for any real number \( x, \)

  \[
    e^{ix} = \cos x + i \sin x.
  \]
&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  This is an HTML file with some LaTeX snippets that would perhaps be
  rendered using a LaTeX rendering tool such as MathJax or KaTeX.  By
  default, when this file is opened in Emacs, the major mode is set to
  HTML+.  However, if one wants to focus on editing the embedded LaTeX
  content, it is possible to change the major mode to LaTeX by
  typing &lt;code&gt;M-x latex-mode RET&lt;/code&gt;.  To change the major mode
  back to HTML+, type &lt;code&gt;M-x mhtml-mode RET&lt;/code&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;
&lt;p&gt;
  The following list includes some links that were discussed during
  the book discussion group meetings:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://orgmode.org/worg/org-tutorials/org-spreadsheet-intro.html&quot;&gt;Org
    as a spreadsheet system: a short introduction&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://orgmode.org/manual/The-Spreadsheet.html&quot;&gt;The
    Spreadsheet (The Org Manual)&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://blog.polaris64.net/post/emacs-using-org-mode-to-track-exercises/&quot;&gt;Using
    Org Mode to keep track of exercise&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://github.com/jkitchin/scimax&quot;&gt;scimax: An emacs
      starterkit for scientists and engineers&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://www.iro.umontreal.ca/~monnier/oclosure.pdf&quot;&gt;Open
    Closures: Disclosing lambda&apos;s inner monomaniac object!&lt;/a&gt; by
    Stefan Monnier
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;http://dantorop.info/project/emacs-animation/&quot;&gt;Emacs Lisp
    Animations&lt;/a&gt; by Dan Torop
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://github.com/karthink/org-auctex&quot;&gt;org-auctex:
      Better LaTeX previews for org-mode&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://emacsconf.org/2022/talks/eshell/&quot;&gt;Top 10 reasons
    why you should be using Eshell&lt;/a&gt; by Howard Abrams
  &lt;/li&gt;
&lt;/ul&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/ch02.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes from Mastering Emacs Meetups</title>
    <link href="https://susam.net/cc/mastering-emacs/notes.html"/>
    <id>urn:uuid:b379fc2e-d03e-49f9-a5bf-e576cd614f79</id>
    <updated>2022-12-17T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;h1&gt;Notes from Mastering Emacs Meetups&lt;/h1&gt;
&lt;p&gt;
  The following notes were taken while discussing the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  Note that these notes are not a good substitute for the actual book.
  Not everything in the book is captured in these notes.  While some
  points mentioned in the book are missing from the notes, there are
  also some points from the book where these notes discuss them in
  much greater detail than the book does.
&lt;/p&gt;
&lt;ul class=&quot;blog&quot;&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch01.html&quot;&gt;Notes on Mastering Emacs: Chapter 1: Introduction&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch02.html&quot;&gt;Notes on Mastering Emacs: Chapter 2: The Way of Emacs&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch03.html&quot;&gt;Notes on Mastering Emacs: Chapter 3: First Steps&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch04.html&quot;&gt;Notes on Mastering Emacs: Chapter 4: The Theory of Movement&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch05.html&quot;&gt;Notes on Mastering Emacs: Chapter 5: The Theory of Editing&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch06.html&quot;&gt;Notes on Mastering Emacs: Chapter 6: The Practicals of Emacs&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch07.html&quot;&gt;Notes on Mastering Emacs: Chapter 7: Conclusion&lt;/a&gt;
  &lt;/li&gt;
&lt;/ul&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/notes.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Mastering Emacs: Chapter 1: Introduction</title>
    <link href="https://susam.net/cc/mastering-emacs/ch01.html"/>
    <id>urn:uuid:14be8e39-2d50-47bd-9fd7-7ccde69e3b05</id>
    <updated>2022-12-16T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  The following notes were taken while discussing Chapter 1 of the
  book &lt;em&gt;Mastering Emacs&lt;/em&gt; by Mickey Petersen (2022 edition) in
  &lt;a href=&quot;./&quot;&gt;book discussion group meetings&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  An index of notes for all chapters are available
  at &lt;a href=&quot;notes.html&quot;&gt;notes.html&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#describe-system&quot;&gt;Describe System&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#language-servers&quot;&gt;Language Servers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#baroque-terminology&quot;&gt;Baroque Terminology&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#active-friendly-community&quot;&gt;Active, Friendly Community&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#vim-emulation-layer&quot;&gt;Vim Emulation Layer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#links&quot;&gt;Links&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;describe-system&quot;&gt;Describe System&lt;/h2&gt;
&lt;p&gt;
  To get a glimpse of the powerful describe system available in Emacs,
  type the following key sequence: &lt;code&gt;C-h C-k C-p&lt;/code&gt;.  This
  shows the documentation associated with the keys
  sequence &lt;code&gt;C-p&lt;/code&gt; that invokes the command
  named &lt;code&gt;previous-line&lt;/code&gt; to move the cursor to the previous
  line.  The documentation mentions that this command is defined in a
  file named &lt;code&gt;simple.el&lt;/code&gt;.  Click on the file name to jump
  straight into the source code of &lt;code&gt;simple.el&lt;/code&gt; where this
  command is defined.  With Emacs, the source code of Emacs is not
  hidden from the user.  The describe system is discussed in Chapter 3
  of the book.
&lt;/p&gt;
&lt;h2 id=&quot;language-servers&quot;&gt;Language Servers&lt;/h2&gt;
&lt;p&gt;
  The two popular language server implementations for Emacs are LSP
  Mode and Eglot.  Since Emacs 29, Eglot is part of Emacs core and
  does not require installing a separate package.  It can be run with
  the key sequence &lt;code&gt;M-x eglot RET&lt;/code&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;baroque-terminology&quot;&gt;Baroque Terminology&lt;/h2&gt;
&lt;p&gt;
  Some examples are:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    The term &lt;em&gt;point&lt;/em&gt; to refer to the cursor.
  &lt;/li&gt;
  &lt;li&gt;
    The term &lt;em&gt;yank&lt;/em&gt; to paste text.  What can be especially
    confusing for users with prior Vim experience is that Vim uses the
    term &lt;em&gt;yank&lt;/em&gt; to mean copying text but Emacs uses this term
    to mean pasting text.
  &lt;/li&gt;
  &lt;li&gt;
    An OS-level or desktop-environment-level window is known
    as &lt;em&gt;frame&lt;/em&gt; in Emacs.  We can split an Emacs frame into
    multiple panes and these panes are called &lt;em&gt;windows&lt;/em&gt; in
    Emacs.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  There are many more such examples.  The above examples illustrate
  the kind of surprises one should be ready for while reading Emacs
  documentation.  Fortunately, it is often possible to understand the
  meaning of these terms from the context.
&lt;/p&gt;
&lt;h2 id=&quot;active-friendly-community&quot;&gt;Active, Friendly Community&lt;/h2&gt;
&lt;p&gt;
  There are three good places to hang out with other Emacs users, seek
  help or help others with Emacs:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    Reddit &lt;a href=&quot;https://www.reddit.com/r/emacs/&quot;&gt;r/emacs&lt;/a&gt;
    community.
  &lt;/li&gt;
  &lt;li&gt;
    Libera &lt;a href=&quot;https://web.libera.chat/#emacs&quot;&gt;#emacs&lt;/a&gt;
    channel.
  &lt;/li&gt;
  &lt;li&gt;
    Matrix &lt;a href=&quot;https://app.element.io/#/room/#emacs:matrix.org&quot;&gt;#emacs&lt;/a&gt;
    room.
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  All three places appear to be quite friendly to beginners to Emacs!
&lt;/p&gt;
&lt;h2 id=&quot;vim-emulation-layer&quot;&gt;Vim Emulation Layer&lt;/h2&gt;
&lt;p&gt;
  The most popular Vim emulation layer these days is Evil Mode.  It is
  often said that the best implementation of Vim is written in Emacs
  Lisp.  Some people also claim that Evil Mode is a better Vim than
  Vim itself.  In fact, the next chapter, i.e. Chapter 3, says the
  following:
&lt;/p&gt;
&lt;blockquote&gt;
  Vim users are migrating to Emacs because, well, Emacs is often a
  better Vim than Vim.
&lt;/blockquote&gt;
&lt;h2 id=&quot;links&quot;&gt;Links&lt;/h2&gt;
&lt;p&gt;
  The following list includes some links that were discussed during
  the book discussion group meetings:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://github.com/Wilfred/helpful&quot;&gt;Helpful&lt;/a&gt; is an
    alternative to the built-in Emacs help that provides much more
    contextual information.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://github.com/xuchunyang/elisp-demos&quot;&gt;Elisp API
    Demos&lt;/a&gt; injects Elisp demo examples in &lt;code&gt;*Help*&lt;/code&gt;
    buffers.
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;https://planet.emacslife.com/&quot;&gt;Planet Emacslife&lt;/a&gt; is a
    feed aggregrator for Emacs-related blogs.
&lt;/ul&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/ch01.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Mastering Emacs Book Club</title>
    <link href="https://susam.net/cc/mastering-emacs/"/>
    <id>urn:uuid:0117f91c-775e-4235-aba0-f4ef38039015</id>
    <updated>2022-12-15T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;h1&gt;Mastering Emacs Book Club&lt;/h1&gt;
&lt;div class=&quot;highlight&quot;&gt;
  This meeting series is complete!  There are no new meetings
  happening for this book.  Go to the meetings
  &lt;a href=&quot;../&quot;&gt;main page&lt;/a&gt; to find out about current
  active meetings.
&lt;/div&gt;
&lt;p&gt;
  The following content on this page is an archive of the content as
  it appeared on the last day of meeting for this book.
&lt;/p&gt;
&lt;hr&gt;
&lt;div class=&quot;highlight&quot;&gt;
  &lt;p&gt;
    Meeting times:
    Usually at 20:00 UTC on Fri, Sat and Sun&lt;sup&gt;&amp;dagger;&lt;/sup&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Meeting duration:
    40 minutes.
  &lt;/p&gt;
  &lt;p&gt;
    Meeting link:
    &lt;a href=&quot;../../meet/&quot;&gt;susam.net/meet&lt;/a&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Meeting log:
    &lt;a href=&quot;log.html#upcoming&quot;&gt;72 meetings&lt;/a&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Reference book:
    &lt;a href=&quot;https://www.masteringemacs.org/&quot;&gt;&lt;em&gt;Mastering Emacs&lt;/em&gt;&lt;/a&gt;
    by Mickey Petersen (2022 edition)
  &lt;/p&gt;
  &lt;p&gt;
    Chapter notes:
    &lt;a href=&quot;notes.html&quot;&gt;Notes&lt;/a&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Club channel:
    &lt;a href=&quot;https://app.element.io/#/room/#susam:matrix.org&quot;&gt;#susam:matrix.org&lt;/a&gt; /
    &lt;a href=&quot;https://web.libera.chat/#susam&quot;&gt;#susam:libera.chat&lt;/a&gt;&lt;sup&gt;&amp;ddagger;&lt;/sup&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Mastodon:
    &lt;a href=&quot;https://mastodon.social/@susam&quot;&gt;@susam@mastodon.social&lt;/a&gt;
  &lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;small&gt;&amp;dagger; There are some exceptions to this schedule
  occasionally.  Join
  &lt;a href=&quot;https://app.element.io/#/room/#susam:matrix.org&quot;&gt;#susam:matrix.org&lt;/a&gt;
  or &lt;a href=&quot;https://web.libera.chat/#susam&quot;&gt;#susam:libera.chat&lt;/a&gt;
  or follow &lt;a href=&quot;https://mastodon.social/@susam&quot;&gt;@susam@mastodon.social&lt;/a&gt;
  to receive schedule updates.&lt;/small&gt;
&lt;/p&gt;
&lt;p&gt;
  &lt;small&gt;&amp;ddagger; You only need to join either the Matrix channel or
  the Libera channel, not both.  Both channels are bridged together.
  If you are not an active IRC user, prefer joining the Matrix channel
  because it is more convenient for someone unfamiliar with IRC.  For
  example, you can close your browser or client and your chat session
  will still stay alive on Matrix.  You can connect back the next day
  and catch up with the messages.  Doing that with IRC requires
  slightly more work such as setting up IRC bouncers etc.&lt;/small&gt;
&lt;/p&gt;
&lt;p&gt;
  The primary reference book for these meetings is
  &lt;em&gt;Mastering Emacs&lt;/em&gt; written by Mickey Petersen (2022 edition).
  PDF and EPUB copies of this book can be purchased
  from &lt;a href=&quot;https://www.masteringemacs.org/&quot;&gt;masteringemacs.org&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  In case you miss any meeting, you can find recordings of the
  meetings that occurred in the last 7 days here:
  &lt;a href=&quot;https://www.twitch.tv/susampal&quot;&gt;twitch.tv/susampal&lt;/a&gt;.
  These recordings are deleted automatically after 7 days.
&lt;/p&gt;
&lt;h2 id=&quot;faq&quot;&gt;FAQ&lt;/h2&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;what-is-this-club-about&quot;&gt;What is this club about?&lt;/h3&gt;
    &lt;p&gt;
      This is a hobby club with a focus on mathematics and
      computation.  This club picks reading material about concepts
      and technologies that have been around for a long time and have
      an air of timelessness around them.  See the blog
      post &lt;a href=&quot;../../reading-classic-computation-books.html&quot;&gt;Reading
      Classic Computation Books&lt;/a&gt; for more details.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;who-runs-this-club&quot;&gt;Who runs this club?&lt;/h3&gt;
    &lt;p&gt;
      My name is Susam.  This is my website.  I run this club.  I host
      the book club meetings.  The last series of book club meetings I
      hosted was about &lt;a href=&quot;../iant/&quot;&gt;analytic number
      theory&lt;/a&gt;.  Some members of Libera IRC network and Hacker News
      participated in those meetings.  This new series is going to be
      about Emacs.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;what-is-planned&quot;&gt;What is planned for the next few meetings?&lt;/h3&gt;
    &lt;p&gt;
      See the &lt;a href=&quot;log.html&quot;&gt;meeting log&lt;/a&gt; which contains a
      rough plan for the next few meetings along with an archive of
      all previous meetings.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;do-i-need-to-read-in-advance&quot;&gt;Do I need to read the planned chapters/pages in advance before coming to the meetings?&lt;/h3&gt;
    &lt;p&gt;
      Not at all.  It is up to you, really.  If you would like to read
      the chapters in advance and come, that&apos;s great.  But it is not
      necessary.  We are going to discuss every page of the book in
      detail anyway.  Further, we will demonstrate the concepts we
      learn from the book live using an actual Emacs editor.  So it is
      perfectly fine if you want to join the meetings without any
      preparation.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;can-beginners-join&quot;&gt;I have little to no knowledge of Emacs.  Can I join?&lt;/h3&gt;
    &lt;p&gt;
      Yes, certainly!  The reference book selected for these meetings
      teaches Emacs from scratch.  No prior knowledge is expected from
      the participants of these meeetings.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;can-experts-join&quot;&gt;I am an expert in Emacs.  Will the meetings be useful to me?&lt;/h3&gt;
    &lt;p&gt;
      In online discussions, often people with many years of Emacs
      experience have claimed that despite their high degree of
      expertise in Emacs, the book taught them new stuff.  Whether
      attending 40-minute meetings, a few days a week, with a
      possibility of learning something new is a good return of your
      investment or not, is something you might want to consider.
    &lt;/p&gt;
    &lt;p&gt;
      Having said that, expert Emacs users and developers are very
      welcome to these meetings.  In the previous meetings on analytic
      number theory, we found that the experts often contributed to
      the meetings with new insights and interesting background
      information that helped everyone learn the reading material
      better.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;can-i-lurk&quot;&gt;Can I just lurk in the meetings?&lt;/h3&gt;
    &lt;p&gt;
      Yes!  Lurking is absolutely fine in our club meetings.  In fact,
      most members of the club join in and stay silent throughout the
      meetings.  Only a few members talk via audio/video or chat.
      This is considered absolutely normal in this club, so please do
      not hesitate to join our meetings!
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;vim-or-emacs&quot;&gt;Tell me honestly.  Which is better?  Vim or Emacs?&lt;/h3&gt;
    &lt;p&gt;
      Sorry, we don&apos;t do this here!  &lt;!-- Emacs!  Definitely Emacs!  --&gt;
    &lt;/p&gt;
  &lt;li&gt;
    &lt;h3 id=&quot;where-can-i-ask-questions&quot;&gt;I have more questions.  Where can I ask?&lt;/h3&gt;
    &lt;p&gt;
      Join the club channel
      at &lt;a href=&quot;https://app.element.io/#/room/#susam:matrix.org&quot;&gt;#susam:matrix.org&lt;/a&gt;
      or &lt;a href=&quot;https://web.libera.chat/#susam&quot;&gt;#susam:libera.chat&lt;/a&gt;
      to ask more questions.
    &lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/mastering-emacs/"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/emacs.html&quot;&gt;#emacs&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/technology.html&quot;&gt;#technology&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Final IANT Meeting Today</title>
    <link href="https://susam.net/final-iant-meeting.html"/>
    <id>urn:uuid:c3ed58ab-09ac-43e2-8e19-1f9de8dbbd9a</id>
    <updated>2021-10-01T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;
  We have been reading the book &lt;em&gt;Introduction to Analytic Number
  Theory&lt;/em&gt; by Apostol (1976) since March 2021.  It has been going
  consistently since then and the previous few posts on this blog
  provide an account of how this journey has been so far.  After about
  seven months of reading this book together, we are having our final
  meeting for this book today.  This is going to be
  the &lt;a href=&quot;cc/iant/log.html#120&quot;&gt;120th meeting&lt;/a&gt; of our book
  discussion group.  The meeting notes from all previous reading
  sessions are archived at
  &lt;a href=&quot;cc/iant/&quot;&gt;IANT Notes&lt;/a&gt;.  We will discuss the
  final two pages of this book today and complete reading this book.
&lt;/p&gt;
&lt;p&gt;
  In the meeting today, we will look at some applications of the
  recursion formula related to partition functions that we learnt
  earlier.  Here is an excerpt from the book that shows a specific
  example that demonstrates the richness and beauty of concepts one
  can discover while studying analytic number theory:
&lt;/p&gt;
&lt;blockquote&gt;
  Equation (24) becomes

  \[
  np(n) = \sum_{k=1}^n \sigma(k) p(n - k).
  \]

  a remarkable relation connecting a function of multiplicative number
  theory with one of additive number theory.
&lt;/blockquote&gt;
&lt;p&gt;
  Now what equation (24) contains is not important for this post.  Of
  course, you can refer to the book if you really want to know what
  equation (24) is.  We learnt to prove that equation in the
  penultimate meeting for this subject yesterday.  In this post, I
  will emphasise how indeed this equation is remarkable.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#introduction&quot;&gt;Introduction&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#divisor-sum-function&quot;&gt;The Divisor Sum Function&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#unrestricted-partition-function&quot;&gt;The Unrestricted Partition Function&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#linkage-of-two-theorems&quot;&gt;The Linkage of Two Theories&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#final-meeting&quot;&gt;The Final Meeting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#thanks&quot;&gt;Thanks!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;divisor-sum-function&quot;&gt;The Divisor Sum Function&lt;/h2&gt;
&lt;p&gt;
  The divisor sum function \( \sigma(n) \) represents the sum of all
  positive divisors of \( n.  \)  Here are some examples:

  \begin{align*}
  \sigma(1) &amp;amp;= 1, \\
  \sigma(2) &amp;amp;= 1 + 2 = 3, \\
  \sigma(3) &amp;amp;= 1 + 3 = 4, \\
  \sigma(4) &amp;amp;= 1 + 2 + 4 = 7, \\
  \sigma(5) &amp;amp;= 1 + 5 = 6.
  \end{align*}

  We have spent a good amount of time with this function in the
  initial chapters of the book.  However, for the purpose of this blog
  post, the definition and the examples above are good enough.
&lt;/p&gt;
&lt;h2 id=&quot;unrestricted-partition-function&quot;&gt;The Unrestricted Partition Function&lt;/h2&gt;
&lt;p&gt;
  The \( p(n) \) function is the unrestricted partition function.  It
  represents the number of ways \( n \) can be written as a sum of
  positive integers \( \le n.  \)  Further, we let \( p(0) = 1.  \)
  Here are some examples:

  \begin{align*}
  p(1) &amp;amp;= 1, \\
  p(2) &amp;amp;= 2, \\
  p(3) &amp;amp;= 3, \\
  p(4) &amp;amp;= 4, \\
  p(5) &amp;amp;= 7.
  \end{align*}

  Let me illustration the last value.  The integer \( 5 \) can be
  represented as a sum of positive integers \( \le 5 \) in 7 different
  ways.  They are: \( 5, \) \( 4 + 1, \) \( 3 + 2, \) \( 3 + 1 + 1, \)
  \( 2 + 2 + 1, \) \( 2 + 1 + 1 + 1 \) and \( 1 + 1 + 1 + 1 + 1.  \)
  Thus \( p(n) = 5.  \)
&lt;/p&gt;
&lt;h2 id=&quot;linkage-of-two-theorems&quot;&gt;The Linkage of Two Theories&lt;/h2&gt;
&lt;p&gt;
  The divisor sum function comes from multiplicative number theory.
  The partition function comes from additive number theory.  Yet these
  two very different things get linked together in the formula
  mentioned in the excerpt included above.  Here is the formula once
  again:

  \[
    np(n) = \sum_{k=1}^n \sigma(k) p(n - k).
  \]

  How beautiful!  How nicely the divisor sum function and the
  unrestricted partition function appear together elegantly in a
  single equation!  Further, this equation provides a recursion
  formula for the partition function.

  Here is an illustration of this equation with \( n = 5 \):

  \[
    5 \cdot p(5) = 5 \cdot 7 = 35.
  \]

  \begin{align*}
    \sum_{k=1}^5 \sigma(k) p(5 - k)
    &amp;amp;= \sigma(1) p(4) + \sigma(2) p(3) + \sigma(3) p(2) + \sigma(4) p(1) + \sigma(5) p(0) \\
    &amp;amp;= (1)(5) + (3)(3) + (4)(2) + (7)(1) + (6)(1) \\
    &amp;amp;= 5 + 9 + 8 + 7 + 6 \\
    &amp;amp;= 35.
  \end{align*}

  We will go through this topic once more in the meeting today, so if
  you are interested to see this formula worked out in a step-by-step
  manner, do join our final meeting for this book.
&lt;/p&gt;
&lt;h2 id=&quot;final-meeting&quot;&gt;The Final Meeting&lt;/h2&gt;
&lt;p&gt;
  The final meeting is coming up at 17:00 UTC today.  Visit
  the &lt;a href=&quot;cc/iant/&quot;&gt;analytic number theory page&lt;/a&gt; to
  get the meeting link.  This is not going to be the final meeting for
  our overall book discussion group though.  This is going to be the
  finally meeting for only the analytic number theory book.  We will
  have more meetings for another book after a short break.
&lt;/p&gt;
&lt;p&gt;
  The meeting today is going to be a lightweight session.  The last
  two pages that we will discuss today contain some examples of
  recursion formulas and some commentary about Ramanujan&apos;s partition
  identities.  Most of it should make sense even to those who have not
  been part of our meetings earlier, so everyone is welcome to join
  this meeting today, even if only to lurk.  You can also join our
  group by joining our IRC channel where we will publish updates about
  future meetings.  Our channel details are available in the
  &lt;a href=&quot;cc/#join&quot;&gt;main page here&lt;/a&gt;.
&lt;/p&gt;
&lt;h2 id=&quot;thanks&quot;&gt;Thanks!&lt;/h2&gt;
&lt;p&gt;
  A big thank you to the Hacker News community and the Libera IRC
  mathematics and algorithms communities who showed interest in these
  meetings, joined the meetings and made this series of meetings
  successful.
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/final-iant-meeting.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Journey to Integer Partitions</title>
    <link href="https://susam.net/journey-to-integer-partitions.html"/>
    <id>urn:uuid:db7dce0f-be2f-4c77-8dfb-0ed3fe9c36a2</id>
    <updated>2021-09-18T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;
  After &lt;a href=&quot;cc/iant/log.html#114&quot;&gt;114 meetings&lt;/a&gt; and 75 hours
  of studying together, our analytic number theory book discussion
  group has finally reached the final chapter of the
  book &lt;em&gt;Introduction to Analytic Number Theory&lt;/em&gt; by Apostol
  (1976).  We have less than 18 pages to read in order to complete
  reading this book.  Considering that we meet 3-4 times in a week and
  we discuss about 2-3 pages in every meeting, it appears that we
  would be able to complete reading this book in another 2 weeks.
&lt;/p&gt;
&lt;p&gt;
  Reading this book has been quite a journey!  The previous three
  posts on this blog provide an account of how this journey has been.
  It has been fun, of course.  The best part of hosting a book
  discussion group like this has been the number of extremely smart
  people I got an opportunity to meet and interact with.  The insights
  and comments on the study material that others shared during the
  meetings were very helpful.
&lt;/p&gt;
&lt;p&gt;
  The &lt;a href=&quot;cc/iant/log.html&quot;&gt;meeting log&lt;/a&gt; shows that our
  meetings started really small with only 4 participants in the first
  meeting in March 2021 and then it gradually grew to about 10-12
  regular members within a month.  Then a few months later, the number
  of participants began dwindling a little.  This happened because
  some members of the group had to drop out as they got busy with
  other personal or professional engagements.  However, six months
  later, we still have about 4-5 regular participants meeting
  consistently.  I think it is pretty good that we have made it this
  far.
&lt;/p&gt;
&lt;h2 id=&quot;unrestricted-partitions&quot;&gt;Unrestricted Partitions&lt;/h2&gt;
&lt;p&gt;
  The final chapter on integer partitions is very unlike all the
  previous 12 chapters.  While the previous chapters dealt
  with &lt;em&gt;multiplicative number theory&lt;/em&gt;, this final chapter deals
  with &lt;em&gt;additive number theory&lt;/em&gt;.  For example, the first
  theorem talks about an interesting property of &lt;em&gt;unrestricted
  partitions&lt;/em&gt;.  We study the number of ways a positive integer can
  be expressed as a sum of positive integers.  The number of summands
  is unrestricted, repetition of summands is allowed and the order of
  the summands is not taken into account.  For example, the number 3
  has 3 partitions: 3, 2 + 1 and 1 + 1 + 1.  Similarly, the number 4
  has 5 partitions: 4, 3 + 1, 2 + 2, 2 + 1 + 1 and 1 + 1 + 1 + 1.
&lt;/p&gt;
&lt;p&gt;
  I have always wanted to learn about partitions more deeply, so I am
  quite happy that this book ends with a chapter on partitions.  The
  subject of partitions is rich with very interesting results obtained
  by various accomplished mathematicians.  In the book, the first
  theorem about partitions is a very simple one that follows from the
  geometric representation of partitions.  Let us see an illustration
  first.
&lt;/p&gt;
&lt;p&gt;
  How many partitions of 6 are there?  There are 11 partitions of 6.
  They are 6, 5 + 1, 4 + 2, 4 + 1 + 1, 3 + 3, 3 + 2 + 1, 3 + 1 + 1 +
  1, 2 + 2 + 2, 2 + 2 + 1 + 1, 2 + 1 + 1 + 1 + 1 and 1 + 1 + 1 + 1 + 1
  + 1.  Now how many of these partitions are made up of 5 parts?  Each
  summand is called a part.  The answer is 2.  There are 2 partitions
  of 6 that are made up of 5 parts.  They are 3 + 1 + 1 + 1 and 2 + 2
  + 1 + 1.  Let us represent both these partitions as arrangements of
  lattice points.  Here is the representation of the partition 3 + 1 +
  1 + 1:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;bull; &amp;bull; &amp;bull;
&amp;bull;
&amp;bull;
&amp;bull;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Now if we read this arrangement from left to right, column by
  column, we get another partition of 6, i.e. 4 + 1 + 1.  Note that
  the number of parts in 3 + 1 + 1 + 1 (i.e. 4) appears as the largest
  part in 4 + 1 + 1.  Similarly, the number of parts in 4 + 1 + 1
  (i.e. 3) appears as the largest part in 3 + 1 + 1 + 1.  Let us see
  one more example of this relationship.  Here is the geometric
  representation of 2 + 2 + 1 + 1:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;bull; &amp;bull;
&amp;bull; &amp;bull;
&amp;bull;
&amp;bull;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Once again, reading this representation from left to right, we get 4
  + 2, another partition of 6.  Once again, we can see that the number
  of partitions in 2 + 2 + 1 + 1 (i.e. 4) appears as the largest part
  in 4 + 2 and vice versa.  These observations lead to the first
  theorem in the chapter on partitions:
&lt;/p&gt;
&lt;blockquote&gt;
  &lt;strong&gt;Theorem 14.1&lt;/strong&gt;
  &lt;em&gt;
    The number ofpartitions of \( n \)
    into \( m \) parts is equal to the number of partitions of \( n \)
    into parts, the largest of which is \( m.  \)
  &lt;/em&gt;
&lt;/blockquote&gt;
&lt;p&gt;
  That was a brief introduction to the chapter on partitions.  In the
  next two or so weeks, we will dive deeper into the theory of
  partitions.
&lt;/p&gt;
&lt;h2 id=&quot;next-meeting&quot;&gt;Next Meeting&lt;/h2&gt;
&lt;p&gt;
  If this blog post was fun for you, consider joining our next
  meeting.  Our next meeting is on Tue, 21 Sep 2021 at 17:00 UTC.
  Since we are at the beginning of a new chapter, it is a good time
  for new participants to join us.  It is also a good time for members
  who have been away for a while to join us back.  Since this chapter
  does not depend much on the previous chapters, new participants
  should be able to join our reading sessions for this chapter and
  follow along easily without too much effort.
&lt;/p&gt;
&lt;p&gt;
  To join our discussions, see our channel details in the
  &lt;a href=&quot;cc/#join&quot;&gt;main page here&lt;/a&gt;.  To get the
  meeting link for the next meeting, visit the
  &lt;a href=&quot;cc/iant/&quot;&gt;analytic number theory book
  page&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  It is worth mentioning here that lurking is absolutely fine in our
  meetings.  In fact, most participants of our meetings join in and
  stay silent throughout the meeting.  Only a few members talk via
  audio/video or chat.  This is considered absolutely normal in our
  meetings, so please do not hesitate to join our meetings!
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/journey-to-integer-partitions.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Journey to the Prime Number Theorem</title>
    <link href="https://susam.net/journey-to-prime-number-theorem.html"/>
    <id>urn:uuid:abeef71a-493c-43d5-a052-8ad2ec058209</id>
    <updated>2021-09-09T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  How long does it take to start with zero knowledge of analytic
  number theory and successfully learn the analytic proof of the prime
  number theorem?  Take a guess!  I will share my answer in the next
  two paragraphs.  This is something I had wondered when we began our
  analytic number theory book discussion group in March 2021.  Back
  then, I thought it would take at least 100 hours of effort.
&lt;/p&gt;
&lt;p&gt;
  The book I had chosen for our discussions was &lt;em&gt;Introduction to
  Analytic Number Theory&lt;/em&gt; by Apostol (1976).  I have been hosting
  40-minute meetings for about 3-4 days every week since March 2021.
  We discuss a couple of pages of the book in every meeting.  Most
  participants in this meeting are from Hacker News and Libera IRC
  network.  For a long time, I was eager to learn the proof of the
  prime number theorem.  For those unfamiliar with the theorem, I will
  describe it briefly in further sections.  Let me first answer the
  question I asked in the previous paragraph.
&lt;/p&gt;
&lt;p&gt;
  So how long does it take to start with no knolwedge of analytic
  number theory and teach ourselves the analytic proof of the prime
  number theorem?  Turns out, it takes 72 hours!  It took our group 72
  hours spread across &lt;a href=&quot;cc/iant/log.html#110&quot;&gt;110 meetings&lt;/a&gt;
  over 6 months to be able to understand the proof.  It is worth
  noting here that most of us in this group have full-time jobs and
  other personal obligations!  We were all doing this for fun, for the
  joy of learning!
&lt;/p&gt;
&lt;p&gt;
  Now I must mention that the 72 hours noted above is only the time
  spent together in reading the book and working through the theorems
  and proofs.  It does not include the personal time spent in solving
  problems, reading some sections again, taking notes, etc.  All of
  that was done in our personal time.  We did discuss the solutions to
  some of the very interesting problems in our meetings just to take a
  break from the theorem-and-proof style of reading but most of these
  72 hours of meetings focussed on working through the theorems and
  proofs in the book.
&lt;/p&gt;
&lt;p&gt;
  It may be possible to achieve this milestone in lesser number of
  hours, perhaps by reading the book alone which for some folks might
  be faster than studying in a group or perhaps by skipping some
  chapters for topics that look very familiar.  In our discussions,
  however, we did not skip any chapter.  There were in fact a few
  chapters we could have skipped.  All members of these meetings were
  very familiar with divisibility, greatest common divisor, the
  fundamental theorem of arithmetic, etc. discussed in Chapter 1.
  Most of us were also very familiar with the concepts discussed in
  Chapter 5 such as congruences, residue classes, the Euler-Fermat
  theorem, the Chinese remainder theorem, etc.  Despite being familiar
  with these concepts, we decided not to skip any chapter for the sake
  of completeness of our coverage of the material.  In fact, we read
  every single line of the book and deliberated over every single
  concept discussed in the book.  With this detailed and tedious
  approach to reading the book, it took us 72 hours to read about 290
  pages and learn the analytic proof of the prime number theorem in
  Chapter 13.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#prime-number-theorem&quot;&gt;Prime Number Theorem&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-basics&quot;&gt;Equivalent Forms&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#dirichlet-dirichlet-dirichlet&quot;&gt;Dirichlet, Dirichlet, Dirichlet!&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#chain-of-proofs&quot;&gt;Chain of Proofs&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#conclusion&quot;&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;prime-number-theorem&quot;&gt;Prime Number Theorem&lt;/h2&gt;
&lt;p&gt;
  The prime number theorem is a very curious fact about the
  distribution of prime numbers that Gauss noticed in the year 1792
  when he was about 15 years old.  He noticed that the occurrence of
  primes become rarer and rarer as we expand our search for them to
  larger and larger integers.  For example, there are 4 primes between
  1 and 10, i.e. 40% of the numbers between 1 and 10 are primes!  But
  there are only 25 primes between 1 and 100, i.e. only 25% of the
  numbers between 1 and 100 are primes.  If we go up to 1000, we
  notice that there are only 168 primes between 1 and 1000, i.e. only
  16.8% of the numbers between 1 and 1000 are primes.  Formally, we
  denote these facts with the mathematical notation \( \pi(x) \) that
  denotes the prime counting function.  We say \( \pi(10) = 4, \) \(
  \pi(100) = 25, \) \( \pi(1000) = 168 \) and so on.  Note that we
  allow \( x \) to be a real number, so while \( \pi(10) = 4, \) we
  have \( \pi(10.3) = 4 \) as well.  One of the reasons we let \( x \)
  be a real number in the definition of \( \pi(x) \) is because it
  makes various problems we come across during the study of this
  function more convenient to work on using real analysis.
&lt;/p&gt;
&lt;p&gt;
  We observe that the &apos;density&apos; of primes continue to fall as we make
  \( x \) larger and larger.  In formal notation, we see that the
  ratio \( \pi(x) / x \) is \( 0.4 \) when \( x = 10.  \)  This ratio
  falls to \( 0.25 \) when \( x = 100.  \)  It falls further to \(
  0.168 \) when \( x = 1000 \) and so on.  Can we predict by how much
  this &quot;density&quot; falls?  The answer is yes.  That leads us to the
  prime number theorem.  The prime number theorem states that \(
  \pi(x) / x \) is asymptotic to \( 1 / \log x \) as \( x \)
  approaches infinity, i.e.

  \[
    \frac{\pi(x)}{x} \sim \frac{1}{\log x} \text{ as } x \to \infty.
  \]

  For those unfamiliar with the notation of asymptotic equality, here
  is another equivalent way to state the above relationship,

  \[
    \lim_{x \to \infty} \frac{\pi(x) / x}{1 / \log x} = 1.
  \]

  We could also write this as

  \[
    \lim_{x \to \infty} \frac{\pi(x)}{x / \log x} = 1
  \]

  or

  \[
    \pi(x) \sim \frac{x}{\log x} \text{ as } x \to \infty.
  \]

  Let us see how well this formula works as an estimate for the
  density of primes for small values of \( x.  \)
&lt;/p&gt;
&lt;table style=&quot;text-align: right&quot; class=&quot;grid center&quot;&gt;
  &lt;tr&gt;
    &lt;th style=&quot;text-align: right&quot;&gt;\( x \)&lt;/th&gt;
    &lt;th style=&quot;text-align: right&quot;&gt;\( \pi(x) \)&lt;/th&gt;
    &lt;th style=&quot;text-align: right&quot;&gt;\( x / \log x \)&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;10&lt;/td&gt;
    &lt;td&gt;4&lt;/td&gt;
    &lt;td&gt;4.3&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;100&lt;/td&gt;
    &lt;td&gt;25&lt;/td&gt;
    &lt;td&gt;21.7&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1000&lt;/td&gt;
    &lt;td&gt;168&lt;/td&gt;
    &lt;td&gt;144.8&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;10000&lt;/td&gt;
    &lt;td&gt;1229&lt;/td&gt;
    &lt;td&gt;1085.7&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;100000&lt;/td&gt;
    &lt;td&gt;9592&lt;/td&gt;
    &lt;td&gt;8685.9&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;
  Not bad!  In fact, the last two columns begin to agree more and more
  as \( x \) becomes larger and larger.
&lt;/p&gt;
&lt;p&gt;
  The analytic proof of the prime number theorem was achieved with an
  intricate chain of equivalences and implications between various
  theorems.  The book consumes 13 chapters and 290 pages before
  completing the proof of the prime number theorem.  Each page is also
  quite dense with information.  The amount of commentary or
  illustrations is very little in the book.  Most of the book keeps
  alternating between theorem statements and proofs.  Occasionally,
  for especially long chapters with an intricate sequence of proofs,
  Apostol provides a plan of the proof in the introductions to such
  chapters.  It is quite hard to summarise a large and dense volume of
  work like this in a blog post but I will make an attempt to paint a
  very high-level picture of some of the key concepts that are
  involved in the proof.
&lt;/p&gt;
&lt;h2 id=&quot;the-basics&quot;&gt;Equivalent Forms&lt;/h2&gt;
&lt;p&gt;
  Everything from Chapters 1 to 3 is about building basic concepts and
  tools we will use later to work on the problem of the prime number
  theorem.  These concepts and tools were very interesting on their
  own.  They involved divisibility, various number-theoretic
  functions, Dirichlet products, the big oh notation, etc.  Chapter 4
  was the first chapter where we engaged ourselves with the prime
  number theorem.  This chapter taught us several other formulas that
  were logically equivalent to the prime number theorem.  One
  equivalence that would play a big role later was the equivalence
  between the prime number theorem

  \[
    \lim_{x \to \infty} \frac{\pi(x) \log x}{x} = 1
  \]

  and the following form:

  \[
    \lim_{x \to \infty} \frac{\psi(x)}{x} = 1.
  \]

  If we could prove one, the validity of the other would be
  established automatically.  The notation \( \psi(x) \) denotes the
  Chebyshev function which in turn is defined in terms of the Mangoldt
  function \( \Lambda(n) \) as \( \psi(x) = \sum_{n \le x} \Lambda(n).  \)
  Note that the formula above can also be stated using the asymptotic
  equality notation as follows:

  \[
    \psi(x) \sim x \text{ as } x \to \infty.
  \]

  There were several other equivalent forms too shown in Chapter 4.
  The fact that all these various forms were equivalent to each other
  was rigorously proved in the chapter.  Thus proving any one of the
  equivalent forms would be sufficient to prove the prime number
  theorem.  But in Chapter 4, we did not know how to prove any of the
  equivalent forms.  We could only prove the equivalence of the
  various formulas, not the formulas themselves.  We only learnt that
  if any of the equivalent forms is true, so is the prime number
  theorem.  Similarly, if any of the equivalent forms is false, so is
  the prime number theorem.  We would visit the prime number theorem
  again in Chapter 13 which would complete the proof of the prime
  number theorem by showing that the equivalent form mentioned above
  is indeed true.
&lt;/p&gt;
&lt;h2 id=&quot;dirichlet-dirichlet-dirichlet&quot;&gt;Dirichlet, Dirichlet, Dirichlet!&lt;/h2&gt;
&lt;p&gt;
  Chapters 5 to 10 introduced more concepts involving congruences,
  finite abelian groups, their characters, Dirichlet characters,
  Dirichlet&apos;s theorem on primes in arithmetic progressions, Gauss
  sums, quadratic residues, primitive roots, etc.  Some of these
  concepts would turn out to be very important in proving the prime
  number theorem but most of them probably are not too important if
  understanding the proof of the prime number theorem is the only
  goal.  Regardless, all of these chapters were very interesting.
&lt;/p&gt;
&lt;p&gt;
  It was in Chapters 11 and 12 that we felt that we were getting
  closer and closer to the proof of the prime number theorem.  Chapter
  11 began a detailed and rigorous study of convergence and divergence
  of Dirichlet series.  The Riemann zeta function is a specific type
  of Dirichlet series.  Chapter 12 introduced analytic continuation of
  the Riemann zeta function.  We could then show interesting results
  like \( \zeta(0) = -1/2 \) and \( \zeta(-1) = -1/12 \) using the
  analytic continuation of the zeta function.  This chapter also
  showed us why all trivial zeroes of \( \zeta(s) \) must lie at
  negative even integers.
&lt;/p&gt;
&lt;p&gt;
  One thing I realised during the study of this book is how frequently
  we use concepts, operations, functions and theorems named after
  Dirichlet.  It was impossible to get through a meeting without
  having uttered &quot;Dirichlet&quot; at least a dozen times!
&lt;/p&gt;
&lt;h2 id=&quot;chain-of-proofs&quot;&gt;Chain of Proofs&lt;/h2&gt;
&lt;p&gt;
  Finally, Chapter 13 showed us how to prove the prime number theorem.
  The plan of the proof was laid out in the first section.  Our goal
  in this chapter is to prove that \( \psi(x) \sim x \) as \( x \to
  \infty.  \)  This is equivalent to the prime number theorem, so
  proving this amounts to proving the prime number theorem too.
&lt;/p&gt;
&lt;p&gt;
  Next we learn that the asymptotic relation \( \psi_1(x) \sim x^2 / 2 \)
  as \( x \to \infty \) implies the previous asymptotic relationship.
  Here \( \psi_1(x) \) is defined as \( \psi_1(x) = \int_1^x \psi(t)
  \, dt.  \)  This implication is proved quite easily in one and a half
  pages.  But we still need to show that the asymptotic relation \(
  \psi_1(x) \sim x^2 / 2 \) as \( x \to \infty \) indeed holds good.
  Proving this takes a lot of work.  To prove this asymptotic relation
  we first learn to arrive at the following equation involving a
  contour integral:

  \[
    \frac{\psi_1(x)}{x^2} - \frac{1}{2} \left( 1 - \frac{1}{x} \right)^2
    = \frac{1}{2\pi i} \int_{c - \infty i}^{c + \infty i} \frac{x^{s - 1}}{s(s + 1)}
    \left( -\frac{\zeta&apos;(s)}{\zeta(s)} - \frac{1}{s - 1} \right) \, ds
  \]

  for \( c \gt 1.  \)  The equation above looks quite complex initially
  but each part of it becomes friendly as we learn to derive it and
  then work on each part of it while working out further proofs.  Now
  if we could somehow show that the integral on the right hand side of
  the above equation approaches 0 as \( x \to \infty, \) that would
  end up proving the asymptotic relation involving \( \psi_1(x) \) and
  thus end up proving the prime number theorem by equivalence.
  However, proving that this integral indeed becomes 0 as \( x \to
  \infty \) requires a careful study of \( \zeta(s)/\zeta&apos;(s) \) in
  the vicinity of the line \( \operatorname{Re}(s) = 1.  \)  This is
  the topic that most of the chapter deals with.
&lt;/p&gt;
&lt;p&gt;
  This plan of the proof looked quite convoluted initially but Apostol
  has done a great job in this chapter to first walk us through this
  plan and then prove each fact that we need to make the proof work in
  a detailed and rigorous manner.  When we reached the end of the
  proof, one of our regular members remarked, &quot;Now the proof does not
  look so complex!&quot;
&lt;/p&gt;
&lt;p&gt;
  Would the elementary proof of the prime number theory have been
  easier?  I don&apos;t know.  I have not studied the elementary proof.
  But Apostol does say this at the beginning of Chapter 13,
&lt;/p&gt;
&lt;blockquote&gt;
  The analytic proof is shorter than the elementary proof sketched in
  Chapter 4 and its principal ideas are easier to comprehend.
&lt;/blockquote&gt;
&lt;p&gt;
  Learning the analytic proof itself was quite a long journey that
  required dedication and consistency in our studies over a period of
  6 months.  If we trust the above excerpt from the book, then I think
  it is fair to assume that the elementary proof is even more
  formidable.
&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;
  That was an account of our journey through an analytic number theory
  book from its first chapter up to the analytic proof of the prime
  number theorem.  We have not completed reading the entire book
  though.  We still have about another 30 pages to go through.  In the
  remaining study of this book, we will learn more about zero-free
  regions for \( \zeta(s), \) the application of the prime number
  theorem to the divisor function and the Euler totient function.  The
  next and the final chapter too has a lot to offer such as integer
  partition, Euler&apos;s pentagonal-number theorem and the partition
  identities of Ramanujan.  I am pretty hopeful that we will be
  complete reading this book in another few weeks of meetings.
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/journey-to-prime-number-theorem.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>One Hundred Meetings</title>
    <link href="https://susam.net/one-hundred-meetings.html"/>
    <id>urn:uuid:6e857f9d-d548-4cc5-98c8-7230f3864bfd</id>
    <updated>2021-08-20T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  Today, our computation book discussion group is going to have the
  100th meeting!  Yes, &lt;a href=&quot;cc/iant/log.html#100&quot;&gt;the 100th
  meeting&lt;/a&gt;!  We began these book discussion meetings about five
  months ago.  The first book we picked up for our discussions
  was &lt;em&gt;Introduction to Analytic Number Theory&lt;/em&gt; by Apostol
  (1976).  We have been reading this book together for the last five
  months.  We have a tiny but consistent community of 6 to 8
  participants who meet regularly to study this book and share our
  understanding and insights with each other.
&lt;/p&gt;
&lt;p&gt;
  In this blog post, I will talk about my personal experience hosting
  these meetings and my personal journey about reading this book.  It
  is worth keeping in mind then that what I am about to write below
  may not have any resemblance with the experience of other
  participants of these meetings.
&lt;/p&gt;
&lt;h2 id=&quot;contents&quot;&gt;Contents&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;#the-reading-experience&quot;&gt;The Reading Experience&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-learning-experience&quot;&gt;The Learning Experience&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#three-concepts&quot;&gt;Three Concepts&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#the-mobius-function&quot;&gt;The M&amp;ouml;bius Function&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#dirichlet-product&quot;&gt;Dirichlet Product&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#hurwitz-zeta-function&quot;&gt;Hurwitz Zeta Function&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-next-meeting&quot;&gt;The Next Meeting&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#join-us&quot;&gt;Join Us&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;the-reading-experience&quot;&gt;The Reading Experience&lt;/h2&gt;
&lt;p&gt;
  As far as I know, everyone who joins our meetings are involved in
  computer programming in one form or another.  A few of them have
  very strong background in mathematics.  I host these meetings
  everyday and discuss a few sections of the book in detail.  I show
  how to work through the proofs, explain some of the steps, etc.
  Sometimes I get stuck in some step that I find too unobvious.
  Sometimes the steps are obvious but my brain is too slow to
  understand why the steps work.  But these tiny glitches have not
  been a problem so far, thanks to all the members who join these
  meetings on a daily basis and contribute their explanations of the
  proofs.
&lt;/p&gt;
&lt;p&gt;
  I believe the group members are the best part of these discussions.
  Thanks to the insights and explanation of the reading material
  shared by all these members, I am fairly confident that we are able
  to take a close look at every proof and convince ourselves that
  every step of the proofs work.
&lt;/p&gt;
&lt;h2 id=&quot;the-learning-experience&quot;&gt;The Learning Experience&lt;/h2&gt;
&lt;p&gt;
  The first web meeting to discuss the chosen analytic number theory
  book occurred on 5 Mar 2021.  See the blog
  post &lt;a href=&quot;reading-classic-computation-books.html&quot;&gt;Reading
  Classic Computation Books&lt;/a&gt; to read about the early days of our
  group and how it was formed.  Back then, I knew little to nothing
  about analytic number theory.  Although I was familiar with some of
  the elementary concepts like divisibility, Euler&apos;s totient function,
  modular arithmetic, calculus and related theorems, chapter 2 of the
  book itself proved to be a significant challenge for me.  In the
  second chapter, it became clear to me that we will be building new
  levels of mathematical abstractions, use these abstractions to build
  yet another layer of abstractions and so on.  The chapter began with
  a description of the M&amp;ouml;bius function, a very neat and
  interesting function that I was previously unaware of.  That was
  fun!  But soon, this chapter began adding new layers of abstractions
  such as Dirichlet product, Dirichlet inverse, generalised
  convolution, etc.  I could almost feel my brain stretching and
  growing as we went through each page of this chapter.
&lt;/p&gt;
&lt;p&gt;
  I often saw that after I have learnt a new concept in a chapter, it
  would not become intuitive immediately.  I would understand the
  concepts, understand the related theorems, understand each step of
  the proofs, solve exercise problems, know how to apply the theorems
  when needed and yet I could not &quot;feel&quot; them.  I wanted to not just
  understand the concepts but I also wanted to &quot;feel&quot; the concepts
  like the way I could feel algebra, calculus, computer programming,
  etc.  In the initial days, I wondered if I was too old to develop
  good intuition for all these new and highly sophisticated concepts.
&lt;/p&gt;
&lt;p&gt;
  Despite always feeling that all these concepts were too technical
  and quite unintuitive, I kept going.  I kept hosting these
  discussions with a frequency of about 3-5 days every week.  We
  continued discussing the various chapters and the proofs in them.
  And then suddenly one day while reading chapter 4, something
  interesting happened.  As we were employing Dirichlet products to
  obtain some useful results, I realised that the concept
  of &lt;em&gt;Dirichlet products&lt;/em&gt; which once felt so foreign two
  chapters earlier, now felt completely intuitive.  I
  could &lt;em&gt;see&lt;/em&gt; different functions being equivalent to Dirichlet
  products intuitively and effortlessly.  Dirichlet products felt no
  more alien than, say, arithmetic multiplication.  I could &quot;feel&quot; it
  now.  It was a great feeling.  I realised that sometimes it might
  take a few additional chapters of reading and using those concepts
  over and over again before they really begin to feel intuitive.
&lt;/p&gt;
&lt;h2 id=&quot;three-concepts&quot;&gt;Three Concepts&lt;/h2&gt;
&lt;p&gt;
  In this section, I will pick three interesting concepts from
  different parts of the book to provide a glimpse of what the journey
  has been like.  These three things occur in the book again and again
  and play a very important role in several chapters of the book.  Of
  course, it goes without saying that there are many interesting
  concepts in the book and many of them may be more important than the
  ones I am about to show below.
&lt;/p&gt;
&lt;h3 id=&quot;the-mobius-function&quot;&gt;The M&amp;ouml;bius Function&lt;/h3&gt;
&lt;p&gt;
 For any positive integer \( n, \) the M&amp;ouml;bius function \( \mu(n)
 \) is defined as follows:

 \[
   \mu(1) = 1;
 \]

 If \( n \gt 1, \) write \( n = p_1^{a_1} \dots p_k^{a_k} \) (prime
 factorisation).  Then

 \begin{align*}
   \mu(n) &amp;amp; = (-1)^k \text{ if } a_1 = a_2 = \dots = a_k = 1, \\
   \mu(n) &amp;amp; = 0 \text{ otherwise}.
 \end{align*}

 If \( n \ge 1, \) we have

 \[
   \sum_{d \mid n} \mu(d) =
   \begin{cases}
   1 &amp;amp; \text{ if } n = 1, \\
   0 &amp;amp; \text{ if } n \gt 1.
   \end{cases}
 \]
&lt;/p&gt;
&lt;p&gt;
  I was unfamiliar with this function prior to reading the book.  It
  felt like a nice little cute function initially but as we went
  through more chapters, it soon became clear that this function plays
  a major role in analytic number theory.
&lt;/p&gt;
&lt;p&gt;
  As a simple example, we will soon see in this post that the Euler&apos;s
  totient function can be expressed as a Dirichlet product of the
  M&amp;ouml;bius function and the arithmetical function \( N(n) = n.  \)
&lt;/p&gt;
&lt;p&gt;
  As a more sophisticated example, the Dirichlet series with
  coefficients as the M&amp;ouml;bius function is the multiplicative
  inverse of the Riemann zeta function, i.e. if \( s = \sigma + it \)
  is a complex number with its real part \( \sigma \gt 1, \) we have

  \[
    \sum_{n=1}^{\infty} \frac{\mu(n)}{n^s} = \frac{1}{\zeta(s)}.
  \]

  This immediately shows that \( \zeta(s) \ne 0 \) for \( \sigma \gt
  1.  \)
&lt;/p&gt;
&lt;h3 id=&quot;dirichlet-product&quot;&gt;Dirichlet Product&lt;/h3&gt;
&lt;p&gt;
  If \( f \) and \( g \) are two arithmetical functions, their
  Dirichlet product \( f * g \) is defined as:

  \[
    (f * g)(n) = \sum_{d \mid n} f(d) g\left( \frac{n}{d} \right).
  \]

  Dirichlet products appear to pop up magically at various places in
  number theory.  Here is a simple example:

  \[
    \varphi(n) = \sum_{d \mid n} \mu(d) \frac{n}{d}.
  \]

  Therefore in the notation of Dirichlet products, the above equation
  can also be written as

  \[
    \varphi = \mu * N
  \]

  where \( N \) represents the arithmetical function \( N(n) = n \)
  for all \( n.  \)
&lt;/p&gt;
&lt;h3 id=&quot;hurwitz-zeta-function&quot;&gt;Hurwitz Zeta Function&lt;/h3&gt;
&lt;p&gt;
  For complex numbers \( s = \sigma + it, \) the Hurwitz zeta function
  \( \zeta(s, a) \) is initially defined for \( \sigma \gt 1 \) as

  \[
    \zeta(s, a) = \sum_{n=0}^{\infty} \frac{1}{(n + a)^s}
  \]

  where \( a \) is a fixed real number, \( 0 \lt a \lt 1.  \)  Then by
  analytic continuation, it is defined for \( \sigma \le 1 \) as

  \[
    \zeta(s, a) = \Gamma(1 - s)I(s, a)
  \]

  where \( \Gamma \) represents the gamma function

  \[
    \Gamma(s) =  \int_0^{\infty} x^{s - 1} e^{-x} \, dx
  \]

  defined for \( \sigma \gt 0 \) and also defined, by analytic
  continuation, for \( \sigma \le 0 \) except for \( \sigma = 0, -1,
  -2, \dots \) (the nonpositive integers) and \( I(s, a) \) is defined
  by the contour integral

  \[
    I(s, a) = \frac{1}{2\pi i} \int_C \frac{z^{s-1} e^{az}}{1 - e^z} \, dz
  \]

  where \( 0 \lt a \le 1 \) and the contour \( C \) is a loop around
  the negative real axis composed of three parts \( C_1, \) \( C_2 \)
  and \( C_3 \) such that for \( c \lt 2\pi, \) we have \( z =
  re^{-\pi i} \) on \( C_1 \) and \( z = re^{\pi i} \) on \( C_3 \) as
  \( r \) varies from \( c \) to \( +\infty \) and \( z = ce^{i
  \theta} \) on \( C_2, \) \( -\pi \le \theta \le \pi.  \)
&lt;/p&gt;
&lt;p&gt;
  Now admittedly, the definition or the analytic continuation of
  Hurwitz zeta function may seem very heavy and obscure to the
  uninitiated and it &lt;em&gt;is&lt;/em&gt; indeed quite heavy.  It takes 6 pages
  in chapter 12 to build the prerequisite concepts before we arrive at
  this definition.  It is evident that this definition uses other
  concepts like the gamma function, a specific contour integral, etc.
  and it is only natural to expect that one has to gain sufficient
  expertise with the gamma function and contour integrals before the
  Hurwitz zeta function begins to feel intuitive.
&lt;/p&gt;
&lt;p&gt;
  But once we have established the analytic continuation of the
  Hurwitz zeta function, many insightful facts about the Riemann zeta
  function follow readily.  It is easy to see that the Riemann zeta
  function can be defined in terms of the Hurwitz zeta function as

  \[
    \zeta(s) = \zeta(s, 1) = \sum_{n=1}^{\infty} \frac{1}{n^s}.
  \]

  Yes, the \( \zeta \) symbol is overloaded: \( \zeta(s, a) \) is the
  Hurwitz zeta function whereas \( \zeta(s) \) is the Riemann zeta
  function.  This relationship between the Riemann zeta function and
  the Hurwitz zeta function along with the analytic continuation of
  the Hurwitz zeta function opens new doors into the wonderful world
  of complex numbers and let us obtain beautiful and profound facts
  about the Riemann zeta function such as the fact that it has zeros
  at negative even integers, i.e. \( \zeta(n) = 0 \) for \( n = -2,
  -4, -6, \dots \) and the fact that \( \zeta(0) = -\frac{1}{2} \) and
  \( \zeta(-1) = -\frac{1}{12} \) and so on.
&lt;/p&gt;
&lt;p&gt;
  I believe beautiful results like these obtained by digging deep into
  complex analysis are what makes the study of analytic number theory
  so rewarding.
&lt;/p&gt;
&lt;h2 id=&quot;the-next-meeting&quot;&gt;The Next Meeting&lt;/h2&gt;
&lt;p&gt;
  The next meeting is coming up today in a few hours.  Are we planning
  anything special for the 100th meeting?
&lt;/p&gt;
&lt;p&gt;
  I think the 100th meeting is a significant milestone in our journey
  of understanding the beautiful and interesting gems hidden away in
  the subject of analytic number theory.  This milestone has been
  possible only due to the sustained curiousity and eagerness among
  the members of the group to learn a significant area of mathematics
  and learn it well.  We have reached this milestone successfully due
  to the passion and love for mathematics that drive the regular
  members to join these meetings and go through a few pages of the
  book everyday.  In these meetings, we have read 12 chapters
  consisting of over 250 pages so far.  Many of us knew nothing about
  analytic number theory merely five months ago and now we can
  appreciate the Riemann zeta function at a deeper level.  We now
  understand what the Riemann hypothesis really means.  This has been
  a great journey so far.
&lt;/p&gt;
&lt;p&gt;
  Despite being a significant milestone and cause for celebration, we
  are going to keep our 100th meeting fairly simple.  We will continue
  where we left off yesterday.  Today we have some more relationships
  between the gamma function and the Riemann zeta function to go
  through, so that is what we will do.  We will also show that \(
  \zeta(0) = -\frac{1}{2} \) and \( \zeta(-1) = -\frac{1}{12} \) using
  the analytic continuation of the Hurwitz zeta function today.
&lt;/p&gt;
&lt;h2 id=&quot;join-us&quot;&gt;Join Us&lt;/h2&gt;
&lt;p&gt;
  If this blog post was fun for you and you would like to join our
  meetups, please go through &lt;a href=&quot;cc/iant/&quot;&gt;this
  page&lt;/a&gt; to get the meeting link and join us.
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/one-hundred-meetings.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Reading Classic Computation Books</title>
    <link href="https://susam.net/reading-classic-computation-books.html"/>
    <id>urn:uuid:0a47dcb6-1357-4505-9522-18c4357c4149</id>
    <updated>2021-06-15T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;p&gt;
  Hello readers and learners!  In the last few months, some of us from
  mathematics and algorithms communities of IRC networks have come
  together to form a tiny group that meets a few times every week and
  reads a book together.  The focus of this loosely formed group is on
  picking reading material about concepts and technologies that have
  been around for a long time and have an air of timelessness around
  them.
&lt;/p&gt;
&lt;p&gt;
  In particular, we will not be chasing the latest trends in
  technology most of the time.  But this is not a retrocomputing
  community either.  For example, we are likely not going to talk
  about BASIC programming on Commodore 64.  The topics we pick for our
  discussions are largely going to be topics that are still quite
  relevant and important in the field of mathematics and computation
  but they may not be what is considered to be mainstream.  For
  example, we will read books like &lt;em&gt;Introduction to Analytic Number
  Theory&lt;/em&gt; or talk about Common Lisp programming.  Sometimes these
  topics may intersect with modern trends or retrocomputing but most
  of the times they would not.  That is the kind of sweet spot we want
  to hit.
&lt;/p&gt;
&lt;h2 id=&quot;past&quot;&gt;Origin&lt;/h2&gt;
&lt;p&gt;
  Here is a little bit of history about the community around these
  discussions.  This community was born on the Freenode IRC network
  when I announced on the &lt;code&gt;##algorithms&lt;/code&gt;
  and &lt;code&gt;##math&lt;/code&gt; channels there that I would be hosting book
  reading and discussion meetings on analytic number theory.  I
  created a makeshift channel named
  &lt;code&gt;#susam&lt;/code&gt; to discuss the book and plan the meeting
  schedule.  Several members joined this channel and we were ready to
  kick off our first meeting.
&lt;/p&gt;
&lt;p&gt;
  Our first meeting occurred via IRC on 4 Mar 2021.  We realised that
  it would be much more efficient to discuss mathematics via audio
  along with a shared desktop session where we can use some software
  tool to scribble out and render mathematics formulas using LaTeX.
  So on the next day, that is, on 5 Mar 2021, we had our first web
  meeting.  Later,
  after &lt;a href=&quot;https://news.ycombinator.com/item?id=26366464&quot;&gt;an
  announcement on Hacker News&lt;/a&gt;, some members from the Hacker News
  community joined our channel too and the community grew a little bit
  more as a result.
&lt;/p&gt;
&lt;h2 id=&quot;present&quot;&gt;Present&lt;/h2&gt;
&lt;p&gt;
  We moved to Matrix later and now continue to operate out of
  the &lt;a href=&quot;https://app.element.io/#/room/#susam:matrix.org&quot;&gt;#susam:matrix.org&lt;/a&gt;.
  It has now been more than 3 months since we began these meetings.
  Although our community is tiny, the meetings have been going on
  consistently and we have learnt numerous new and interesting
  concepts and theorems in the field of analytic number theory.  In
  this community, we pick classics from the field of mathematics and
  computation and read them together.
&lt;/p&gt;
&lt;p&gt;
  Since this group was formed, we have made good progress with the
  study of analytic number theory.  The meetings for this topic have
  been going on consistently.  When I get some more free time now in
  future, I will add a few more topics for our meetings.
&lt;/p&gt;
&lt;h2 id=&quot;join-us&quot;&gt;Join Us&lt;/h2&gt;
&lt;p&gt;
  Join the discussion channel at
  &lt;a href=&quot;https://app.element.io/#/room/#susam:matrix.org&quot;&gt;#susam:matrix.org&lt;/a&gt;.
  and be a part of these activities.  See you there!
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/reading-classic-computation-books.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Chapter 3: Averages of Arithmetical Functions</title>
    <link href="https://susam.net/cc/iant/ch03.html"/>
    <id>urn:uuid:eebea036-59fb-499b-b42e-a66ca8ab2a13</id>
    <updated>2021-04-09T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->

&lt;!-- Section 3.3 --&gt;
&lt;h2 id=&quot;3.3&quot;&gt;&amp;sect; 3.3: Euler&apos;s summation formula&lt;/h2&gt;
&lt;h3 id=&quot;main-idea-behind-the-proof-of-eulers-summation-formula&quot;&gt;Main idea behind the proof of Euler&apos;s summation formula&lt;/h3&gt;
&lt;p&gt;
  Important numbers in the proof:

  \[
    0, \quad
    \underbrace{[y]}_{=\,m}, \quad
    y, \quad
    \underbrace{[y] + 1}_{=\,m + 1}, \quad
    \underbrace{[x]}_{=\,k}, \quad
    x.
  \]

  Splitting the definite integral:

  \[
    \int_y^x f(t)\,dt
    = \int_{y}^{[y] + 1} f(t)\,dt
    + \underbrace{\int_{[y] + 1}^{[y] + 2} f(t)\,dt + \dots
    + \int_{[x] - 1}^{[x]} f(t)\,dt}_{=\,\int_{[y] + 1}^{[x]} f(t)\, dt}
    + \int_{[x]}^{x} f(t)\,dt.
  \]

  Using the more convenient variables \( m \) and \( k, \) we get:

  \[
    \int_y^x f(t)\,dt
    = \int_m^{m + 1} f(t)\,dt
    + \underbrace{\int_{m + 1}^{m + 2} f(t)\,dt + \dots
    + \int_{k - 1}^{k} f(t)\,dt}_{=\,\int_{m + 1}^{k} f(t)\, dt}
    + \int_{k}^{x} f(t)\,dt.
  \]
&lt;/p&gt;
&lt;h3 id=&quot;sum-of-integrals-in-the-proof-of-eulers-summation-formula&quot;&gt;Sum of integrals in the proof Euler&apos;s summation formula&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    \int_{m + 1}^{k} [t] f&apos;(t) dt
    &amp;amp; = \int_{m + 1}^{m + 2} [t] f&apos;(t) dt
    + \int_{m + 2}^{m + 3} [t] f&apos;(t) dt + \dots
    + \int_{k - 1}^{k} [t] f&apos;(t) dt \\
    &amp;amp; =
    \begin{aligned}[t]
      &amp;amp; (m + 2) f(m + 2) - (m + 1) f(m + 1) - f(m + 2) \\
    + &amp;amp; (m + 3) f(m + 3) - (m + 2) f(m + 2) - f(m + 3) \\
      &amp;amp; \dots \\
    + &amp;amp; (k) f(k) - (k - 1) f(k - 1) - f(k)
    \end{aligned} \\
    &amp;amp; = kf(k) - (m + 1)f(m + 1) - \sum_{n=m + 2}^{k} f(n) \\
    &amp;amp; = kf(k) - mf(m + 1) - f(m + 1) - \sum_{n=m + 2}^{k} f(n) \\
    &amp;amp; = kf(k) - mf(m + 1) - \sum_{n=m + 1}^{k} f(n) \\
    &amp;amp; = kf(k) - mf(m + 1) - \sum_{y \lt n \le x} f(n).
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;equation-6-in-the-proof-of-eulers-summation-formula&quot;&gt;Equation (6) in the proof of Euler&apos;s summation formula&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    \sum_{y \lt n \le x} f(n)
    &amp;amp; = - \int_{m + 1}^k [t] f&apos;(t) \, dt + k f(k) - m f(m + 1) \\
    &amp;amp; = \begin{aligned}[t]
          &amp;amp; \left( - \int_y^{m + 1} [t] f&apos;(t) \, dt
                       - \int_{m + 1}^k [t] f&apos;(t) \, dt
                       - \int_k^x [t] f&apos;(t) \, dt \right) \\
          &amp;amp; + f(k) - m f(m + 1)
                + \int_y^{m + 1} [t] f&apos;(t) \, dt
                + \int_k^x [t] f&apos;(t) \, dt
        \end{aligned} \\
    &amp;amp; = - \int_y^x [t] f&apos;(t) \, dt + k f(k) - m f(m + 1)
            + \int_y^{m + 1} m f&apos;(t) \, dt + \int_k^x k f&apos;(t) \, dt \\
    &amp;amp; = - \int_y^x [t] f&apos;(t) \, dt + k f(k) - m f(m + 1)
            + \biggl( m f(m + 1) - m f(y) \biggr) + \biggl( k f(x) - k f(k) \biggr) \\
    &amp;amp; = - \int_y^x [t] f&apos;(t) \, dt + k f(x) - m f(y).
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;using-integration-by-parts-in-the-proof-of-eulers-summation-formula&quot;&gt;Using integration by parts in the proof of Euler&apos;s summation formula&lt;/h3&gt;
&lt;p&gt;
  Integration by parts:

  \[
    \int uv \, dt = u \int v \, dt - \int u&apos; \left( \int v \, dt \right) \, dt.
  \]

  \[
    \int_y^x t f&apos;(t) \, dt
    = \left. \left( t f(t) - \int f(t) \, dt \right) \right|_y^x
    = x f(x) - y f(y) - \int_y^x f(t) \, dt.
  \]

  Final step of the proof:

  \begin{align*}
    \sum_{y \lt n \le x} f(n)
    &amp;amp; = -\int_y^x [t] f&apos;(t) \, dt + k f(x) - m f(y) \\
    &amp;amp; = \begin{aligned}[t]
          &amp;amp; -\int_y^x [t] f&apos;(t) \, dt + [x] f(x) - [y] f(y) \\
          &amp;amp; + \underbrace{
            \left( \int_y^x t f&apos;(t) \, dt - x f(x) + y f(y)
                   + \int_y^x f(t) \, dt \right)}_{0 \text{ by above definite integral}}
        \end{aligned} \\
    &amp;amp; = \int_y^x f(t) \, dt + \int_y^x (t - [t]) f&apos;(t) \, dt
        + f(x)([x] - x) - f(y)([y] - y).
  \end{align*}
&lt;/p&gt;

&lt;!-- Section 3.4 --&gt;
&lt;h2 id=&quot;3.4&quot;&gt;&amp;sect; 3.3: Some elementary asymptotic formulas&lt;/h2&gt;
&lt;h3 id=&quot;splitting-integral-in-the-proof-of-theorem-3.2&quot;&gt;Splitting integral in the proof of Theorem 3.2&lt;/h3&gt;
&lt;p&gt;
  Splitting definite integral:

  \begin{align*}
    &amp;amp; \int_1^{\infty} f(t) \, dt = \int_1^{x} f(t) \, dt + \int_x^{\infty} f(t) \, dt \\
    &amp;amp; \iff
    \int_1^{\infty} f(t) \, dt - \int_x^{\infty} f(t) \, dt = \int_1^x f(t) \, dt.
  \end{align*}

  Solving improper integral:

  \[
    \int_x^{\infty} \frac{1}{t^2} \, dt
    = \lim_{b \to \infty} \int_x^b \frac{1}{t^2} dt
    = \lim_{b \to \infty} \frac{-1}{t} \Biggr|_x^b
    = \left( \lim_{b \to \infty} \frac{-1}{b} \right) + \frac{1}{x}
    = 0 + \frac{1}{x} = \frac{1}{x}.
  \]
&lt;/p&gt;
&lt;h3 id=&quot;eulers-constant-in-the-proof-of-theorem-3.2-a&quot;&gt;Euler&apos;s constant in the proof of Theorem 3.2 (a)&lt;/h3&gt;
&lt;p&gt;
  Definition of Euler&apos;s constant:

  \[
    C = \lim_{n \to \infty}
        \left( 1 + \frac{1}{2} + \frac{1}{3} + \dots + \frac{1}{n} - \log n \right)
      = \lim_{x \to \infty} \left( \sum_{n \le x} \frac{1}{n} - \log x \right).
  \]

  We begin with

  \[
    \sum_{n \le x} \frac{1}{n}
    = \log x
    + \underbrace{1 - \int_1^{\infty} \frac{t - [t]}{t^2} \, dt}_{\text{We will show below that this is \( C \)}}
    + O\left( \frac{1}{x} \right).
  \]

  Rearranging the terms, we get

  \[
    \sum_{n \le x} \frac{1}{n} - \log x
    = 1 - \int_1^{\infty} \frac{t - [t]}{t^2} \, dt
    + O\left( \frac{1}{x} \right).
  \]

  Using the definition of \( C, \) we get

  \begin{align*}
    C
    &amp;amp; = \lim_{x \to \infty}
            \left( \sum_{n \le x} \frac{1}{n} - \log x \right) \\
    &amp;amp; = \lim_{x \to \infty}
            \left( 1 - \int_1^{\infty} \frac{t - [t]}{t^2} \, dt
                     + O\left( \frac{1}{x} \right) \right) \\
    &amp;amp; = 1 - \int_1^{\infty} \frac{t - [t]}{t^2} \, dt.
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;some-integrals-in-the-proof-of-theorem-3.2-b&quot;&gt;Some integrals in the proof of Theorem 3.2 (b)&lt;/h3&gt;
&lt;p&gt;
  \[
    \int_1^x \frac{dt}{t^s}
    = \frac{t^{-s + 1}}{-s + 1} \Biggr|_1^x
    = \frac{t^{1 - s}}{1 - s} \Biggr|_1^x
    = \frac{x^{1 - s}}{1 - s} - \frac{1}{1 - s}.
  \]

  \[
    \int_1^x \frac{t - [t]}{t^{s + 1}} \, dt
    =   \int_1^{\infty} \frac{t - [t]}{t^{s + 1}} \, dt
      - \int_x^{\infty} \frac{t - [t]}{t^{s + 1}} \, dt
    = \int_1^{\infty} \frac{t - [t]}{t^{s + 1}} \, dt
    + \underbrace{\frac{1}{s} O\left( x^{-s}\right)}_{\text{explained below}}.
  \]

  \[
    0
    \le \int_x^{\infty} \frac{t - [t]}{t^{s + 1}} \, dt
    \le \int_x^{\infty} \frac{1}{t^{s + 1}} \, dt
    = \frac{-1}{st^s} \Biggr|_x^\infty = \frac{1}{sx^s} = \frac{1}{s} x^{-s}.
  \]

  \begin{align*}
    \sum_{n \le x} \frac{1}{n^s}
    &amp;amp; = \int_1^x \frac{dt}{t^s}
            - s \int_1^x \frac{t - [t]}{t^{s + 1}} + 1
            - \frac{x - [x]}{x^s} \, dt \\
    &amp;amp; = \frac{x^{1 - s}}{1 - s} - \frac{1}{1 - s}
            - s \int_1^{\infty} \frac{t - [t]}{t^{s + 1}} \, dt + 1 + O(x^{-s}).
  \end{align*}
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/iant/ch03.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Chapter 2: Arithmetical Functions and Dirichlet Multiplication</title>
    <link href="https://susam.net/cc/iant/ch02.html"/>
    <id>urn:uuid:331435b5-4577-48ac-a5cc-727bafa58b68</id>
    <updated>2021-03-26T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->

&lt;!-- Section 2.11 --&gt;
&lt;h2 id=&quot;2.11&quot;&gt;&amp;sect; 2.11: The inverse of a completely multiplicative function&lt;/h2&gt;
&lt;h3 id=&quot;completely-multiplicative-function&quot;&gt;Completely Multiplicative Function&lt;/h3&gt;
&lt;p&gt;
  \[
    f(mn) = f(m) f(n) \text{ for all } m, n.
  \]
&lt;/p&gt;
&lt;h3 id=&quot;identity-function-dirichlet-product&quot;&gt;Identity function (Dirichlet product)&lt;/h3&gt;
&lt;p&gt;
  \[
    I(n) =
    \begin{cases}
    1 &amp;amp; \text{ if } n = 1, \\
    0 &amp;amp; \text{ if } n \gt 1.
    \end{cases}
  \]
&lt;/p&gt;
&lt;p&gt;
  \begin{align*}
    f(n)I(n)
    &amp;amp; =
    \begin{cases}
      1 \cdot 1    &amp;amp; \text{ if } n = 1, \\
      f(n) \cdot 0 &amp;amp; \text{ if } n \gt 1.
    \end{cases} \\
    &amp;amp; = \begin{cases}
      1 &amp;amp; \text{ if } n = 1, \\
      0 &amp;amp; \text{ if } n \gt 1.
    \end{cases} \\
    &amp;amp; = I(n).
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;mobius-function-for-prime-powers&quot;&gt;M&amp;ouml;bius function for prime powers&lt;/h3&gt;
&lt;p&gt;
  \[
    \mu(1) = 1, \qquad
    \mu(p) = -1, \qquad
    \mu(p^2) = \mu(p^3) = \dots = 0.
  \]
&lt;/p&gt;
&lt;h3 id=&quot;third-equation-in-the-proof-of-theorem-2.17&quot;&gt;Third equation in the proof of Theorem 2.17&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    \sum_{d \mid p^a} \mu(d) f(d) f\left(\frac{p^a}{d}\right)
    &amp;amp; = \sum_{d = 1, p, p^2, \dots, p^a} \mu(d) f(d) f\left(\frac{p^a}{d}\right) \\
    &amp;amp; = \begin{aligned}[t]
           &amp;amp; \mu(1) f(1) f\left( \frac{p^a}{1} \right) +
                 \mu(p) f(p) f\left( \frac{p^a}{p} \right) \\
           &amp;amp; + \underbrace{\mu(p^2) f(p^2) f\left( \frac{p^a}{p^2} \right) + \dots +
                               \mu(p^a) f(p^a) f\left( \frac{p^a}{p^a} \right)}_{=\,0}
        \end{aligned} \\
    &amp;amp; = \mu(1) f(1) f(p^a) + \mu(p) f(p) f(p^{a - 1}) \\
    &amp;amp; = f(p^a) - f(p) f(p^{a - 1}).
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;final-step-in-the-proof-of-theorem-2.17&quot;&gt;Final step in the proof of Theorem 2.17&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    f(p^a)
    &amp;amp; = f(p)f(p^{a - 1}) \\
    &amp;amp; = f(p)f(p)f(p^{a - 2}) \\
    &amp;amp; = \dots \\
    &amp;amp; = \underbrace{f(p)f(p)f(p) \dots f(p)}_{a \text{ times}} \\
    &amp;amp; = \left( f(p) \right)^a.
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;how-the-completely-multiplicative-property-works-for-prime-powers&quot;&gt;How the completely multiplicative property works for prime powers&lt;/h3&gt;
&lt;p&gt;
  \[
    f(mn) = f(m)f(n) \text{ whenever } (m, n) = 1.
  \]
&lt;/p&gt;
&lt;p&gt;
  \[
    f(p_1^{\alpha_1} p_2^{\alpha_2} \dots p_k^{\alpha_k})
    = f(p_1^{\alpha_1}) f(p_2^{\alpha_2}) \dots f(p_k^{\alpha_k}).
  \]
&lt;/p&gt;
&lt;h3 id=&quot;euler-totient-function-as-dirichlet-product&quot;&gt;Euler totient function as Dirichlet product&lt;/h3&gt;
&lt;p&gt;
  \[
    \varphi(n)
    = \sum_{d \mid n} \mu(d) \frac{n}{d}
    = \sum_{d \mid n} \mu(d) N\left(\frac{n}{d}\right)
    = (\mu * N)(n).
  \]
&lt;/p&gt;
&lt;h3 id=&quot;proof-of-theorem-2.18&quot;&gt;Proof of Theorem 2.18&lt;/h3&gt;
&lt;p&gt;
  Let \( f \) be multiplicative.  We want to show that

  \[
    \sum_{d \mid n} \mu(d) f(d) = \prod_{p \mid n} (1 - f(p)).
  \]

  Note the following:

  \[
    g(n)
    = \sum_{d \mid n} \mu(d) f(d)
    = \sum_{d \mid n} (\mu f) (d)
    u\left( \frac{n}{d} \right)
    = (\mu f) * u.
  \]

  The functions \( \mu \) and \( f \) are multiplicative.  Thus \( \mu
  f \) is multiplicative.  Thus \( (\mu f) * u \) is multiplicative.
  Therefore

  \[
    g(n) = g(p_1^{a_1} p_2^{a_2} \dots p_k^{a_k}) =
    g(p_1^{a_1}) g(p_2^{a_2}) \dots g(p_k^{a_k}).
  \]

  But

  \begin{align*}
    g(p_i^{a_i})
    &amp;amp; = \sum_{d \mid p_i^{a_i}} \mu(d) f(d) \\
    &amp;amp; = \mu(1) f(1) + \mu(p_i) f(p_i) +
             \underbrace{\mu(p_i^2) f(p_i^2) + \dots + \mu(p_i^{a_i}) f(p_i^{a_i})}_{=\,0} \\
    &amp;amp; = 1 - f(p).
  \end{align*}

  From the two equations above, we get

  \begin{align*}
    g(n)
    &amp;amp; = g(p_1^{a_1}) g(p_2^{a_2}) \dots g(p_k^{a_k}) \\
    &amp;amp; = (1 - f(p_1)) (1 - f(p_2)) \dots (1 - f(p_k)) \\
    &amp;amp; = \prod_{p \mid n} (1 - f(p)).
  \end{align*}
&lt;/p&gt;

&lt;!-- Section 2.15 --&gt;
&lt;h2 id=&quot;2.15&quot;&gt;&amp;sect; 2.15: Formal power series&lt;/h2&gt;

&lt;h3 id=&quot;product-of-formal-power-series&quot;&gt;Product of formal power series&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    A(x)B(x)
    &amp;amp; = \left( \sum_{n=0}^{\infty} a(n) x^n \right) \left( \sum_{n=0}^{\infty} b(n) x^n \right) \\
    &amp;amp; = \left( a(0) + a(1)x + a(2)x^2 + \dots \right)
            \left( b(0) + b(1)x + b(2)x^2 + \dots \right) \\
    &amp;amp; = a(0)b(0) +
            \Bigl( a(0)b(1) + a(1)b(0) \Bigr) x +
            \Bigl( a(0)b(2) + a(1)b(1) + a(2)b(0) \Bigr) x^2 + \dots \\
    &amp;amp; = \sum_{k=0}^0 a(k)b(n - k) + \sum_{k=0}^1 a(k)b(1 - k)x + \sum_{k=0}^2 a(k)b(2 - k)x^2 + \dots \\
    &amp;amp; = \sum_{n=0}^{\infty} \sum_{k=0}^n a(k)b(n - k).
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;commutativity-of-product-of-formal-power-series&quot;&gt;Commutativity of product of formal power series&lt;/h3&gt;
&lt;p&gt;
  \[
    A(x)B(x)
    = \sum_{n=0}^{\infty} \underbrace{\left\{ \sum_{k=0}^{n} a(k) b(n - k) \right\}}_{c(n)} x^n.
  \]
  \[
    B(x)A(x)
    = \sum_{n=0}^{\infty} \underbrace{\left\{ \sum_{k=0}^{n} a(n - k) b(k) \right\}}_{c&apos;(n)} x^n.
  \]
  \[
    c(3) = a(0)b(3) + a(1)b(2) + a(2)b(1) + a(3)b(0).
  \]
  \[
    c&apos;(3) = a(3)b(0) + a(2)b(1) + a(1)b(2) + a(0)b(3).
  \]
&lt;/p&gt;
&lt;h3 id=&quot;distributivity-of-multiplication-over-addition-in-formal-power-series&quot;&gt;Distributivity of multiplication over addition in formal power series&lt;/h3&gt;
&lt;p&gt;
  \[
    A(x)\Bigl(B(x) + C(x)\Bigr) = A(x)B(x) + A(x)C(x).
  \]
  \[
    \Bigl(B(x) + C(x)\Bigr)A(x) = B(x)A(x) + C(x)A(x).
  \]

  \begin{align*}
    A(x)\Bigl(B(x) + C(x)\Bigr)
    &amp;amp; = \left( \sum_{n=0}^{\infty} a(n) x^n \right)
        \left( \sum_{n=0}^{\infty} \Bigl( b(n) + c(n) \Bigr) x^n \right) \\
    &amp;amp; = \sum_{n=0}^{\infty} \Bigl\{ \sum_{k=0}^{n} a(k) \Bigl( b(n - k) + c(n - k) \Bigr) \Bigr\} x^n.
  \end{align*}

  \[
    A(x)B(x) + A(x)C(x)
    = \sum_{n=0}^{\infty} \sum_{k=0}^n a(k) b(n - k) x^n +
    \sum_{n=0}^{\infty} \sum_{k=0}^n a(k) c(n - k) x^n.
  \]
&lt;/p&gt;
&lt;h3 id=&quot;determining-coefficients-of-inverse-of-power-series&quot;&gt;Determining coefficients of inverse of power series&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    A(x)B(x)
    &amp;amp; = \sum_{n=0}^{\infty} \Bigl( \sum_{k=0}^{n} a(k) b(n - k) \Bigr) x^n \\
    &amp;amp; = \Bigl( a(0) b(0) \Bigr) x^0 +
            \Bigl( a(0) b(1) + a(1) b(0) \Bigr) x^1 +
            \Bigl( a(0) b(2) + a(1) b(1) + a(2) b(0) \Bigr) x^2 +
            \dots \\
    &amp;amp; = 1.
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;inverse-of-geometric-series&quot;&gt;Inverse of geometric series&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    A(x) &amp;amp; = 1 + ax + (ax)^2 + (ax)^3 + \dots, \\
    B(x) &amp;amp; = 1 - ax.
  \end{align*}

  \begin{align*}
    A(x) B(x)
    &amp;amp; = \Bigl( 1 + ax + (ax)^2 + (ax)^3 + \dots \Bigr) (1 - ax) \\
    &amp;amp; = \Bigl( 1 + ax + (ax)^2 + (ax)^3 + \dots \Bigr) -
            \Bigl( (ax) - (ax)^2 - (ax)^3 - \dots \Bigr)
    = 1.
  \end{align*}
&lt;/p&gt;

&lt;!-- Section 2.16 --&gt;
&lt;h2 id=&quot;2.16&quot;&gt;&amp;sect; 2.16: The Bell series of an arithmetical function&lt;/h2&gt;
&lt;h3 id=&quot;bell-series-of-f-modulo-p&quot;&gt;Bell series of \( f \) modulo \( p \)&lt;/h3&gt;
&lt;p&gt;
  \[
    f_p(x)
    = \sum_{n=0}^{\infty} f(p^n) x^n
    = f(1) + f(p) x + f(p^2) x^2 + f(p^3) x^3 + \dots
  \]
&lt;/p&gt;
&lt;h3 id=&quot;theorem-2.24-uniqueness-theorem&quot;&gt;Theorem 2.24: Uniqueness theorem&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    f(n)
    &amp;amp; = f(p_1^{a_1} p_2^{a_2} \dots p_k^{a_k})
    = f(p_1^{a_1}) f(p_2^{a_2}) \dots f(p_k^{a_k}), \\ \\

    g(n)
    &amp;amp; = g(p_1^{a_1} p_2^{a_2} \dots p_k^{a_k})
    = g(p_1^{a_1}) g(p_2^{a_2}) \dots g(p_k^{a_k}).  \\
  \end{align*}
&lt;/p&gt;
&lt;h3 id=&quot;example-1-mobius-funcion&quot;&gt;Example 1: Möbius function&lt;/h3&gt;
&lt;p&gt;
  \begin{align*}
    \mu_p(x) = \sum_{n=0}^{\infty} \mu(p^n) x^n
    &amp;amp; = \mu(1) + \mu(p) x + \mu(p^2) x^2 + \mu(p^3) x^3 + \dots \\
    &amp;amp; = 1 - x + 0 + 0 + \dots \\
    &amp;amp; = 1 - x.
  \end{align*}
&lt;/p&gt;

&lt;!-- Section 2.17 --&gt;
&lt;h2 id=&quot;2.17&quot;&gt;&amp;sect; 2.17: Bell series and Dirichlet multiplication&lt;/h2&gt;
&lt;h3 id=&quot;power-series-multiplication&quot;&gt;Power series multiplication&lt;/h3&gt;
&lt;p&gt;
  \[
    A(x) = \sum_{n=0}^{\infty} a(n) x^n, \quad
    B(x) = \sum_{n=0}^{\infty} b(n) x^n, \quad
    A(x) B(x) = \sum_{n=0}^{\infty} \underbrace{\sum_{k=0}^n a(k) b(n - k)}_{c(n)} x^n.
  \]
&lt;/p&gt;
&lt;h3 id=&quot;relationship-with-dirichlet-multiplication&quot;&gt;Relationship with Dirichlet multiplication&lt;/h3&gt;
&lt;p&gt;
  \[
    (f * g)_p(x) = f_p(x) g_p(x).
  \]

  \[
    f_p(x) = \sum_{n=0}^{\infty} f(p^n) x^n, \quad
    g_p(x) = \sum_{n=0}^{\infty} g(p^n) x^n, \quad
    f_p(x) g_p(x) = \sum_{n=0}^{\infty} \sum_{k=0}^n f(p^k) g(p^{n-k}) x^n.
  \]

  \[
    h = f * g = \sum_{d \mid n} f(d) g\left( \frac{n}{d} \right).
  \]

  \[
    h_p(x)
    = \sum_{n=0}^{\infty} h(p^n) x^n
    = \sum_{n=0}^{\infty} \sum_{d \mid p^n} f(d) g\left( \frac{p^n}{d} \right) x^n
    = \sum_{n=0}^{\infty} \sum_{k=0}^{n} f(p^k) g(p^{n-k}) x^n.
  \]
&lt;/p&gt;
&lt;p&gt;
  Some steps of Example 1:

  \[
    I(n)= \mu^2(n) * \lambda(n)
    \implies I_p(x) = \mu_p^2(x) \lambda_p(x)
  \]

  \[
    I_p(x) = \mu_p^2(x) \lambda_p(x)
    \iff 1 = \mu_p^2(x) \cdot \frac{1}{1 + x}
    \iff \mu_p^2(x) = 1 + x.
  \]
&lt;/p&gt;
&lt;p&gt;
  Some steps of Example 2:

  \begin{align*}
    \frac{1}{1 - p^{\alpha}} \cdot \frac{1}{1 - x}
    &amp;amp; = \frac{1}{1 - x - p^{\alpha}x + p^{\alpha}x^2} \\
    &amp;amp; = \frac{1}{1 - (1 + p^{\alpha})x + p^{\alpha}x^2} \\
    &amp;amp; = \frac{1}{1 - \sigma_{\alpha}(p)x + p^{\alpha}x^2}.
  \end{align*}

  Note that \( \sigma_{\alpha}(n) = \sum_{d\,\mid\,n} d^{\alpha}, \) so

  \[
    \sigma_{\alpha}(p)
    = \sum_{d\,\mid\,p} d^{\alpha}
    = 1^{\alpha} + p^{\alpha}
    = 1 + p^{\alpha}.
  \]
&lt;/p&gt;
&lt;p&gt;
  Some steps of Example 3: Showing That \( f(n) = 2^{\nu(n)} \) is
  multiplicative:

  \[
    f(n) = 2^{\nu(n)}.
  \]

  \[
    f(p_1^{\alpha_1} p_2^{\alpha_2} \dots p_k^{\alpha_k})
    = 2^{\nu(p_1^{\alpha_1} p_2^{\alpha_2} \dots p_k^{\alpha_k})} = 2^k.
  \]

  \[
    f(p_1^{\alpha_1}) f(p_2^{\alpha_2}) \dots f(p_k^{\alpha_k})
    = 2^{\nu(p_1^{\alpha_1})} 2^{\nu(p_2^{\alpha_2})} \dots 2^{\nu(p_k^{\alpha_k})}
    = \underbrace{2 \cdot 2 \cdot \dots \cdot 2}_{k \text{ times}}.
    = 2^k.
  \]
&lt;/p&gt;

&lt;!-- Section 2.18 --&gt;
&lt;h2 id=&quot;2.18&quot;&gt;&amp;sect; 2.18: Derivatives of arithmetical functions&lt;/h2&gt;
&lt;h3 id=&quot;ordinary-derivative&quot;&gt;Ordinary derivative&lt;/h3&gt;
&lt;p&gt;
  \[
    (f + g)&apos; = f&apos; + g&apos;.
  \]

  \[
    (fg)&apos; = f&apos;g + fg&apos;.
  \]

  \[
    \left( f^{-1} \right)&apos; = \frac{-f&apos;}{f^2} = -f&apos; \cdot (f \cdot f)^{-1}.
  \]
&lt;/p&gt;
&lt;h3 id=&quot;similarities-in-special-derivative&quot;&gt;Similarities in special derivative&lt;/h3&gt;
&lt;p&gt;
  \[
    f&apos;(n) = f(n) \log n.
  \]

  \[
    (f + g)&apos; = f&apos; + g&apos;.
  \]

  \[
    (f * g)&apos; = f&apos; * g + f * g&apos;.
  \]

  \[
    \left( f^{-1} \right)&apos; = -f&apos; * (f * f)^{-1}.
  \]
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/iant/ch02.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Notes on Introduction to Analytic Number Theory</title>
    <link href="https://susam.net/cc/iant/notes.html"/>
    <id>urn:uuid:541eab4a-e243-4115-9728-36327d8b7913</id>
    <updated>2021-03-07T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;h1&gt;Notes on Introduction to Analytic Number Theory&lt;/h1&gt;
&lt;p&gt;
  This page contains an archive of notes from the book
  &lt;em&gt;Introduction to Analytic Number Theory&lt;/em&gt; by Tom M. Apostol
  (1976).
&lt;/p&gt;
&lt;p&gt;
  Note that this set of notes is not meant to be a systematic
  exposition of analytic number theory.  Instead this is just a
  collection of examples that illustrate some of the theorems in the
  reference textbook and intermediate steps that are not explicitly
  expressed in the book.  These boards were used to aid the
  discussions during book discussion meetings.  As a result, the
  content of these boards is informal in nature and is not intended to
  be a substitute for the book or the actual discussion meetings.
&lt;/p&gt;
&lt;p&gt;
  If you find any mistakes in the content of the board files, please
  &lt;a href=&quot;https://github.com/susam/susam.net/issues/new&quot;&gt;create a new
  issue&lt;/a&gt; or &lt;a href=&quot;https://github.com/susam/susam.net&quot;&gt;send a
  pull request&lt;/a&gt;.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch02.html&quot;&gt;Notes on Chapter 2: Arithmetical Functions and Dirichlet Multiplication&lt;/a&gt;
  &lt;/li&gt;
  &lt;!--
  &lt;li&gt;
    &lt;a href=&quot;ch03.html&quot;&gt;Notes on Chapter 3: Averages of Arithmetical Functions&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch04.html&quot;&gt;Notes on Chapter 4: Some Elementary Theorems on the Distribution of Prime Numbers&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch05.html&quot;&gt;Notes on Chapter 5: Congruences&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch06.html&quot;&gt;Notes on Chapter 6: Finite Abelian Groups and Their Characters&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch07.html&quot;&gt;Notes on Chapter 7: Dirichlet&apos;s Theorem on Primes in Arithmetical Progressions&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch08.html&quot;&gt;Notes on Chapter 8: Periodic Arithmetical Functions and Gauss Sums&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch09.html&quot;&gt;Notes on Chapter 9: Quadratic Residues and the Quadratic Reciprocity Law&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch10.html&quot;&gt;Notes on Chapter 10: Primitive Roots&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch11.html&quot;&gt;Notes on Chapter 11: Dirichlet Series and Euler Products&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch12.html&quot;&gt;Notes on Chapter 12: The Functions and \( \zeta(s) \) and \( L(s, \chi) \)&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch13.html&quot;&gt;Notes on Chapter 13: Analytic Proof of Prime Number Theorem&lt;/a&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;ch14.html&quot;&gt;Notes on Chapter 14: Partitions&lt;/a&gt;
  &lt;/li&gt;
  --&gt;
&lt;/ul&gt;
&lt;p&gt;
  More notes coming soon!  We have all the meeting notes safely
  archived.  Just need to format them and publish them here.
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/iant/notes.html"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
  <entry>
    <title>Introduction to Analytic Number Theory Book Discussions</title>
    <link href="https://susam.net/cc/iant/"/>
    <id>urn:uuid:03bb0d52-4dbc-4e91-a612-1624345bd60c</id>
    <updated>2021-03-05T00:00:00Z</updated>
    <content type="html">
<!-- BEGIN HTML -->
&lt;h1&gt;Introduction to Analytic Number Theory Book Discussions&lt;/h1&gt;
&lt;div class=&quot;highlight&quot;&gt;
  This meeting series is complete!  There are no new meetings
  happening for this book.  Go to the meetings
  &lt;a href=&quot;../&quot;&gt;main page&lt;/a&gt; to find out about current
  active meetings.
&lt;/div&gt;
&lt;p&gt;
  The following content on this page is an archive of the content as
  it appeared on the last day of meeting for this book.
&lt;/p&gt;
&lt;hr&gt;
&lt;div class=&quot;highlight&quot;&gt;
  &lt;p&gt;
    Meeting time: 17:00 UTC from Tuesday to Friday,
    usually.&lt;sup&gt;&amp;dagger;&lt;/sup&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Meeting duration: 40 minutes.
  &lt;/p&gt;
  &lt;p&gt;
    Meeting link: &lt;a href=&quot;https://bit.ly/spzoom2&quot;&gt;bit.ly/spzoom2&lt;/a&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Meeting log: &lt;a href=&quot;log.html&quot;&gt;120 meetings&lt;/a&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Reference Book: &lt;a href=&quot;https://www.springer.com/gp/book/9780387901633&quot;&gt;&lt;em&gt;Introduction
    to Analytic Number Theory&lt;/em&gt;&lt;/a&gt; by Tom M. Apostol (1976)
  &lt;/p&gt;
  &lt;p&gt;
    Chapter notes: &lt;a href=&quot;notes.html&quot;&gt;Notes&lt;/a&gt;
  &lt;/p&gt;
  &lt;p&gt;
    Started: 05 Mar 2021
  &lt;/p&gt;
  &lt;p&gt;
    Ended: 01 Oct 2021
  &lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;small&gt;&amp;dagger; There are some exceptions to this schedule
  occasionally.  &lt;a href=&quot;../#join&quot;&gt;Join our channel&lt;/a&gt; to
  receive schedule updates.&lt;/small&gt;
&lt;/p&gt;
&lt;p&gt;
  The primary reference book for these meetings is
  &lt;em&gt;Introduction to Analytic Number Theory&lt;/em&gt; written by Tom
  M. Apostol.  Admittedly, the book is quite expensive but you may
  find a relatively cheap paperback (softcover) copy on some websites.
&lt;/p&gt;
&lt;p&gt;
  These meetings are hosted by Susam and attended by some members of
  &lt;code&gt;#math&lt;/code&gt; and &lt;code&gt;#algorithms&lt;/code&gt; channels of Libera
  IRC network as well as by some members
  from &lt;a href=&quot;https://news.ycombinator.com/&quot;&gt;Hacker News&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  You are welcome to join these meetings anytime.  If you are
  concerned that the meetings may not make sense if you join when we
  are in the middle of a chapter, please free to talk to us about it
  in the &lt;a href=&quot;../#join&quot;&gt;group channel&lt;/a&gt;.  I can
  recommend the next best time to begin joining the meetings.
  Usually, it would be when we begin reading a new section or chapter
  that is fairly self-contained and does not depend a lot on material
  we have read previously.
&lt;/p&gt;
<!-- ### -->
&lt;p&gt;
  &lt;a href="https://susam.net/cc/iant/"&gt;Read on website&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/mathematics.html&quot;&gt;#mathematics&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/number-theory.html&quot;&gt;#number-theory&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/book.html&quot;&gt;#book&lt;/a&gt; |
  &lt;a href=&quot;https://susam.net/tag/meetup.html&quot;&gt;#meetup&lt;/a&gt;
&lt;/p&gt;
<!-- END HTML -->
    </content>
  </entry>
</feed>
