Sunday, June 30, 2013

Elisp Function to Add License File at Beginning of Buffer

I wrote a small function that allows for reading a file and adding it at the beginning of the buffer. This comes in handy when you need to add license terms to all your source files.
The function can be found in my .emacs on github. There is also a fake license containing just one line for trying that function.

The call syntax is
(add-license-handling license_dir license_type)

license_dir is the directory containing the license file (defaulting to ~/.emacs.d/license) and license_type is the license that you want to use stored in the file <license_dir>/<license_type>. You will also need the functions get_default_license_dir and get_default_license_type from my .emacs file to get this to work.
If you want to set different default values, add this to your .emacs:

(setq default_license_dir "~")
(setq default_license_type "FAKE")

No comments:

Post a Comment