autotype: Copyrights
7 Inserting and Updating Copyrights
***********************************
‘M-x copyright’ is a skeleton inserting command, that adds a copyright
notice at the point. The “by” part is taken from your environment
variable ‘$ORGANIZATION’ or if that isn’t set you are prompted for it.
If the buffer has a comment syntax ((emacs)Comments), this is
inserted as a comment.
‘M-x copyright-update’ looks for a copyright notice in the first
‘copyright-limit’ characters of the buffer and updates it when
necessary. The current year (variable ‘copyright-current-year’) is
added to the existing ones, in the same format as the preceding year,
i.e., 1994, ’94 or 94. If a dash-separated year list up to last year is
found, that is extended to current year, else the year is added
separated by a comma. Or it replaces them when this is called with a
prefix argument. If a header referring to a wrong version of the GNU
General Public License ((emacs)Copying) is found, that is
updated too.
An interesting application for this function is to have it be called
automatically every time a file is saved. This is accomplished by
putting ‘(add-hook 'before-save-hook 'copyright-update)’ into your
‘~/.emacs’ file ((emacs)Init File). Alternative, you can do
‘M-x customize-variable <RET> before-save-hook <RET>’.
‘copyright-update’ is conveniently listed as an option in the
customization buffer.
The variable ‘copyright-query’ controls whether to update the
copyright or whether to ask about it. When this is ‘nil’ updating is
only done with ‘M-x copyright-update’. When this is ‘function’ you are
queried whenever ‘copyright-update’ is called as a function, such as in
the ‘before-save-hook’ feature mentioned above. Otherwise you are
always queried.