[comp.sources.d] less v97 edit +linenumber

root@libove.UUCP (Jay M. Libove) (10/01/88)

The recently posted less version 97 differs from its predecessor (I have
version 73) in the way it handles the "v" (edit file) command.

Less v73 would only give to +linenumber argument to the editor if the
editor was vi or ex, but v97 gives it anyway, and in the case of (the
admittedly brain damaged) microemacs (v3.9e) the command "emacs +l f"
edits two files, +l and f, and only starts the display screen with +l
open.

Does anyone have a fix for this? (or know what file I should hack
through?) Thanks-

-- 
Jay Libove		ARPA:	jl42@andrew.cmu.edu or libove@cs.cmu.edu
5731 Centre Ave, Apt 3	BITnet:	jl42@andrew or jl42@drycas
Pittsburgh, PA 15206	UUCP:	uunet!nfsun!libove!libove or
(412) 362-8983		UUCP:	psuvax1!pitt!darth!libove!libove

DMasterson@cup.portal.com (10/05/88)

>Less v73 would only give to +linenumber argument to the editor if the
>editor was vi or ex, but v97 gives it anyway, and in the case of (the
>admittedly brain damaged) microemacs (v3.9e) the command "emacs +l f"
>edits two files, +l and f, and only starts the display screen with +l
>open.
>
>Does anyone have a fix for this? (or know what file I should hack
>through?) Thanks-
>
The simple fix is to build a shell script front end to emacs that converts
the '+1' argument into a '-g1' argument and then execs the real emacs.  It
slows it down a little, but not that much.  Benefit is that you get less
interfaced to emacs just like it would be to vi.

The long fix is to check the linenumber code within less and convert the
sprintf function that builds the command that less will execute to start
up the editor (grep for 'system(' in the .c files).  Have it check the name
of the editor and construct the system() string appropriately.

Alternatively, you could modify the main() routine in microemacs to accept
a '+' argument as well as '-' arguments.  Not exactly straightforward, but
not too hard.

Recommend going with the first idea, even if you have to right a small program
to do it.  It's probably the quickest.

David Masterson
DMasterson@cup.portal.com

steve@lucifer.UUCP (Steve Goodwin) (10/05/88)

In article <159@libove.UUCP> root@libove.UUCP (Jay M. Libove) writes:
>
>The recently posted less version 97 differs from its predecessor (I have
>version 73) in the way it handles the "v" (edit file) command.
>
>Less v73 would only give to +linenumber argument to the editor if the
>editor was vi or ex, but v97 gives it anyway, and in the case of (the
>admittedly brain damaged) microemacs (v3.9e) the command "emacs +l f"
>edits two files, +l and f, and only starts the display screen with +l
>open.
>
>...............

I had a similar problem, you need to patch command.c in the
vicinity of line 715.
Put in a bit of code to check whether EDITOR is vi or ex (or
whatever) and select the relevant editor-calling routine.


-----------------------------------------------------------------------------
|  Steve Goodwin                                                            |
|  Electronic Control Group,                                                |
|  Lucas Diesel Systems, Phoenix Way, Cirencester, Glos. GL7 1QG  U.K.      |
|  Tel: (44) 285 67981   Fax: (44) 285 68258   Twx: 43561                   |
|                                                                           |
|  steve@lucifer.UUCP or ..!ukc!lucifer!steve (depending on the             |
|  peculiarities of you or your mailer).                                    |
|                                                                           |
-----------------------------------------------------------------------------

woods@gpu.utcs.toronto.edu (Greg Woods) (10/07/88)

In article <9755@cup.portal.com> DMasterson@cup.portal.com writes:
> [ DMasterson@cup.portal.com didn't include the attribution line. ]
>> [ Discussion about MicroEMACS 3.9 not handling '+LINE' args, which
>>   also admits that MicroEMACS is brain-damaged. ]
> [ Three appropriate solutions to the problem. ]

Might I suggest a third?  Why not dump MicroEMACS, which you consider
brain-damaged in the first place?

I use Jove4.9a, which handles the '+LINE' syntax quite well.  It does
lots of other things too, including acting as a flexible and powerful,
not to mention robust, text editor.  If I remember right, Jove4.7 did
require '-LINE', but that's all behind us :-).

Every (Unix) editor worthy of placement in $EDITOR (and/or $VISUAL)
should understand (as a subset possibly) the set of vi options.
-- 
						Greg Woods.

UUCP: utgpu!woods, utgpu!{ontmoh, ontmoh!ixpierre}!woods, tmsoft!ixpierre!woods
VOICE: (416) 443-1734 [h]		LOCATION: Toronto, Ontario, Canada

jim@eda.com (Jim Budler) (10/10/88)

In article <9755@cup.portal.com> DMasterson@cup.portal.com writes:
||Less v73 would only give to +linenumber argument to the editor if the
||editor was vi or ex, but v97 gives it anyway, and in the case of (the
||admittedly brain damaged) microemacs (v3.9e) the command "emacs +l f"
||edits two files, +l and f, and only starts the display screen with +l
||open.
||
||Does anyone have a fix for this? (or know what file I should hack
||through?) Thanks-
||
|The simple fix is to build a shell script front end to emacs that converts
|the '+1' argument into a '-g1' argument and then execs the real emacs.  It
|slows it down a little, but not that much.  Benefit is that you get less
|interfaced to emacs just like it would be to vi.

|David Masterson
|DMasterson@cup.portal.com

I did this in a very fast quick and dirty way, and I am sure I will
be told many, many things which are wrong about the following script,
but it fixes the problem.
--------------------- <cut here> -----------------------
: This is a shar archive.  Extract with sh, not csh.
: The rest of this file will extract:
: em
echo extracting - em
sed 's/^X//' > em << '!EOR!'
X#! /bin/sh
Xif [ $# -gt 1 ];then
Xgoto=$1
Xcase "$1" in
X	+*) goto=`echo "$1" | sed s/+/-g/` ;;
Xesac
Xexec /usr/local/bin/em.exe $goto $2 $3 $4 $5 $6 $7 $8 $9
Xelse
Xexec /usr/local/bin/em.exe $1
Xfi
!EOR!
exit
-- 
uucp:     {decwrl,uunet}!eda!jim        Jim Budler
internet: jim@eda.com                   EDA Systems, Inc.

news@investor.UUCP ( Bob Peirce) (10/16/88)

In article <31@lucifer.UUCP> steve@lucifer.UUCP (Steve Goodwin) writes:
>In article <159@libove.UUCP> root@libove.UUCP (Jay M. Libove) writes:
>>
>>The recently posted less version 97 differs from its predecessor (I have
>>version 73) in the way it handles the "v" (edit file) command.
>>
>>Less v73 would only give to +linenumber argument to the editor if the
>>editor was vi or ex, but v97 gives it anyway, and in the case of (the
>>admittedly brain damaged) microemacs (v3.9e) the command "emacs +l f"
>>edits two files, +l and f, and only starts the display screen with +l
>>open.
>>
>>...............
>
>I had a similar problem, you need to patch command.c in the
>vicinity of line 715.
>Put in a bit of code to check whether EDITOR is vi or ex (or
>whatever) and select the relevant editor-calling routine.

Actually, the better thing to do is to modify uEmacs to use +line.
I haven't installed 3.9e yet, but my older version of 3.9 has been
modified to work with many programs that try to start up at a line
number.  I can't get to the source to check what I did right now,
but it was in main where you are checking the command line.

-- 
Bob Peirce, Pittsburgh, PA				 412-471-5320
uucp: ...!{allegra, bellcore, cadre, idis, psuvax1}!pitt!investor!rbp
	    NOTE:  Mail must be < 30K  bytes/message