header2.el is the way to go, however, here is an occasion to learn some emacs lisp and see how we can script our use of emacs. Maybe it's a bad idea now since you are learning programming, but maybe you'll find it clearer (than the non friendly header2 and yasnippet docs).
The advantage of this code is that you call it on demand and we can do what we want.
(defun my-insert-header ()
"Asks for file name, date, description, ... and insert at point."
(interactive)
(setq cur-file (read-from-minibuffer "file name ? "
(file-name-nondirectory (buffer-file-name))))
(setq cur-date (org-read-date))
(setq cur-author "Me")
(setq cur-description (read-from-minibuffer "description ? "))
(insert (format "# File: %s \n" cur-file))
(insert (format "# date : %s \n" cur-date))
(insert (format "# Description : %s \n" cur-description))
)
Put it in your dot file (.emacs.d/init.el or ~/.emacs).
You can just try it by putting it in the scratch buffer, going just after the last parentheses and hitting C-x C-e (eval-last-sexp). (see this tutorial: http://wikemacs.org/wiki/Emacs_Lisp_in_15_minutes)
Now explanations:
- defun: define a function, like def in python.
- (interactive): let the function be called with Alt-x. see http://ergoemacs.org/emacs/elisp_basics.html
- setq: way to define a variable
- read-from-minibuffer: does what it says :) the second argument is an optional default text to edit
- org-read-date: a nice utility function from org-mode. You can change dates with Shift-left/right. It returns a string.
- buffer-file-name: returns "/home/you/dir/try.py"
- file-name-nondirectory: returns "try.py"
- insert: insert text in current buffer
- format "foo %s \n": string formatting, like in python
and that's it. I let you finish the function as you want !
M-x list-packages-- your headers can be added with a keyboard shortcut using yasnippet. You may also wish to have a form file directory (with all your forms), and the files containing your forms (e.g., header, etc.) can be inserted into your current /working file by using the functioninsert-file-contents.