Normally, you don't modify source files when working with Patcher. However, ChangeLog files need update and saving in automatic mode. Patcher provides two hooks for plugging in additional processing on ChangeLog files.
:link-change-log-hook
This hook is run every time Patcher “links” a ChangeLog file to a
project. Linking a ChangeLog file in this context means figuring out
that it is involved in the current patch. Every function in this hook
will be given the ChangeLog file name (relative to the project's
directory) as argument. Also, it is guaranteed that when this hook is
run, the current directory (in whatever the current buffer is) is set to
the project's directory.
:after-save-change-log-hook
This hook is run every time you save a ChangeLog file. The functions in
this hook are executed in the ChangeLog's buffer. To be honest with you,
I didn't invent anything here, and I must confess that this is not a
real hook. Instead, what you specify in this project option is simply
added to the ChangeLog's local after-save-hook.
Now you're wondering what you could possibly use these two options for (apart from ringing the terminal bell I mean), and you're right. In fact, their existence comes from my desire to support Git projects by index.
If you look at patcher-built-in-themes
, you will find two themes
for Git (along with their their whitespace-cleaning counterpart):
git
and git-index
. The git-index
one will only work
on what's in the Git staging area. This is cool as long as ChangeLog
files are written by hand see Manual ChangeLogs. However, in
automatic mode, we need a way to add them to the index once the
skeletons are filled in. This is done by another built-in theme that you
must add explicitly to your project, called
git-index-automatic-change-logs
. This theme uses the two options
described above to automatically add ChangeLog entries to the staging
area.