<?xml version="1.0" encoding="UTF-8"?>
<!--

 Authors: Jacob Ilsø Christensen, Paolo Borelli
 Copyright (C) 2005 Jacob Ilsø Christensen <jacobilsoe@gmail.com>
 Copyright (C) 2005 Paolo Borelli <pborelli@katamail.com>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Library General Public
 License as published by the Free Software Foundation; either
 version 2 of the License, or (at your option) any later version.

 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Library General Public License for more details.

 You should have received a copy of the GNU Library General Public
 License along with this library; if not, write to the
 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.

-->
<language id="changelog" _name="ChangeLog" version="2.0" _section="Others">

  <metadata>
    <property name="mimetypes">text/x-changelog</property>
    <property name="globs">ChangeLog*</property>
  </metadata>

  <styles>
    <style id="date" _name="Date" map-to="def:number"/>
    <style id="name" _name="Name" map-to="def:statement"/>
    <style id="email" _name="E-mail address" map-to="def:identifier"/>
    <style id="file" _name="File" map-to="def:comment"/>
    <style id="bullet" _name="Bullet" map-to="def:type"/>
    <style id="function" _name="Function" map-to="def:function"/>
    <style id="release" _name="Release" map-to="def:statement"/>
  </styles>

  <definitions>
    <define-regex id="identifier">[A-Za-z_][A-Za-z0-9_]*</define-regex>
    <define-regex id="weekday">Mon|Tue|Wed|Thu|Fri|Sat|Sun</define-regex>
    <define-regex id="month">Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec</define-regex>

    <define-regex id="date" extended="true">
      \%{weekday}\s+\%{month}\s+\d{1,2}\s+(\d{1,2}:\d{1,2}:\d{1,2}\s+)?([aApP][mM]\s+)?(\w{3}\s+)?\d{4} |   # Wed Jun 27 13:27:21 2007
      \d{4}-\d{2}-\d{2}                                                       # 2007-06-28
    </define-regex>

    <context id="changelog">
      <include>

        <context id="date-and-stuff">
          <!-- FIXME: how to match date here? The date and name line is
            something like (DATE) (NAME) <EMAIL>, where DATE and NAME may
            be quite arbitrary. -->
          <match extended="true">
            ^(?P&lt;date&gt;\%{date})\s+
            (?P&lt;name&gt;.*)\s*
            (?P&lt;email&gt;\&lt;[^\&lt;]+\&gt;)\s*$
          </match>
          <include>
            <context sub-pattern="date" style-ref="date"/>
            <context sub-pattern="name" style-ref="name"/>
            <context sub-pattern="email" style-ref="email"/>
          </include>
        </context>

        <context id="release" style-ref="release">
          <match>^\s*\=.*\=\s*$</match>
        </context>

        <context id="file" style-ref="file">
          <start>^\s+(\*)</start>
          <!-- end at blank lines if there's no colon -->
          <end>\:|^(?!\S)</end>
          <include>
            <context sub-pattern="1" where="start" style-ref="bullet"/>
          </include>
        </context>

        <context id="function" style-ref="function">
          <match>\(\s*\%{identifier}\s*\)</match>
        </context>

      </include>
    </context>
  </definitions>

</language>
