What has your editor done for you lately?

Motivated by the setup of a vim user at work (a bright but clearly misguided guy), I decided to configure emacs to rebuild my active ctags file whenever I saved a buffer. This is only lightly tested, but it seems to do the trick:

; Reconstruct the active TAGS file on file save
(defun create-tags ()
  "Reconstruct the active tags file, if it's defined"
  (if (boundp `tags-file-name)
      (shell-command
       (format "ctags -f %s -e -R %s"
               tags-file-name
               (file-name-directory tags-file-name)))))

(add-hook 'after-save-hook 'create-tags)

This probably won’t be acceptable for large projects because of the time needed to run ctags, but for small-to-medium project you probably won’t notice the hit.

Advertisements
  1. Leave a comment

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: