Wednesday, March 5, 2014

Using malabar-mode to auto-populate a new Java file

Java has a lot of "template" code that needs to be written and most editors and IDEs understand this and help alliviate the common tasks.  One of these is the putting a skeleton into a blank file.  To do this in malabar-mode, there is the malabar-codegen-insert-class-template function that will:
  • add the class declaration based on the name of the buffer
  • add a javadoc comment skeleton
  • update the package statement
To have EMACS run this function when a new file is created, add the following to your .emacs:

;; Auto-populate an empty java file
(add-hook 'malabar-mode-hook
      '(lambda ()
         (when (= 0 (buffer-size))
           (malabar-codegen-insert-class-template))))

Tuesday, March 4, 2014

malabar-update-package now works in Windows

The functions malabar-update-package is used to add or fix the package statement in a Java class based on the location of a file in the maven source tree.  For example running malabar-update-package in a buffer looking at  src/main/java/com/m0smith/Test.java will result in the package being set to  package com.m0smith;