Joshua Spiewak writes: > Is there a way to (easily) make the boilerplate (a little) dynamic? The > particular circumstance I am thinking of is that I would like to define a > boilerplate using the LGPL in my .emacs, and have each prj.el for my > projects only define the project name and to have the boilerplate template > insert the project name in the three appropriate places in the license. > Currently, I have to customize the boilerplate for each project, the only > difference being the project name. > > Thanks! > Here's one way to do it:
1. Put the following in your .emacs file. (defvar my-boilerplate-template () "Defines boilerplate text that has one occurrence of variable text indicated by %s." "Boilerplate for project %s ...") (defcustom jde-my-boilerplate-variable-text "Default text" "Defines text that occurs at %s in my-boilerplate-template." :group 'jde-gen :type 'string) (defun gen-my-boilerplate () "This function substitutes jde-my-boilerplate-variable-text where %s occurs in my-boilerplate-template." (format my-boilerplate-template jde-my-boilerplate-variable-text)) 2. Open a project that you want to use your boilerplate text. 3. Customize jde-gen-boilerplate-function to be gen-my-boilerplate and set for current session. 3. Customize jde-my-boilerplate-variable-text to be the variable text for the project and set for current session. 4. Execute save project file for the project. This saves the settings of jde- variables in the project file, including jde-gen-boilerplate-function and jde-my-boilerplate-variable-text. 5. Repeat 2-4 for other projects in which you want to use my-boilerplate-text. Paul
