Learning some emacs

I have been a very faithful Vim user for the last couple years, but recently I ran into more and more things which made me want to know more OS like shortcuts. On Mac OS that means that using Emacs is pretty close, most of the basic text navigation just works in most other text windows, and Emacs is a powerful editor in itself as well. The advantage is that I can more or less have my whole setup inside emacs, it can act as my terminal, my editor, as well as my interface to other servers via SSH and the emacs built in trampmode. When editing some ruby I realized that I’ve been relying on CTags quite a lot, and I need to have a quick way to generate and update them in emacs as well, which let me to write my first few lines in ELisp in years.

(defun create-tags ()
  "Create tags file for current project defined by the textmate-project-root"
  (let ((root (textmate-project-root))
        (tags-file (concat (textmate-project-root) "TAGS")))
    (shell-command (concat "ctags -e -R -f " tags-file " " root))
    (visit-tags-table tags-file)))

This small function allows me to run a simple

M-x create-tags

to update the CTags for the current project, aka the closest folder with containing .git directory, a Makefile, Rakefile etc.. So far the experience has been really nice, but I’m still catching up speed wise to my Vim days.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.