domingo, 13 de mayo de 2012

imap for emacs (insert templates on emacs)

You just miss good old :imap for your temporary configuration of your editor (remember vim?).  When you know you'll be going to insert similar strings over and over.

And you love the way vim allowed you to do crazy stuff inside a map.  But now you're in emacs, so let's see how we can scratch your itch.

My concrete case was inserting strings like (?* ?x) where x is a parameter.

  •  Skeletons. Skeletons can do that and much more. it's a classical template inserter.  For example, you can setup a skeleton of the desired output and interleave str symbol, that will be replaced for the input you'enter.
     
    Skeleton can do more sophisticated things, like inserting multiple lines while user keeps entering data.  I can imagine myself using this when entering lots of data with some desired format.

  • Yasnippets. Yasnippets are skeletons on steroids. Sad thing is that there's no direct way to bypass the file used to define snippets. I guess you can open a new buffer, put it into yasnippet-mode, and c-c c-c to activate the binding for just this session, but maybe it's too much of a hassle.

  • defun+insert.  The dumb way to do it, but the most straightforward if you tend to forget rarely used functionalities like skeletons.  Just define an interactive function that inserts your shit there, and call it at will.  That's the option I go when I don't wanna spend a minute looking for skeleton docs.
Then to call the functions/skeletons, you have different ways, if you want to global-set-key, or even just set the key in insert mode (using evil), reminding of imap style,

I'd love to hear other solutions on that same issue. Any suggestions?

sábado, 12 de mayo de 2012

The art of demo programming

Some time ago I met a guy on the internetz that was quite fond of demoscene. I never looked at it before, but since then,, I'm quite amazed by everything related to demos.

BIG BIG respect.

 From programming techniques, to creativity. Raymatching, compressing, and music. Everything pushed to its limits. There's been a recent thread in HN, with a quite a few links to tutorials, videos. 

And here's the freaking amazing demo that started the hn thread. Prepared to shit bricks? All that thing fits in 4096 bytes.

Yeah. 4kb.

 

jueves, 3 de mayo de 2012

simple made easy, twice

Here there are a couple of videos of the same talk "Simple, made easy", by Rich Hickey. I love Rich's talks, and I think it's even enlightening seeing the same talk twice, fine tuned for different audiences.

First one is from RailsConf 2012 Keynote. Done with a ruby audience in mind.

Second one is from StrangeLoop 2011. much more hilarious and punchy IMHO, and maybe a little less serious tone, but equally enlightening.

Here it is. bye!

lunes, 23 de abril de 2012

elisp of the day: undefine a defun

Elisp is a pretty archaic lisp. I'm not refering to the problems everyone talk about (dynamic scope, One namespace to rule them all,...) but the aspect of being very rudimentary in its construction.

That's why there have been several attempts to substitute elisp for something else (let's rewrite emacs in erlang!). For me, it's doing pretty well, and now that we have lexical scope there, I think I can live with prefixed-and-very-long-method-names.

A positive thing of elisp being archaic is that the system is wide open to users, and most things are just obvious (once you were given the proper explanation, heh).

One place that doesn't work like that is when redefining a defun to defmethod. setfing the symbol-function to nil does not work. (It makes the old defun inaccessible, but doesn't free the symbol)

That's why fmakunbound exists. fmakunbound 'symbol,  and after that you'll be able to defmethod on that symbol.

For now, I haven't found any other real use case for that, but I can imagine unloading a package by removing all methods it previously defined.  That's not much in the culture of emacs though (never seen any plugin that does that) 

sábado, 31 de marzo de 2012

Singulars



Video molt interessant per passar-lo als vostres pares (o fills), per explicar-los de que va la historia 'del internes'. Privacitat, entorn, poder, efecte bombolla. La qualitat divulgativa es bonissima. Jutgeu vosaltres la dels continguts.

sábado, 17 de marzo de 2012

shell and vim superpowers


It seems that the commandline is making a comeback, maybe with some hype. At least, I keep seeing more and more articles with titles like 'vim advanced features', courses like 'programando a toda leche con vim' (that are not cheap at all), or extensive articles like use unix as an ide or the zen of the vi wu wei (I like these 2), and other articles with this similar topic. It's amazing how people are reinventing the same wheel every other decade.

But out of these new tutorials that (mostly) bring nothing new to the scene, once in a while you find some useful tips or tools that people build that add orthogonal functionality (if that concept exists), and allow faster access to things, or better interface to them (note the orthogonality of the word 'thing').

You know, there's no problem that another level of indirection can't solve. So here you are. a couple of projects that allow you to refer to files, directories, and git stuff by numbers. fasd and git-number . The first one based on autojump.

Unfortunately, the web is so volatile that I can't find many of the top 10 vim articles from past decade, but I have seen isomorphic articles to this one by thousands. during the last 10 years.

So welcome guys, let's invent the future now! :)

domingo, 4 de marzo de 2012

more macros

Some links to useful/cool/smart lisp macros are appearing in that reddit post . There are a few really nice examples: from 'simple' templating systems to output html from Lisp, to more or less sophisticated macros-that-generate-macros, and even execute comments using reader macros. And the amazing factor-like stack concatenative language inside emacs (||| lisp-val: (list 1 2 3 4) { 1 + } map { 2 > } filter )

Here is a page where you can find most 'standard' macros from On lisp, ready to use for emacs lisp. I've used some of them for my new emacs project I'm doing with davazp.

There are also some nice macros in the third part of lisp for the web articles.

And here's a nice example of how awesome can 25 lines of lisp be. Not sure it's the best macro example, but got a smile in my face the first time I saw it.