[comp.unix.questions] The CR in a map via .exrc: A new question

schaefer@ogcvax.UUCP (Barton E. Schaefer) (03/24/88)

I suppose it had to happen eventually.  I've been able to figure out
solutions for nearly all the vi map problems posted here, but the one I
tried today has got me stumped.  Does anybody know how to include a
control-D character in a map or map! in a ".exrc" file?

Following is what I want to create.  I have no problem doing this with
:map! once I am already in vi, but I can't get it to fly in a ".exrc".  I
want to map! control-B to the sequence "carat control-D control-T" as in
	map! ^B ^^D^T
(miscellaneous control-Vs left out of the above for clarity).  This
should mean "remember the current position for autoindent, but go left to
column zero and then right one shiftwidth".  What I get, with every
sensible escaping sequence, is "carat control-T".

In experimenting with this I discovered that attempting to map or map!
control-D to anything invariably results first in "Missing rhs" and then
in vi crashing with "Input read error".  Again, there are no problems with
doing any of this from inside vi.

In case it's relevant, below is the output of ":se all" for the vi I'm
running right now.  Note that I do not have "beautify" or "edcompatible"
set.  Version is 3.7, dated 6/7/85, under Mt. Xinu 4.3 BSD + Sun 3.2 NFS.

autoindent              nonumber                        noslowopen
autoprint               open                            nosourceany
noautowrite             nooptimize                      tabstop=8
nobeautify              paragraphs=IPLPPPQPP LIpplpipbp taglength=0
directory=/tmp          prompt                          tags=tags /usr/lib/tags
noedcompatible          noreadonly                      term=vt100
noerrorbells            redraw                          noterse
hardtabs=8              remap                           timeout
noignorecase            report=0                        ttytype=vt100
nolisp                  scroll=11                       warn
nolist                  sections=NHSHH HUnhsh           window=23
nomagic                 shell=/bin/csh                  nowrapscan
nomesg                  shiftwidth=4                    wrapmargin=1
nomodeline              showmatch                       nowriteany

Thanks in advance ....

-- 
Bart Schaefer			CSNET:	schaefer@cse.ogc.edu
				UUCP:	...{tektronix,verdix}!ogcvax!schaefer
"You can lead a yak to water, but you can't teach an old dog to make a silk
purse out of a pig in a poke."			-- Opus

chris@mimsy.UUCP (Chris Torek) (03/27/88)

In article <1598@ogcvax.UUCP> schaefer@ogcvax.UUCP (Barton E. Schaefer) writes:
>I suppose it had to happen eventually.  I've been able to figure out
>solutions for nearly all the vi map problems posted here, but the one I
>tried today has got me stumped.  Does anybody know how to include a
>control-D character in a map or map! in a ".exrc" file?

Looking at the source, the answer I find is that it cannot be done.
The culprit is the `getchar' routine, which reads (in part)

	do
		c = getcd();
	while (!globp && c == CTRL('d'));

Probably a minimal change to fix it would be

	do
		c = getcd();
	while (!globp && intty && c == CTRL('d'));

(see /usr/src/ucb/ex/ex_get.c and /usr/src/ucb/ex/ex_io.c.)  `map' and
`map!' in ex mode would still fail, but :map and :map! in open or
visual would continue to work (those work by stuffing the command into
a buffer and making globp point at it).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

irf@kuling.UUCP (Bo Thide) (04/02/88)

In article <10816@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes:
>In article <1598@ogcvax.UUCP> schaefer@ogcvax.UUCP (Barton E. Schaefer) writes:
>>I suppose it had to happen eventually.  I've been able to figure out
>
>Looking at the source, the answer I find is that it cannot be done.

There are ways you can map (or map!) CTRL-D to something useful.  Look at
my vi macro packages 'evi' ("The Expert's vi or The Emacs Style vi")
and 'lvi' ("Learner's vi").

If you don't have 'evi' or 'lvi', please contact me by e-mail and
I'll send the packages to you.  As soon as I have got rid of the
terrible flu I have and I am done with the extremely urgent sampling
hardware/software integration that has to be finished by the end of
this month, I will post newer and better versions.

"If EMACS is a big, heavy Rolls-Royce, VI is a small fast English
sports car".

I love English sports cars.

-Bo
-- 
>>> Bo Thide', Swedish Institute of Space Physics, S-755 90 Uppsala, Sweden <<<  Phone (+46) 18-300020.  Telex: 76036 (IRFUPP S).  UUCP: ..enea!kuling!irfu!bt

seth@violin.columbia.edu (Seth Robertson) (04/04/88)

In article <690@kuling.UUCP> irf@kuling.UUCP (Bo Thide) writes:
>
>"If EMACS is a big, heavy Rolls-Royce, VI is a small fast English
>sports car".
>
>I love English sports cars.
>-Bo

English sports cars are, however, very prone to breakdowns and malfunctions,
and so spend most of their time in the shop.  Rolls-Royces, however, are
built for comfort, so can cruise past the broken down sports cars. :=)

					-seth

-------------------------------------------------------------------------------
**    Seth Robertson a.k.a Earendur Ranger 27th Lord of Andunie in Numenor   **
**    Center for Telecommunications Research at Columbia University          **
** ------------------------------------------------------------------------- **
**    Columbia University & CTR aren't saying if they have any opinions...   **
** ------------------------------------------------------------------------- **
**    seth@sirius.ctr.columbia.edu                  sjr@cunixc.columbia.edu  **
**    !uunet!columbia!sirius.ctr.columbia!seth    rjs!cxinuc!aibmuloc!tenuu! **
**    706 John Jay; Columbia University; NYC 10027           (212) 280-6107  **
-------------------------------------------------------------------------------


-------------------------------------------------------------------------------
**    Seth Robertson                             || aka Earendur Ranger 20th **
**    Center for Telecommunications Research     || CTR Staff!!!!            **
** --------------------------------------------- || ------------------------ **
**   INTERnet                                    ||                          **
**    seth@earth.ctr.columbia.edu                || "SILENCE!  Your constant **
**    sjr@cunixc.columbia.edu                    ||  chatter   is   draining **
**   BITnet                                      ||  my circuits!"           **
**    sjr@cunixc.columbia.edu                    ||                          **
**    sjr%cunixc@columbia.edu                    ||                          **
**   USEnet                                      ||                          **
**    ...!uunet!columbia!earth.ctr.columbia!seth || CTR and Columbia  hardly **
**    ...!uunet!columbia!cunixc!sjr              || want  me,  let  alone my **
**   NYNEX                                       || opinions                 **
**    (212) 280-6107                             ||                          **
-------------------------------------------------------------------------------