{"id":13686622,"url":"https://github.com/susam/emfy","last_synced_at":"2025-05-16T13:05:33.324Z","repository":{"id":44356029,"uuid":"442829618","full_name":"susam/emfy","owner":"susam","description":"A dark and sleek Emacs setup for general purpose editing and programming","archived":false,"fork":false,"pushed_at":"2024-09-09T07:56:24.000Z","size":104,"stargazers_count":938,"open_issues_count":1,"forks_count":38,"subscribers_count":16,"default_branch":"main","last_synced_at":"2024-10-30T00:32:17.402Z","etag":null,"topics":["dark-theme","emacs","emacs-initialization","emacs-lisp","markdown","minimalist","paredit","rainbow-delimiters"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/susam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-29T16:31:18.000Z","updated_at":"2024-10-20T16:34:18.000Z","dependencies_parsed_at":"2023-12-25T20:58:44.158Z","dependency_job_id":"1f21c576-3c7f-4bcf-a84b-c9ea2f4faa96","html_url":"https://github.com/susam/emfy","commit_stats":{"total_commits":64,"total_committers":5,"mean_commits":12.8,"dds":0.46875,"last_synced_commit":"85e5ef1362ca4d80c042483f7352673263a4a724"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Femfy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Femfy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Femfy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susam%2Femfy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/susam","download_url":"https://codeload.github.com/susam/emfy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247563934,"owners_count":20958971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dark-theme","emacs","emacs-initialization","emacs-lisp","markdown","minimalist","paredit","rainbow-delimiters"],"created_at":"2024-08-02T15:00:36.255Z","updated_at":"2025-04-06T23:15:55.398Z","avatar_url":"https://github.com/susam.png","language":"Emacs Lisp","funding_links":[],"categories":["Emacs Lisp"],"sub_categories":[],"readme":"Emacs for You (Emfy)\n====================\n\nThis project provides a tiny [`init.el`] file to set up Emacs quickly.\nThis document provides a detailed description of how to set it up and\nget started with Emacs.\n\n[![View Source][Source SVG]][Source URL]\n[![Mastodon][Mastodon SVG]][Mastodon URL]\n\n[Source SVG]: https://img.shields.io/badge/view-init.el-brightgreen\n[Source URL]: init.el\n[Mastodon SVG]: https://img.shields.io/badge/mastodon-%40susam-%2355f\n[Mastodon URL]: https://mastodon.social/@susam\n[`init.el`]: init.el\n[`em`]: em\n\nFurther this project also provides a tiny convenience command named\n[`em`] to start Emacs server and edit files using Emacs server.  This\nhelps in using Emacs efficiently.  This script and its usage is\nexplained in detail later in the [Emacs Server](#emacs-server) and\n[Emacs Launcher](#emacs-launcher) sections.  Here is how the Emacs\nenvironment is going to look after setting up this project:\n\n[![Screenshot of Emacs][demo-img]][demo-img]\n\n[demo-img]: https://susam.github.io/blob/img/emfy/emfy-0.4.0.png\n\nIf you are already comfortable with Emacs and only want to understand\nthe content of [`init.el`] or [`em`], you can skip ahead directly to\nthe [Line-by-Line Explanation](#line-by-line-explanation) section that\ndescribes every line of these files in detail.\n\n\nContents\n--------\n\n* [Who Is This For?](#who-is-this-for)\n* [Features](#features)\n* [Get Started](#get-started)\n* [Step-by-Step Usage](#step-by-step-usage)\n  * [Use Emacs](#use-emacs)\n  * [Use Paredit](#use-paredit)\n  * [Evaluate Emacs Lisp Code](#evaluate-emacs-lisp-code)\n  * [Use Rainbow Delimiters](#use-rainbow-delimiters)\n* [Useful Terms](#useful-terms)\n* [Line-by-Line Explanation](#line-by-line-explanation)\n  * [Tweak UI](#tweak-ui)\n  * [Dark Theme](#dark-theme)\n  * [Highlight Parentheses](#highlight-parentheses)\n  * [Minibuffer Completion](#minibuffer-completion)\n  * [Show Stray Whitespace](#show-stray-whitespace)\n  * [Require Final Newline](#require-final-newline)\n  * [Single Space for Sentence Spacing](#single-space-for-sentence-spacing)\n  * [Indentation](#indentation)\n  * [Keep Working Directory Tidy](#keep-working-directory-tidy)\n  * [Custom Command and Key Sequences](#custom-command-and-key-sequences)\n  * [Emacs Server](#emacs-server)\n  * [Install Packages](#install-packages)\n  * [Configure Paredit](#configure-paredit)\n  * [Configure Rainbow Delimiters](#configure-rainbow-delimiters)\n  * [End of File](#end-of-file)\n  * [Emacs Launcher](#emacs-launcher)\n* [Opinion References](#opinion-references)\n* [Channels](#channels)\n* [License](#license)\n* [See Also](#see-also)\n\n\nWho Is This For?\n----------------\n\nAre you an absolute beginner to Emacs?  Are you so new to Emacs that\nyou do not even have the `~/.emacs.d/` directory on your file system?\nHave you come across recommendations to use starter kits like Doom\nEmacs, Spacemacs, etc. but then you wondered if you could use vanilla\nEmacs and customise it slowly to suit your needs without having to\nsacrifice your productivity in the initial days of using Emacs?  Do\nyou also want your Emacs to look sleek from day zero?  If you answered\n\"yes\" to most of these questions, then this project is for you.\n\nThe [`init.el`] file in this project provides a quick way to get\nstarted with setting up your Emacs environment.  This document\nexplains how to do so in a step-by-step manner.  This document also\nexplains the content of [`init.el`] and [`em`] in a line-by-line\nmanner.\n\nNote that many customisations in the Emacs initialisation file\navailable in this project are a result of the author's preferences.\nThey may or may not match others' preferences.  They may or may not\nsuit your taste and requirements.  Wherever applicable, the pros and\ncons of each customisation and possible alternatives are discussed in\nthis document.  You are encouraged to read the line-by-line\nexplanation that comes later in this document, understand each\ncustomisation, and modify the initialisation file to suit your needs.\n\n\nFeatures\n--------\n\nThis project provides a file named [`init.el`] that offers the\nfollowing features:\n\n  - Disable a few UI elements to provide a clean and minimal\n    look-and-feel.\n  - Show current column number in the mode line.\n  - Load a dark colour theme named Wombat.\n  - Customise the colour theme to accentuate the cursor, comments, and\n    search matches.\n  - Highlight matching parentheses.\n  - Enable Fido mode for automatic completion of minibuffer input.\n  - Show trailing whitespace at the end of lines clearly.\n  - Show trailing newlines at the end of buffer clearly.\n  - Show missing newlines at the end of buffer clearly.\n  - Always add a newline automatically at the end of a file while\n    saving.\n  - Use single spacing convention to end sentences.\n  - Use spaces, not tabs, for indentation.\n  - Configure indentation settings according to popular coding\n    conventions.\n  - Move auto-save files and backup files to a separate directory to\n    keep our working directories tidy.\n  - Do not move original files while creating backups.\n  - Provide examples of user-defined custom commands and a few custom\n    key sequences.\n  - Start Emacs server automatically, so that terminal users can use\n    Emacs client to edit files with an existing instance of Emacs.\n  - Custom command to install configured packages conveniently.\n  - Install Markdown mode for convenient editing of Markdown files.\n  - Install and configure Paredit for editing S-expressions\n    efficiently.\n  - Install and configure Rainbow Delimiters to colour parentheses by\n    their nesting depth level.\n\nAdditionally, this project also provides a convenience command named\n[`em`] that is a thin wrapper around the `emacs` and `emacsclient`\ncommands.  It offers the following features:\n\n  - Start a new instance of Emacs when requested.\n  - Open files in an existing Emacs server if a server is running\n    already.\n  - Automatically start a new Emacs server if a server is not running\n    already.\n\nAll of these features along with every line of code that enables these\nfeatures are explained in the sections below.\n\n\nGet Started\n-----------\n\nThis section helps you to set up Emfy quickly and see what the end\nresult looks like.  Perform the following steps to get started:\n\n 1. Install Emacs 28.1 or later.\n\n    On macOS, enter the following command if you have\n    [Homebrew](https://brew.sh):\n\n    ```sh\n    brew install --cask emacs\n    ```\n\n    On Debian, Ubuntu, or another Debian-based Linux system, enter the\n    following command:\n\n    ```sh\n    sudo apt-get install emacs\n    ```\n\n    For other environments, visit https://www.gnu.org/software/emacs/\n    to see how to install Emacs.\n\n 2. Copy the Emacs initialisation file [`init.el`] provided here to\n    your home directory.  Here is an example `curl` command that does\n    this:\n\n    ```sh\n    mkdir ~/.emacs.d\n    curl -L https://github.com/susam/emfy/raw/main/init.el \u003e\u003e ~/.emacs.d/init.el\n    ```\n\n    Here is another alternative that copies the initialisation file to\n    an XDG-compatible location as follows:\n\n    ```sh\n    mkdir -p ~/.config/emacs\n    curl -L https://github.com/susam/emfy/raw/main/init.el \u003e\u003e ~/.config/emacs/init.el\n    ```\n\n    Some Emacs users who have been using Emacs for a long time like to\n    keep the initialisation file at its traditional location\n    illustrated below:\n\n    ```sh\n    curl -L https://github.com/susam/emfy/raw/main/init.el \u003e\u003e ~/.emacs\n    ```\n\n    Emacs can automatically load the Emacs initialisation file from\n    any of the paths used above.  See section [The Emacs\n    Initialisation File][emacs-init-doc] of the Emacs manual for more\n    details about this.\n\n 3. Copy the Emacs launcher script [`em`] provided here to some\n    directory that belongs to your `PATH` variable.  For example, here\n    are a few commands that download this script and place it in the\n    `/usr/local/bin/` directory:\n\n    ```sh\n    curl -L https://github.com/susam/emfy/raw/main/em \u003e /tmp/em\n    sudo mv /tmp/em /usr/local/bin/em\n    chmod +x /usr/local/bin/em\n    ```\n\n    The usefulness of this launcher script will be explained in the\n    section [Emacs Launcher](#emacs-launcher) later.\n\n 4. Install packages configured in Emfy:\n\n    ```sh\n    emacs --eval '(progn (install-packages) (kill-emacs))'\n    ```\n\n    We will see how this command works later in the section [Install\n    Packages](#install-packages).\n\n    On macOS, you may receive the following error message in a dialog\n    box: '“Emacs.app” can’t be opened because Apple cannot check it\n    for malicious software.'  To resolve this issue, go to Apple menu \u003e\n    System Preferences \u003e Security \u0026 Privacy \u003e General and click \"Open\n    Anyway\".\n\n 5. Start Emacs:\n\n    ```sh\n    emacs\n    ```\n\nNow that your environment is setup, read the next section to learn how\nto use this environment in more detail.\n\n[emacs-init-doc]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html\n\n\nStep-by-Step Usage\n------------------\n\n### Use Emacs\n\nEmacs is a very powerful and extensible editor.  It comes with over\n10,000 built-in commands.  A small section like this can barely\nscratch the surface of Emacs.  Yet, this section makes a modest\nattempt at getting you started with Emacs and then provides more\nresources to learn further.  Perform the following steps to get\nstarted:\n\n 1. Start Emacs:\n\n    ```sh\n    emacs\n    ```\n\n 2. Within Emacs, enter the following command to open a file, say,\n    `hello.txt`:\n\n    ```\n    C-x C-f hello.txt RET\n    ```\n\n    A new buffer to edit `hello.txt` is created.  If a file with that\n    name already exists on your file system, then it loads the content\n    of the file into the buffer.\n\n    Note that in the Emacs world (and elsewhere too), the notation\n    `C-` denotes the \u003ckbd\u003ectrl\u003c/kbd\u003e modifier key.  Thus `C-x` denotes\n    \u003ckbd\u003ectrl\u003c/kbd\u003e+\u003ckbd\u003ex\u003c/kbd\u003e.\n\n    The notation `RET` denotes the \u003ckbd\u003eenter\u003c/kbd\u003e or\n    \u003ckbd\u003ereturn\u003c/kbd\u003e key.\n\n    Typing consecutive `C-` key sequences can be optimised by pressing\n    and holding down the \u003ckbd\u003ectrl\u003c/kbd\u003e key, then typing the other\n    keys, and then releasing the \u003ckbd\u003ectrl\u003c/kbd\u003e key.  For example, to\n    type `C-x C-f`, first press and hold down \u003ckbd\u003ectrl\u003c/kbd\u003e, then\n    type \u003ckbd\u003ex\u003c/kbd\u003e, then type \u003ckbd\u003ef\u003c/kbd\u003e, and then release\n    \u003ckbd\u003ectrl\u003c/kbd\u003e.  In other words, think of `C-x C-f` as `C-(x f)`.\n    This shortcut works for other modifier keys too.\n\n 3. Now type some text into the buffer.  Type out at least 3-4 words.\n    We will need it for the next two steps.\n\n 4. Move backward by one word with the following key sequence:\n\n    ```\n    M-b\n    ```\n\n    The notation `M-` denotes the meta modifier key.  The above\n    command can be typed with \u003ckbd\u003ealt\u003c/kbd\u003e+\u003ckbd\u003eb\u003c/kbd\u003e or\n    \u003ckbd\u003eoption\u003c/kbd\u003e+\u003ckbd\u003eb\u003c/kbd\u003e or \u003ckbd\u003eesc\u003c/kbd\u003e \u003ckbd\u003eb\u003c/kbd\u003e.\n\n    If you face any issue with the \u003ckbd\u003ealt\u003c/kbd\u003e key or the\n    \u003ckbd\u003eoption\u003c/kbd\u003e key, read [Emacs Wiki: Meta Key\n    Problems](https://www.emacswiki.org/emacs/MetaKeyProblems).\n\n 5. Now move forward by one word with the following key sequence:\n\n    ```\n    M-f\n    ```\n\n 5. The `C-g` key sequence cancels the current command.  This can be\n    used when you mistype a command and want to start over or if you\n    type a command partially, then change your mind and then you want\n    to cancel the partially typed command.  Try out these examples:\n\n    ```\n    C-x C-f C-g\n    ```\n\n    ```\n    C-x C-g\n    ```\n\n 7. Save the buffer to a file on the file system with this command:\n\n    ```\n    C-x C-s\n    ```\n\n 8. Quit Emacs:\n\n    ```\n    C-x C-c\n    ```\n\nNow you know how to start Emacs, open a file, save it, and quit.\nImprove your Emacs knowledge further by taking the Emacs tutorial that\ncomes along with Emacs.  In Emacs, type `C-h t` to start the tutorial.\n\nThe key bindings to perform various operations like creating file,\nsaving file, quitting the editor, etc. may look arcane at first, but\nrepeated usage of the key bindings develops muscle memory soon and\nafter having used them for a few days, one does not even have to think\nabout them.  The fingers do what the mind wants effortlessly due to\nmuscle memory.\n\nWhile you are getting used to the Emacs key bindings, keep this [GNU\nEmacs Reference Card][emacs-ref] handy.  Also, if you are using it in\nGUI mode, then the menu options can be quite helpful.\n\n[emacs-ref]: https://www.gnu.org/software/emacs/refcards/pdf/refcard.pdf\n\n\n### Use Paredit\n\nParedit helps in keeping parentheses balanced and also in performing\nstructured editing of S-expressions in Lisp code.  It provides a\npowerful set of commands to manipulate S-expressions in various ways.\nPerform the following steps to get started with Paredit:\n\n 1. Run Emacs:\n\n    ```sh\n    emacs\n    ```\n\n 2. Open an Emacs Lisp source file:\n\n    ```\n    C-x C-f foo.el\n    ```\n\n 3. Type the following code only:\n\n    ```elisp\n    (defun square (x\n    ```\n\n    At this point, Paredit should have inserted the two closing\n    parentheses automatically.  The code should look like this:\n\n    ```elisp\n    (defun square (x))\n                    -\n    ```\n\n    The cursor should be situated just after the parameter `x`.  The\n    underbar shows where the cursor should be.\n\n 4. Type the closing parentheses now.  Yes, type it even if the\n    closing parenthesis is already present.  The cursor should now\n    skip over the first closing parenthesis like this:\n\n    ```elisp\n    (defun square (x))\n                     -\n    ```\n\n    Of course, there was no need to type the closing parenthesis\n    because it was already present but typing it out to skip over it\n    is more efficient than moving over it with movement commands.\n    This is, in fact, a very nifty feature of Paredit.  We can enter\n    code with the same keystrokes as we would without Paredit.\n\n 5. Now type \u003ckbd\u003eenter\u003c/kbd\u003e to insert a newline just before the last\n    parenthesis.  A newline is inserted like this:\n\n    ```elisp\n    (defun square (x)\n      )\n      -\n    ```\n\n 6. Now type only this:\n\n    ```elisp\n    (* x x\n    ```\n\n    Again, Paredit would insert the closing parenthesis automatically.\n    The code should look like this now:\n\n    ```elisp\n    (defun square (x)\n      (* x x))\n            -\n    ```\n\nThere is a lot more to Paredit than this.  To learn more, see [The\nAnimated Guide to Paredit][paredit-ref].\n\nNote: While many Lisp programmers find Paredit very convenient and\npowerful while manipulating S-expressions in Lisp code, there are a\nfew people who do not like Paredit because they find the Paredit\nbehaviour intrusive.  See the [Opinion References](#opinion-references)\nsection for more discussion on this topic.\n\n[paredit-ref]: http://danmidwood.com/content/2014/11/21/animated-paredit.html\n\n\n### Evaluate Emacs Lisp Code\n\nThe previous section shows how to write some Emacs Lisp code and how\nParedit helps in keeping the parentheses balanced.  In this section,\nwe will see how to execute some Emacs Lisp code.\n\n 1. Run Emacs:\n\n    ```sh\n    emacs\n    ```\n\n 2. Open an Emacs Lisp source file:\n\n    ```\n    C-x C-f foo.el\n    ```\n\n 3. Enter the following code:\n\n    ```elisp\n    (defun square (x)\n      (* x x))\n    ```\n\n 4. With the cursor placed right after the last closing parenthesis,\n    type `C-x C-e`.  The name of the function defined should appear in\n    the echo area at the bottom.  This confirms that the function has\n    been defined.\n\n 5. Now add the following code to the Emacs Lisp source file:\n\n    ```elisp\n    (square 5)\n    ```\n\n 6. Once again, with the cursor placed right after the last closing\n    parenthesis, type `C-x C-e`.  The result should appear in the echo\n    area at the bottom.\n\n\n### Use Rainbow Delimiters\n\nThere is not much to learn about using Rainbow Delimiters.  In the\nprevious sections, you must have seen that as you type nested\nparentheses, each parenthesis is highlighted with a different colour.\nThat is done by Rainbow Delimiters.  It colours each parenthesis\naccording to its nesting depth level.\n\nNote: Not everyone likes Rainbow Delimiters.  Some people find\nparentheses in multiple colours distracting.  See the [Opinion\nReferences](#opinion-references) section for more discussion on this\ntopic.\n\n\nUseful Terms\n------------\n\nIn this section, we clearly describe a few terms that we use later in\nthis document.\n\n  - *Frame*: The Emacs manual uses the term frame to mean a GUI\n    window, or a region of the desktop, or the terminal where Emacs is\n    displayed.  We do not call it window in Emacs parlance because the\n    term \"window\" is reserved for another element discussed further\n    below in this list.\n\n  - *Menu bar*: An Emacs frame displays a menu bar at the very top.\n    It allows access to commands via a series of menus.\n\n  - *Echo area*: An Emacs frame displays an echo area at the very\n    bottom.  The echo area displays informative messages.\n\n  - *Minibuffer*: The echo area is also used to display the\n    minibuffer, a special buffer where we can type and enter arguments\n    to commands, such as the name of a file to be edited after typing\n    the key sequence `C-x C-f`.\n\n  - *Tool bar*: On a graphical display, a tool bar is displayed\n    directly below the menu bar.  The tool bar contains a row of icons\n    that provides quick access to several editing commands.\n\n  - *Window*: The main area of the frame between the menu bar or the\n    tool bar (if it exists) and the echo area contains one or more\n    windows.  This is where we view or edit files.  Each window\n    displays a *buffer*, i.e., the text or graphics we are editing or\n    viewing.  By default, only one window is displayed when we start\n    Emacs.  We can split this main area into multiple windows using\n    key sequences like `C-x 2`, `C-x 3`, etc. and then open different\n    files or buffers in different windows.\n\n  - *Mode line*: The last line of each window is a mode line.  It\n    displays information about the buffer.  For example, it shows the\n    name of the buffer, the line number at which the cursor is\n    currently present, etc.\n\n  - *Scroll bar*: On a graphicaly display, a scroll bar is displayed\n    on one side which can be used to scroll through the buffer.\n\nThere are many other peculiar terms found in the world of Emacs such\nas the term *point* to refer to the current location of the cursor,\nthe term *kill* to cut text, the term *yank* to paste text, etc. but\nwe will not discuss them here for the sake of brevity.  The meanings\nof most such terms become obvious from the context when you encounter\nthem.  The terms described above should be sufficient to understand\nthe line-by-line explanation presented in the next section.\n\n\nLine-by-Line Explanation\n------------------------\n\nThis section explains the [`init.el`] file provided here line-by-line.\n\n\n### Tweak UI\n\nThe first few lines in our [`init.el`] merely tweak the Emacs user\ninterface.  These are of course not essential for using Emacs.\nHowever, many new Emacs users often ask how to customise the user\ninterface to add a good colour scheme and make it look minimal, so\nthis section indulges a little in customising the user interface.\n\nHere is a line-by-line explanation of the UI tweaks in [`init.el`]:\n\n  - When Emacs runs in a GUI window, by default, it starts with a menu\n    bar, tool bar, and scroll bar.  Some users like to hide them in\n    order to make the Emacs frame look clean and minimal.  The\n    following lines disable the tool bar and scroll bar.  The menu bar\n    is left enabled.\n\n    ```elisp\n    (when (display-graphic-p)\n      (tool-bar-mode 0)\n      (scroll-bar-mode 0))\n    ```\n\n    The `when` expression checks if Emacs is running with graphic\n    display before disabling the tool bar and scroll bar.  Without the\n    `when` expression, we get the following error on Emacs without\n    graphic display support: `Symbol's function definition is void:\n    tool-bar-mode`.  An example of Emacs without graphics support is\n    `emacs-nox` on Debian 10.  Note that this is only an author's\n    preference.  You may comment out one or more of these lines if you\n    want to retain the tool bar or scroll bar.\n\n    Some users like to hide the menu bar as well.  To disable the menu\n    bar, include `(menu-bar-mode 0)` as top-level-expression (i.e.,\n    outside the `when` expression) in the initialisation file.  Even\n    with the menu bar disabled, the menu can be accessed anytime by\n    typing `\u003cf10\u003e`.  For beginners to Emacs, it is advisable to keep\n    the menu bar enabled because it helps in discovering new features.\n\n  - Inhibit the startup screen with the `Welcome to GNU Emacs` message\n    from appearing:\n\n    ```elisp\n    (setq inhibit-startup-screen t)\n    ```\n\n    If you are a beginner to Emacs, you might find the startup screen\n    helpful.  It contains links to tutorial, manuals, common tasks,\n    etc.  If you want to retain the startup screen, comment this line\n    out.\n\n  - Show column number in the mode line:\n\n    ```elisp\n    (column-number-mode)\n    ```\n\n    By default, Emacs shows only the current line number in the mode\n    line.  For example, by default, Emacs may display something like\n    `L4` in the mode line to indicate that the cursor is on the fourth\n    line of the buffer.  The above Emacs Lisp code enables column\n    number display in the mode line.  With column number enabled,\n    Emacs may display something like `(4,0)` to indicate the cursor is\n    at the beginning of the fourth line.\n\n\n### Dark Theme\n\nIn this section, we will choose a dark theme for Emacs.  If you do not\nlike dark themes, you might want to stick with the default theme,\nchoose another theme, or skip this section.\n\n  - Load a beautiful dark colour theme known as `wombat`:\n\n    ```elisp\n    (load-theme 'wombat)\n    ```\n\n    If you want to check the other built-in themes, type `M-x\n    customize-themes RET`.  A new window with a buffer named `*Custom\n    Themes*` appear.  In this buffer, select any theme you want to\n    test.  After you are done testing, you can close this new window\n    with `C-x 0`.\n\n    By default the Wombat theme looks like this:\n\n    \u003c!-- wombat-default --\u003e\n    \u003ca href=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-wombat1.png\"\u003e\u003cimg\n        src=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-wombat1.png\"\n        alt=\"Screenshot of Wombat default theme\"\n        width=\"580\"\u003e\u003c/a\u003e\n\n    In this theme, the cursor, search matches, and comments can often\n    be difficult to spot because they are all coloured with different\n    shades of grey while the background is also grey.  In the next few\n    points, we will customise this theme a little to make these\n    elements easier to spot.  We colour them differently to add more\n    contrast between the background and foreground colours of these\n    elements.  In the end, our customised Wombat theme would look like\n    this:\n\n    \u003c!-- wombat-custom --\u003e\n    \u003ca href=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-wombat2.png\"\u003e\u003cimg\n        src=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-wombat2.png\"\n        alt=\"Screenshot of Wombat custom theme\"\n        width=\"580\"\u003e\u003c/a\u003e\n\n  - Choose a darker shade of grey for the background colour to improve\n    the contrast of the theme:\n\n    ```elisp\n    (with-eval-after-load 'wombat-theme\n      (set-face-background 'default \"#111\")\n    ```\n\n    The above `with-eval-after-load` expression ensures that the code\n    within its body is executed after `wombat-theme` gets loaded.\n    Since `wombat-theme` is already loaded here (due to the\n    `load-theme` expression discussed earlier), the body is evaluated\n    immediately.  However, if `wombat-theme` were not yet loaded, the\n    body would be evaluated as soon as `wombat-theme` gets loaded.\n\n    The first expression in the the body sets the background colour to\n    `#111`, i.e., a very dark shade of grey.\n\n    The name `wombat-theme` refers to the feature provided by the\n    Wombat theme.  Emacs packages (including the ones for themes) can\n    declare the feature they provide.  If we ever remove or comment\n    out the `load-theme` expression mentioned earlier, then the\n    `wombat-theme` feature will not be loaded and the body of the\n    `with-eval-after-load` expression will not be executed.\n    Therefore, removing or commenting out the `load-theme` call is a\n    convenient way to disable the theme along with all the additional\n    color customizations made here.\n\n  - Choose a pale shade of orange for the cursor, so that it stands\n    out clearly against the dark grey background:\n\n    ```elisp\n      (set-face-background 'cursor \"#c96\")\n    ```\n\n  - Use tangerine yellow to colour the comments:\n\n    ```elisp\n      (set-face-foreground 'font-lock-comment-face \"#fc0\")\n    ```\n\n  - Highlight the current search match with bright yellow background\n    and dark foreground:\n\n    ```elisp\n      (set-face-background 'isearch \"#ff0\")\n      (set-face-foreground 'isearch \"#000\")\n    ```\n\n  - Highlight search matches other than the current one with a darker\n    shade of yellow as the background and dark foreground:\n\n    ```elisp\n      (set-face-background 'lazy-highlight \"#990\")\n      (set-face-foreground 'lazy-highlight \"#000\"))\n    ```\n\n**Personal note:** I see that many recent colour themes choose a dim\ncolour for comments in code.  Such colour themes intend to\nunderemphasise the comments.  I think comments play an important role\nin code meant to be read by humans and should be emphasised\nappropriately.  That's why I have chosen tangerine yellow for\ncomments.  This makes the comments are easily readable.\n\n\n### Line Numbers\n\nEnable line numbers in modes for configuration, programming, and text\nwith the following loop:\n\n```elisp\n(dolist (hook '(prog-mode-hook conf-mode-hook text-mode-hook))\n  (add-hook hook 'display-line-numbers-mode))\n```\n\nEvery buffer has a *major mode* which determines the editing\nbehaviour, syntax highlighting, etc. of the buffer.  To see the\ncurrent major mode, type `M-: major-mode RET`.  The name of the\ncurrent major mode is also always displayed in the mode line at the\nbottom.\n\nThe `add-hook` calls in the loop above ensure that\n`display-line-numbers-mode` is enabled automatically when certain\nmajor modes become active.  In particular, this ensures that line\nnumbers are enabled while editing configuration files, program files,\nor text files.  For instance, when editing a C program (say with `C-x\nC-f foo.c RET`), the above hook enables line numbers for the buffer\nfor the C program file.  This happens because while editing C program\nfiles, the major mode named `c-mode` is activated and `c-mode` is\nderived from `prog-mode`.\n\nThe above loop also ensures that this feature *does not* get enabled\nwhile working with other types of buffers.  For example, if we start a\nterminal emulator with `M-x ansi-term RET`, this feature does not get\nenabled because the terminal emulator buffer has the major mode named\n`term-mode` which is not derived from any of the three modes mentioned\nabove.  Displaying line numbers in such a mode can be distracting, so\nwe keep line numbers disabled in such modes.\n\n\n### Highlight Parentheses\n\nThe following points describe how we enable highlighting of\nparentheses:\n\n  - The next point shows how to enable highlighting of matching pair\n    of parentheses.  By default, there is a small delay between the\n    movement of a cursor and the highlighting of the matching pair of\n    parentheses.  The following line of code gets rid of this delay:\n\n    ```elisp\n    (setq show-paren-delay 0)\n    ```\n\n    This line of code must come before the one in the next point for\n    it to be effective.\n\n  - Highlight matching parentheses:\n\n    ```elisp\n    (show-paren-mode)\n    ```\n\n    A pair of parentheses is highlighted when the cursor is on the\n    opening parenthesis of the pair or just after the closing\n    parenthesis of the pair.\n\n\n### Minibuffer Completion\n\nEnable automatic minibuffer completion:\n\n```elisp\n(fido-vertical-mode)\n```\n\nTo test this out, perform the following exercises:\n\n  - Type `C-x C-f /etc/hst` and watch Fido mode automatically\n    presenting `/etc/hosts` as one of the completion options.  Type\n    `RET` to select it.  Alternatively, type `C-n` and/or `C-p` to\n    pick a different option and type `RET`.\n\n  - Type `C-x b msg RET` and watch Fido presenting the buffer named\n    `*Messages*` as one of the options and selecting it.  By the way,\n    the key sequence `C-x b` is used to switch buffers.\n\n  - Type `M-x wspmod RET` and watch Fido presenting the command named\n    `whitespace-mode` as one of the options and selecting it.  The key\n    sequence `M-x` is used to execute Emacs commands.  We will see\n    later how to make our own commands.\n\nIn the steps above, note how it is not necessary to type out the\nfilename or buffer name or command accurately.  We can enter our input\npartially and Fido will automatically find matches for it.\n\n\n### Show Stray Whitespace\n\nWhile writing text files, it can often be useful to quickly spot any\ntrailing whitespace at the end of lines or unnecessary trailing new\nlines at the end of the file.  The next few points describe how we\nhighlight stray whitespace and newlines.\n\n  - Highlight trailing whitespace at the end of lines in modes for\n    configuration, programming, and text with the following loop:\n\n    ```elisp\n    (dolist (hook '(conf-mode-hook prog-mode-hook text-mode-hook))\n      (add-hook hook (lambda () (setq show-trailing-whitespace t))))\n    ```\n\n    When the variable `show-trailing-whitespace` is set to `t`, any\n    stray trailing whitespace at the end of lines is highlighted\n    (usually with a red background) as shown in the screenshot below:\n\n    \u003c!-- lorem1 --\u003e\n    \u003ca href=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem1.png\"\u003e\u003cimg\n        src=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem1.png\"\n        alt=\"Screenshot of whitespace highlighted in Emacs\"\n        width=\"580\"\u003e\u003c/a\u003e\n\n    The screenshot above shows one stray trailing space in the second\n    line and two trailing spaces in the third line.  These trailing\n    spaces can be removed with the key sequence `M-x\n    delete-trailing-whitespace RET`.\n\n    Note that we enable this feature only for modes pertaining to\n    configuration, programming, and text.  It can be distracting to\n    see stray whitespace highlighted in other modes like `term-mode`,\n    `erc-mode`, etc.\n\n  - Show the end of buffer with a special glyph in the left fringe:\n\n    ```elisp\n    (setq-default indicate-empty-lines t)\n    ```\n\n    Showing the end of the buffer conspicuously can be helpful to spot\n    any unnecessary blank lines at the end of a buffer.  A blank line\n    is one that does not contain any character except the terminating\n    newline itself.  Here is a screenshot that demonstrates this\n    feature:\n\n    \u003c!-- lorem2 --\u003e\n    \u003ca href=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem2.png\"\u003e\u003cimg\n        src=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem2.png\"\n        alt=\"Screenshot of non-existent line indicators\"\n        width=\"580\"\u003e\u003c/a\u003e\n\n    The screenshot shows that there are two blank lines just before\n    the end of the buffer.  The tiny horizontal dashes on the left\n    fringe mark the end of the buffer.  Note: This is similar to how\n    Vim displays the tilde symbol (`~`) to show the end of the buffer.\n    The trailing blank lines at the end of a buffer can be removed\n    with the key sequence `M-x delete-trailing-whitespace RET`.\n\n  - Show buffer boundaries in the left fringe:\n\n    ```elisp\n    (setq-default indicate-buffer-boundaries 'left)\n    ```\n\n    The buffer boundaries can be useful to check if the last line of\n    the buffer has a terminating newline or not.  If the buffer does\n    not contain a terminating newline, then a top-right corner shape\n    (`⌝`) appears in the fringe.  For example, see this screenshot of\n    a file that does not contain a terminating newline:\n\n    \u003c!-- lorem3 --\u003e\n    \u003ca href=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem3.png\"\u003e\u003cimg\n        src=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem3.png\"\n        alt=\"Screenshot of a file without terminating newline\"\n        width=\"580\"\u003e\u003c/a\u003e\n\n    If there is only one line in the buffer and that line is\n    terminated with a newline then a left-bracket (`[`) appears in the\n    fringe.  If there are multiple lines in the buffer and the last\n    line is terminated with a newline then a bottom-left corner shape\n    (`⌞`) appears in the fringe.  Here is a screenshot of a file that\n    contains a terminating newline:\n\n    \u003c!-- lorem4 --\u003e\n    \u003ca href=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem4.png\"\u003e\u003cimg\n        src=\"https://susam.github.io/blob/img/emfy/emfy-0.4.0-lorem4.png\"\n        alt=\"Screenshot of a file with terminating newline\"\n        width=\"580\"\u003e\u003c/a\u003e\n\n    To summarise, these shapes (`[`, `⌞`, or `⌝`) show where the last\n    newline of the buffer exists.  The last newline of the buffer\n    exists above the lower horizontal bar of these shapes.  No\n    newlines exist below the lower horizontal bar.\n\n\n### Require Final Newline\n\nIt is good practice to terminate text files with a newline.  For many\ntypes of files, such as files with extensions `.c`, `.el`, `.json`,\n`.lisp`, `.org`, `.py`, `.txt`, etc., Emacs inserts a terminating\nnewline automatically when we save the file with `C-x C-s`.  Emacs\nachieves this by ensuring that the major modes for these files set the\nvariable `require-final-newline` to `t` by default.  However, there\nare many other types of files, such as files with extensions `.ini`,\n`.yaml`, etc. for which Emacs does not insert a terminating newline\nautomatically.  We now  ensure that Emacs always inserts a\nterminating newline for all types of files with the following call:\n\n```elisp\n(setq require-final-newline t)\n```\n\nMany tools on Unix and Linux systems expect text files to be\nterminated with a newline.  For example, in a crontab entry, if the\nfinal line is not followed by a terminating newline, it is ignored.\nSimilarly, `wc -l` does not count the final line if it is not followed\nby a terminating newline.  That is why, in the above step we configure\nEmacs to ensure that it always inserts a terminating newline before\nsaving a file.\n\n\n### Single Space for Sentence Spacing\n\nEmacs uses the convention of treating a full stop followed by two\nspaces as end of sentence.  However, many people these days seem to\nprefer ending sentences with a full stop followed by a single space.\nThis section explains how to configure Emacs to treat a full stop\nfollowed by a single space as end of sentence.\n\nIf you like the convention of having two spaces after full stop, you\nshould remove the code discussed below from your Emacs initialisation\nfile and then skip this section.  If you are unable to make up your\nmind about whether you should end sentences with one space or two\nspaces, read the final paragraph of this section for some discussion\nabout it.\n\nWe can configure Emacs to treat a sentence-terminating character (like\na full stop, question mark, etc.) followed by a single space as end of\nsentence with the following code:\n\n```elisp\n(setq sentence-end-double-space nil)\n```\n\nThis little setting has significant consequences while editing and\nmoving around text files.  We will discuss two such consequences now\nwith two tiny experiments:\n\n**Experiment A: Moving By Sentences:** To check the default behaviour,\nfirst comment out the above line of Emacs Lisp code in the Emacs\ninitialisation file, save the file, and restart Emacs.  Now copy the\nfollowing text:\n\n```\nLorem ipsum dolor sit amet, consectetur adipiscing elit donec. Porttitor id lacus non consequat.\n```\n\nThen open a new text buffer in Emacs with `C-x C-f foo.txt RET` and\npaste the copied text with `C-y`.  Then type `C-a` to go to the\nbeginning of the line.  Finally, type `M-e` to move to the end of the\nsentence.  Without `sentence-end-double-space` set to `nil`, typing\n`M-e` moves the cursor all the way to the end of the line (i.e., after\nthe second full stop).  It ignores the first full stop as end of\nsentence because it is followed by one space whereas Emacs expects two\nspaces at the end of a sentence.\n\nNow to verify that the above line of Emacs Lisp code works as\nexpected, uncomment it again to enable it, save the file, restart\nEmacs, and then perform the above experiment again.  With\n`sentence-end-double-space` set to `nil`, typing `M-e` moves the\ncursor to the end of the of first sentence (i.e., after the first full\nstop).  This is what we normally expect these days.\n\n**Experiment B: Filling Paragraphs:** While writing text files, it is\ncustomary to limit the length of each line to a certain maximum\nlength.  In Emacs, the key sequence `M-q` invokes the `fill-paragraph`\ncommand that works on the current paragraph and reformats it such that\neach line is as long as possible without exceeding 70 characters in\nlength.\n\nTo check the default behaviour, first comment out the above line of\nEmacs Lisp code in the Emacs initialisation file, save the file, and\nrestart Emacs.  Then create the same text buffer as the one in the\nprevious experiment.  Now place the cursor anywhere on text and type\n`M-q` to reformat it as a paragraph.  Without\n`sentence-end-double-space` set to `nil`, typing `M-q` reformats the\nparagraph as follows:\n\n```\nLorem ipsum dolor sit amet, consectetur adipiscing elit\ndonec. Porttitor id lacus non consequat.\n```\n\nNow to verify that the above line of Emacs Lisp code works as\nexpected, uncomment it again to enable it, save the file, then restart\nEmacs, and then perform the above experiment again.  With\n`sentence-end-double-space` set to `nil`, typing `M-q` reformats the\nparagraphs as follows:\n\n```\nLorem ipsum dolor sit amet, consectetur adipiscing elit donec.\nPorttitor id lacus non consequat.\n```\n\nWe see that without `sentence-end-double-space` set to `nil`, Emacs\nrefuses to insert a hard linebreak after the string `donec.`, so it\nmoves the entire word to the next line.  This is a result of following\nthe convention of double spaces at the end of a sentence.  This\nconvention prevents inadvertently placing a hard linebreak within an\nabbreviation.  Since many people prefer ending a sentence with a\nsingle space, we would like the text above to be reformatted as shown\nin the last example above.  Setting `sentence-end-double-space` to\n`nil` achieves this.\n\nWhile the step above explains how to configure Emacs to treat a full\nstop followed by a single space as the end of sentence, it is worth\nmentioning here that the number of spaces that must follow the end of\na sentence is a very controversial matter.  Many people prefer two\nspaces between sentences while many others prefer a single space\ninstead.  Section [Sentences][emacs-sentences-doc] of the Emacs manual\nrecommends putting two spaces at the end of a sentence because it\nhelps the Emacs commands that operate on sentences distinguish between\ndots that end a sentence and those that do not.  The author of this\nproject uses two spaces to end sentences.  Also, see the [Opinion\nReferences](#opinion-references) section for more discussion on this\ntopic.  In case, you want to follow the convention of two spaces at\nthe end of a sentence, omit the above line of Emacs Lisp from your\nEmacs initialisation file.\n\n[emacs-sentences-doc]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Sentences.html\n\n\n### Indentation\n\nThe following point shows how to configure Emacs to insert spaces, not\ntabs, for indenting code.\n\n  - Use spaces, not tabs, for indentation:\n\n    ```elisp\n    (setq-default indent-tabs-mode nil)\n    ```\n\n    Emacs uses a mix of tabs and spaces by default for indentation and\n    alignment.  To verify the default behaviour, first comment out the\n    above line of Emacs Lisp code, save it, then restart Emacs, then\n    open a new Emacs Lisp source file, say, `C-x C-f foo.el RET` and\n    type the following three lines of Emacs Lisp code:\n\n    ```elisp\n    (defun foo ()\n      (concat \"foo\"\n              \"bar\"))\n    ```\n\n    While typing the above code, do not type \u003ckbd\u003etab\u003c/kbd\u003e or\n    \u003ckbd\u003espace\u003c/kbd\u003e to indent the second and third lines.  When you\n    type \u003ckbd\u003eenter\u003c/kbd\u003e at the end of each line, Emacs automatically\n    inserts the necessary tabs and spaces to indent the code.  After\n    entering this code, type `M-x whitespace-mode RET` to visualise\n    whitespace characters.  This mode displays each space with a\n    middle dot (`·`) and each tab with a right pointing guillemet\n    (`»`).  With whitespace mode enabled, you should find that the\n    second line of code is indented with two spaces but the third line\n    is indented with a single tab followed by two spaces.  The buffer\n    should look like this:\n\n    ```elisp\n    (defun·foo·()$\n    ··(concat·\"foo\"$\n    »       ··\"bar\"))\n    ```\n\n    Emacs has a `tab-width` variable that is set to `8` by default.\n    For every `tab-width` columns of indentation, Emacs inserts a tab\n    to indent the code.  The third line requires 10 leading spaces for\n    alignment, so Emacs inserts one tab character followed by two\n    spaces to make the third line look aligned.  However, this code\n    would look misaligned with a different `tab-width` setting.\n    That's why we configure Emacs to use only spaces to indent and\n    align code.\n\n    Now to verify that the above line of Emacs Lisp code works as\n    expected, uncomment the function call to set `indent-tabs-mode` to\n    `nil`, save it, then restart Emacs, and then perform the above\n    experiment involving the three lines of Emacs Lisp code again.\n    This time, you should see that no tabs are used for indentation.\n    Only spaces are used for indentation.  Typing `M-x whitespace-mode\n    RET` would display this in the buffer:\n\n    ```elisp\n    (defun·foo·()$\n    ··(concat·\"foo\"$\n    ··········\"bar\"))\n    ```\n\n    In some type of files, we must use literal tabs.  For example, in\n    `Makefile`, the syntax of target rules require that the commands\n    under a target are indented by literal tab characters.  In such\n    files, Emacs is smart enough to always use literal tabs for\n    indentation regardless of the above variable setting.\n\n    Mixing tabs and spaces for indenting source code can be\n    problematic, especially, when the author of code or Emacs\n    inadvertently uses tabs for alignment (as opposed to using tabs\n    for indentation only which would be fine) and another programmer\n    views the file with an editor with a different tab width setting.\n    In fact, in the experiment above, Emacs did use a literal tab\n    character to align code which would cause the code to look\n    misaligned on another editor with a different tab width setting.\n    See [Tabs Are Evil](https://www.emacswiki.org/emacs/TabsAreEvil)\n    for more details on this topic.\n\n  - Display the distance between two tab stops as whitespace that is\n    as wide as 4 characters:\n\n    ```elisp\n    (setq-default tab-width 4)\n    ```\n\n    Note that this primarily affects how a literal tab character is\n    displayed.  Further, along with the previous variable setting\n    where we set `indent-tabs-mode` to `nil`, in some types of files,\n    this variable setting decides how many spaces are inserted when we\n    hit the \u003ckbd\u003etab\u003c/kbd\u003e key.  For example, in text buffers, on\n    hitting the \u003ckbd\u003etab\u003c/kbd\u003e key, as many spaces are inserted as are\n    necessary to move the cursor to the next tab stop where the\n    distance between two tab stops is assumed to be `tab-width`.\n\n    In some type of files, we must use literal tabs.  For example, in\n    `Makefile`, the syntax of target rules require that the commands\n    under a target are indented by a literal tab character.  In such\n    files, Emacs displays the distance between two tab stops as\n    whitespace that is as wide as 8 characters by default.  This\n    default setting is often too large for many users.  They feel that\n    a tab width of 8 consumes too much horizontal space on the screen.\n    The variable setting above reduces the tab width to 4.  Of course,\n    different users may have different preferences for the tab width.\n    Therefore, users are encouraged to modify this variable setting to\n    a value they prefer or omit the above line of Emacs Lisp code from\n    their Emacs initialisation file to leave it to the default value\n    of 8.\n\n  - Set indentation levels according to popular coding conventions for\n    various languages:\n\n    ```elisp\n    (setq c-basic-offset 4)\n    (setq js-indent-level 2)\n    (setq css-indent-offset 2)\n    ```\n\n    Emacs uses 2 spaces for indentation in C by default.  We change\n    this to 4 spaces.\n\n    Emacs uses 4 spaces for indentation in JavaScript and CSS by\n    default.  We change this to 2 spaces.\n\n\n### Keep Working Directory Tidy\n\nEmacs creates a number of temporary files to ensure that we do not\ninadvertently lose our work while editing files.  However, these files\ncan clutter our working directories.  This section shows some ways to\nkeep the current working directory tidy by asking Emacs to manage\nthese files at a different location.\n\n  - Create a directory to keep auto-save files:\n\n    ```elisp\n    (make-directory \"~/.tmp/emacs/auto-save/\" t)\n    ```\n\n    In the next point, we discuss auto-save files in detail and ask\n    Emacs to write auto-save files to a separate directory instead of\n    writing them to our working directory.  Before we do that, we need\n    to create the directory we will write the auto-save files to,\n    otherwise Emacs would fail to write the auto-save files and\n    display the following error: `Error (auto-save): Auto-saving\n    foo.txt: Opening output file: No such file or directory,\n    /Users/susam/.tmp/emacs/auto-save/#!tmp!foo.txt#`\n\n    Note that this issue occurs only for auto-save files, not for\n    backup files discussed in the third point of this list.  If the\n    parent directory for backup files is missing, Emacs creates it\n    automatically.  However, Emacs does not create the parent\n    directory for auto-save files automatically, so we need the above\n    line of Emacs Lisp code to create it ourselves.\n\n  - Write auto-save files to a separate directory:\n\n    ```elisp\n    (setq auto-save-file-name-transforms '((\".*\" \"~/.tmp/emacs/auto-save/\" t)))\n    ```\n\n    If we open a new file or edit an existing file, say, `foo.txt` and\n    make some changes that have not been saved yet, Emacs\n    automatically creates an auto-save file named `#foo.txt#` in the\n    same directory as `foo.txt` every 300 keystrokes, or after 30\n    seconds of inactivity.  Emacs does this to ensure that the unsaved\n    changes are not lost inadvertently.  For example, if the system\n    crashes suddenly while we are editing a file `foo.txt`, the\n    auto-save file would keep a copy of our unsaved worked.  The next\n    time we try to edit `foo.txt`, Emacs would warn that auto-save\n    data already exists and it would then suggest us to recover the\n    auto-save data using `M-x recover-this-file RET`.  These auto-save\n    files are removed automatically after we save our edits but until\n    then they clutter our working directories.  The above line of\n    Emacs Lisp code ensures that all auto-save files are written to a\n    separate directory, thus leaving our working directories tidy.\n\n  - Write backup files to a separate directory:\n\n    ```elisp\n    (setq backup-directory-alist '((\".\" . \"~/.tmp/emacs/backup/\")))\n    ```\n\n    If we create a new file or edit an existing file, say, `foo.txt`,\n    then make some changes to it, and save it, the previous copy of\n    the file is saved as a backup file `foo.txt~`.  These backup files\n    too clutter our working direcories.  The above line of Emacs Lisp\n    code ensures that all backup files are written to a separate\n    directory, thus leaving our working directories tidy.\n\n  - Create backup files by copying our files, not moving our files:\n\n    ```elisp\n    (setq backup-by-copying t)\n    ```\n\n    Everytime Emacs has to create a backup file, it moves our file to\n    the backup location, then creates a new file at the same location\n    as that of the one we are editing, copies our content to this new\n    file, and then resumes editing our file.  This causes any hard\n    link referring to the original file to be now referring to the\n    backup file.\n\n    To experience this problem due to the default behaviour, first\n    comment out the above line of Emacs Lisp code in the Emacs\n    initialisation file, save the file, and restart Emacs.  Then\n    create a new file along with a hard link to it with these\n    commands: `echo foo \u003e foo.txt; ln foo.txt bar.txt; ls -li foo.txt\n    bar.txt`.  The output should show that `foo.txt` and `bar.txt`\n    have the same inode number and size because they both refer to the\n    same file.  Now run `emacs foo.txt` to edit the file, add a line\n    or two to the file, and save the file with `C-x C-s`.  Now run `ls\n    -li foo.txt bar.txt` again.  The output should show that `foo.txt`\n    now has a new inode number and size while `bar.txt` still has the\n    original inode number and size.  The file `bar.txt` now refers to\n    the backup file instead of referring to the new `foo.txt` file.\n\n    To see the improved behaviour with the above line of Emacs Lisp\n    code, uncomment it to enable it again in the Emacs initialisation\n    file, save the file, restart Emacs and perform the same experiment\n    again.  After we save the file, we should see that both `foo.txt`\n    and `bar.txt` have the same inode number and size.\n\n  - Disable lockfiles:\n\n    ```elisp\n    (setq create-lockfiles nil)\n    ```\n\n    As soon as we make an edit to a file, say `foo.txt`, Emacs creates\n    a lockfile `.#foo.txt`.  If we then launch another instance of\n    Emacs and try to edit this file, Emacs would refuse to edit the\n    file, then warn us that the file is locked by another Emacs\n    session, and provide us a few options regarding whether we want to\n    steal the lock, proceed with editing anyway, or quit editing it.\n    These lockfiles are removed automatically as soon as we save our\n    edits but until then they clutter our directories.  Unlike\n    auto-save files and backup files, there is no way to tell Emacs to\n    write these files to a different directory.  We can however\n    disable lockfile creation with the above line of Emacs Lisp code.\n\n    **Caution:** Note that disabling lockfiles could be risky if you\n    are in the habit of launching multiple Emacs instances while\n    editing files.  With such a habit, it is easy to make the mistake\n    of opening the same file in two different Emacs instances and\n    inadvertently overwrite changes made via one instance with changes\n    made via another instance.  The lockfiles are hidden files anyway,\n    so they should not bother you in directory listings.  If they\n    bother you in, say, `git status` output, consider ignoring the\n    lockfiles in `.gitignore` instead of disabling them.  Having said\n    that, it may be okay to disable lockfiles if you are in the habit\n    of launching only a single instance of Emacs for the entire\n    lifetime of their desktop session and edit all files via that\n    single instance.  The [Emacs Server](#emacs-server) and [Emacs\n    Launcher](#emacs-launcher) sections later discuss techniques about\n    how to make this usage style more convenient.  If you are willing\n    to follow this style of using Emacs, then it may be okay to\n    disable lockfiles.  To summarise, if you are in doubt, comment out\n    or remove the above line of Emacs Lisp code to keep lockfiles\n    enabled.\n\n  - When we install packages using `package-install` (coming up soon\n    in a later section), a few customisations are written\n    automatically into the Emacs initialisation file (e.g., in\n    `~/.emacs.d/init.el`).  This has the rather undesirable effect of\n    our carefully handcrafted `init.el` being meddled by\n    `package-install`.  To be precise, it is the `custom` package\n    invoked by `package-install` that intrudes into our Emacs\n    initialisation file.  To prevent that, we ask `custom` to write\n    the customisations to a separate file with the following code:\n\n    ```elisp\n    (setq custom-file (concat user-emacs-directory \"custom.el\"))\n    ```\n\n  - Emacs does not load the custom-file automatically, so we add the\n    following code to load it:\n\n    ```elisp\n    (load custom-file t)\n    ```\n\n    It is important to load the custom-file because it may contain\n    customisations we have written to it directly or via the customise\n    interface (say, using `M-x customize RET`).  If we don't load this\n    file, then any customisations written to this file will not become\n    available in our Emacs environment.\n\n    The boolean argument `t` ensures that no error occurs when the\n    custom-file is missing.  Without it, when Emacs starts for the\n    first time with our initialisation file and there is no\n    custom-file yet, the following error occurs: `File is missing:\n    Cannot open load file, No such file or directory,\n    ~/.emacs.d/custom.el`.  Setting the second argument to `t`\n    prevents this error when Emacs is run with our initialisation file\n    for the first time.\n\n\n### Custom Command and Key Sequences\n\nIn this section we will see how to make our own custom command.\n\n  - Create a very simple custom command to display the current time in\n    the echo area at the bottom of the Emacs frame:\n\n    ```elisp\n    (defun show-current-time ()\n      \"Show current time.\"\n      (interactive)\n      (message (current-time-string)))\n    ```\n\n    This creates an interactive function named `show-current-time`.\n    An interactive function is an Emacs command that can be invoked\n    with `M-x`.  For example, the above command can be invoked by\n    typing `M-x show-current-time RET`.  On running this command, the\n    current time appears in the echo area.\n\n  - Create a custom key sequence to invoke the command defined in the\n    previous point:\n\n    ```elisp\n    (global-set-key (kbd \"C-c t\") 'show-current-time)\n    ```\n\n    Now the same command can be invoked by typing `C-c t`.\n\n  - Create another custom key sequence to delete trailing whitespace\n    using the `delete-trailing-whitespace` introduced in the [Show\n    Stray Whitespace](#show-stray-whitespace) section:\n\n    ```elisp\n    (global-set-key (kbd \"C-c d\") 'delete-trailing-whitespace)\n    ```\n\n    Note that the custom key sequence in this point and the previous\n    one only serve as examples.  You should define key sequences based\n    on your needs that you find more convenient.\n\n\n### Emacs Server\n\nMany users prefer to run a single instance of Emacs and do all their\nediting activities via this single instance.  It is possible to use\nEmacs alone for all file browsing needs and never use the terminal\nagain.  Despite the sophisticated terminal and file browsing\ncapabilities of Emacs, some users still like to use a traditional\nterminal to move around a file system, find files, and edit them.\nThis practice may become inconvenient quite soon because it would lead\nto the creation of too many Emacs frames (desktop-level windows) and\nprocesses.  This section explains how to create a single Emacs server,\na single Emacs frame, and edit all your files in this frame via the\nserver even while you are browsing files in the terminal.  You don't\nneed this section if you use Emacs for all your file browsing needs\nbut if you don't, this section may be useful.  Let us now see how we\nstart the Emacs server in our Emacs initialisation file.\n\n  - This is necessary to use the function `server-running-p` coming up\n    in the next point:\n\n    ```elisp\n    (require 'server)\n    ```\n\n    If we omit the above line of Emacs Lisp code, we will encounter\n    the following error when we try to use `server-running-p`\n    discussed in the next point: `Symbol’s function definition is\n    void: server-running-p`.\n\n  - If there is no Emacs server running, start an Emacs server:\n\n    ```elisp\n    (unless (server-running-p)\n      (server-start))\n    ```\n\n    The `unless` expression ensures that there is no Emacs server\n    running before starting a new Emacs server.  If we omit the\n    `unless` expression, the following error would occur if an Emacs\n    server is already running: `Warning (server): Unable to start the\n    Emacs server. There is an existing Emacs server, named \"server\".\n    To start the server in this Emacs process, stop the existing\n    server or call ‘M-x server-force-delete’ to forcibly disconnect\n    it.`\n\n    Finally, the `server-start` function call starts an Emacs server.\n\nWhen Emacs starts for the first time with the above lines of Emacs\nLisp code in its initialisation file, it starts an Emacs server.  Now\nthe following commands can be used on a terminal to edit files:\n\n  - `emacs` or `emacs foo.txt bar.txt`: Starts another instance of\n    Emacs.  It does not start a new server due to the `unless`\n    expression discussed above.  Typically, we will not use this\n    because we don't want to launch a second instance of Emacs.  But\n    it is good to know that this command still works as expected in\n    case we ever need it.\n\n  - `emacsclient foo.txt bar.txt`: Opens files in the existing Emacs\n    instance via the Emacs server.  The command waits for us to finish\n    editing all the files.  It blocks the terminal until then.  When\n    we are done editing a file, we must type `C-x #` to tell Emacs to\n    switch to the next file.  Once we are done editing all the files,\n    the `emacsclient` command exits and the shell prompt returns on\n    the terminal.\n\n  - `emacsclient -n foo.txt bar.txt`: Opens files in the existing\n    Emacs instance but does not wait for us to finish editing.  The\n    command exits immediately and the shell prompt returns immediately\n    on the terminal.\n\nWith this setup, the Emacs server quits automatically when we close\nthe first Emacs instance that started the Emacs server.  Running the\n`emacs` command or starting Emacs via another method after that would\nstart the Emacs server again.\n\nIt is worth noting here that there are other ways to start the Emacs\nserver and to use the `emacsclient` command.  See section [Using Emacs\nas a Server][emacs-server-doc] and section [`emacsclient`\nOptions][emacs-client-doc] of the Emacs manual for more details.\n\n[emacs-server-doc]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html\n[emacs-client-doc]: https://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html\n\n\n### Install Packages\n\nThe following points describe how we automate the installation of\nEmacs packages we need:\n\n  - We begin defining a new command that we use to install external\n    packages automatically.\n\n    ```elisp\n    (defun install-packages ()\n      \"Install and set up packages for the first time.\"\n      (interactive)\n      (require 'package)\n    ```\n\n    The `(require 'package)` line is necessary for defining the\n    `package-archives` list we will use in the next point.\n\n  - Add Milkypostman's Emacs Lisp Package Archive (MELPA) to the list\n    of archives to fetch packages from:\n\n    ```elisp\n      (add-to-list 'package-archives '(\"melpa\" . \"https://melpa.org/packages/\") t)\n    ```\n\n    By default GNU Emacs Lisp Package Archive (ELPA) and NonGNU Emacs\n    Lisp Package Archive (NonGNU ELPA) are the only package archives\n    configured for fetching packages.  The above line adds MELPA too\n    to the list of archives to fetch packages from.  Although we are\n    not going to install any package from MELPA in this project, it is\n    common practice to include it as a package source.  Adding MELPA\n    now ensures you are prepared to explore a broader range of\n    packages as your Emacs usage evolves.\n\n  - Download package descriptions from package archives:\n\n    ```elisp\n      (package-refresh-contents)\n    ```\n\n    See the `~/.emacs.d/elpa/archives` or `~/.config/emacs/elpa/archives`\n    directory for archive contents in case you are curious.\n\n  - Install some packages:\n\n    ```elisp\n      (dolist (package '(markdown-mode paredit rainbow-delimiters))\n        (unless (package-installed-p package)\n          (package-install package))))\n    ```\n\n    This loop iterates over each package name in a list of packages.\n    For each package, it checks whether the package is installed with\n    the `package-installed-p` function.  If it is not installed, then\n    it is installed with the `package-install` function.\n\n    You can modify the list of packages in the first line to add other\n    packages that you might need in future or remove packages that you\n    do not need.\n\nThe code discussed above creates a new command named\n`install-packages` that we can execute anytime with\n`M-x install-packages RET`.\n\nYou can also add new packages to the list used in the `dolist` call,\ntype `C-M-x` to evaluate the `install-packages` function again, so\nthat this command is now updated according to your latest code, and\nthen run `M-x install-packages RET` to install the new packages.\n\nHaving understood this section, step 4 of the [Get\nStarted](#get-started) section should now make sense.  The command we\nused there was:\n\n```sh\nemacs --eval '(progn (install-packages) (kill-emacs))'\n```\n\nThis command simply runs Emacs (with your Emacs initialisation file)\nand evaluates an Emacs Lisp expression that runs the\n`install-packages` function followed by `kill-emacs`.  As a result,\nthis command installs the packages configured in the code discussed\nabove and quits Emacs.\n\n**Alternative:** If you know enough Emacs already, you might notice\nthat this project does not use the `use-package` package.  The\n`use-package` package allows us to install and configure packages\ndeclaratively such that the configuration of each package is neatly\ncontained within one `use-package` expression.  The author of this\nproject has been using Emacs long before `use-package` existed and\nprefers a more traditional method of installing and configuring\npackages using `package.el` and `with-eval-after-load`.  However, if\nyou want to explore installing and configuring packages declaratively,\nplease take a look at the [use-package User Manual][use-package].\n\n[use-package]: https://www.gnu.org/software/emacs/manual/html_node/use-package/\n\n\n### Configure Paredit\n\nThis section describes how to enable Paredit.  Paredit helps in\nkeeping parentheses balanced and in performing structured editing of\nS-expressions.  Some Emacs Lisp programmers find it useful while some\ndo not.\n\nIn case you decide not to use Paredit, you may skip this section.  In\nthat case, you might also want to remove this package from the\n`dolist` loop discussed in the previous section.\n\nWe enable Paredit in various modes pertaining to Lisp programming with\nthe following Emacs Lisp code:\n\n```elisp\n(when (fboundp 'paredit-mode)\n  (dolist (hook '(emacs-lisp-mode-hook\n                  eval-expression-minibuffer-setup-hook\n                  ielm-mode-hook\n                  lisp-interaction-mode-hook\n                  lisp-mode-hook))\n    (add-hook hook 'enable-paredit-mode)))\n```\n\nHere is an explanation of the above code:\n\n  - The `when` expression checks if `paredit-mode` is available before\n    setting up hooks to enable it in various modes.  If it is\n    unavailable, then the hooks are not set up.\n\n  - The `dolist` expression iterates over hooks for various modes\n    where we want Paredit to be enabled.  In each iteration, the\n    `add-hook` expression adds the function `enable-paredit-mode` to\n    each mode's hook.  This ensures that whenever one of these modes\n    gets activated, `enable-paredit-mode` is called thereby enabling\n    Paredit in that mode.\n\n  - Adding `enable-paredit-mode` to `emacs-lisp-mode-hook` enables\n    Paredit while editing Emacs Lisp code.\n\n    To test that Paredit is enabled while editing Emacs Lisp code,\n    open a new Emacs Lisp file, say, `foo.el`.  Then type `(`.\n    Paredit should automatically insert the corresponding `)`.\n\n  - Adding `enable-paredit-mode` to `eval-expression-minibuffer-setup-hook`\n    enables Paredit in eval-expression minibuffer.\n\n    To test this, enter `M-:` to bring up the eval-expression minbuffer\n    and type `(`.  Paredit should automatically insert the corresponding\n    `)`.\n\n  - Adding `enable-paredit-mode` to `ielm-mode-hook` enables Paredit\n    while interactively evaluating Emacs Lisp expressions in\n    `inferior-emacs-lisp-mode` (IELM).\n\n    To test this, enter `M-x ielm RET`.  When the `*ielm*` buffer\n    appears, type `(`.  Paredit should automatically insert the\n    corresponding `)`.\n\n  - Adding `enable-paredit-mode` to `lisp-interaction-mode-hook`\n    enables Paredit in Lisp interaction mode.\n\n    To test this, first open a non-Lisp file, say, `C-x C-f foo.txt\n    RET`.  Now type `(`.  Note that no corresponding `)` is inserted\n    because we are not in Lisp interaction mode yet.  Delete `(`.  Then\n    start Lisp interaction mode with the command `M-x\n    lisp-interaction-mode RET`.  Type `(` again.  Paredit should now\n    automatically insert the corresponding `)`.\n\n  - Adding `enable-paredit-mode` to `lisp-mode-hook` enables Paredit\n    while editing Lisp code other than Emacs Lisp.\n\n    To test this, open a new Common Lisp source file, say, `C-x C-f\n    foo.lisp RET`.  Then type `(`.  Paredit should automatically insert\n    the corresponding `)`.\n\nBy default, Paredit overrides the behaviour of the `RET` key such that\na newline is inserted whenever we press `RET` key.  Unfortunately,\nthis behaviour is problematic in the eval-expression minibuffer and\nIELM where we want to evaluate the expression we have entered when we\ntype `RET`.  Therefore, we disable the overriding behaviour of Paredit\nusing the following code:\n\n\n```elisp\n(with-eval-after-load 'paredit\n  (define-key paredit-mode-map (kbd \"RET\") nil))\n```\n\nThe above code ensures that whenever Paredit is loaded, the `RET`\nkey binding in its keymap is set to `nil`, so that Paredit does\nnot override the default behaviour of the `RET` key.\n\n\n### Configure Rainbow Delimiters\n\nThis section describes how to enable rainbow delimiters and configure\nit.  Rainbow Delimiters colour nested parentheses with different\ncolours according to the depth level of each parenthesis.  Some people\nfind it useful and some do not.\n\nIf you decide not to use Rainbow Delimiters, you may skip this\nsection.  In that case, you might also want to remove this package\nfrom the `dolist` loop discussed in the previous section.\n\nWe enable Paredit in various modes pertaining to Lisp programming with\nthe following Emacs Lisp code:\n\n```elisp\n(when (fboundp 'rainbow-delimiters-mode)\n  (dolist (hook '(emacs-lisp-mode-hook\n                  ielm-mode-hook\n                  lisp-interaction-mode-hook\n                  lisp-mode-hook))\n    (add-hook hook 'rainbow-delimiters-mode)))\n```\n\nHere is an explanation of the above code:\n\n  - Then `when` expression checks if `rainbow-delimiters-mode` is\n    available before setting up hooks to enable it in various modes.\n    If it is unavailable, then the hooks are not set up.\n\n  - The `dolist` expression iterates over hooks for various modes\n    where we want Rainbow Delimiters to be enabled.  In each\n    iteration, the `add-hook` expression adds the function\n    `rainbow-delimiters-mode` to each mode's hook.  This ensures that\n    whenever one of these modes gets activated,\n    `rainbow-delimiters-mode` is called thereby enabling Rainbow\n    Delimiters in that mode.\n\n  - Adding `rainbow-delimiters-mode` to `emacs-lisp-mode-hook` enables\n    Rainbow Delimiters while editing Emacs Lisp code.\n\n    To test this open a new Emacs Lisp file, say, `foo.el`.  Then type\n    `(((`.  Rainbow Delimiters should colour each parenthesis\n    differently.\n\n  - Adding `rainbow-delimiters-mode` to `ielm-mode-hook` enables\n    Rainbow Delimiters while interactively evaluating Emacs Lisp\n    expressions in inferior-emacs-lisp-mode (IELM):\n\n    To test this, enter `M-x ielm RET`.  When the `*ielm*` buffer comes\n    up, type `(((`.  Rainbow Delimiters should colour each parenthesis\n    differently.\n\n  - Adding `rainbow-delimiters-mode` to `lisp-interaction-mode-hook`\n    enables Rainbow Delimiters in Lisp interaction mode.\n\n    To test this, first open a non-Lisp file, say, `foo.txt`.  Now type\n    `(((`.  Then start Lisp interaction mode with the command `M-x\n    lisp-interaction-mode RET`.  Rainbow Delimiters should now colour each\n    parenthesis differently.\n\n  - Adding `rainbow-delimiters-mode` to `lisp-mode-hook` enables\n    Rainbow Delimiters while editing Lisp code other than Emacs Lisp:\n\n    To test this, open a new Common Lisp source file, say, `foo.lisp`.\n    Then type `(((`.  Rainbow Delimiters should colour each parenthesis\n    differently.\n\nIn the discussion above, you may have noticed that we did not enable\nRainbow Delimiters for eval-expression minibuffer.  That is because\neval-expression minibuffer does not support syntax highlightng.\nTherefore enabling Rainbow Delimiters in it has no effect.  See\nhttps://github.com/Fanael/rainbow-delimiters/issues/57 for more\ndetails.\n\nThe default colours that Rainbow Delimiters chooses for the nested\nparentheses are too subtle to easily recognise the matching pair of\nparentheses.  The following Emacs Lisp code makes the parentheses more\ncolourful:\n\n```elisp\n(with-eval-after-load 'rainbow-delimiters\n  (set-face-foreground 'rainbow-delimiters-depth-1-face \"#c66\")  ; red\n  (set-face-foreground 'rainbow-delimiters-depth-2-face \"#6c6\")  ; green\n  (set-face-foreground 'rainbow-delimiters-depth-3-face \"#69f\")  ; blue\n  (set-face-foreground 'rainbow-delimiters-depth-4-face \"#cc6\")  ; yellow\n  (set-face-foreground 'rainbow-delimiters-depth-5-face \"#6cc\")  ; cyan\n  (set-face-foreground 'rainbow-delimiters-depth-6-face \"#c6c\")  ; magenta\n  (set-face-foreground 'rainbow-delimiters-depth-7-face \"#ccc\")  ; light gray\n  (set-face-foreground 'rainbow-delimiters-depth-8-face \"#999\")  ; medium gray\n  (set-face-foreground 'rainbow-delimiters-depth-9-face \"#666\")) ; dark gray\n```\n\nThe colours chosen above make matching pairs of parentheses easier to\nrecognise.\n\n\n### End of File\n\nThe final line of code in the file is:\n\n```elisp\n(provide 'init)\n```\n\nThe above line is not really necessary for the Emacs initialisation\nfile.  The `provide` function call declares a feature that an Emacs\npackage provides, so `provide` calls like the one above are typically\nfound in Emacs packages.  Here, we simply declare that this Emacs\ninitialisation file provides a feature named `init`, only for the sake\nof completeness.\n\nOther Emacs Lisp programs can test whether a feature is availabe using\nthe `featurep` function.  For example, Paredit provides the feature\nnamed `paredit`.  To test if this feature is available, type `M-:\n(featurep 'paredit) RET`.\n\nSimilarly, to test if the `init` feature declared above is available,\ntype `M-: (featurep 'init) RET`\n\n\n### Emacs Launcher\n\nIn the [Emacs Server](#emacs-server) section, we saw how our Emacs\ninitialisation file ensures that an Emacs server is started when we\nrun `emacs` for the first time.  Once Emacs server has started, we can\nedit new files from the terminal using the `emacsclient` command.\nThis section describes a script named `em` that can automatically\ndecide whether to run `emacs` or `emacsclient` depending on the\nsituation.\n\nAs mentioned in the previous section, you don't need this section if\nyou use Emacs for all your file browsing needs but if you don't, this\nsection may be useful.  Further, it is worth mentioning that this\nscript solves a very specific problem of using a single command named\n`em` to both launch a new Emacs server as well as to open existing\nfiles in an existing Emacs frame via the existing Emacs server.  If you\nhave this specific problem, you may find this script helpful.  However,\nif you do not have this problem or if you have a different problem to\nsolve, it would be useful to understand how `emacsclient` works and\nread the related documentation mentioned in the previous section and\nthen modify this script or write your own shell script, shell alias,\nor shell function that solves your problems.\n\nThe `em` script should be already present on the system if the steps\nin the [Get Started](#get-started) section were followed.  The third\nstep there installs this script to `/usr/local/bin/em`.  Now we discuss\nevery line of this script in detail.\n\n  - When `em` is run without any arguments, start a new Emacs process:\n\n    ```sh\n    #!/bin/sh\n    if [ \"$#\" -eq 0 ]\n    then\n        echo \"Starting new Emacs process ...\" \u003e\u00262\n        nohup emacs \u0026\n    ```\n\n    This Emacs process launches a new Emacs frame.  Further, if an\n    Emacs server is not running, it starts a new Emacs server.  The\n    `nohup` command ensures that this Emacs process is not terminated\n    when we close the terminal or the shell where we ran the `em`\n    command.\n\n  - When `em` is run with one or more filenames as arguments and there\n    is an Emacs server already running, edit the files using the\n    existing Emacs server:\n\n    ```sh\n    elif emacsclient -n \"$@\" 2\u003e /dev/null\n    then\n        echo \"Opened $@ in Emacs server\" \u003e\u00262\n    ```\n\n    However, if there is no Emacs server already running, the above\n    command in the `elif` clause fails and the execution moves to the\n    `else` clause explained in the next point.\n\n  - When `em` is run with one or more filenames as arguments and there\n    is no Emacs server running, start a new Emacs process to edit the\n    files:\n\n    ```sh\n    else\n        echo \"Opening $@ in a new Emacs process ...\" \u003e\u00262\n        nohup emacs \"$@\" \u0026\n    fi\n    ```\n\n    The new Emacs process also starts a new Emacs server.\n\nNow that we know what the `em` script does, let us see the various\nways of using this script as a command:\n\n  - `em`: Start a new instance of Emacs.  If there is no Emacs server\n    running, this ends up starting an Emacs server too.  Normally, this\n    command should be run only once after logging into the desktop\n    environment.\n\n  - `em foo.txt bar.txt`: Edit files in an existing instance of Emacs\n    via Emacs server.  If no Emacs server is running, this ends up\n    starting an Emacs server automatically.  This command is meant to\n    be used multiple times as needed for editing files while browsing\n    the file system in a terminal.\n\nThat's it!  Only two things to remember from this section: start Emacs\nwith `em` and edit files with `em foo.txt`, `em foo.txt bar.txt`, etc.\n\n\nOpinion References\n------------------\n\n- [Give paredit mode a chance][paredit-chance]\n- [Never warmed up to paredit][paredit-never-warmed]\n- [Coloring each paren differently only adds noise][rainbow-noise]\n- [The drawbacks of using single space between sentences][single-space-drawbacks]\n- [Why you should never, ever use two spaces after a period][space-invaders]\n\n[paredit-chance]: https://stackoverflow.com/a/5243421/303363\n[paredit-never-warmed]: https://lobste.rs/s/vgjknq/emacs_begin_learning_common_lisp#c_0y6zpd\n[rainbow-noise]: https://lobste.rs/s/vgjknq/emacs_begin_learning_common_lisp#c_1n78vl\n[single-space-drawbacks]: https://old.reddit.com/r/emacs/comments/p5zlr6/\n[space-invaders]: https://slate.com/technology/2011/01/two-spaces-after-a-period-why-you-should-never-ever-do-it.html\n\n\nChannels\n--------\n\nThe following channels are available for asking questions, seeking\nhelp and receiving updates regarding this project:\n\n- GitHub: [emfy/issues](http://github.com/susam/emfy/issues)\n- Mastodon: [@susam@mastodon.social](https://mastodon.social/@susam)\n- Matrix: [#susam:matrix.org](https://matrix.to/#/#susam:matrix.org)\n- Libera: [#susam](https://web.libera.chat/#susam)\n\nYou are welcome to follow or subscribe to one or more of these channels\nto receive updates and ask questions about this project.\n\n\nLicense\n-------\n\nThis is free and open source software.  You can use, copy, modify,\nmerge, publish, distribute, sublicense, and/or sell copies of it,\nunder the terms of the MIT License.  See [LICENSE.md][L] for details.\n\nThis software is provided \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nexpress or implied.  See [LICENSE.md][L] for details.\n\n[L]: LICENSE.md\n\n\nSee Also\n--------\n\n* [Emacs4CL](https://github.com/susam/emacs4cl) - Tiny DIY kit to set up vanilla Emacs for Common Lisp programming\n\n* [Devil](https://github.com/susam/devil) - Emacs minor mode that intercepts and translates keystrokes to provide a modifier-free non-modal editing experience\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusam%2Femfy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsusam%2Femfy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusam%2Femfy/lists"}