Emacs is large and it's totally understandable to feel daunted. Likely the path of least resistance to learning how to program Emacs lisp is to figure out some tasks that you really want to get done. Once it's personal, the motivation will be much higher.
That being said, maybe you want to write a web browser... Here are some initial ideas of simple things to implement. Most are already provided (either by emacs or additional packages), but learning to do them will entail learning how to learn about Emacs lisp.
Note: Solutions to the example problems can be found in
this other answer.
load-my-favorite-file
- a function that when called loads up your favorite (hard-coded) file. for example, your .emacs file.
cycle-special-files
- a function that when called repeatedly, cycles through a list of your favorite files (e.g. .aliases, weeklystatus, trackerlist)
count-string-matches
- return the number of occurrences of STRING in the buffer following the point
reload-dot-emacs
- prompt to save .emacs file (if necessary) and load the file
strip-trailing-whitespace
- delete whitespace at end of lines in the entire buffer
insert-code-template
- a function that inserts a template into the current buffer
e.g. a template of a header file, or a .cpp file, or a perl file
- bonus points for providing a mechanism for making it general enough to use so that it will work differently based on the appropriate mode and/or file extension
- hints : the variable 'major-mode, association lists
- more bonus points, hook it up so that this function is automatically called when a new (empty) file is opened
insert-checkin-template
- a function that prompts you for the various fields for a check-in request, giving useful defaults
- bonus points for properly indenting the list of files
string-replace
- take three string arguments, replace all occurrences of the first by the second in the third string. Return the newly created string.
Emacs documentation is pretty complete, here are some invaluable references:
C-h i m elisp RET (emacs lisp info page)
M-x find-function (show the source for the given function)
C-h C-h (list the help topics)
C-h f interactive RET (read documentation for this, it's what tells Emacs the defun is a command)
And here are some of the Emacs lisp routines you'll find you need to implement the above ideas:
Movement/Positional
forward-line
forward-char
goto-char
beginning-of-line
end-of-line
point
mark
Buffer related
set-buffer
current-buffer
buffer-name
Other
search-forward
match-beginning
match-end
match-string
save-excursion
y-or-n-p
file-exists-p
find-file-noselect
copy-region-as-kill
Reading The Source
Additionally, if you like a particular piece of functionality (say, indent-region
, column-number-mode
, rot13-region
), go and look at the source (using M-x find-function
). The fact that you already know what the function does will help you quite a bit in determining how it does what it does. You start small and move to bigger things as you gain confidence. Chances are you'll learn something new with each function you examine.