From: alan@jade.uucp (Alan Covington)
Subject: Galaxy: new galrep tool for new and old report formats
Organization: Jade Simulations International Corp., Calgary, AB, Canada
Distribution: rec.games.pbm
Date: Fri, 11 Dec 1992 22:24:35 GMT

The output format of the Galaxy game report has changed for games
Alpha and Beta.  The following "galrep" perl script understands the
old and the new formats.  I have also included the "galrep.el" emacs
mode just in case interested people do not have it.

The galrep perl script should be put into a file, and the file should
be made executable.  The argument to the script should be the turn
report.  This tool only works with turn reports that are in one column
format and that have underscores in place of spaces in names.

The galrep emacs functions should just be loaded into your emacs.

I obtained the original from the net.  I don't know who wrote it
originally, so credits there.  You are free to distribute it, mung it,
throw it at your Galaxy enemies, or ..., just don't blame me if it
doesn't work the way you would like it to. :-)

I hope that this increases your enjoyment of Galaxy.


-----------------galrep the perl script--------------------------
#!/usr/local/bin/perl

$n_planets = 0;
$n_ships = 0;
$n_grps = 0;

while (<>) {

# process "status of players" section
if ($_ =~ /Status of Players/) {
    # Skip blank line
    <>;

    # Skip lines of section
    while (<> !~ /^[ \t]*$/) {}
}

# process ship types sections
if ($_ =~ /([^ \t]+) Ship Types/) {
    # skip blank line and header line
    <>;<>;
    # gather information about ship types
    $owner = $1;
    while(<>) {
      last if /^$/;
	$owner[$n_ships] = $owner;
	($snames[$n_ships], $drive[$n_ships], $arms[$n_ships],
	 $weap[$n_ships], $shield[$n_ships], $cargo[$n_ships]) = split(' ');
	$mass[$n_ships] = $drive[$n_ships] +
	    $weap[$n_ships] *
		(1 + ($arms[$n_ships] > 1? ($arms[$n_ships] - 1) / 2: 0)) +
	    $shield[$n_ships] + $cargo[$n_ships];
	$sname2snum{$snames[$n_ships], $owner} = $n_ships;
	$n_ships += 1;
    }
}    
    

# note when the start of the map is seen
if ($_ =~ /^---------------------------------/) {
    $map_seen = 1;

    # skip the map lines
    while (<>) {
	last if /^--------------------------------/;
    }
}

# process incoming alien groups
if ($map_seen && $_ =~ /Incoming Groups/) {
    # skip blank and header lines
    <>;<>;
    while (<>) {
      last if /^$/;
	($from, $dest, $dist, $speed, $mass) = split(' ');
	$n = ($agrp_plnt{$dest} += 1);
	$agrp_plnt{$dest . $n} = $_;
    }
}

# process your planets
if ($_ =~ /Your Planets/) {
    # skip blank and header lines
    <>;<>;
    $n_planets = 0;
    while(<>) {
      last if /^$/;
	  ($p_names[$n_planets], $p_x[$n_planets], $p_y[$n_planets],
	   $p_size[$n_planets], $p_pop[$n_planets], $p_ind[$n_planets],
	   $p_res[$n_planets], $p_prod[$n_planets], $p_cap[$n_planets],
	   $p_mat[$n_planets], $p_col[$n_planets]) = split(' ');
	  $pname2pnum{$p_names[$n_planets]} = $n_planets;
	  $n_planets += 1;
    }

}


# process your routes
if ($_ =~ /Your Routes/) {
    <>;<>;
    while(<>) {
      last if /^$/;
      
	($from, $cap, $mat, $col, $empty) = split(' ');
	$route{$from,1} = $col;
	$route{$from,2} = $cap;
	$route{$from,3} = $mat;
	$route{$from,4} = $empty;
	if ($cap ne "-") {
	    $cap_from{$cap} .= " $from,";
	}
	if ($mat ne "-") {
	    $mat_from{$mat} .= " $from,";
	} 
	if ($col ne "-") {
	    $col_from{$col} .= " $from,";
	}
	if ($empty ne "-") {
	    $emp_from{$empty} .= " $from,";
	}
    }
}

# process your groups.  This must occur before alien groups or the
# group numbers will not match
if ($map_seen && $_ =~ /Your Groups/) {
    <>; # skip blank line
    $_ = <>; # get header so we can determine which report format we have
    split(' ');
    if ($_[9] eq "M") {
	$rfmt = "new";
    }
    else {
	$rfmt = "old";
    }
    $gn = 0;
    while(<>) {
      last if /^$/;
	$gn += 1;   # match group numbers in input

	if ($rfmt eq "old") {
	    ($junk, $gp_num[$gn], $gp_name[$gn], $gp_dtech[$gn],
	     $gp_wtech[$gn], $gp_stech[$gn], $gp_ctech[$gn], $gp_contents[$gn],
	     $gp_quan[$gn], $gp_dest[$gn], $gp_distance[$gn]) = split(' ');
	    $gp_owner[$gn] = "Your";
	}
	else {
	    ($junk, $gp_num[$gn], $gp_name[$gn], $gp_dtech[$gn],
	     $gp_wtech[$gn], $gp_stech[$gn], $gp_ctech[$gn], $gp_contents[$gn],
	     $gp_quan[$gn], $gp_mass[$gn], $gp_speed[$gn], $gp_dest[$gn],
	     $gp_distance[$gn]) = split(' ');
	    $gp_owner[$gn] = "Your";
	    # gp_mass is not used
	    # gp_speed is recalculated later on
	}
	    
	    
	if ($junk != $gn) {
	    print STDERR "Real group number $junk does not match " .
		"calculated group number $gn.\n";
	    exit(1);
	}

	if (defined $pname2pnum{$gp_dest[$gn]}) {
	    $pn = $pname2pnum{$gp_dest[$gn]};
	    if ($gp_distance[$gn] == 0) {
		$gp_at_planet[$pn] .= " " . $gn;
	    }
	    else {
		$gp_to_planet[$pn] .= " " . $gn;
	    }
	}
	else {
	    $gp_to_unknown .= " " . $gn;
	}
    }
    $n_grps = $gn;
}

# process alien groups
if ($map_seen && $_ =~ /([^ \t]+) Groups/ && $1 ne "Incoming" && $1 ne "Your"){
    # skip blank and header lines
    <>;<>;
    $owner = $1;

    $gn = $n_grps;    
    while (<>) {
      last if /^$/;
	$gn += 1;
	if ($rfmt eq "old") {
	    ($gp_num[$gn], $gp_name[$gn], $gp_dtech[$gn],
	     $gp_wtech[$gn], $gp_stech[$gn], $gp_ctech[$gn],
	     $gp_contents[$gn], $gp_quan[$gn], $gp_loc[$gn])
		= split(' ');
	}
	else {
	    ($gp_num[$gn], $gp_name[$gn], $gp_dtech[$gn],
	     $gp_wtech[$gn], $gp_stech[$gn], $gp_ctech[$gn],
	     $gp_contents[$gn], $gp_quan[$gn], $gp_mass[$gn],
	     $gp_speed[$gn], $gp_loc[$gn])
		= split(' ');
	    # gp_mass is not used
	    # gp_speed is recalculated later on
	}

	$gp_owner[$gn] = $owner;
	if (defined $pname2pnum{$gp_loc[$gn]}) {
	    $pn = $pname2pnum{$gp_loc[$gn]};
	    $ag_at_planet[$pn] .= " " . $gn;
	}
    }
    $n_grps = $gn;
}
}
# END-OF-FILE seen.  The while loop has been not indented.

# calculate derived data for all ship groups
for ($gn = 1; $gn <= $n_grps; $gn++) {
    $sn = $sname2snum{$gp_name[$gn], $gp_owner[$gn]};
    $gp_quan[$gn] *= $gp_num[$gn];
    $gp_edrive[$gn] = $gp_dtech[$gn] * $drive[$sn];
    $gp_eweap[$gn] = $gp_wtech[$gn] * $weap[$sn];
    $gp_eshield[$gn] = $gp_stech[$gn] * $shield[$sn];
    $gp_ecargo[$gn] = $gp_ctech[$gn] * ($cargo[$sn] + $cargo[$sn]**2/10);
    if ($cargo[$sn] != 0) {
	$gp_lspeed[$gn] = $gp_edrive[$gn] * 20 /
	    ($mass[$sn] + $gp_ecargo[$gn] / $gp_ctech[$gn]);
	$gp_speed[$gn] =  $gp_edrive[$gn] * 20 /
	    ($mass[$sn] + $gp_quan[$gn] / ($gp_ctech[$gn] * $gp_num[$gn]));
    }
    else {
	$gp_speed[$gn] = $gp_edrive[$gn] * 20 / $mass[$sn];
	$gp_lspeed[$gn] = $gp_speed[$gn];
    }
}

# print out the data
#@p_names = sort (@p_names);
for ($pn = 0; $pn < $n_planets; $pn++) {
    $pname = $p_names[$pn];

    chop $col_from{$pname};
    chop $cap_from{$pname};
    chop $mat_from{$pname};
    chop $emp_from{$pname};


format PLANET =
>@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 $p_names[$pn]

    Size      Indu       Pop    Res  Produce        Mat       Cap       Col
@####.##  @####.##  @####.##  @#.##  @<<<<<<< @#####.##  @####.##  @####.##
$p_size[$pn], $p_ind[$pn], $p_pop[$pn], $p_res[$pn], $p_prod[$pn], $p_mat[$pn], $p_cap[$pn], $p_col[$pn]

Routes from this planet:
    Colonists(1)      Capital(2)        Materials(3)      Empty(4)
    @<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<  @<<<<<<<<<<<<<<<
$route{$pname,1}||"-", $route{$pname,2}||"-", $route{$pname, 3}||"-",$route{$pname,4}||"-"

Routes to this planet:
    Colonists: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$col_from{$pname}||"-"
~              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$col_from{$pname}
    Capital:   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$cap_from{$pname}||"-"
~              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$cap_from{$pname}
    Materials: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$mat_from{$pname}||"-"
~              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$mat_from{$pname}
    Empty:     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$emp_from{$pname}||"-"
~              ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$emp_from{$pname}
.


    $~ = 'PLANET';
    write;

    if (defined $gp_at_planet[$pn]) {
	print "\n\nGroups at this planet                               ".
	      "                    Min.\n";
	print "Group  #   Ship Type         W     S     C  Cargo      ".
	      "Quant   Speed   Speed\n";

format SHIP =
@###@###   @<<<<<<<<<<< @###.#@###.#@###.#  @<<<<<<<< @###.# @###.## @###.##
$gn, $gp_num[$gn], $gp_name[$gn], $gp_eweap[$gn], $gp_eshield[$gn], $gp_ecargo[$gn], $gp_contents[$gn], $gp_quan[$gn], $gp_speed[$gn], $gp_lspeed[$gn]
.
	$~ = 'SHIP';
	@gps = split(' ', $gp_at_planet[$pn]);
	for ($j = 0; $j <= $#gps; $j++) {
	    $gn = $gps[$j];
	    write;
	}
    }

    if (defined $gp_to_planet[$pn]) {
	print "\n\nGroups on their way to this planet.\n";
	print "Group  #   Ship Type         W     S  Cargo      ".
	      "Quant   Dist.   Speed\n";

format COMING =
@###@###   @<<<<<<<<<<< @###.#@###.#  @<<<<<<<< @###.# @###.## @###.##
$gn, $gp_num[$gn], $gp_name[$gn], $gp_eweap[$gn], $gp_eshield[$gn], $gp_contents[$gn], $gp_quan[$gn], $gp_distance[$gn], $gp_speed[$gn]
.

	$~ = 'COMING';
	@gps = split(' ', $gp_to_planet[$pn]);
	for ($j = 0; $j <= $#gps; $j++) {
	    $gn = $gps[$j];
	    write;
	}
    }

    if (defined $ag_at_planet[$pn]) {
	print "\n\nAlien groups at this planet                       " .
	      "                         Min.\n";
	print "Owner          #   Ship Type           W     S     C ".
	      "Car  Quant   Speed   Speed\n";

format ASHIP =
@<<<<<<<<<< @###   @<<<<<<<<<<<<< @###.#@###.#@###.# @<< @###.# @###.## @###.##
$gp_owner[$gn], $gp_num[$gn], $gp_name[$gn], $gp_eweap[$gn], $gp_eshield[$gn], $gp_ecargo[$gn], $gp_contents[$gn], $gp_quan[$gn], $gp_speed[$gn], $gp_lspeed[$gn]
.
	$~ = 'ASHIP';
	@gps = split(' ', $ag_at_planet[$pn]);
	for ($j = 0; $j <= $#gps; $j++) {
	    $gn = $gps[$j];
	    write;
	}
    }

    if (defined $agrp_plnt{$pname}) {
format ALIENS_COMING = 
@##.###@####.##@##.##@>>>>>>>>>>
$dist / $speed, $mass, $speed, $from
.
	$~ = 'ALIENS_COMING';
	print "\n\nAlien groups on their way to this planet.\n";
	print "Arrival    Mass Speed     Source\n";
	for ($n = $agrp_plnt{$pname}; $n > 0; $n--) {
	    ($from, $dest, $dist, $speed, $mass) =
		split(' ', $agrp_plnt{$pname . $n});
	    write;
	}
    }
    print "\n";
}   


if (defined $gp_to_unknown) {
format COLONIZE =
@###@###   @<<<<<<<<<<< @###.#@###.#  @<<<< @###.# @>>>>>>>>> @###.## @###.##
$gn, $gp_num[$gn], $gp_name[$gn], $gp_eweap[$gn], $gp_eshield[$gn], $gp_contents[$gn], $gp_quan[$gn], $gp_dest[$gn], $gp_distance[$gn], $gp_speed[$gn]
.
    $~ = 'COLONIZE';
    print "\nGroups on their way to unknown planets.\n";
    print "\nGroup  #   Ship Type       W     S    Cargo  Quant       Dest    Dist.  Speed\n";
    @gps = split(' ', $gp_to_unknown);
    for ($j = 0; $j <= $#gps; $j++) {
	$gn = $gps[$j];
	write;
    }
}
---------------end of galrep perl script-------------------

---------------galrep.el the emacs functions---------------
(defun galaxy-forward-planet ()
  (interactive)
  (widen)
  (forward-page)
  (narrow-to-page)
  (galaxy-read-planet-name))

(defun galaxy-backward-planet ()
  (interactive)
  (widen)
  (backward-page 2)
  (narrow-to-page)
  (galaxy-read-planet-name))

(defun galaxy-read-planet-name ()
  (goto-char 1)
  (forward-char)
  (setq galaxy-planet-name (prin1-to-string (read (get-buffer (buffer-name))))))

(defun galaxy-goto-groups ()
  (interactive)
  (widen)
  (setq galaxy-marker-list (cons (point) galaxy-marker-list))
  (goto-char (point-max))
  (narrow-to-page))

(defun galaxy-goto-planet (planet)
  (interactive "sJump to planet: ")
  (widen)
  (setq galaxy-marker-list (cons (point) galaxy-marker-list))
  (goto-line 1)
  (if (not (search-forward (concat '">" planet) nil t))
      (galaxy-return-to-sender))
  (narrow-to-page)
  (galaxy-read-planet-name))

(defun galaxy-read-word (count)
  (if (> count 1)
	(galaxy-read-word (- count 1)))
  (read (get-buffer (buffer-name))))

(defun galaxy-goto-receiver (num)
  (move-to-window-line 7)
  (galaxy-goto-planet (prin1-to-string (galaxy-read-word num))))

(defun galaxy-goto-capital-receiver ()
  (interactive)
  (galaxy-goto-receiver 1))

(defun galaxy-goto-material-receiver ()
  (interactive)
  (galaxy-goto-receiver 2))

(defun galaxy-goto-colonist-receiver ()
  (interactive)
  (galaxy-goto-receiver 3))

(defun galaxy-goto-empty-receiver ()
  (interactive)
  (galaxy-goto-receiver 4))

(defun galaxy-return-to-sender ()
  (interactive)
  (widen)
  (if (car galaxy-marker-list)
      (goto-char (car galaxy-marker-list)))
  (setq galaxy-marker-list (cdr galaxy-marker-list))
  (narrow-to-page)
  (galaxy-read-planet-name))

(defun galaxy-request-cargo ()
  (setq what "Foo")
  (while (equal what "Foo")
    (message "$ M C or E: ")
    (setq ans (read-char))
    (cond ((eq ?$ ans) (setq what "CAP"))
	  ((or (eq ?M ans) (eq ?m ans)) (setq what "MAT"))
	  ((or (eq ?C ans) (eq ?c ans)) (setq what "COL"))
	  ((or (eq ?E ans) (eq ?e ans)) (setq what "EMP"))
	  (t (beep))))
  what)

(defun galaxy-change-route ()
  (interactive)
  (galaxy-princ (format "R %s %s %s\n"
		 galaxy-planet-name
		 (galaxy-request-cargo)
		 (read-from-minibuffer "New destination: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-load-group ()
  (interactive)
  (galaxy-princ (format "L %s %s\n"
		 (read-from-minibuffer "Which group: ")
		 (galaxy-request-cargo))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-unload-group ()
  (interactive)
  (galaxy-princ (format "U %s\n"
		 (read-from-minibuffer "Which group: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-new-production-type ()
  (interactive)
  (galaxy-princ (format "P %s " galaxy-planet-name) galaxy-command-buffer)
  (let ((galaxy-produce (galaxy-completing-read "Produce what: "
						'(("MAT " 1)
						  ("CAP " 2)
						  ("DRIVE " 3)
						  ("WEAPONS " 4)
						  ("SHIELDS " 5)
						  ("CARGO " 6)
						  ("SHIP " 7))
						nil t)))
    (if (equal "SHIP " galaxy-produce)
	(galaxy-princ (format "%s\n"
			      (read-from-minibuffer "What ship-type: "))
		      galaxy-command-buffer)
      (galaxy-princ (format "%s\n" galaxy-produce) galaxy-command-buffer))
  (galaxy-recenter-galaxy-command-window)))

(defun galaxy-send-group ()
  (interactive)
  (galaxy-princ (format "S %s %s %s\n"
		 (read-from-minibuffer "Which group: ")
		 (read-from-minibuffer "Where: ")
		 (read-from-minibuffer "How many ships: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-change-name-of-planet ()
  (interactive)
  (galaxy-princ (format "N %s %s\n"
		 galaxy-planet-name
		 (read-from-minibuffer "New planet name: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-change-name-of-race ()
  (interactive)
  (galaxy-princ (format "C %s\n"
		 (read-from-minibuffer "New race name: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-declare-peace ()
  (interactive)
  (galaxy-princ (format "A %s\n"
		 (read-from-minibuffer "Peace with which race: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-declare-war ()
  (interactive)
  (galaxy-princ (format "W %s\n"
		 (read-from-minibuffer "War with which race: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-erase-ship-type ()
  (interactive)
  (galaxy-princ (format "E %s\n"
		 (read-from-minibuffer "Which ship-type: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-rename-ship-type ()
  (interactive)
  (galaxy-princ (format "T %s %s\n"
		 (read-from-minibuffer "Old name: ")
		 (read-from-minibuffer "New name: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-break-off-group ()
  (interactive)
  (galaxy-princ (format "B %s %s\n"
		 (read-from-minibuffer "Which group: ")
		 (read-from-minibuffer "How many ship: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-change-map-size ()
  (interactive)
  (galaxy-princ (format "M %s %s %s\n"
		 (read-from-minibuffer "X: ")
		 (read-from-minibuffer "Y: ")
		 (read-from-minibuffer "Size: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-design-ship-type ()
  (interactive)
  (galaxy-princ (format "D %s %s %s %s %s %s\n"
		 (read-from-minibuffer "Name: ")
		 (read-from-minibuffer "Drive: ")
		 (read-from-minibuffer "Attacks: ")
		 (read-from-minibuffer "Weapons: ")
		 (read-from-minibuffer "Shields: ")
		 (read-from-minibuffer "Cargo: "))
	 galaxy-command-buffer)
  (galaxy-recenter-galaxy-command-window))

(defun galaxy-planet-quit ()
  (interactive)
  (kill-buffer (current-buffer)))

(defun galaxy-recenter-galaxy-command-window ()	;I wish (princ) moved the point itself.
  )
;  (set-buffer galaxy-command-buffer)
;  (goto-char (point-max))

(defun galaxy-princ (string buffer)
  "Moves to end of buffer before inserting the string."
  (let* ((cur-buf (current-buffer)))
    (set-buffer buffer)
    (goto-char (point-max))
    (insert string)
    (if (get-buffer-window buffer)
	(let ((cur-win (get-buffer-window cur-buf)))
	  (select-window (get-buffer-window buffer))
	  (goto-char (point-max))
	  (select-window cur-win)))
    (set-buffer cur-buf)))

;; A completing read that ignores case
(defun galaxy-completing-read (prompt table &optional predicate require-match
				      initial-input)
  (let* ((comp-state completion-ignore-case)
	 (answer (unwind-protect
		     (progn
		       (setq completion-ignore-case t)
		       (completing-read prompt table predicate require-match
					initial-input))
		   (progn
		     (setq completion-ignore-case comp-state)
		     nil))))
    answer))
    
 
  

(defvar galaxy-planet-mode-map nil "")
(defvar galaxy-marker-list nil)
(defvar galaxy-command-buffer nil)
(defvar galaxy-command-window nil)
(defvar galaxy-command-window nil)
(defvar galaxy-planet-name "")


(if galaxy-planet-mode-map ()
  (setq galaxy-planet-mode-map (make-sparse-keymap))
  (define-key galaxy-planet-mode-map "q" 'galaxy-planet-quit)
  (define-key galaxy-planet-mode-map "1" 'galaxy-goto-capital-receiver)
  (define-key galaxy-planet-mode-map "2" 'galaxy-goto-material-receiver)
  (define-key galaxy-planet-mode-map "3" 'galaxy-goto-colonist-receiver)
  (define-key galaxy-planet-mode-map "4" 'galaxy-goto-empty-receiver)
  (define-key galaxy-planet-mode-map "5" 'galaxy-return-to-sender)
  (define-key galaxy-planet-mode-map "n" 'galaxy-change-name-of-planet)
  (define-key galaxy-planet-mode-map " " 'galaxy-forward-planet)
  (define-key galaxy-planet-mode-map "p" 'galaxy-new-production-type)
  (define-key galaxy-planet-mode-map "\^?" 'galaxy-backward-planet)
  (define-key galaxy-planet-mode-map "j" 'galaxy-goto-planet)
  (define-key galaxy-planet-mode-map "c" 'galaxy-change-name-of-race)
  (define-key galaxy-planet-mode-map "r" 'galaxy-change-route)
  (define-key galaxy-planet-mode-map "l" 'galaxy-load-group)
  (define-key galaxy-planet-mode-map "m" 'galaxy-change-map-size)
  (define-key galaxy-planet-mode-map "u" 'galaxy-unload-group)
  (define-key galaxy-planet-mode-map "s" 'galaxy-send-group)
  (define-key galaxy-planet-mode-map "p" 'galaxy-new-production-type)
  (define-key galaxy-planet-mode-map "g" 'galaxy-goto-groups)
  (define-key galaxy-planet-mode-map "e" 'galaxy-erase-ship-type)
  (define-key galaxy-planet-mode-map "t" 'galaxy-rename-ship-type)
  (define-key galaxy-planet-mode-map "d" 'galaxy-design-ship-type)
  (define-key galaxy-planet-mode-map "w" 'galaxy-declare-war)
  (define-key galaxy-planet-mode-map "b" 'galaxy-break-off-group)
  (define-key galaxy-planet-mode-map "a" 'galaxy-declare-peace)
  (define-key galaxy-planet-mode-map "h" 'describe-mode))


(defun planet-mode ()
  "Mode to help organizing a galaxy empire
Commands: \\{galaxy-planet-mode-map}"
  (interactive)
  (kill-all-local-variables)
  (setq buffer-read-only t)
  (setq mode-line-format
	(list ""
	      'mode-line-modified
	      "%b--"
	      'global-mode-string
	      "---("
	      'mode-name
	      'minor-mode-alist
	      ")"
	      "-------------"
	      "("
	      'galaxy-planet-name
	      ")%-"))
  (setq mode-line-modified "---")
  ;;(rename-buffer "*galaxy*")
  (use-local-map galaxy-planet-mode-map)
  (setq mode-name "Planet-mode")
  (setq major-mode 'planet-mode)
  (setq galaxy-command-buffer (get-buffer-create "Galaxy commands"))
  (setq galaxy-window (selected-window))
  (setq galaxy-command-window (split-window galaxy-window (- (window-height) 6)))
  ;;(setq completion-ignore-case t)
  (set-window-buffer galaxy-command-window galaxy-command-buffer)
  (widen)
  (goto-char (point-min))
  (narrow-to-page)
  (galaxy-read-planet-name))
------------------end of galrep.el----------------------
--
Alan Covington, Jade Simulations International Corp., Calgary, Alta.
alan@jade.ab.ca
-- 
Alan Covington, Jade Simulations International Corp., Calgary, Alta.
alan@jade.ab.ca
Newsgroups: rec.games.pbm