sábado, 25 de enero de 2014

ANN: erc-youtube.el

 This time is erc-image and erc-tweet's little brother: erc-youtube.

Sometimes, when someone posts a youtube link in an IRC channel, you feel like clicking, but from time to time it's some link you really wouldn't like to have clicked. And it's too late.

Erc-youtube will inline the video's title in the erc buffer so you can decide then if you want to click or not.


Supersimple plugin, but it may be useful for some of you.  Shortly it'll be in melpa.

miércoles, 15 de enero de 2014

ANN: Helm-dash, the documentation browser for emacs

This post is the official announcement of a minor mode Toni and myself have developed which allows you to browse documentation for many languages using helm machinery to drive the find-as-you-type. It's called helm-dash

Intro


Helm is gaining lots of traction lately in the emacs environment (there are over 50 helm-* packages is the melpa now). It's a find-as-yo-type helper which provides an easy way to act on the selections. 

Dash is a mac osX app which lets you browse what they call docsets. Docsets contain an sqlite db and some html with the documentation of a given topic.

helm-dash


The basic usage is pretty simple:
  • helm-dash-install-package will give you the available docsets in the official repo (we'll choose Redis for testing).
  • Add the docset to either the global variable helm-dash-common-docsets. 
     (setq helm-dash-common-docsets '("Redis")) 
  • execute the interactive command helm-dash
  • Type some letters that match a redis command you want to look for (push, for example)
  • Press RET when you are on the command you want. Your favourite browser should open pointing to the documentation.

buffer-local docsets


For further configuration, we allow per-buffer sets of docsets. Let's say you want the GoLang docset available, but just in go-mode buffers. Install Go docset, and evaluate the following elisp:

(defun go-doc ()
  (interactive)
  (setq-local helm-dash-docsets '("Go")))

(add-hook 'go-mode-hook 'go-doc)

Then, when you open a go buffer, helm-dash will search both Redis and Go.

Here's a demo of the basic usage. (Mind that the video is not setting the variables accordingly because they were already set)

Try it, patch it, or talk about it, we'd love to hear your comments and improve it. 

The package has been developed and tested under linux.It should work on Mac OSX but it hasn't been tested there.If you find any issue on Mac, please, Pull Request :)

sábado, 11 de enero de 2014

Evil: The exact amount of vim in emacs (but no more than that)

I love emacs, but I also love modal editing.  Evil was (and vimpulse before that), was a great finding.

What I want is to have a normal mode where most commands feel like vim, and an insert mode where most commands feel like emacs, so c-p would do previous-line in insert mode instead of autocomplete word. Here are some of my tricks (many of them gathered from other people's configs)

99% emacs insert mode

Although using lots of insert mode commands when I was using vim daily, now I hardly find the necessity for them.

(setcdr evil-insert-state-map nil)
(define-key evil-insert-state-map [escape] 'evil-normal-state)

And that's it. with this, you're mostly done. In insert mode, every key but escape will behave as in plain emacs.

Undo-tree? nah (99% of vim in normal mode)

I still prefer emacs' undo-redo schema than the undo-tree. In the docs (also in the code), evil states that undo-tree will be used if available, and regular undo-redo will be used in case it's not there. That sounds fine, but if you get evil from elpa, undo-tree will be downloaded and installed without asking.Uninstalling undo-tree afterwards is not an enough because when loading, evil will complain it has some unmet dependency.

To make evil forget about it I edited the evil-pkg.el in my ~/.emacs.d/elpa/evil-xxxxxxx/ dir deleting undo-tree as a requirementand leaving it like this:

(define-package "evil" "20140109.605" "Extensible Vi layer for Emacs." '((goto-chg "1.6")))

c-r tries to redo

Just remap the desired key in the chosen mode to your prefered function.

(define-key evil-normal-state-map (kbd "C-r") 'isearch-backward) 
With these few tricks you can hack further to fine tune your keybindings and submodes inside evil. If you dig deeper into its code, you'll see it's quite well organized and quite clear.

martes, 7 de enero de 2014

Emacs keybindings everywhere

If you're using conkeror or keysnail you know how nice it is to have the usual keybindings in your browser.

Just in case you aren't using them, or if you're using them but want to have c-a, c-e,etc... in many linux desktop apps, here's a little trick.

Open (or create) the file "~/.gtkrc-2.0" and put the following line

gtk-key-theme-name = "Emacs"
Save, and open plain firefox. Then in any text field, try c-a, c-e, c-k . Neat, right?

You're welcome :)