[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
Patch (0.54): Use user's preferred editor, if possible
- To: zzdev@xxxxxxxxxx
- Subject: Patch (0.54): Use user's preferred editor, if possible
- From: Mark-Jason Dominus <mjd@xxxxxxxxxx>
- Date: Sun, 25 Oct 1998 02:59:13 -0500
- Cc: mjd@xxxxxxxxxx
- Organization: Plover Systems
- Reply-to: zzdev@xxxxxxxxxx
--- zigzag.054 Sun Oct 25 02:57:14 1998
+++ zigzag Sun Oct 25 02:54:44 1998
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# Xanadu(R) DIMENSIA(tm) Hyperstructure Kit, $Revision: 0.54 $
+# Xanadu(R) DIMENSIA(tm) Hyperstructure Kit, $Revision: 0.55 $
#
# Designed by Ted Nelson
# Programmed by Andrew Pam ("xanni") and Bek Oberin ("gossamer")
@@ -25,9 +25,17 @@
# ===================== Change Log
#
# Inital zigzag implementation
-# $Id: zigzag,v 0.54 1998/10/08 03:56:21 xanni Exp $
+# $Id: zigzag,v 0.55 1998/10/25 07:54:44 mjd Exp $
#
# $Log: zigzag,v $
+# Revision 0.55 1998/10/25 07:54:44 mjd
+# Choose editor based on ordinary user preferences, if available.
+# That means look at VISUAL and EDITOR environment variables, in that
+# order.
+#
+# If neither is set, use old logic: Select first program available
+# from a list that includes several common editors.
+#
# Revision 0.54 1998/10/08 03:56:21 xanni
# Incorporate Gossamer's changes, fix $TEMP_FILE problem
#
@@ -77,18 +85,14 @@
# Put brackets around all function arguments.
# Define constants
-#my ($VERSION) = q$Revision: 0.54 $ =~ /([\d\.]+)/;
-my $VERSION = q$Id: zigzag,v 0.54 1998/10/08 03:56:21 xanni Exp $;
+#my ($VERSION) = q$Revision: 0.55 $ =~ /([\d\.]+)/;
+my $VERSION = q$Id: zigzag,v 0.55 1998/10/25 07:54:44 mjd Exp $;
my $FALSE = 0;
my $TRUE = not $FALSE;
my $CELLS_PER_WIN = 5; # Number of cells displayed across each window
my $CURSOR_HOME = 10; # NOTE! This assumes it stays fixed!
my $DELETE_HOME = 99; # NOTE! This assumes it stays fixed!
-my $EDITOR = "/bin/joe";
- $EDITOR = "/bin/vi" if -x "/bin/vi";
- $EDITOR = "/usr/bin/emacs" if -x "/usr/bin/emacs";
- $EDITOR = "/usr/local/bin/mule" if -x "/usr/local/bin/mule";
- $EDITOR = "/usr/X11R6/bin/gvim -f" if -x "/usr/X11R6/bin/gvim";
+my $EDITOR = choose_editor();
my $FILENAME = "zigzag.data"; # Default filename for initial slice
my $TEMP_FILE = "/tmp/zigzag-$<-$^T"; # Filename used for external editing
my $LOTS_OF_COLOURS = $TRUE; # What style
@@ -1779,6 +1783,28 @@
{ &display_refresh(); }
}
+
+#
+# Initialization functions
+#
+sub choose_editor()
+{
+ my @edlist = qw(/usr/X11R6/bin/gvim
+ /usr/local/bin/mule
+ /usr/bin/emacs
+ /bin/vi
+ /bin/joe
+ );
+ my $editor = $ENV{VISUAL} || $ENV{EDITOR};
+ return $editor if $editor;
+ my $e;
+ foreach $e (@edlist) {
+ return $e if -x $e;
+ }
+ print STDERR "Sorry, ZigZag couldn't locate any usable editor.
+Please set your EDITOR variable and try again.\n";
+ exit 0;
+}
#
# Background functions, if any, can be executed here