less (part 1 of 6)

Mark Nudelman mark at unix386.Convergent.COM
Wed Mar 6 10:12:36 AEST 1991


For some reason, I have been recieving a lot requests lately for
the latest version of "less".  So I decided to post it here rather
than sending umpteen copies thru mail.  If you haven't seen less
before, its a paginator program, similar to more or pg.

If you find any bugs or have any suggestions for improvements,
PLEASE PLEASE PLEASE send them to me rather than posting patches
to the net.  I will combine them and post "official" patches as
seems appropriate.  I will attempt to address any issues in a
timely manner, although I'm very busy right now and can't promise
quick turnaround at all times.

Enjoy!

Mark Nudelman
{uunet,sun,decwrl,hplabs}!pyramid!ctnews!unix386!mark

===================================================================

#! /bin/sh
# This is a shell archive.
# Remove anything before this line, then unpack it
# by saving it into a file and typing "sh file".

echo shar: Extracting \"README\"
sed "s/^X//" >'README' <<'END_OF_FILE'
X=======================================================================
X===     NOTE: THIS IS A BETA DISTRIBUTION OF less (version 170)     ===
X===            PLEASE REPORT ANY PROBLEMS TO THE AUTHOR.            ===
X=======================================================================
X
XThis is the distribution of "less", a paginator similar to "more" or "pg".
XThe manual page is in less.man (nroff source in less.nro).
XMajor changes made since the last posted version are in CHANGES.
X
XINSTALLATION (Unix systems only):
X
X1. Move the distributed source to its own directory and 
X   unpack it by running "sh" or "unshar" on the distribution 
X   files, if you have not already done so.
X
X2. Type "sh linstall" and answer the questions it asks.
X   This will generate a makefile and a defines.h.
X
X   If you choose not to include some features in your version,
X   you may wish to edit the manual page "less.nro" and the help
X   page "less.help" to remove the references to the appropriate 
X   commands or options.
X
X3. It is a good idea to look over the generated makefile 
X   and make sure it looks ok.
X
X4. Type "make" and watch the fun.
X
X5. If the make succeeds, it will generate a program "less"
X   in your current directory.  Test the generated program.
X
X6. When satisfied that it works, if you wish to install it
X   in a public place, type "make install".
X
XIf you have any problems building or running "less", 
Xsuggestions, complaints, etc., you may mail to the 
Xauthor via USENET at:
X	sun	 \
X	uunet 	  } !pyramid!ctnews!unix386!mark
X	hplabs   /
X
X
XNote to hackers: comments noting possible improvements are enclosed
Xin double curly brackets {{ like this }}.
END_OF_FILE
echo shar: Extracting \"CHANGES\"
sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
X	Major changes between "less" versions 123 and 170
X
X* New option -j allows target lines to be positioned anywhere on screen.
X
X* New option -S truncates displayed line at the screen width,
X  rather than wrapping onto the next line.
X
X* New option -y limits amount of forward scroll.
X
X* New option -T specifies a "tags" file.
X
X* Non-printable, non-control characters are displayed in octal.
X  Such characters, as well as control characters, are displayed 
X  in blinking mode.
X
X* New command -+ sets an option to its default.
X* New command -- sets an option to the opposite of its default.
X
X* Lesskey file may have a string appended to a key's action,
X  which acts as though typed in after the command.
X
X* New commands ESC-^F and ESC-^B match arbitrary types of brackets.
X
X* New command F monitors a growing file (like "tail -f").
X
X* New command | pipes a section of the input file into a shell command.
X
X* New command :x directly jumps to a file in the command line list.
X
X* Search commands have been enhanced and reorganized:
X	n	Repeat search, same direction.
X	N	Repeat search, opposite direction.
X	ESC-/	Search forward thru file boundaries
X	ESC-?	Search backward thru file boundaries
X	ESC-n	Repeat search thru file boundaries, same direction.
X	ESC-N	Repeat search thru file boundaries, opposite direction.
X  Special character * causes search to search thru file boundaries.
X  Special character @ causes search to begin at start/end of file list.
X
X* Examining a new file adds it to the command line list.
X  A list of files, or an expression which matches more than one file,
X  may be examined; all of them are added to the command line list.
X
X* Environment variables LESSCHARSET and LESSCHARDEF can define
X  a non-ASCII character set.
X
X* Partial support for MSDOS, including options -R for repainting screen
X  on quit, -v/-V to select video mode, and -W to change window size.
X
X
X======================================================================
X
X
X	Major changes between "less" versions 97 and 123
X
X* New option (-N) causes line numbers to be displayed in the
X  text of the file (like vi "set nu").
X
X* New option (-?) prints help message immediately.
X
X* New option (-r) displays "raw" control characters, without
X  mapping them to ^X notation.
X
X* New option (-f) forces less to open non-regular files
X  (directories, etc).
X
X* New option (-k) can be used to specify lesskey files by name.
X
X* New option (-y) can be used to set a forward scroll limit
X  (like -h sets a backward scroll limit).
X
X* File marks (set by the m command) are now preserved when a new
X  file is edited.  The ' command can thus be used to switch files.
X
X* New command ESC-/ searches all files (on the command line) 
X  for a pattern.
X
X* New command ESC-n repeats previous search, spanning files.
X
X* The N command has been changed to repeat the previous search
X  in the reverse direction.  The old N command is still available 
X  via :n.
X
X* New command ESC-N repeats previous search in the reverse
X  direction and spanning files.
X
X* 8 bit characters are now supported.  A new option (-g) can be 
X  used to strip off the eighth bit (the previous behavior).
X
X* Options which take a following string (like -t) may now
X  optionally have a space between the option letter and the string.
X
X* Six new commands { } ( ) [ and ] can be used to match
X  brackets of specific types, similar to vi % command.
X
X* New commands z and w move forward/backward one window and
X  simultaneously set the window size.
X
X* Prompt string expansion now has %L for line number of the last
X  line in the file, and %E for the name of the editor.
X  Also, % escapes which refer to a line (b=bottom, t=top, etc.)
X  can use j for the jump target line.
X
X* New environment variable LESSEDIT can be used to tailor the
X  command string passed to the editor by the v command.
X
X* Examining a file which was previously examined will return
X  to the same position in the file.
X
X* A "%" is expanded to the current filename and a "#" to the 
X  previous filename, in both shell commands and the E command.
X  (Previously % worked only in shell commands and # worked 
X  only in the E command.)
X
X* New command ":ta" is equivalent to "-t".
X
X* New command "s" is equivalent to "-l".
X
X* The - command may be followed by "+X" to revert to the default
X  for option X, or "-X" to get the opposite of the default.
X
X* Lesskey files may now include characters after the action as
X  extra input to be parsed after the action; for example:
X  "toggle-option X" to toggle a specific option X.
END_OF_FILE
echo shar: Extracting \"linstall\"
sed "s/^X//" >'linstall' <<'END_OF_FILE'
X#! /bin/sh
X# Installation script for less.
X# This script prompts the operator for various information
X# and constructs a makefile.
X
Xecho "This script will build a makefile for less."
Xecho "If you already have a file called \"makefile\" it will be overwritten,"
Xecho "as will the file \"defines.h\"."
Xecho "Press RETURN to continue."
Xread ans
X
Xecho "I will ask you some questions about your system."
Xecho "If you do not know the answer to any question,"
Xecho "just press RETURN and I will choose a default for you."
Xecho "Press RETURN now."
Xread ans
X
XECHO=./vecho
Xif [ ! -f $ECHO ]
Xthen
X	echo "One moment..."
X	cc -o $ECHO vecho.c
X	echo ""
Xfi
X
X$ECHO "Most Unix systems are derived from either System V"
X$ECHO "or Berkeley BSD 4.1, 4.2, 4.3, etc."
X$ECHO ""
X$ECHO "Is your system closest to:"
X$ECHO "  1. System V"
X$ECHO "  2. BSD 4.1"
X$ECHO "  3. BSD 4.2 or later"
X$ECHO "  4. Xenix"
X$ECHO "Enter a number, or just RETURN if you don't know: \c"
Xread ans
Xxenix=0
Xcase "X$ans" in
XX1) sys=sys5; sysname="System V" ;;
XX2) sys=bsd; bsd41=1; sysname="BSD 4.1" ;;
XX3) sys=bsd; bsd41=0; sysname="BSD 4.2" ;;
XX4) sys=sys5; xenix=1; sysname="Xenix" ;;
X*) sys=unknown ;;
Xesac
X$ECHO ""
X
XDATE=`date`
Xcat >makefile <<EOF
X# Makefile for "less"
X# Generated $DATE by $0.
XEOF
X
Xcat >>makefile <<"EOF"
X#
X# Invoked as:
X#	make all
X#   or	make install
X# Plain "make" is equivalent to "make all".
X#
X# If you add or delete functions, remake funcs.h by doing:
X#	make newfuncs
X# This depends on the coding convention of function headers looking like:
X#	" \t public <function-type> \n <function-name> ( ... ) "
X#
X# Also provided:
X#	make lint	# Runs "lint" on all the sources.
X#	make clean	# Removes "less" and the .o files.
X#	make clobber	# Pretty much the same as make "clean".
X
XSHELL = /bin/sh
X
XEOF
X
Xcat >defines.h <<EOF
X/* Definition file for less */
X/* Generated $DATE by $0. */
X
XEOF
X
Xcat >>defines.h <<EOF
X/*
X * Define XENIX if running under XENIX 3.0.
X */
X#define	XENIX		$xenix
X
XEOF
X$ECHO ""
X
X
X
Xif [ "X$sys" = "Xunknown" ]
Xthen
X	alldefault=0
Xelse
X	def=yes
X	alldefault=1
X	$ECHO "Do you want to use ALL the defaults for $sysname?"
X	$ECHO "  Enter \"yes\" if you have a STANDARD $sysname."
X	$ECHO "  Enter \"no\" if you want to change any of the defaults. [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) alldefault=1 ;;
X	X[nN]*) alldefault=0 ;;
X	esac
X	$ECHO ""
Xfi
X
Xif [ $alldefault = 0 ]
Xthen
X	alloptional=0
Xelse
X	def=yes
X	alloptional=1
X	$ECHO "Do you want to use all the optional features of less?"
X	$ECHO "  Less has several features which you may or may not"
X	$ECHO "  wish to include, such as shell escapes."
X	$ECHO "  Enter \"yes\" if you want to include ALL the optional features."
X	$ECHO "  Enter \"no\" if you want to select individual features. [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) alloptional=1 ;;
X	X[nN]*) alloptional=0 ;;
X	esac
X	$ECHO ""
Xfi
X
X
X
Xdef=yes
Xx=1
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Does your C compiler support the \"void\" type? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * VOID is 1 if your C compiler supports the "void" type,
X * 0 if it does not.
X */
X#define	VOID		$x
X#if VOID
X#define	VOID_POINTER	void *
X#else
X#define	VOID_POINTER	char *
X#endif
X
XEOF
X
X
X
Xdef=long
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "What type is the \"offset\" argument to lseek? [$def] \c"
X	read ans
X	if [ "X$ans" != "X" ]
X	then
X		def=$ans
X	fi
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * offset_t is the type which lseek() returns.
X * It is also the type of lseek()'s second argument.
X */
X#define	offset_t	$def
X
XEOF
X
X
X
X
Xdef=yes; x=1
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Most Unix systems provide the stat() function."
X	$ECHO "Does your system have stat()? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * STAT is 1 if your system has the stat() call.
X */
X#define	STAT		$x
X
XEOF
X
X
X
X
Xdef=yes; x=1
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Most Unix systems provide the perror() function."
X	$ECHO "Does your system have perror()? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * PERROR is 1 if your system has the perror() call.
X * (Actually, if it has sys_errlist, sys_nerr and errno.)
X */
X#define	PERROR		$x
X
XEOF
X
X
X
X
Xdef=yes; x=1
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Most Unix systems provide the time() function."
X	$ECHO "Does your system have time()? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * GET_TIME is 1 if your system has the time() call.
X */
X#define	GET_TIME	$x
X
XEOF
X
Xif [ $x = 0 ]
Xthen
X	$ECHO "What is the APPROXIMATE performance of your"
X	$ECHO "machine, as a percentage of a Vax 11/750?"
X	$ECHO "(Enter 100 if your machine is as fast as a Vax,"
X	$ECHO " 50 if it is half as fast, 200 if it is twice as fast, etc.)"
X	$ECHO "The accuracy of this information is not critical."
X	while :
X	do
X		$ECHO "Percent of Vax 11/750 [100]: \c"
X		read ans
X		if [ "X$ans" = "X" ]
X		then
X			ans=100
X		fi
X		longloop=`expr "$ans" "*" 3`
X		if [ $? = 0 ]
X		then
X			break
X		fi
X		$ECHO "Enter a number please!"
X	done
X	$ECHO ""
X
X	cat >>defines.h <<EOF
X/*
X * LONGLOOP is the number of lines we should process in the line number
X * scan before displaying a warning that it will take a while.
X */
X#define	LONGLOOP	($longloop)
XEOF
Xfi
X
X
X
X
Xif [ "$sys" = "bsd" ]
Xthen
X	def=no; x=0
Xelse
X	def=yes; x=1
Xfi
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Most System V systems have termio.h, while most"
X	$ECHO "Berkeley-derived systems have sgtty.h."
X	$ECHO "Does your system have termio.h? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * TERMIO is 1 if your system has /usr/include/termio.h.
X * This is normally the case for System 5.
X * If TERMIO is 0 your system must have /usr/include/sgtty.h.
X * This is normally the case for BSD.
X */
X#define	TERMIO		$x
X
XEOF
X
X
X
X
Xif [ "$sys" = "bsd" -a "$bsd41" = "0" ]
Xthen
X	def=yes; x=1
Xelse
X	def=no; x=0
Xfi
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Most BSD 4.2 and 4.3 systems have both _setjmp() and setjmp()."
X	$ECHO "Most System V and BSD 4.1 systems have only setjmp()."
X	$ECHO "Does your system have both _setjmp() and setjmp()? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * HAS__SETJMP is 1 if your system has the _setjmp() call.
X * This is normally the case only for BSD 4.2 and up,
X * not for BSD 4.1 or System 5.
X */
X#define	HAS__SETJMP	$x
X
XEOF
X
X
X
X
Xif [ "$sys" = "bsd" -a "$bsd41" = "0" ]
Xthen
X	def=yes; x=1
Xelse
X	def=no; x=0
Xfi
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Most BSD 4.2 and 4.3 systems have the sigsetmask() call."
X	$ECHO "Most System V and BSD 4.1 systems do not."
X	$ECHO "Does your system have sigsetmask()? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * SIGSETMASK is 1 if your system has the sigsetmask() call.
X * This is normally the case only for BSD 4.2,
X * not for BSD 4.1 or System 5.
X */
X#define	SIGSETMASK	$x
X
XEOF
X
X
X
Xif [ "$sys" = "bsd" ]
Xthen
X	def=2; REGCMP=0;RECOMP=1
Xelse
X	def=1; REGCMP=1;RECOMP=0
Xfi
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "Most System V systems have the regcmp() function."
X	$ECHO "Most Berkeley-derived systems have the re_comp() function."
X	$ECHO "Does your system have:"
X	$ECHO "  1. regcmp"
X	$ECHO "  2. re_comp"
X	$ECHO "  3. neither   [$def] \c"
X	read ans
X	case "X$ans" in
X	X1) REGCMP=1;RECOMP=0 ;;
X	X2) REGCMP=0;RECOMP=1 ;;
X	X3) REGCMP=0;RECOMP=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * REGCMP is 1 if your system has the regcmp() function.
X * This is normally the case for System 5.
X * RECOMP is 1 if your system has the re_comp() function.
X * This is normally the case for BSD.
X * If neither is 1, pattern matching is supported, but without metacharacters.
X */
X#define	REGCMP		$REGCMP
X#define	RECOMP		$RECOMP
X
XEOF
X
X
X
X
Xdef=yes
Xx=1
Xif [ $alloptional = 0 ]
Xthen
X	$ECHO "Do you wish to allow shell escapes? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * SHELL_ESCAPE is 1 if you wish to allow shell escapes.
X * (This is possible only if your system supplies the system() function.)
X */
X#define	SHELL_ESCAPE	$x
X
XEOF
X
X
X
Xdef=yes
Xx=1
Xedname="vi"
Xif [ $alloptional = 0 ]
Xthen
X	$ECHO "Do you wish to allow editor escapes? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[nN]*) x=0; edname="" ;;
X	X[yY]*) x=1
X		$ECHO "What is the pathname of the default editor? [$edname] \c"
X		read ans 
X		if [ "x$ans" != "x" ]
X		then
X			edname=$ans
X		fi
X		;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * EDITOR is 1 if you wish to allow editor invocation (the "v" command).
X * (This is possible only if your system supplies the system() function.)
X * EDIT_PGM is the name of the (default) editor to be invoked.
X */
X#define	EDITOR		$x
X#define	EDIT_PGM	"$edname"
X
XEOF
X
X
X
X
Xdef=yes
Xx=1
Xif [ $alloptional = 0 ]
Xthen
X	$ECHO "Do you wish to support \"tag\" files? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * TAGS is 1 if you wish to support tag files.
X */
X#define	TAGS		$x
X
XEOF
X
X
X
Xdef=yes
Xx=1
Xif [ $alloptional = 0 ]
Xthen
X	$ECHO "Do you wish to allow user-defined key definitions? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
XUSERFILE=$x
Xcat >>defines.h <<EOF
X/*
X * USERFILE is 1 if you wish to allow a .less file to specify 
X * user-defined key bindings.
X */
X#define	USERFILE	$x
X
XEOF
X
X
X
Xdef=yes
Xx=1
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "If your system provides the popen() function and"
X	$ECHO "the \"echo\" shell command, you may allow shell metacharacters" 
X	$ECHO "to be expanded in filenames."
X	$ECHO "Do you wish to allow shell metacharacters in filenames? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * GLOB is 1 if you wish to have shell metacharacters expanded in filenames.
X * This will generally work if your system provides the "popen" function
X * and the "echo" shell command.
X */
X#define	GLOB		$x
X
X/*
X * PIPEC is 1 if you wish to have the "|" command
X * which allows the user to pipe data into a shell command.
X */
X#define	PIPEC		$x
X
XEOF
X
X
X
Xdef=yes
Xx=1
Xif [ $alloptional = 0 ]
Xthen
X	$ECHO "Do you wish to allow log files (-l option)? [$def] \c"
X	read ans
X	case "X$ans" in
X	X[yY]*) x=1 ;;
X	X[nN]*) x=0 ;;
X	esac
X	$ECHO ""
Xfi
Xcat >>defines.h <<EOF
X/*
X * LOGFILE is 1 if you wish to allow the -l option (to create log files).
X */
X#define	LOGFILE		$x
X
XEOF
X
Xcat >>defines.h <<EOF
X/*
X * ONLY_RETURN is 1 if you want RETURN to be the only input which
X * will continue past an error message.
X * Otherwise, any key will continue past an error message.
X */
X#define	ONLY_RETURN	0
X
XEOF
X
Xcat >>makefile <<EOF
X
X##########################################################################
X# Compilation environment.
X##########################################################################
X
XEOF
X
X
X
Xif [ "$xenix" = "1" ]
Xthen
X	LIBS="-ltermlib"
Xelif [ "$sys" = "bsd" ]
Xthen
X	LIBS="-ltermcap"
Xelse
X	LIBS="-lcurses -ltermcap -lPW"
Xfi
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "To build \"less\", you must link with libraries supplied by your system."
X	$ECHO "(If this needs to be changed later, edit the makefile"
X	$ECHO "and change the definition of LIBS.)"
X	$ECHO "What libraries should be used [$LIBS] \c"
X	read ans
X	if [ "X$ans" != "X" ]
X	then
X		LIBS="$ans"
X	fi
X	$ECHO ""
Xfi
Xcat >>makefile <<EOF
X# LIBS is the list of libraries needed.
XLIBS = $LIBS
X
XEOF
X
X
X
XINSTALL_LESS="/usr/local/bin/less"
XINSTALL_KEY="/usr/local/bin/lesskey"
XINSTALL_HELP="/usr/local/bin/less.hlp"
XINSTALL_LESSMAN="/usr/man/man1/less.1"
XINSTALL_KEYMAN="/usr/man/man1/lesskey.1"
XLESS_MANUAL="less.nro"
XKEY_MANUAL="lesskey.nro"
Xif [ $alldefault = 0 ]
Xthen
X	$ECHO "What is the name of the \"public\" (installed) version of less?"
X	$ECHO " [$INSTALL_LESS] \c"
X	read ans
X	if [ "X$ans" != "X" ]
X	then
X		INSTALL_LESS="$ans"
X	fi
X	$ECHO "What is the name of the \"public\" (installed) version of lesskey?"
X	$ECHO " [$INSTALL_KEY] \c"
X	read ans
X	if [ "X$ans" != "X" ]
X	then
X		INSTALL_KEY="$ans"
X	fi
X	$ECHO "What is the name of the \"public\" (installed) version of the help file?"
X	$ECHO " [$INSTALL_HELP] \c"
X	read ans
X	if [ "X$ans" != "X" ]
X	then
X		INSTALL_HELP="$ans"
X	fi
X	$ECHO "What is the name of the \"public\" (installed) version of the less manual page?"
X	$ECHO " [$INSTALL_LESSMAN] \c"
X	read ans
X	if [ "X$ans" != "X" ]
X	then
X		INSTALL_LESSMAN="$ans"
X	fi
X	$ECHO "What is the name of the \"public\" (installed) version of the lesskey manual page?"
X	$ECHO " [$INSTALL_KEYMAN] \c"
X	read ans
X	if [ "X$ans" != "X" ]
X	then
X		INSTALL_KEYMAN="$ans"
X	fi
X	$ECHO ""
Xfi
X
Xcat >>defines.h <<EOF
X/*
X * HELPFILE is the full pathname of the help file.
X */
X#define	HELPFILE	"$INSTALL_HELP"
X
XEOF
X
Xcat >>makefile <<EOF
X# INSTALL_LESS is a list of the public versions of less.
X# INSTALL_KEY is a list of the public versions of lesskey.
X# INSTALL_HELP is a list of the public version of the help file.
X# INSTALL_LESSMAN is a list of the public versions of the less manual page.
X# INSTALL_KEYMAN is a list of the public versions of the lesskey manual page.
XINSTALL_LESS =		\$(ROOT)$INSTALL_LESS
XINSTALL_KEY =		\$(ROOT)$INSTALL_KEY
XINSTALL_HELP =		\$(ROOT)$INSTALL_HELP
XINSTALL_LESSMAN =	\$(ROOT)$INSTALL_LESSMAN
XINSTALL_KEYMAN =	\$(ROOT)$INSTALL_KEYMAN
XLESS_MANUAL =		$LESS_MANUAL
XKEY_MANUAL =		$KEY_MANUAL
XHELPFILE =		$INSTALL_HELP
X
X
XEOF
X
X
X
Xcat >>makefile <<"EOF"
X# OPTIM is passed to the compiler and the loader.
X# It is normally "-O" but may be, for example, "-g".
XOPTIM = -O
X
XCFLAGS = $(OPTIM)
X
X
X
X##########################################################################
X# Files
X##########################################################################
X
XSRC1 =	ch.c cmdbuf.c command.c decode.c help.c input.c 
XSRC2 =	line.c linenum.c main.c edit.c option.c optfunc.c \
X	opttbl.c os.c 
XSRC3 =	charset.c filename.c lsystem.c output.c position.c ifile.c \
X	brac.c forwback.c jump.c search.c 
XSRC4 =	mark.c prompt.c screen.c signal.c tags.c ttyin.c version.c
X
XSRC =	$(SRC1) $(SRC2) $(SRC3) $(SRC4)
X
XOBJ =	brac.o ch.o charset.o cmdbuf.o command.o decode.o edit.o filename.o \
X	forwback.o help.o input.o jump.o line.o linenum.o \
X	lsystem.o main.o option.o optfunc.o opttbl.o os.o \
X	output.o position.o mark.o ifile.o prompt.o screen.o \
X	search.o signal.o tags.o ttyin.o version.o
X
X
X##########################################################################
X# Rules for building stuff
X##########################################################################
X
XEOF
X
Xif [ "$USERFILE" = "1" ]
Xthen
X	cat >>makefile <<"EOF"
Xall: less lesskey
Xinstall: install_less install_help install_key install_lman install_kman
XEOF
Xelse
X	cat >>makefile <<"EOF"
Xall: less
Xinstall: install_less install_help install_lman
XEOF
Xfi
X
Xcat >>makefile <<"EOF"
X
Xless: $(OBJ)
X	$(CC) $(LDFLAGS) $(OPTIM) -o less $(OBJ) $(LIBS) $(LDLIBS)
X
Xlesskey: lesskey.o
X	$(CC) $(LDFLAGS) $(OPTIM) -o lesskey lesskey.o $(LDLIBS)
X
Xinstall_less: less
X	for f in $(INSTALL_LESS); do  rm -f $$f; cp less $$f;  done
X	touch install_less
X
Xinstall_key: lesskey
X	for f in $(INSTALL_KEY); do  rm -f $$f; cp lesskey $$f;  done
X	touch install_key
X
Xinstall_help: less.hlp
X	for f in $(INSTALL_HELP); do  rm -f $$f; cp less.hlp $$f;  done
X	touch install_help
X
Xinstall_lman: $(LESS_MANUAL) 
X	for f in $(INSTALL_LESSMAN); do  rm -f $$f; cp $(LESS_MANUAL) $$f;  done
X	touch install_lman
X
Xinstall_kman: $(KEY_MANUAL)
X	for f in $(INSTALL_KEYMAN); do  rm -f $$f; cp $(KEY_MANUAL) $$f;  done
X	touch install_kman
X
X##########################################################################
X# Maintenance
X##########################################################################
X
Xlint:
X	lint -hp $(SRC)
X
Xnewfuncs funcs.h:
X	if [ -f funcs.h ]; then mv funcs.h funcs.h.OLD; fi
X	awk -f mkfuncs.awk $(SRC) >funcs.h
X
Xclean:
X	rm -f $(OBJ) lesskey.o less lesskey vecho
X
Xclobber:
X	rm -f *.o less lesskey vecho install_less install_key \
X		install_help install_lman install_kman
X
Xshar:
X	shar -v README CHANGES linstall \
X		less.nro lesskey.nro \
X		vecho.c mkfuncs.awk > less1.shr
X	shar -v less.man lesskey.man \
X		less.h position.h cmd.h option.h > less2.shr 
X	shar -v lesskey.c $(SRC1) > less3.shr
X	shar -v $(SRC2) > less4.shr
X	shar -v $(SRC3) less.hlp > less5.shr
X	shar -v $(SRC4) funcs.h > less6.shr
X
X
X##########################################################################
X# Dependencies
X##########################################################################
X
X$(OBJ): less.h funcs.h defines.h position.h
Xcommand.o decode.o: cmd.h
Xoption.o opttbl.o optfunc.o: option.h
X
Xlesskey.o: less.h funcs.h defines.h cmd.h
X
XEOF
X$ECHO ""
X
X$ECHO "The makefile and defines.h have been built."
X$ECHO "You should check them to make sure everything is as you want it to be."
X$ECHO "When you are satisfied, just type \"make\", and \"less\" will be built."
END_OF_FILE
echo shar: Extracting \"less.nro\"
sed "s/^X//" >'less.nro' <<'END_OF_FILE'
X.TH LESS 1
X.SH NAME
Xless \- opposite of more
X.SH SYNOPSIS
X.B "less -?"
X.br
X.B "less [-[+]aABcCdeEfimMnNqQrsSuUw] [-b\fIN\fP] [-x\fIN\fP] [-[z]\fIN\fP]"
X.br
X.B "     [-h\fIN\fP] [-y\fIN\fP] [-P[mM=]\fIstring\fP] [-[oO]\fIlogfile\fP] [-k\fIkeyfile\fP]"
X.br
X.B "     [-t\fItag\fP] [-T\fItagsfile\fP] [+\fIcmd\fP] [\fIfilename\fP]..."
X
X.SH DESCRIPTION
X.I Less
Xis a program similar to 
X.I more
X(1), but which allows backward movement
Xin the file as well as forward movement.
XAlso,
X.I less
Xdoes not have to read the entire input file before starting,
Xso with large input files it starts up faster than text editors like
X.I vi
X(1).
X.I Less
Xuses termcap (or terminfo on some systems),
Xso it can run on a variety of terminals.
XThere is even limited support for hardcopy terminals.
X(On a hardcopy terminal, lines which should be printed at the top
Xof the screen are prefixed with an up-arrow.)
X.PP
XCommands are based on both
X.I more
Xand
X.I vi.
XCommands may be preceded by a decimal number, 
Xcalled N in the descriptions below.
XThe number is used by some commands, as indicated.
X
X.SH COMMANDS
XIn the following descriptions, ^X means control-X.
XESC stands for the ESCAPE key; for example ESC-v means the
Xtwo character sequence "ESCAPE", then "v".
X.IP "h or H"
XHelp: display a summary of these commands.
XIf you forget all the other commands, remember this one.
X.PP
X.IP "SPACE or ^V or f or ^F"
XScroll forward N lines, default one window (see option -z below).
XIf N is more than the screen size, only the final screenful is displayed.
XWarning: some systems use ^V as a special literalization character.
X.PP
X.IP "z"
XLike SPACE, but if N is specified, it becomes the new window size.
X.PP
X.IP "RETURN or ^N or e or ^E or j or ^J"
XScroll forward N lines, default 1.
XThe entire N lines are displayed, even if N is more than the screen size.
X.PP
X.IP "d or ^D"
XScroll forward N lines, default one half of the screen size.
XIf N is specified, it becomes the new default for 
Xsubsequent d and u commands.
X.PP
X.IP "b or ^B or ESC-v"
XScroll backward N lines, default one window (see option -z below).
XIf N is more than the screen size, only the final screenful is displayed.
X.PP
X.IP "w"
XLike ESC-v, but if N is specified, it becomes the new window size.
X.PP
X.IP "y or ^Y or ^P or k or ^K"
XScroll backward N lines, default 1.
XThe entire N lines are displayed, even if N is more than the screen size.
XWarning: some systems use ^Y as a special job control character.
X.PP
X.IP "u or ^U"
XScroll backward N lines, default one half of the screen size.
XIf N is specified, it becomes the new default for 
Xsubsequent d and u commands.
X.PP
X.IP "r or ^R or ^L"
XRepaint the screen.
X.PP
X.IP R
XRepaint the screen, discarding any buffered input.
XUseful if the file is changing while it is being viewed.
X.PP
X.IP "F"
XScroll forward, and keep trying to read when the
Xend of file is reached.
XNormally this command would be used when already at the end of the file.
XIt is a way to monitor the tail of a file which is growing
Xwhile it is being viewed.
X(The behavior is similar to the "tail -f" command.)
X.PP
X.IP "g or < or ESC-<"
XGo to line N in the file, default 1 (beginning of file).
X(Warning: this may be slow if N is large.)
X.PP
X.IP "G or > or ESC->"
XGo to line N in the file, default the end of the file.
X(Warning: this may be slow if N is large,
Xor if N is not specified and
Xstandard input, rather than a file, is being read.)
X.PP
X.IP "p or %"
XGo to a position N percent into the file.
XN should be between 0 and 100.
X(This works if standard input is being read, but only if
X.I less
Xhas already read to the end of the file.
XIt is always fast, but not always useful.)
X.PP
X.IP "{"
XIf a left curly bracket appears in the top line displayed
Xon the screen,
Xthe { command will go to the matching right curly bracket.
XThe matching right curly bracket is positioned on the bottom
Xline of the screen.
XIf there is more than one left curly bracket on the top line,
Xa number N may be used to specify the N-th bracket on the line.
X.PP
X.IP "}"
XIf a right curly bracket appears in the bottom line displayed
Xon the screen,
Xthe } command will go to the matching left curly bracket.
XThe matching left curly bracket is positioned on the top
Xline of the screen.
XIf there is more than one right curly bracket on the top line,
Xa number N may be used to specify the N-th bracket on the line.
X.PP
X.IP "("
XLike {, but applies to parentheses rather than curly brackets.
X.PP
X.IP ")"
XLike }, but applies to parentheses rather than curly brackets.
X.PP
X.IP "["
XLike {, but applies to square brackets rather than curly brackets.
X.PP
X.IP "]"
XLike }, but applies to square brackets rather than curly brackets.
X.PP
X.IP "ESC-^F"
XFollowed by two characters,
Xacts like {, but uses the two characters as open and close brackets,
Xrespectively.
XFor example, "ESC ^F < >" could be used to 
Xgo forward to the > which matches the < in the top displayed line.
X.IP "ESC-^B"
XFollowed by two characters,
Xacts like }, but uses the two characters as open and close brackets,
Xrespectively.
XFor example, "ESC ^B < >" could be used to 
Xgo backward to the < which matches the > in the bottom displayed line.
X.IP m
XFollowed by any lowercase letter, 
Xmarks the current position with that letter.
X.PP
X.IP "'"
X(Single quote.)
XFollowed by any lowercase letter, returns to the position which
Xwas previously marked with that letter.
XFollowed by another single quote, returns to the position at
Xwhich the last "large" movement command was executed.
XFollowed by a ^ or $, jumps to the beginning or end of the
Xfile respectively.
XMarks are preserved when a new file is examined,
Xso the ' command can be used to switch between input files.
X.PP
X.IP "^X^X"
XSame as single quote.
X.PP
X.IP /pattern
XSearch forward in the file for the N-th line containing the pattern.
XN defaults to 1.
XThe pattern is a regular expression, as recognized by
X.I ed.
XThe search starts at the second line displayed
X(but see the -a and -j options, which change this).
X.sp
XCertain characters are special
Xif entered at the beginning of the pattern;
Xthey modify the type of search rather than become part of the pattern:
X.RS
X.IP !
XSearch for lines which do NOT match the pattern.
X.IP *
XSearch multiple files.
XThat is, if the search reaches the end of the current file 
Xwithout finding a match,
Xthe search continues in the next file in the command line list.
X.IP @
XBegin the search at the first line of the first file
Xin the command line list,
Xregardless of what is currently displayed on the screen
Xor the settings of the -a or -j options.
X.RE
X.PP
X.IP ?pattern
XSearch backward in the file for the N-th line containing the pattern.
XThe search starts at the line immediately before the top line displayed.
X.sp
XCertain characters are special as in the / command:
X.RS
X.IP !
XSearch for lines which do NOT match the pattern.
X.IP *
XSearch multiple files.
XThat is, if the search reaches the beginning of the current file 
Xwithout finding a match,
Xthe search continues in the previous file in the command line list.
X.IP @
XBegin the search at the last line of the last file
Xin the command line list,
Xregardless of what is currently displayed on the screen
Xor the settings of the -a or -j options.
X.RE
X.PP
X.IP "ESC-/pattern"
XSame as "/*".
X.PP
X.IP "ESC-?pattern"
XSame as "?*".
X.PP
X.IP n
XRepeat previous search, for N-th line containing the last pattern.
XIf the previous search was modified by !, the search is made for the
XN-th line NOT containing the pattern.
XIf the previous search was modified by *, the search continues
Xin the next (or previous) file if not satisfied in the current file.
XThere is no effect if the previous search was modified by @.
X.PP
X.IP N
XRepeat previous search, but in the reverse direction.
X.PP
X.IP "ESC-n"
XRepeat previous search, but crossing file boundaries.
XThe effect is as if the previous search were modified by *.
X.PP
X.IP "ESC-N"
XRepeat previous search, but in the reverse direction
Xand crossing file boundaries.
X.PP
X.IP ":e [filename]"
XExamine a new file.
XIf the filename is missing, the "current" file (see the :n and :p commands
Xbelow) from the list of files in the command line is re-examined.
XA percent sign (%) in the filename is replaced by the name of the
Xcurrent file.  
XA pound sign (#) is replaced by the name of the previously examined file.
XThe filename is inserted into the command line list of files
Xso that it can be seen by subsequent :n and :p commands.
XIf the filename consists of several files, they are all inserted into
Xthe list of files and the first one is examined.
X.PP
X.IP "^X^V or E"
XSame as :e.
XWarning: some systems use ^V as a special literalization character.
X.PP
X.IP ":n"
XExamine the next file (from the list of files given in the command line).
XIf a number N is specified, the N-th next file is examined.
X.PP
X.IP ":p"
XExamine the previous file in the command line list.
XIf a number N is specified, the N-th previous file is examined.
X.PP
X.IP ":x"
XExamine the first file in the command line list.
XIf a number N is specified, the N-th file in the list is examined.
X.PP
X.IP "= or ^G or :f"
XPrints some information about the file being viewed,
Xincluding its name
Xand the line number and byte offset of the bottom line being displayed.
XIf possible, it also prints the length of the file,
Xthe number of lines in the file
Xand the percent of the file above the last displayed line.
X.PP
X.IP \-
XFollowed by one of the command line option letters (see below),
Xthis will change the setting of that option
Xand print a message describing the new setting.
XIf the option letter has a numeric value (such as -b or -h),
Xor a string value (such as -P or -t),
Xa new value may be entered after the option letter.
XIf no new value is entered, a message describing
Xthe current setting is printed and nothing is changed.
X.PP
X.IP \-+
XFollowed by one of the command line option letters (see below),
Xthis will reset the option to its default setting
Xand print a message describing the new setting.
X(The "\-+\fIX\fP" command does the same thing
Xas "\-+\fIX\fP" on the command line.)
XThis does not work for string-valued options.
X.PP
X.IP \-\-
XFollowed by one of the command line option letters (see below),
Xthis will reset the option to the "opposite" of its default setting
Xand print a message describing the new setting.
X(The "\-\-\fIX\fP" command does the same thing
Xas "\-\fIX\fP" on the command line.)
XThis does not work for numeric or string-valued options.
X.PP
X.IP _
X(Underscore.)
XFollowed by one of the command line option letters (see below),
Xthis will print a message describing the current setting of that option.
XThe setting of the option is not changed.
X.PP
X.IP +cmd
XCauses the specified cmd to be executed each time a new file is examined.
XFor example, +G causes 
X.I less
Xto initially display each file starting at the end 
Xrather than the beginning.
X.PP
X.IP V
XPrints the version number of 
X.I less 
Xbeing run.
X.PP
X.IP "q or :q or :Q or ZZ or ESC ESC"
XExits
X.I less.
X.PP
XThe following 
Xthree
Xcommands may or may not be valid, depending on your particular installation.
X.PP
X.IP v
XInvokes an editor to edit the current file being viewed.
XThe editor is taken from the environment variable EDITOR,
Xor defaults to "vi".
XSee also the discussion of LESSEDIT under the section on PROMPTS below.
X.PP
X.IP "! shell-command"
XInvokes a shell to run the shell-command given.
XA percent sign (%) in the command is replaced by the name of the
Xcurrent file.  
XA pound sign (#) is replaced by the name of the previously examined file.
X"!!" repeats the last shell command.
X"!" with no shell command simply invokes a shell.
XIn all cases, the shell is taken from the environment variable SHELL,
Xor defaults to "sh".
X.PP
X.IP "| <m> shell-command"
X<m> represents any mark letter.
XPipes a section of the input file to the given shell command.
XThe section of the file to be piped is between the current position and 
Xthe position marked by the letter.
X<m> may also be ^ or $ to indicate beginning or end of file respectively.
XIf <m> is . or newline, the current screen is piped.
XThe current screen is the minimum amount piped in any case.
X.PP
X.SH OPTIONS
XCommand line options are described below.
XMost options may be changed while
X.I less 
Xis running, via the "\-" command.
X.PP
XOptions are also taken from the environment variable "LESS".
XFor example, 
Xto avoid typing "less -options ..." each time 
X.I less 
Xis invoked, you might tell 
X.I csh:
X.sp
Xsetenv LESS "-options"
X.sp
Xor if you use 
X.I sh:
X.sp
XLESS="-options"; export LESS
X.sp
XThe environment variable is parsed before the command line,
Xso command line options override the LESS environment variable.
XIf an option appears in the LESS variable, it can be reset
Xto its default on the command line by beginning the command
Xline option with "-+".
X.sp
XA dollar sign ($) may be used to signal the end of an option string.
XThis is important only for options like -P which take a
Xfollowing string.
X.IP -?
XThis option displays a summary of the commands accepted by
X.I less
X(the same as the h command).
XIf this option is given, all other options are ignored, and
X.I less
Xexits after the help screen is viewed.
X(Depending on how your shell interprets the question mark,
Xit may be necessary to quote the question mark, thus: "-\\?".)
X.IP -a
XCauses searches to start after the last line
Xdisplayed on the screen, 
Xthus skipping all lines displayed on the screen.
XBy default, searches start at the second line on the screen
X(or after the last found line; see the -j option).
X.IP -b\fIn\fP
XCauses
X.I less
Xto use a non-standard number of buffers.
XBuffers are 1K, and by default 10 buffers are used
X(except if data in coming from standard input; see the -B option).
XThe number \fIn\fP specifies a different number of buffers to use.
X.IP -B
XDisables automatic allocation of buffers,
Xso that only the default number of buffers are used.
XIf more data is read than will fit in the buffers, the oldest
Xdata is discarded.
XBy default, when data is coming from standard input,
Xbuffers are allocated automatically as needed
Xto avoid loss of data.
X.IP -c
XCauses full screen repaints to be painted from the top line down.
XBy default,
Xfull screen repaints are done by scrolling from the bottom of the screen.
X.IP -C
XThe -C option is like -c, but the screen is cleared before it is repainted.
X.IP -d
XThe -d option suppresses the error message
Xnormally displayed if the terminal is dumb;
Xthat is, lacks some important capability,
Xsuch as the ability to clear the screen or scroll backward.
XThe -d option does not otherwise change the behavior of
X.I less
Xon a dumb terminal).
X.IP -e
XCauses 
X.I less 
Xto automatically exit
Xthe second time it reaches end-of-file.
XBy default, the only way to exit 
X.I less
Xis via the "q" command.
X.IP -E
XCauses 
X.I less
Xto automatically exit the first time it reaches end-of-file.
X.IP -f
XForces non-regular files to be opened.
X(A non-regular file is a directory or a device special file.)
XAlso suppresses the warning message when a binary file is opened.
XBy default,
X.I less
Xwill refuse to open non-regular files.
X.IP -h\fIn\fP
XSpecifies a maximum number of lines to scroll backward.
XIf it is necessary to scroll backward more than \fIn\fP lines,
Xthe screen is repainted in a forward direction instead.
X(If the terminal does not have the ability to scroll
Xbackward, -h0 is implied.)
X.IP -i
XCauses searches to ignore case; that is,
Xuppercase and lowercase are considered identical.
XAlso, text which is overstruck or underlined can be searched for.
XThis option is ignored if any uppercase letters
Xappear in the search pattern.
X.IP -j\fIn\fP
XSpecifies a line on the screen where "target" lines
Xare to be positioned.
XTarget lines are the object of text searches, 
Xtag searches, jumps to a line number,
Xjumps to a file percentage, and jumps to a marked position.
XThe screen line is specified by a number: the top line on the screen
Xis 1, the next is 2, and so on.
XThe number may be negative to specify a line relative to the bottom
Xof the screen: the bottom line on the screen is -1, the second
Xto the bottom is -2, and so on.
XIf the -j option is used, searches begin at the line immediately
Xafter the target line.
XFor example, if "-j4" is used, the target line is the
Xfourth line on the screen, so searches begin at the fifth line
Xon the screen.
X.IP -k\fIfilename\fP
XCauses
X.I less
Xto open and interpret the named file as a
X.I lesskey
X(1) file.
XMultiple -k options may be specified.
XIf a file called .less exists in the user's home directory, this
Xfile is also used as a
X.I lesskey
Xfile.
X.IP -m
XCauses 
X.I less
Xto prompt verbosely (like \fImore\fP),
Xwith the percent into the file.
XBy default,
X.I less
Xprompts with a colon.
X.IP -M
XCauses 
X.I less
Xto prompt even more verbosely than 
X.I more.
X.IP -n
XSuppresses line numbers.
XThe default (to use line numbers) may cause
X.I less
Xto run more slowly in some cases, especially with a very large input file.
XSuppressing line numbers with the -n flag will avoid this problem.
XUsing line numbers means: the line number will be displayed in the verbose
Xprompt and in the = command,
Xand the v command will pass the current line number to the editor
X(see also the discussion of LESSEDIT in PROMPTS below).
X.IP -N
XCauses a line number to be displayed at the beginning of
Xeach line in the display.
X.IP -o\fIfilename\fP
XCauses
X.I less
Xto copy its input to the named file as it is being viewed.
XThis applies only when the input file is a pipe,
Xnot an ordinary file.
XIf the file already exists, 
X.I less
Xwill ask for confirmation before overwriting it.
X.IP -O\fIfilename\fP
XThe -O option is like -o, but it will overwrite an existing
Xfile without asking for confirmation.
X.sp
XIf no log file has been specified,
Xthe -o and -O options can be used from within 
X.I less
Xto specify a log file.
XWithout a file name, they will simply report the name of the log file.
XThe "s" command is equivalent to specifying -o from within
X.I less.
X.IP -p\fIpattern\fP
XThe -p option on the command line is equivalent to 
Xspecifying +/\fIpattern\fP;
Xthat is, it tells
X.I less
Xto start at the first occurence of \fIpattern\fP in the file.
X.IP -P\fIprompt\fP
XProvides a way to tailor the three prompt
Xstyles to your own preference.
XThis option would normally be put in the LESS environment
Xvariable, rather than being typed in with each 
X.I less
Xcommand.
XSuch an option must either be the last option in the LESS variable,
Xor be terminated by a dollar sign.
X-P followed by a string changes the default (short) prompt to that string.
X-Pm changes the medium (-m) prompt to the string, and
X-PM changes the long (-M) prompt.
XAlso, -P= changes the message printed by the = command to the given string.
XAll prompt strings consist of a sequence of 
Xletters and special escape sequences.
XSee the section on PROMPTS for more details.
X.IP -q
XCauses moderately "quiet" operation:
Xthe terminal bell is not rung 
Xif an attempt is made to scroll past the end of the file
Xor before the beginning of the file.
XIf the terminal has a "visual bell", it is used instead.
XThe bell will be rung on certain other errors,
Xsuch as typing an invalid character.
XThe default is to ring the terminal bell in all such cases.
X.IP -Q
XCauses totally "quiet" operation:
Xthe terminal bell is never rung.
X.IP -r
XCauses "raw" control characters to be displayed.
XThe default is to display control characters using the caret notation;
Xfor example, a control-A (octal 001) is displayed as "^A".
XWarning: when the -r flag is used,
X.I less
Xcannot keep track of the actual appearance of the screen
X(since this depends on how the screen responds to
Xeach type of control character).
XThus, various display problems may result,
Xsuch as long lines being split in the wrong place.
X.IP -s
XCauses consecutive blank lines to be squeezed into a single blank line.
XThis is useful when viewing
X.I nroff
Xoutput.
X.IP -S
XCauses lines longer than the screen width to be
Xchopped rather than folded.
XThat is, the remainder of a long line is simply discarded.
XThe default is to fold long lines; that is, display the remainder
Xon the next line.
X.IP -t\fItag\fP
XThe -t option, followed immediately by a TAG,
Xwill edit the file containing that tag.
XFor this to work, there must be a file called "tags" in the
Xcurrent directory, which was previously built by the 
X.I ctags
X(1) command.
XThis option may also be specified from within 
X.I less 
X(using the \- command) as a way of examining a new file.
XThe command ":t" is equivalent to specifying -t from within
X.I less.
X.IP -T\fItagsfile\fP
XSpecifies a tags file to be used instead of "tags".
X.IP -u
XCauses backspaces and carriage returns to be treated as printable characters;
Xthat is, they are sent to the terminal when they appear in the input.
X.IP -U
XCauses backspaces and carriage returns to be treated as control characters;
Xthat is, they are handled as specified by the -r option.
X.sp
XBy default, if neither -u nor -U is given,
Xbackspaces which appear adjacent to an underscore character
Xare treated specially:
Xthe underlined text is displayed 
Xusing the terminal's hardware underlining capability.
XAlso, backspaces which appear between two identical characters
Xare treated specially: 
Xthe overstruck text is printed 
Xusing the terminal's hardware boldface capability.
XOther backspaces are deleted, along with the preceding character.
XCarriage returns immediately followed by a newline are deleted.
XOther carriage returns are handled as specified by the -r option.
X.IP -w
XCauses blank lines to be used to represent lines
Xpast the end of the file.
XBy default,
Xa tilde character is used.
X.IP -x\fIn\fP
XSets tab stops every \fIn\fP positions.
XThe default for \fIn\fP is 8.
X.IP -y\fIn\fP
XSpecifies a maximum number of lines to scroll forward.
XIf it is necessary to scroll forward more than \fIn\fP lines,
Xthe screen is repainted instead.
XThe -c or -C option may be used to repaint from the top of
Xthe screen if desired.
XBy default, any forward movement causes scrolling.
X.IP -[z]\fIn\fP
XChanges the default scrolling window size to \fIn\fP lines.
XThe default is one screenful.
XThe z and w commands can also be used to change the window size.
XThe "z" may be omitted, as in "-\fIn\fP" for compatibility with
X.I more.
X.IP +
XIf a command line option begins with \fB+\fP,
Xthe remainder of that option is taken to be an initial command to
X.I less.
XFor example, +G tells
X.I less
Xto start at the end of the file rather than the beginning,
Xand +/xyz tells it to start at the first occurrence of "xyz" in the file.
XAs a special case, +<number> acts like +<number>g; 
Xthat is, it starts the display at the specified line number
X(however, see the caveat under the "g" command above).
XIf the option starts with ++, the initial command applies to
Xevery file being viewed, not just the first one.
XThe + command described previously
Xmay also be used to set (or change) an initial command for every file.
X
X.SH "KEY BINDINGS"
XYou may define your own 
X.I less
Xcommands by using the program 
X.I lesskey
X(1)
Xto create a file called ".less" in your home directory.
XThis file specifies a set of command keys and an action
Xassociated with each key.
XSee the
X.I lesskey
Xmanual page for more details.
X
X.SH "NATIONAL CHARACTER SETS"
XThere are three types of characters in the input file:
X.IP "normal characters"
Xcan be displayed directly to the screen.
X.IP "control characters"
Xshould not be displayed directly, but are expected to be found
Xin ordinary text files (such as backspace and tab).
X.IP "binary characters"
Xcannot be displayed directly and are not expected to be found
Xin text files.
X.PP
XBy default, 
X.I less
Xuses the ASCII character set.
XIn the ASCII character set, characters
Xwith values between 128 and 255 are treated as binary.
XThe LESSCHARSET environment variable may be used to select
Xanother character set.
XIf it is set to the value "latin1",
Xthe ISO 8859/1 character set is assumed.
XLatin-1 is the same as ASCII, except characters between 128 and 255 are
Xtreated as normal characters.
XThe only valid values for LESSCHARSET currently are "ascii" and "latin1".
X.PP
XIn special cases, it may be desired to tailor
X.I less
Xto use a character set other than the ones definable by LESSCHARSET.
XIn this case, the environment variable LESSCHARDEF can be used
Xto define a character set.
XIt should be set to a string where each character in the string represents
Xone character in the character set.
XThe character "." is used for a normal character, "c" for control,
Xand "b" for binary.
XA decimal number may be used for repetition.
XFor example, "bccc4b." would mean character 0 is binary,
X1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
XAll characters after the last are taken to be the same as the last,
Xso characters 9 through 255 would be normal.
X(This is an example, and does not necessarily 
Xrepresent any real character set.)
X.PP
XSetting LESSCHARDEF to "8bcccbcc18b95.b" is the same as setting
XLESSCHARSET to "ascii".
XSetting LESSCHARDEF to "8bcccbcc18b95.33b." is the same as setting
XLESSCHARSET to "latin1".
X.PP
XControl and binary characters are displayed in blinking mode.
XEach such character is displayed in caret notation if possible
X(e.g. ^A for control-A).  Caret notation is used only if 
Xinverting the 0100 bit results in a normal printable character.
XOtherwise, the character is displayed as an octal number preceded
Xby a backslash.
XThis octal format can be changed by 
Xsetting the LESSBINFMT environment variable
Xto a printf-style format string; the default is '\\%o'.
X
X.SH "PROMPTS"
XThe -P option allows you to tailor the prompt to your preference.
XThe string given to the -P option replaces the specified prompt string.
XCertain characters in the string are interpreted specially.
XThe prompt mechanism is rather complicated to provide flexibility,
Xbut the ordinary user need not understand the details of constructing
Xpersonalized prompt strings.
X.sp
XA percent sign followed by a single character is expanded
Xaccording to what the following character is:
X.IP "%b\fIX\fP"
XReplaced by the byte offset into the current input file.
XThe b is followed by a single character (shown as \fIX\fP above)
Xwhich specifies the line whose byte offset is to be used.
XIf the character is a "t", the byte offset of the top line in the
Xdisplay is used,
Xan "m" means use the middle line,
Xa "b" means use the bottom line,
Xa "B" means use the line just after the bottom line,
Xand a "j" means use the "target" line, as specified by the -j option.
X.IP "%B"
XReplaced by the size of the current input file.
X.IP "%E"
XReplaced by the name of the editor (from the EDITOR environment variable).
XSee the discussion of the LESSEDIT feature below.
X.IP "%f"
XReplaced by the name of the current input file.
X.IP "%i"
XReplaced by the index of the current file in the list of
Xinput files.
X.IP "%l\fIX\fP"
XReplaced by the line number of a line in the input file.
XThe line to be used is determined by the \fIX\fP, as with the %b option.
X.IP "%L"
XReplaced by the line number of the last line in the input file.
X.IP "%m"
XReplaced by the total number of input files.
X.IP "%p\fIX\fP"
XReplaced by the percent into the current input file.
XThe line used is determined by the \fIX\fP as with the %b option.
X.IP "%s"
XSame as %B.
X.IP "%t"
XCauses any trailing spaces to be removed.
XUsually used at the end of the string, but may appear anywhere.
X.IP "%x"
XReplaced by the name of the next input file in the list.
X.PP
XIf any item is unknown (for example, the file size if input
Xis a pipe), a question mark is printed instead.
X.PP
XThe format of the prompt string can be changed
Xdepending on certain conditions.
XA question mark followed by a single character acts like an "IF":
Xdepending on the following character, a condition is evaluated.
XIf the condition is true, any characters following the question mark
Xand condition character, up to a period, are included in the prompt.
XIf the condition is false, such characters are not included.
XA colon appearing between the question mark and the
Xperiod can be used to establish an "ELSE": any characters between
Xthe colon and the period are included in the string if and only if
Xthe IF condition is false.
XCondition characters (which follow a question mark) may be:
X.IP "?a"
XTrue if any characters have been included in the prompt so far.
X.IP "?b\fIX\fP"
XTrue if the byte offset of the specified line is known.
X.IP "?B"
XTrue if the size of current input file is known.
X.IP "?e"
XTrue if at end-of-file.
X.IP "?f"
XTrue if there is an input filename
X(that is, if input is not a pipe).
X.IP "?l\fIX\fP"
XTrue if the line number of the specified line is known.
X.IP "?L"
XTrue if the line number of the last line in the file is known.
X.IP "?m"
XTrue if there is more than one input file.
X.IP "?n"
XTrue if this is the first prompt in a new input file.
X.IP "?p\fIX\fP"
XTrue if the percent into the current input file
Xof the specified line is known.
X.IP "?s"
XSame as "?B".
X.IP "?x"
XTrue if there is a next input file
X(that is, if the current input file is not the last one).
X.PP
XAny characters other than the special ones
X(question mark, colon, period, percent, and backslash)
Xbecome literally part of the prompt.
XAny of the special characters may be included in the prompt literally
Xby preceding it with a backslash.
X.PP
XSome examples:
X.sp
X?f%f:Standard input.
X.sp
XThis prompt prints the filename, if known;
Xotherwise the string "Standard input".
X.sp
X?f%f .?ltLine %lt:?pt%pt\\%:?btByte %bt:-...
X.sp
XThis prompt would print the filename, if known.
XThe filename is followed by the line number, if known,
Xotherwise the percent if known, otherwise the byte offset if known.
XOtherwise, a dash is printed.
XNotice how each question mark has a matching period,
Xand how the % after the %pt
Xis included literally by escaping it with a backslash.
X.sp
X?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t
X.sp
XThis prints the filename if this is the first prompt in a file,
Xfollowed by the "file N of N" message if there is more
Xthan one input file.
XThen, if we are at end-of-file, the string "(END)" is printed
Xfollowed by the name of the next file, if there is one.
XFinally, any trailing spaces are truncated.
XThis is the default prompt.
XFor reference, here are the defaults for
Xthe other two prompts (-m and -M respectively).
XEach is broken into two lines here for readability only.
X.nf
X.sp
X?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.:
X	?pB%pB\\%:byte\ %bB?s/%s...%t
X.sp
X?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltline\ %lt?L/%L.\ :byte\ %bB?s/%s.\ .
X	?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t
X.sp
X.fi
XAnd here is the default message produced by the = command:
X.nf
X.sp
X?f%f\ .?m(file\ %i\ of\ %m)\ .?ltline\ %lt?L/%L.\ .
X	byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t
X.fi
X.PP
XThe prompt expansion features are also used for another purpose:
Xif an environment variable LESSEDIT is defined, it is used
Xas the command to be executed when the v command is invoked.
XThe LESSEDIT string is expanded in the same way as the prompt strings.
XThe default value for LESSEDIT is:
X.nf
X.sp
X	%E\ ?lm+%lm.\ %f
X.sp
X.fi
XNote that this expands to the editor name, followed by a + and the
Xline number, followed by the file name.
XIf your editor does not accept the "+linenumber" syntax, or has other
Xdifferences in invocation syntax, the LESSEDIT variable can be 
Xchanged to modify this default.
X
X.SH "ENVIRONMENT VARIABLES"
X.IP COLUMNS
XSets the number of columns on the screen.
XTakes precedence over the number of columns specified by the TERM variable.
X.IP EDITOR
XThe name of the editor (used for the v command).
X.IP HOME
XName of the user's home directory (used to find a .less file).
X.IP LESS
XFlags which are passed to 
X.I less
Xautomatically.
X.IP LESSBINFMT
XFormat for displaying non-printable, non-control characters.
X.IP LESSCHARDEF
XDefines a character set.
X.IP LESSCHARSET
XSelects a predefined character set.
X.IP LESSEDIT
XEditor prototype string (used for the v command).
XSee discussion under PROMPTS.
X.IP LINES
XSets the number of lines on the screen.
XTakes precedence over the number of lines specified by the TERM variable.
X.IP SHELL
XThe shell used to execute the ! command, as well as to expand filenames.
X.IP TERM
XThe type of terminal on which
X.I less
Xis being run.
X
X.SH "SEE ALSO"
Xlesskey(1)
X
X.SH WARNINGS
XThe = command and prompts (unless changed by -P)
Xreport the line number of the line at the top of the screen,
Xbut the byte and percent of the line at the bottom of the screen.
X.PP
XIf the :e command is used to name more than one file,
Xand one of the named files has been viewed previously,
Xthe new files may be entered into the list in an unexpected order.
X.PP
XThe handling of national character sets is nonstandard as well as
Xinsufficient for multibyte characters.
XIt will probably change in a later release.
END_OF_FILE
echo shar: Extracting \"lesskey.nro\"
sed "s/^X//" >'lesskey.nro' <<'END_OF_FILE'
X.TH LESSKEY 1
X.SH NAME
Xlesskey \- specify key bindings for less
X.SH SYNOPSIS
X.B "lesskey [-o output] [input]"
X.SH DESCRIPTION
X.I Lesskey
Xis used to specify a set of key bindings to be used by 
X.I less.
XThe input file is a text file which describes the key bindings,
Xand the output file is a binary file which is used by 
X.I less.
XIf no input file is specified, standard input is used.
XIf no output file is specified, $HOME/.less is used.
X.PP
XThe input file consists of lines of the form:
X.sp
X	string <whitespace> action [extra-string] <newline>
X.sp
XWhitespace is any sequence of one or more spaces and/or tabs.
XThe "string" is the command key(s) which invoke the action.
XThe string may be a single command key, or a sequence of up to 15 keys.
XThe "action" is the name of the less action, from the list below.
XThe characters in the "string" may appear literally, or be
Xprefixed by a carat to indicate a control key.
XA backslash may be used to cause the following character
Xto be taken literally.
XCharacters which must be preceded by backslash include
Xcarat, space, tab and the backslash itself.
XA backslash followed by one to three octal digits may be used to
Xspecify a character by its octal value.
XBlank lines and lines which start with a pound sign (#) are ignored.
X.PP
XAn action may be followed by an extra string.
XThis string is parsed after the command is entered,
Xjust as if it were entered on the command line.
XThis feature can be used in certain cases to extend
Xthe functionality of a command.
XFor example, these entries would create a pair of commands
Xto turn on/off line numbers using
X.I vi
Xsyntax:
X.sp
X.nf
X	:set\\ nu		toggle-option -N
X	:set\\ nonu	toggle-option +N
X.fi
X.sp
XSee also the ":ta" command in the example below.
X
X.SH EXAMPLE
XThe following input file describes the set of
Xdefault command keys used by less:
X.sp
X.nf
X	r		forw-line 
X	n		forw-line 
X	e		forw-line 
X	j		forw-line 
X	^E		forw-line 
X	^N		forw-line 
X	k		back-line 
X	y		back-line 
X	^Y		back-line 
X	^K		back-line 
X	^P		back-line 
X	J		forw-line-force 
X	K		back-line-force 
X	Y		back-line-force 
X	d		forw-scroll 
X	^D		forw-scroll 
X	u		back-scroll 
X	^U		back-scroll 
X	'		back-scroll 
X	\e40		forw-screen 
X	f		forw-screen 
X	^F		forw-screen 
X	^V		forw-screen 
X	b		back-screen 
X	^B		back-screen 
X	\e33v		back-screen 
X	z		forw-window 
X	w		back-window 
X	F		forw-forever 
X	R		repaint-flush 
X	r		repaint 
X	^R		repaint 
X	^L		repaint 
X	g		goto-line 
X	<		goto-line 
X	\e33<		goto-line 
X	p		percent 
X	%		percent 
X	{		forw-bracket {}
X	}		back-bracket {}
X	(		forw-bracket ()
X	)		back-bracket ()
X	[		forw-bracket []
X	]		back-bracket []
X	\e33^F	forw-bracket 
X	\e33^B	back-bracket 
X	G		goto-end 
X	\e33>		goto-end 
X	>		goto-end 
X	P		goto-end 
X	=		status 
X	^G		status 
X	:f		status 
X	/		forw-search 
X	?		back-search 
X	\e33/		forw-search *
X	\e33?		back-search *
X	n		repeat-search 
X	\e33n		repeat-search-all 
X	N		reverse-search 
X	\e33N		reverse-search-all 
X	m		set-mark 
X	'		goto-mark 
X	^X^X		goto-mark 
X	E		examine 
X	:e		examine 
X	^X^V		examine 
X	:n		next-file 
X	:p		prev-file 
X	:x		index-file 
X	-		toggle-option 
X	:t		toggle-option t
X	s		toggle-option o
X	_		display-option 
X	|		pipe 
X	v		visual 
X	!		shell 
X	+		firstcmd 
X	H		help 
X	h		help 
X	V		version 
X	q		quit 
X	:q		quit 
X	:Q		quit 
X	ZZ		quit 
X	\e33\e33	quit 
X.fi
X.sp
XCommands specified by
X.I lesskey
Xtake precedence over the default commands.
XA default command key may be disabled by including it in the
Xkey file with the action "invalid".
X
X.SH "SEE ALSO"
Xless(1)
END_OF_FILE
echo shar: Extracting \"vecho.c\"
sed "s/^X//" >'vecho.c' <<'END_OF_FILE'
X/*
X * This dumb little program emulates the System V "echo" command,
X * to accommodate BSD systems which don't understand the \c escape,
X * meaning don't echo a newline.  BSD uses "echo -n".
X */
X
X#include <stdio.h>
X
Xint putnl;
X
Xmain(argc, argv)
X	int argc;
X	char *argv[];
X{
X	putnl = 1;
X	while (--argc > 0)
X	{
X		vecho(*++argv);
X		if (argc > 1)
X			putchar(' ');
X	}
X	if (putnl)
X		putchar('\n');
X	exit(0);
X}
X
Xvecho(str)
X	char *str;
X{
X	register char *s;
X
X	for (s = str;  *s != '\0';  s++)
X	{
X		if (*s == '\\' && s[1] == 'c')
X		{
X			putnl = 0;
X			return;
X		}
X		putchar(*s);
X	}
X}
END_OF_FILE
echo shar: Extracting \"mkfuncs.awk\"
sed "s/^X//" >'mkfuncs.awk' <<'END_OF_FILE'
XBEGIN { FS="("; state = 0 }
X
X/^	public/ { ftype = $0; state = 1 }
X
X{ if (state == 1)
X	state = 2
X  else if (state == 2)
X	{ print ftype,$1,"();"; state = 0 }
X}
END_OF_FILE



More information about the Alt.sources mailing list