Fun With Emacs

Tweet

Xah Lee, 2006-01, 2009-08-21

You probably heard that emacs can do lots of things, such as running shell, as a file manager, do ftp/sftp, read and send email, read newsgroup forums, and even as a web browser, and lots of other things other than text editing. But you are rather new and don't know how. This page lists some of fun things with simple instructions you can do right away with emacs.

emacs learning curve

A comic on emacs's learning curve. (Original source appears to be Steve Rowe's blog. “A friend of mine put this together” Source)

Split Windows

wildly split emacs screen

Wildly split emacs screen. From top to bottom: calendar, unicode, shell, hex editing mode, HTML mode, file management, calculator.

You can split your window into two or more panes, vertically or horizontally. Type 【Alt+x split-window-vertically】 to split into two panes, one on top of the other. To unsplit, type 【Alt+x delete-other-windows】. To split into side-by-side panes, type 【Alt+x split-window-horizontally】.

Spliting Window is available under the menu “File▸Split Window”.

View Calendar

To run calendar in emacs, pull the menu “Tools▸Calendar”, or type 【Alt+x calendar】.

emacs calendar

A screenshots of emacs's calendar feature.

Calculator

To run a calculator in emacs, type 【Alt+x calc】.

emacs calculator

Calc mode in emacs.

To quit calculator, type q.

To compute 「1+2」, type 【1 Enter 2 +】. Or, you can type the expression directly by starting with a sinle quote, like this: 【' 1 + 2 Enter】.

Calculator can also be started by going to the menu “Tools▸Programmable Calculator”.

Converting Numbers to Binary, Octal, Hexadecimal forms.

To convert the decimal 10 to binary representation in calc, type 【10 Enter d2】. The d2 will display all numbers in the window in the binary form. The numbers will have a “2#” prefix to indicate that they are in base 2. To display them back in decimal form, type “d0”. To show numbers in octal or hexadecimal form, type “d8” or “d6”.

To convert a binary number 1010 to decimal, type 【2#1010 Enter】 to enter the number then type “d0” to show all numbers in decimal form. Similarly, to enter a number in octal form, precede it with “8#” and hexadecimal numbers are prefixed with “16#”.

unit conversion

To find out what is 40 F° in C°, type 【40 Enter ut dF Enter dC Enter】.

Directory Navigation and Managing Files

A Screenshot of emacs's feature of directory navigation.

Emacs is a excellent tool for file management, such as viewing directory, creating files, copying files, moving files, creating directory, deleting files or directory. Once you become familiar with it, you almost never go back to shell or your operating system's file viewer for these tasks.

To start, pull the menu “File▸Dired”, then, give a dir path.

For a full tutorial, see: File Management with Emacs (dired tutorial).

FTP (or file transfer)

You can also transfer files between different machines connected by a network. The way to do this in emacs is consistent with the way it does directory navigation.

Type 【Alt+x dired】 and type a directory you want to work with. In this directory, suppose myfile.html is the one you want to upload across the network to the machine on “example.org” in the directory 〔/public_html〕. Suppose your login name for that machine is “mary”.

Here's what you do. Type 【Alt+x dired】 then choose a source dir. Then move your cursor to the file you want to copy. Type “C” (for copy), then emacs will prompt you for a directory to copy to. Type “/ftp:mary@example.org:/public_html”. You'll be asked for password, then it'll be copied over.

Once you logged in the ftp server, you can actually edit and save files on the remote server, bypassing all the upload/download pain.

Emacs also allows you to do sftp or ftp over ssh.

(info "(emacs) Remote Files")

Colors

To view the many colors and their hexadecimal values in RGB model, type 【Alt+x list-colors-display】. This is very useful when you work in HTML.

emacs showing colors

Command Line Interface (aka Shell)

To use emacs as the OS's command line interface (in Mac OS X, Linux, or Windows), type 【Alt+x shell】. Now, you can use emacs just as a shell. The advantage is that, you can have the entire shell's screen output history in your window, and you can copy and paste any part you like, just as if it is a normal text file. Normally in a shell, you can visit past command by pressing the up arrow. But now up arrow moves you cursor to the line above. To show the previous commands you used, press 【Ctrl+】.

See: Emacs Shell Tutorial (bash, cmd.exe, PowerShell).

LISP in Emacs

Sometime you hear that emacs has the artificial intelligence language LISP built in. That's right. Here's how you can run a short example.

In emacs, open a file, any file. In the file, type “(+ 1 2) ”, then, select the whole text, then type 【Alt+x eval-region】. You will see the result “3”. CONGRADULATIONS, you've just evaluated a lisp program!

See: Emacs Lisp Basics.

Internet Relay Chat (IRC)

If you don't know already, IRC is Internet Relay Chat. IRC is a public instant messaging forum that allows a groups of people to discuss things together. Typically, irc topics are about programing languages (perl, bash, php, html, ocaml, ...) or tools (emacs, ubuntu, git ...).

Yes, you can run IRC in emacs if you are running emacs version 22 or later. To see what version of emacs you have, type “emacs --version” in the command line prompt. Or, inside emacs, type 【Alt+x version】.

To start irc, type 【Alt+x irc】. Then, you'll be prompted to enter the server name and port and user name, and channel you want to join. For example, use the following:

IRC Server: irc.freenode.net
IRC Port: 6667
IRC Nick: imrandomjack
Channels: #emacs

then you'll be connected to the #emacs discussion room in the irc.freenode.net server.

O My GOD, Too Many Commands

emacs icon

Yeah, that's emacs. Some say, it's a operating system. Others say, it's a overflowing kitchen sink.

Life is filled with endless meaningful things to learn, if it is gonna be a fulfilling life.

Was this page useful? If so, please do donate $3, thank you donors!
  • 3 people liked this.
Community

Add New Comment

Showing 0 comments

Sort by   Subscribe by email   Subscribe by RSS
blog comments powered by Disqus
Home
Terms of Use
About
Advertise
Subscribe
Google
2005-10
© 2005 by Xah Lee.