2012-08-31

Java Autocompletion for Emacs

The past few weeks I have been using the great eclim, and the corresponding emacs-eclim package. It allows you to use many of Eclipse's features in your favourite editor. The installation of emacs-eclim is rather easy, and the one for eclim is even easier, since it comes with a simple clickety-click-installer.

I use emacs-eclim for Java development, and it works rather well. I use the two functions ac-complete-emacs-eclim and ac-complete-eclim-c-dot for auto-completion, which is the most important aspect when using such heavily object oriented languages and when developing large projects. Also useful are the functions eclim-java-import-missing, and eclim-java-remove-unused-imports. The current project can be compiled by calling eclim-project-build.

In theory, you can also use eclim with CDT for C++ development and auto-completion, but I rather stick with my earlier clang based solution, which is very fast and accurate.

2012-08-09

An argument for Emacs window-local variables

The Emacs developers used argue that window-local variables are not neccessary, since there are indirect buffers, which can do mostly the same thing. In recent Emacs releases, the window state is anyway mostly hidden from Lisp. However, I think sometimes it is useful to have window-local variables, instead of buffer-local variables. Emacs is very buffer-centric, but sometimes the UI and the user's view is rather window-centric. Two use-cases for window-local variables are:
I am using ECB, and it would be neat to enable or disable minor modes according to the ECB window I am in. This is also useful for people who manually tile their Emacs frame. In the main edit window, I like to have the tabbar, but in my compilation window, I'd rather not.

The buffer stack for a navigation history definitely should be window specific. Everything else would be very confusing. If a window is split, the new window will inherit its parents history.

2012-08-07

Updating GNU Global GTAGS file when Emacs is idle

GNU Global is a very useful code navigation tool. In order for it to work well, it needs to be run regularly. Until now, I used the after-save-hook, to keep it up to date. However, when using emacs-eclim (also see Eclim), saving becomes so frequent that performance takes a massive hit. So I whipped up this small code snippet to run Global only when Emacs is idle for some number of seconds (default is 10):
(defcustom my-gtags-update-idle-time 10
  "Number of idle seconds before an incremental gtags update is launched"
  :group 'my-group ;; Put whatever customization group you like here
  :type 'integer
  )
(run-with-idle-timer my-gtags-update-idle-time t
                     (lambda ()
                       (if (not (minibufferp) )
                           (progn
                             (message "Running gtags...")
                             (global-update-incrementally)
                             )
                         ) 
                       )
                     )