Subject: reworked samx patch, plus softtab feature

From: [email-masked] (Paul Jackson)
Date: Thu, 13 Apr 2000 19:09:09 -0400

[sorry for the email a few minutes ago w/o a Subject,
 I botched an email session ... pj ]

Bengt in particular, but anyone -- I invite comment on
where (or if) to publicize these 3 sam and samx patches.

--

I would like to make available the following three patches:

	samx.a.patch	-- upgrade sam to samx (samx2 for 9libs)
	samx.b.patch	-- fix compiler warnings
	samx.c.patch	-- add softtab feature to samx

    These three patches apply to the Editor "sam", in the
    "9libs" for maintained by Bengt Kleberg <[email-masked]>,
    and distributed from:

	ftp://ftp.demon.co.uk/pub/unix/plan9/sam-9libs.*

    These three patches update the "samx2" extensions for Sam,
    and add one more feature: softtabs.

--

What is samx:

    Samx Version 2 (samx2) adds some extensions to the sam editor.

    So far as I can find, the only samx patches are:

        Samx Version 2: Extensions to the Unix/X11 Sam Editor
        -----------------------------------------------------
        Ed Kubaitis ([email-masked])
        17 April 1993
    
    from:

        ftp://ftp.funet.fi/pub/unix/editors/sam/samx2/

    Samx provides several additional gui editing features,
    and a "samkeys" facility for mapping these features to
    the desired keyboard or mouse input.

--

What each patch does:

    samx.a.patch:

	This patch reworks the old "samx2" patch for application
	to the current (as of May 1999) 9libs version of the
	sam editor.  The old 1993 samx patch no longer applied
	cleanly to this current sam.

    samx.b.patch:

	Recompiling the above current 9libs sam on my system (SGI
	Irix 6.5.7m) generated several compiler warnings, mostly
	for (1) unused variables (2) missing enum typecasts and
	(3) missing 'int' in declarations.  This patch corrects
	these warnings.

    samx.c.patch:

	This patch adds a "softtab" capability, to let you
	work with 4 space (the '4' is configurable) soft tabs,
	while maintaining compatibility with 8 space (the '8'
	was already hardcoded in sam, and continues to be so)
	hardware (or display manager) tabs.

	The details of these softtabs are given below.

--

Applying these patches:

    These three patches are intended to be applied sequentially
    to the 9libs sam base.  The following instructions are
    overly specific in several places -- I figure it is easier
    for the reader to generalize the specific than to attempt
    these instructions in their full generality.

    1) Obtain 9libs and sam-9libs, from:

	ftp://ftp.demon.co.uk/pub/unix/plan9/9libs-1.0.tar.gz
	ftp://ftp.demon.co.uk/pub/unix/plan9/sam-9libs.tar.gz
    
    2) Obtain samx2, from:
    
	ftp://ftp.funet.fi/pub/unix/editors/sam/samx2/samx2.shar.Z

    3) Obtain these samx.[abc].patch patches, from:

	??? Not publically available yet -- would it make sense to
	    put these patches on ftp.demon.co.uk or ftp.funet.fi
	    or SourceForge.net (perhaps we should establish a
	    "sam" project there) or oss.sgi.com (my employers Open
	    Source site).

	    I can email or otherwise deliver these patches, but
	    want to give the sam old-timers, especially Bengt,
	    a chance to comment and express preferences before
	    putting them up on a public site.

	    My preference would be to create a SourceForge.net
	    project, and put all the pieces (sam, samx and my
	    three patches) there.  But I'm quite flexible.

    4) Unpack 9libs:
    
	gunzip 9libs-1.0.tar.gz
	tar xvf 9libs-1.0.tar

    5) Unpack sam-9libs:

	gunzip sam-9libs.tar.gz
	cd 9libs-1.0
	tar xvf ../sam-9libs.tar

    6) Unpack samx2 (for the documentation and example configuration,
       not for the patch, which samx.a.patch replaces):

	cd ..
	gunzip samx2.shar.Z
	mkdir samx
	mv samx2.shar samx
	cd samx
	sh samx2.shar

    7) Apply patches.  They are intended to be applied in order.
       You can apply just a, or a and b, and all three a, b and c.
    
	cd ..
	patch < samx.a.patch
	patch < samx.b.patch
	patch < samx.c.patch

    8) Configure, make and install:

	cd 9libs-1.0
	./configure
	make
	su
	make install

--

Details of softtabs:

    These softtabs emulate tabs at a specified spacing, while
    assuming that the actual tab character '\t' has a fixed 8
    column spacing.  These softtabs _only_ apply in the left
    margin (in the horizontal whitespace immediately following
    a new line or beginning of file).

    The "softtab" key spaces to the next column, modulo
    "softtabWidth", and rewrites all the preceeding horizontal
    whitespace on that line to use as many hard tab '\t'
    characters as there is space for, given the hardcoded
    assumption that hard tabs are 8 columns.

    The "softbackspace" key (in the left margin) backs up to
    the previous soft tab stop, converting hard tabs to spaces
    and removing spaces, as need be.

    Outside of the left margin, or if softtabs are not enabled
    or if softtabwidth is not > 0, softtab and softbackspace
    behave like simple tab and backspace (adding a tab char,
    and deleting the previous char, whatever it is).
    
    The X11 resource samterm*softtabWidth controls the soft tab
    width.  Attempts to set softtabWidth to any number greater
    than 16 are silently forced to set it to 16.  The resource
    samterm*softTab controls the initial setting of whether
    softtabs are enabled or not.  The Samkey softtabtoggle
    toggles whether softtabs are enabled.

--

Configuring softtabs:

    The following settings, copied from my .Xresources and
    Samkeys files, control and bind softtabs:

    ............ .Xresources ................
	samterm*softtabWidth: 4
	samterm*softTab: on

    ............ Samkeys ................
	BackSpace   : softbackspace
	Tab         : softtab
	Delete      : softbackspace
	ctrl h      : softbackspace
	ctrl i      : softtab
	alt Tab     : softtabtoggle

=======================================================================
I won't rest till it's the best ...	   Software Production Engineer
Paul Jackson ([email-masked]; [email-masked]) 3x1373 http://sam.engr.sgi.com/pj