In Excel you can easily fill in a column with a list of values.
Some times also in Emacs you my need to write down a bunch of similar code.
The dotimes function with the “elsp eval”
M-x : (Esc + : on windooze)
will solve your trouble easily.
Try out this code on scratch buffer:
(dotimes (i 15) (insert (format "Guys born on %04d will be %02d years old on 2017 \n" (+ 1970 i) (- 2017 (+ 1970 i)) )))
and live happy
Also, in a regexp replace you can use the ‘ \, ‘ syntax to push an elisp expression:
For instance enter \,(1+ #1), where , indicates that an elisp form to substitute follows, 1+ is an increment function, and #1 is the first captured match text, interpreted as a number.
Example of camel case transformer:
Replace regexp: \(\w\)\(\w+\)Value(
Replace regexp with: get\,(upcase \1)\2(
Okey, getting emacs working on Windows is a pain, but we deserve a better editor for us(tm).
I havce found a bunch of emacs alternative distributions, and this 64bit build seems a nice shot
Did you know? Emacs supports killing rectangles of text!
Issuing “C-x r k” (kill-rectangle) will kill a rectangular area of text. This can be very useful when you have fixed-string text you must process.
yank-rectangle “C-x r y” will paste it where you like.
As usual Emacs rocks!
Ops I did it again. Although I repeatedly said I didn’t love emacs Lisp, I finally managed to learn it.
So I want to share with you my tips, to help entering in the Emacs Lisp world in a fast, fun and easy way.
First of all Lisp is a very elegant language, as you may expect.
Lisp is so elegant you will have to take your time to learn it, because it is a bit cryptic. To make things even worst, emacs function names are less than intuitive. The solution anyway is here: cookbooks!
The following web page will show you a set of tips for making small steps into emacs lisp. The scratch buffer will execute the code interactively (just press C-j)
The second thing you must learn to master is the C-h f (describe-function) key bindings, because will help you a lot. Take the time to study the code of the basic functions you find in your way.
Learn by Example
The best way to start is to use ert unit testing framework which is built in in the last version of Emacs…
(ert-deftest testname ()
To start playing, see the example on this web page http://steve-yegge.blogspot.it/2008/01/emergency-elisp.html
Lisp magical constructs
To understand better lisp, take a look to this “useless” library http://www.emacswiki.org/emacs/SyntacticSugar
which simply create “alias” to the same function (!)
This web page will teach you a bunch of other tips I find very userful.
unwind-protect is the emacs lisp function for “try……finally” idiom. It is very important to use it because will avoid you fatal error on the go. Anyway I like also this form
(message "oh no!")