Emacs, with Emacspeak, on macOS
This guide will, through open source collaboration, spell checking, and Doctor Pepper, show users of Apple (Mac) computers how to install Emacs, Emacspeak, and link the two together for an enjoyable text editing experience, and if there is enough Doctor Pepper, how to best use the included Emacs modes for greater productivity than is provided by newer software.
Why Emacs with Emacspeak?
From the Emacs Manual: Gnu Emacs is the GNU incarnation of the advanced, self-documenting, customizable, extensible editor Emacs. It is open source, and has a few maintainers who update the software. At the time of this writing, January 18, 2020, Emacs is at version 26.3.
Emacs has tons of documentation, and getting to it is easy. One can bring up a list of hotkeys in Emacs, pertaining to which type of file you’re working with. One can find out what a key command does, or find out if a function, like "next-line" has any key commands assigned to it. One can even browse the Emacs manual, along with any other manuals provided by other programs, to the Info program on your computer, from Emacs using Emacspeak.
Emacs is almost completely written in Emacs Lisp. In and of itself, this fact is unremarkable. More remarkable, however, is that one can run Lisp within the editor while it runs, which is exactly what a configuration file does. This gives plenty of opportunity for extending Emacs, and this is how Emacspeak is so powerful. If you do not want to write your own programs for Emacs, though, there is the "package manager" which has plenty of packages for many users and developers.
Emacs is cross-platform. It works on Windows, Linux, Mac, along with mobile devices through terminal apps. Emacspeak works by using speech servers to speak information. There are speech servers for some hardware speech synthesizers, which do not see much use nowadays, ViaVoice and eSpeak for Linux, and one for the Mac. There is a Github repository for using Emacspeak on Windows, but it hasn’t been updated since January 10, 2016. Since Emacspeak on Linux can be a complex topic, and may, depending on if you want subjectively better speech or not, cost $5 or more, I’ll focus here on using Emacs, with Emacspeak, on the Mac. In the future, mobile devices and terminal apps like Termux for Android or iSH for iOS and iPadOS may provide on-the-go Emacs. For now, though, Emacspeak speech servers are limited to general purpose computer operating systems, and so, practically, is Emacspeak and its level of access to Emacs for the blind.
Emacspeak is more than a package to self-voice Emacs. It does not read the screen, but reads Emacs itself. This means that it not only knows what the name of the file is that you’re editing, but the type of file as well. It not only knows that you’re editing text, but also what formatting information is involved, what parts are highlighted, and what lines have errors. Emacspeak doesn’t only speak that information in a description either. It shows formatting and code syntax highlighting through changes in pitch and intonation, and errors using a sound.
When you read by character, the speech rate is increased so you can move faster to the part of a line you want. Instead of saying "quote deleted," it beeps as it says "quote," to speed up interaction. Instead of saying "Active Processes exist dialog" it plays a sound based on if the answer it needs is yes/no, y/n, or a short line of text, like a command or text to be placed in a heading. All these sounds and speech changes speed up interaction, give information, and make using Emacs with Emacspeak an enjoyable experience. It also doesn’t hurt that interaction across Emacs is uniform, everything is accessible through the keyboard, there are no unlabeled buttons or things only F6 or control+Tab can get to, no web applications where one must switch from Browse to Focus mode, no ribbons, or any number of accessibility stumbling blocks which riddle more modern programs. This isn’t to say that Emacs is perfect. Third-party packages can be pretty hard to use, like Md4Rd, a Reddit client.
First, let’s lay the groundwork with Emacs. You’ll need to get Homebrew, which is a community-driven package manager for the Mac. Do this by first finding the Terminal app, opening it, running a command, and following the prompts to install the package manager. If you already have Homebrew, skip this step.
The Terminal app is in the Utilities folder in Finder. from Finder, press Command + Shift + U to open the Utilities folder. Begin typing "Terminal", until you hear VoiceOver say "Terminal application," and press Command + O to open the app. Alternatively, you can open it from Spotlight, using Command + Space, then typing "Terminal", and pressing Return.
Now, inside Terminal, paste the following command and press Return (Enter):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once Homebrew is installed, you can install Emacs. We’ll use Emacs-Mac, because it works well, for me at least:
brew tap railwaycat/emacsmacport brew cask install emacs-mac
This installs the "cask" Emacs-mac, which will put the Emacs app in your Applications folder. To prepare things, let’s open it. Go to Finder, and press Command + Shift + A, and find "Emacs application." Press VO + Shift + M, to open the menu, and choose "Open," and press Return.
Even though the Mac is a general purpose computer, MacOS is becoming a bit of a pain when it comes to running apps which Apple hasn’t officially accepted, so when you open Emacs for the first time, you may only be given the option to "move to trash" or "cancel" opening the app. Cancel that, do not move to trash, then try opening the app again from the menu, and you’ll be given the option to actually open the app. Storming gatekeeper! On the record, this should not be necessary on a "pro" laptop. Apple should have learned from Windows Vista. But, the Mac has Emacs and Emacspeak speech servers, and VoiceOver is sort of okay with the Mac’s GUI, so what can you do. And no, workarounds are not fixes. But let’s move on to more positive things, which we can work with.
Setting Up Emacspeak
Setting up Emacspeak is just as easy as setting up Emacs. First, get git. In the Terminal, run:
brew install git
Once that’s done, install mplayer:
brew install mplayer
Now, you should be ready to get Emacspeak:
git clone http://www.github.com/tvraman/emacspeak/
That command may take a moment, but once it’s done, type:
That brings you to Emacspeak’s folder. Now, you have to build the program:
make config make emacspeak
At the end, you should hear a message about how to configure Emacs to work with Emacspeak. we’ll do that part next.
Linking Emacs with Emacspeak
Now, it’s time to link the two pieces of software together. To do this, make an Emacs configuration file, and add a line which loads Emacspeak whenever Emacs starts.
To create the Emacs configuration file, you can use Text edit. That’s in your Applications folder in Finder, so go to Finder, press Command + Shift + A, find Text Edit, and open it with Command + O.
One of MacoS’ differentiating aspects is its attention to detail... Well, sometimes. When writing text, some symbols are replaced by their prettier, more accurate representations. Straight quotes normally used by other operating systems are replaced by their more accurate curved versions. Two or three dashes are transformed into em-dashes and en-dashes. This is great for writing prose, but not program configurations.
Let’s turn off those handy fixes to the text, as Emacs may not know what to do with those pretty symbols. Within Text edit, before typing anything, press Command + Shift + T. This should put Text Edit into Plain Text mode, instead of Rich Text mode. VoiceOver will say "Plain Text Mode." If not, press the command again.
Now, you can finally add that line which will load Emacspeak from Emacs., so paste this into your file:
This tells Emacs that, on startup, load the file "emacspeak-setup.el" in the lisp folder of the Emacspeak folder in your Home directory. Now, save that file, Command + S as .emacs.el in your Home folder, press Command + Shift + h to choose that. Do not forget the dot at the beginning. It should sound like "dot emacs dot el". When you’ve typed the name and chosen the home folder, press Return to save.
Testing the setup
To test the file you’ve just created, open Emacs from the Applications folder, in Finder. If it worked, you’ll hear a small tune on pipe organs, and a deep ViaVoice TTS voice say "This, is Emacspeak." If not, contact a contributor.
Now that Emacs is running with Emacspeak, let’s learn to use it. the best way is to use the Emacs Tutorial by pressing Control + H, t. This means to hold control, press H, release both keys, and type t. This will open the Emacs tutorial, and Emacspeak will begin reading it. You can read line by line using the arrow keys, at first. as the tutorial continues, through, I encourage you to practice what is taught, beginning with reading by screens of text (commonly called pages).
When done with that, try customizing Emacspeak to your liking. Press C-H . You should have learned what that means in the Emacs Tutorial. The Mini buffer will allow you to type in a "group" to customize. Type "Emacspeak" and press RET.
You can navigate the resulting buffer with the arrow keys, RET to expand items, showing values, Tab to get to text areas or item pickers, and C-X C-S to save your changes. Press C-X K RET to close a file. This is how you customize Emacs, by using the "Custom" system. This is much easier than editing a configuration file; Custom does that for you.
First, Emacspeak may be speaking a little too slowly for you. You can speed it up by pressing "C-U C-E d 3** or any other number from 1 to 0. You can set "Mac-speech-rate" in Emacspeak’s customization settings. If that is too slow for you, press C-u C-e d r, and type a number. I recommend starting around 350. You can also go into Emacspeak’s customization, and find the "TTS" subgroup, and and set the TTS base, and TTS rate step, so you can easily set the amount Emacspeak increases speech rate from numbers used. For example, if the step is at 100, pressing C-u C-e d 2 will be at 200, if base is 100. If you get stuck along the path of a command, press the question mark (?). For example, if you are typing C-u C-e, d, and press the question mark, you’ll get a list of commands starting with that. To get to help windows or other windows, press C-x o. To get rid of the other windows, not deleting buffers, press C-X 0. After that, you’re ready to go dive into using Emacs in the following sections.
Basic Emacs usage
When you first start Emacs, you’ll be greeted with a startup screen. It’ll say something like "Welcome to GNU Emacs, a part of the GNU / Linux operating system.". You can arrow down, or Tab, through options. Don’t worry, though; Tab normally indents, but this is not a normal editable file.
At this time, if you haven’t before, you may want to open the Emacs tutorial to familiarize yourself with its use. I encourage you to practice the lessons taught there, because from now on, I will assume that you’ve gone through them. I will go over some basic usage, to acclimate you to the difference in Emacs and Windows/Mac usage. To learn about how to move around in text, and other features, see the tutorial.
Buffers are basically documents. I say basically, because documents can’t be used to write emails, and only blind people talk about a web document to be read because screen readers and virtual buffers. You can save buffers to files on your computer, sending them from RAM to your hard drive. You can "open" a file, having its contents put into a buffer for editing. I suspect that this is what happens with all text editors, even the new emails you create are all text.
Buffers can be dealt with easily in Emacs. To make a new one, just make a new file with C-x C-f, (Control + X, then Control + F). Even if it is a file not yet on the computer, its buffer is created, and you can save it to make it official. To save a buffer to a file, press C-x C-s. This can be remembered by the following: C-x is the file command, having things to do with files, windows, and closing Emacs. C-F is find, like Control + F in Windows, or Command + F in Mac. Everyone has heard of Control + S, right?
Closing buffers, called killing them in Emacs, is C-x k. Killing buffers may sound cruel, but you must remember that the culture of the twentieth century was filled with killing, so we cannot fault the Emacs programmers for using such unsanitary language in their inventions. Rest assured that no known life forms are killed by closing a buffer... That we know of. After pressing C-x k, you’ll be asked which buffer to kill. You can press RET for the current buffer, or arrow through a list of them to kill another, and press RET to officially commit buffercide.
Switching buffers is also easy, and there are a few ways of doing it. You can open the Buffer List, which has a list of buffers and their sizes, with C-x C-b. Here, you can choose a buffer with the arrow keys, and press RET to switch to one. The Buffer List stays open, though, so be aware of that. The next is to use the mini buffer, a small window at the bottom of the screen, to input the name of a buffer, or use the arrow keys to switch to one using completion. This is the way I switch buffers. Choose one with RET, the mini buffer goes away, and there you are, in another buffer. The quickest, but least precise way, is to press C-Right or C-left. This switches among buffers like Alt + Tab does on Windows. If you have hundreds of buffers open, though, like T. V. Raman once claimed to have, using the C-Right method will quickly become too much effort.
Searches Can Be Interactive
Have you ever searched a GameFAQs guide, looking for that section that looked something like "220.127.116.11: Letter from Harmony", and didn’t want to type it all out into your find box, were too far down into the guide to find how it was actually spelled, but remembered "9.4"? You put that in, pressed enter a good many times, until you found that section. No? Well then, you probably have a better attention span than I do. For those of us who are not so gifted blind people, but still want that same power, there is interactive search.
Interactive search, shortened to I-search, allows one to search a buffer even while typing the search. Emacspeak plays a sound as you search, letting you know that it still has found something, then a soft crack when your search now has no results. So, say you searched for "9.4.1". You’d hear that entire line, so you’d know that it isn’t anywhere near what you’re looking for. So, you may try deleting that and trying "9.4.2". This brings you closer, so you press RET and you’re there, ready to navigate down a few lines to get to where you start.
On other operating systems, you’d have to press Control + F, or Command + F, type in your search, hit Enter or Return, and then Escape so that your screen reader actually reads what you’ve found because screen readers are actually quite unintelligent. No, the screen reader find dialog isn’t any better. Then, if you’d gotten to 9.491, you’d have to do the whole thing all over again. With Emacs, you don’t even leave the search feature.
So, how do you get to this I-search? Press C-S. There, type the search until you hear what you want. Notice that you don’t have to type a full search phrase or even word if you find what you’re looking for before then. If you have, and that’s not the occurrence of that phrase you want, press C-s again. To search backward, press C-r.
When you’ve found what you’re looking for, press RET, and you’re there. For more on searching, see the Search section of the Emacs Manual
Selecting, Cutting, Copying, and Pasting
So, you know how to type, you know how to search, but what about cut, copy, and paste?
Mark and Point
In Emacs, everything has a term. This term is different between Emacs and other systems. For example, consider the cursor. In Emacs, it is called "point," named from the period used to show where the cursor is in even older text editors.
"Mark" is the beginning of the selection. It is like pressing Insert + F9 in NVDA. You can "mark" a "region" of text to be selected, then act upon it. For more on Mark, see Mark in the Emacs Manual. To begin selecting, press C-SPC. Move to the place you want the region to end, and simply use the action you want to perform:
- Delete: Deletes (kills in Emacs terms), the text in the region, and places it in the ring of text able to be pasted, or in Emacs terms, yanked.
- C-w: cuts (kills) the text into a place where it can later be retrieved.
- C-y: Yanks (pastes) the text from the latest kill into the buffer. Change with M-y.
- M-w: Copies the text of the buffer into the kill ring without deleting it from the buffer, thus "copying" it.
For more information, see killing and moving text in the Emacs manual
Quitting and leaving
If you start to press a command which you don’t mean to, or want to quit a running command, press C-g. This quits the thing you’re doing. It does not close a file, but it does cancel selection.
To close Emacs and take a break from all this for a while, press C-x C-c. If you have any unsaved files, don’t worry, you’ll be asked to save them before Emacs closes. If Emacs says there are active processes, choose to close those too, as that’s just Emacspeak.
Packages are like addons, plugins, scripts, applets, gadgets, or apps. They extend the function of Emacs. You can get them through the package manager. If you want, you can even add new repositories to get packages from. To get to the package manager, press C-h p. This means "help with packages." You may here "Package refresh done. 16 packages can be upgraded; type ‘U’ to mark them for upgrading."
As you hear, 16 packages can be updated, and "Capital U" tells Emacs to upgrade them. We’ll get to how you can tell, in most cases, when to use lowercase and uppercase letters for commands later on. Press "n" to move to the next package in the list, or "p" to move backward. Press "i" to mark packaged for installing. When done, press "x" to install. You can find more keyboard commands by pressing C-h m.
Writing with Markdown
If you’re anything like me, which you probably aren’t, you eventually learn, through programs not using definition lists correctly, or aside HTML elements being mangles into plain divider elements, that Org-mode, discussed later, will not convert cleanly to Markdown. So, with the depressingly tragic knowledge that you’ll have to convert all of your courses from HTML exported by Org-mode into Markdown, and you recognize that Markdown, even with its less abundant syntax and the horror of having to use two asterisks for bolding all those hotkeys instead of one, has soundly defeated your efforts to find anything objectively better, simpler, and ubiquitous. And that sentence had 65 words. Does that count as a run-on sentence?
So, you resolutely learn Markdown, find that, in most circumstances, it does its job rather well, learn Markdown-mode, and you might just be coming to terms with having to do definition lists, tables, and side notes in HTML. Great. Thanks a lot, Github. But how does Emacs, with Emacspeak, help?
headings, italics, and bold
Markdown uses symbols to show formatting, like HTML, Latex, Org-mode, ASCII Doc, XML, and any other markup language. Some are easier than others, and even in Markdown, there are variations. PHP-Extra Markdown allows definition lists and tables to be made in plain, readable text, while Common Mark does not, for some reason. But you didn’t come here to read about Markdown, so I’ll let you research that on your own. I can’t spoil the blind community too much, after all. At least, I dearly hope not.
Emacs’ Markdown-mode should be built in. This section will be updated later.