Recently in Emacs Category

A Quick Port of App::EditorTools to Emacs

| No Comments | No TrackBacks |
|

I saw an article about Stealing from Padre for Vim and I got a bit jealous that this functionality wasn't already available for Emacs. I guess I lucked out because it was very easy to make use of App::EditorTools in Emacs.

It probably took about a half hour to an hour to get this all up and running. The hardest part was actually tracking down the elisp functions that would return the current row and column of the beginning and end of a region. The terminology was just not easy to search for.

I did not include any default bindings in the package. I am still not entirely sure where their permanent home will be within my own config. For now I am using these:

(define-key cperl-mode-map (kbd "C-c e r") 'editortools-vim-renamevariable)
(define-key cperl-mode-map (kbd "C-c e t") 'editortools-vim-introducetemporaryvariable)

I don't think I want a binding for the renamepackage/renamepackagefrompath functions. I think I might set it up to call one of those automatically when I create a new file.

The elisp file can be found at:

http://rcs.patshead.com/dists/editortools-vim-el/

A Darcs repository is also available at http://rcs.patshead.com.

Screencast: yasnippet for emacs Now Supports Snippet in a Snippet

| No Comments | No TrackBacks |
|

I am pretty excited that yasnippet can now expand a snippet from inside another snippet. I've slowly been tweaking my own snippets to be able to better take advantage of this new feature. I've already gotten most of my Moose snippets working well. I am very happy that I was able to get them to indent pretty well without any manual intervention.

I've worked pretty hard to overload my tab key. I am using it for hippie-expand, yas/expand, and indenting. It probably does what I want to over 95% of the time. I do run into two problems with this, though.

I can't call hippie expand from a snippet. I suppose I could have an extra hippie-expand binding, but I don't really like that idea. I may break down and set one up, though, because I haven't thought of a better solution.

Sometimes my tab key calls hippie-expand when I want to indent. This is the one that drives me nuts because I can't predict when it is going to happen. I tried adding an extra indent bind but I just can't train myself to use it. I've used the tab key for indenting for so many years that the habit has just become too hard to break.

I have my enter key bound to newline-and-indent but I still have to manually hit my indent key sometimes. I've thought about having the enter key also run an indent on the current line. I haven't done it because I don't like the idea of accidentally changing the indentation of existing lines. I don't need to pull indentation changes into version control for no good reason.

How I Configured My Tab Key

I cheated. I tried every trick I could find to bind yas/expand, hippie-expand, and indenting to the same key and none of them were working. I ended up putting yas/hippie-try-expand at the front of my hippie-expand-try-functions-list and indent-for-tab-command at the end.

The only side effect this seems to have is that I get a No expansion found message on a successful indent. That doesn't bother me at all, though.

Advertisement

Get 20% off all servers at ServerSwarm using promo code 'patshead'

Archives