debmode

Jörg Sommer joerg at alea.gnuu.de
Wed Mar 29 15:46:50 UTC 2006


Hello,

I've started writing a Debian mode for jed. Nothing mind, but it is
helpful especially the autoupdate of the date in changelog files.

% File:      debmode.sl             -*- mode: SLang -*-
%
% Copyright (c)
%       2006  Jörg Sommer <joerg at alea.gnuu.de>
%
% Description:   This mode is for Debian developers. It has many helper
%                functions useful for the daily work with Debian packages.
%
% License: This program is free software; you can redistribute it and/or
%	   modify it under the terms of the GNU General Public License as
%	   published by the Free Software Foundation; either version 2 of
%	   the License, or (at your option) any later version.
%
%          This program 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 General Public License for more details.

if (length(where("debmode" == _get_namespaces())))
  use_namespace("debmode");
else
  implements("debmode");

_debug_info = 1;

private variable MODE="DebMode";

define before_save_hook(file_name)
{
    if (andelse {strlen(file_name) > 17}
                {strcmp(file_name[[-17:]], "/debian/changelog") == 0} )
    {
        push_spot();
        bob();
        try
        {
            !if ( bol_fsearch(" -- ") )
              return;

            ()=right(4);
            if ( ffind_char('>') ) ()=right(1);
            push_mark(); eol;
            del_region();

            variable MONTH = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
                               "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
            variable DAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];

            variable time = localtime(_time());
            
            vinsert("  %s, %d %s %d %02d:%02d:%02d %s", DAY[time.tm_wday],
                    time.tm_mday, MONTH[time.tm_mon], 1900+time.tm_year,
                    time.tm_hour, time.tm_min, time.tm_sec, strftime("%z"));
        } finally {
            pop_spot();
        }
    }
}

append_to_hook("_jed_save_buffer_before_hooks", &before_save_hook);

define new_version()
{
    bob();
    push_mark();
    ()=down(1);
    insert( bufsubstr() );
    ()=up(1); bol();
    insert("\n  * \n\n");
    push_spot();

    ()=bol_fsearch(" -- ");
    push_mark();
    ()=down(2);
    bufsubstr();
    pop_spot();
    insert( () ); % () is bufsubstr()

    bob();
    ()=ffind_char(')');
    push_mark();
    ()=bfind_char('(');
    ()=right(1);
    variable old_version = bufsubstr();

    variable sep;
    if ( is_substr(old_version, "-") )
      sep = "-";
    else
      % a native package
      sep = ".";

    variable split_vers = strtok(old_version, sep);
    split_vers[-1] = string( integer( split_vers[-1] ) + 1 );

    variable new_version = strjoin(split_vers, sep);

    new_version = read_mini("New version:", new_version, new_version);
    ()=replace_chars(strlen(old_version), new_version);
    ()=bol_fsearch("  *");
    eol();

    if (new_version[[-2:-1]] == "-1")
    {
        push_spot();
        bol();
        insert("  * New upstream release\n");
        pop_spot();
    }
}

Regards, Jörg.
-- 
Das Recht, seine Meinung zu wechseln, ist eines der wichtigsten
menschlichen Privilegien.
	     		 			(Robert Peel)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 483 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-jed-devel/attachments/20060329/be0d328d/attachment.pgp


More information about the Pkg-jed-devel mailing list