Emacs – 30 Days Challenge

This is my learning journey to learn emacs in the next 30 Days. I am going to share my learning on this blog page.
 
Four years earlier I started with the similar thought to write about my learning about emacs. Then due to some personal reasons, was not able to complete this challenge after the Day 10.
 
Below is the outline of the content I am planning to touch upon during my 30 Days challenge.
  • Day 1: Welcome to emacs
  • Day 2: Different modes in emacs
  • Day 3: IDO Mode and its benefits
  • Day 4: org-mode a personal organizer and a notepad
  • Day 5: Getting Things Done(GTD) with org-mode
  • Day 6: tramp: doing remote work with tramp
  • Day 7: running command by its name
  • Day 8: commands for fixing typos
  • Day 9: moving around in the file
  • Day 10: select, cut, copy and paste in emacs
  • Day 11: understanding emacs registers or the clipboard.
  • Day 12: working with emacs window and using multiple windows
  • Day 13: multiple buffers in a window
  • Day 14: creating multiple frames and using the graphical display.
  • Day 15: How to search text and replace.
  • Day 16: file handeling in emacs.
  • Day 17: using emacs as your terminal and run commands.
  • Day 18: using your emacs as and IDE. Editing, compiling, testing and maintaining programs.
  • Day 19: As an alternate MTA to outlook/gmail. Sending mail, reading mail with rmail
  • Day 20: Dired mode – A file manager for emacs
  • Day 21: Making emacs as an online diary. calendar and the diary
  • Day 22: Being Social with emacs
  • Day 23: Emacs as an IDE (Perl/Python/HTML)
  • Day 24: Beautifying emacs with themes.
  • Day 25: Mould emacs as you like it.
  • Day 26: extend your emacs
  • Day 27: version control and git with emacs
  • Day 28: when you are bored and just want to chill
  • Day 29: Programming emacs
  • Day 30: Where to find emacs help, mailing lists, chatrooms and websites.

“ Emacs is the extensible, customisable, self-documenting real-time display editor.”

– Emacs Manual

Emacs can control OS subprocesses, helps in indenting programs, perform functions on many files at once and act as a simple text editor.

Emacs can be easily altered to behave in certain way and is highly customisable. Advanced users of emacs can go beyond simple customisation and can create entirely new commands. These new commands are simple program written in LISP and are also known as macros.

Downloading

Most of my writing I do mainly with a Mac Pro, so I downloaded the mac version of emacs, there are multiple emacs variants present, but I preferred vanilla emacsformacosx, which gives me enough room for customization as per my needs.

I downloaded for MAC OS X from http://emacsformacosx.com/.

A lot of blogs and on #emacs IRC channel, people recommend to use vanilla emacs while learning emacs. Customised variants of emacs comes with pre-built commands which limits the learning curve.
It is much easier to download and install emacs on Mac OS X. Download the latest version of emacs. Double click on the installer and follow the instructions.

 

For windows and Linux you can download GNU Emacs releases from a nearby GNU mirror; or if automatic redirection does not work see the list of GNU mirrors, or use the main GNU ftp server.

GNU Emacs development is hosted on savannah.gnu.org.

Working with emacs

  • Starting the editor: once installed start emacs from Launchpad -> emacs, clicking on which took me to the editor in its full glory, with a nice welcome message with link to the manual and the beginner emacs tutorials to get a start working with emacs and to quickly get help in emacs “C-h (Hold down Ctrl and Press h)
emacs welcome screen
When starting the emacs editor for the first time, the emacs welcome screen

Few things to note and which is global to emacs.

We are following the standard emacs documentation while learning emacs to do our tasks, for the rest of the blog and my future emacs/non-emacs related posts, I am going to use Control Key as ‘C’. Alt or Esc Key as ‘M’ or referred in document as meta key. Shift as ‘S’.

Moving around

Arrow keys on the keyboard can help you navigate around emacs text, its same as with other text editors.
 
Though, it is prudent to learn the Ctrl and Meta key sequences to navigate around your document.
Keys Movement
C-v View next screen also as Page Up.
M-v Move Backward one screen or Page Down.
C-l redisplay the text with cursor at the center of the screen.
C-p Previous line or up arrow key.
C-b back one character or left arrow key.
C-f forward one character or right arrow key.
C-n Next line or down arrow key.
M-f Move one forward one word.
M-b Move back one word.
C-a Move to the beginning of the line.
C-e Move to the end of the line.
M-a Move to the beginning of the sentence.
M-e Move to the end of the sentence.
C-u to specify a repeat count. C-v and M-v are exceptions as they won’t move pages but instead will scroll to that many lines forward/backward
C-g Kill the running command in minibffer, or in case emacs stop responding.
C-d Delete the next character after the cursor cursor.
DEL delete the character just before the cursor.
Insert text insertion is as simple as typing it. you can use the C-u to insert text as well. for eg. C-u 10 – will insert 10 hyphens “-———”.
M-</td> Kill the word before the cursor.
M-d Kill the word after the cursor
C-k Kill from the cursor position to end of line.
M-k Kill to the end of current sentence.
C-</td> Set the mark, move aroung with the above keys to highlight the text.
C-y Yank the file back.
C-x C-f Find file, can be used for creating a file or opening an exitisitng file.
C-x C-s Save the file, when you made some changes to the file and want to write the same to disk or save it.
C-x s Save some buffers.
C-x C-b List all the opened Buffers.
C-x b Switch buffer around.
C-x C-c Quit Emacs.
These are some of the common keys for moving around while in emacs.
 
In the beginning it seems hard to remember these patterns for moving around. As we go along and with practice, these key sequences will become part of daily usage.
 
As a begineer we may feel to use arrow keys as it is easier to move around, but we should discourage this practice and try to use Ctrl and Meta sequences wherever possible and become more used to using them in the long run you will observe it is much more easier to work with these sequences.
 
Closing emacs or quitting emacs will be a challenge for the new users. I remember, pressing the cross on the top bar to close emacs, but what will you do when you are running emacs in terminal. There is no top bar in terminal and only options left would be to close the window, kill the process or you can use ‘C-x C-q’