6.5 Creating new Arguments

You can create new arguments for use in template files by writing new Emacs Lisp functions. Doing so is easy. Here is an example for the :user argument:

(defun srecode-semantic-handle-:user (dict)
  "Add macros into the dictionary DICT based on the current :user."
  (srecode-dictionary-set-value dict "AUTHOR" (user-full-name))
  (srecode-dictionary-set-value dict "LOGIN" (user-login-name))
   ;; ...
  )

In this case, a function with the name prefix srecode-semantic-handle- that ends in :user creates a new argument :user that can be used in a template.

Your argument handler must take one argument dict, which is the dictionary to fill in. Inside your function, you can do whatever you want, but adding dictionary values is the right thing.