[comp.sources.bugs] jove 4.9

cudcv@warwick.ac.uk (Rob McMahon) (09/10/88)

Jove on a terminal which uses magic cookie type standout has the interesting
side effect of alternating the screen between normal and reverse video every
thirty seconds---disconcerting for the first time user ... it's not at all
careful about where it puts its magic cookies, and doesn't take them into
account when it's working out where it is on the screen.  This patch to disp.c
seems to fix it ok:

RCS file: disp.c,v
retrieving revision 1.1
diff -c -r1.1 disp.c
*** /tmp/,RCSt1a01844	Sat Sep 10 11:43:50 1988
--- disp.c	Thu Aug 25 17:27:00 1988
***************
*** 902,908 ****
  ModeLine(w)
  register Window	*w;
  {
! 	extern int	i_line;
  	extern char	*pwd();
  	int	n,
  		ign_some = NO;
--- 902,909 ----
  ModeLine(w)
  register Window	*w;
  {
! 	extern int	i_line, i_col, CapCol;
! 	extern char	*cursor;
  	extern char	*pwd();
  	int	n,
  		ign_some = NO;
***************
*** 1120,1141 ****
  		if (IN_INSmode)
  			INSmode(0);
  #endif
  #ifdef TERMCAP
  		putpad(SO, 1);
  #else 
  		SO_on();
  #endif /* TERMCAP */
  	}
  	if (swrite(line, BriteMode, YES))
  		do_cl_eol(i_line);
  	else
  		UpdModLine = 1;
! 	if (BriteMode)
  #ifdef TERMCAP
  		putpad(SE, 1);
  #else 
  		SO_off();
  #endif /* TERMCAP */
  }
  
  /* This tries to place the current line of the current window in the
--- 1121,1151 ----
  		if (IN_INSmode)
  			INSmode(0);
  #endif
+ 		Placur(i_line, i_col);
  #ifdef TERMCAP
  		putpad(SO, 1);
  #else 
  		SO_on();
  #endif /* TERMCAP */
+ 		i_col += SG;
+ 		CapCol += SG;
+ 		cursor += SG;
  	}
  	if (swrite(line, BriteMode, YES))
  		do_cl_eol(i_line);
  	else
  		UpdModLine = 1;
! 	if (BriteMode) {
! 	        Placur(i_line, i_col);
  #ifdef TERMCAP
  		putpad(SE, 1);
  #else 
  		SO_off();
  #endif /* TERMCAP */
+ 		i_col += SG;
+ 		CapCol += SG;
+ 		cursor += SG;
+ 	}
  }
  
  /* This tries to place the current line of the current window in the


-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/10/88)

Under MSDOS, under certain circumstances using describe-command or
describe-bindings can leave jove in a state where it echoes the wrong
characters.  E.g. C-x ? C-p will report that Alt-Q is bound to previous-line.
The routines that go hunting for keys (describe-bindings, or describe-command
when it is looking to see how to access a command), can leave specialmap
turned on.  This patch to extend.c seems to fix the problem:

RCS file: extend.c,v
retrieving revision 1.1
diff -c -r1.1 extend.c
*** /tmp/,RCSt1a01895	Sat Sep 10 11:53:21 1988
--- extend.c	Sat Sep 10 11:17:12 1988
***************
*** 361,366 ****
--- 361,367 ----
  	data_obj	**prefp;
  
  #ifdef IBMPC
+ 	int oldspecialmap = specialmap;
  	specialmap = (map == miscmap);
  #endif
  
***************
*** 383,388 ****
--- 384,392 ----
  		else
  			Typeout("%-18s%s", keydescbuf, map[c1]->Name);
  	}
+ #ifdef IBMPC
+ 	specialmap = oldspecialmap;
+ #endif
  }
  
  private void
***************
*** 413,418 ****
--- 417,423 ----
  	data_obj	**prefp;
  
  #ifdef IBMPC
+ 	int oldspecialmap = specialmap;
  	specialmap = (map == miscmap);
  #endif	
  
***************
*** 445,450 ****
--- 450,458 ----
  		}
  		bufp += strlen(bufp);
  	}
+ #ifdef IBMPC
+ 	specialmap = oldspecialmap;
+ #endif
  }
  
  void
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/10/88)

Jove declares an unsigned int, assigns the return value from read to it,
and then compares it against -1.  There are machines (e.g. the Gould)
where this will never be true, and since read returns an int delcaring
this variable as unsigned seems odd in the first place.

RCS file: iproc-ptys.c,v
retrieving revision 1.1
diff -c -r1.1 iproc-ptys.c
*** /tmp/,RCSt1a01956	Sat Sep 10 12:02:15 1988
--- iproc-ptys.c	Sat Sep 10 12:01:52 1988
***************
*** 90,96 ****
  register int	fd;
  {
  	register Process	*p;
! 	unsigned int	n;
  	char	ibuf[1024];
  
  	for (p = procs; p != 0; p = p->p_next)
--- 90,96 ----
  register int	fd;
  {
  	register Process	*p;
! 	register int	n;
  	char	ibuf[1024];
  
  	for (p = procs; p != 0; p = p->p_next)
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/10/88)

The filter-region command in jove uses mktemp("...") which dumps core when
compiled with GCC or any compiler that puts strings in read-only memory.  Fix:

RCS file: proc.c,v
retrieving revision 1.1
diff -c -r1.1 proc.c
*** /tmp/,RCSt1a02006	Sat Sep 10 12:07:58 1988
--- proc.c	Sat Sep 10 11:24:22 1988
***************
*** 748,754 ****
  {
  	Mark	*m = CurMark();
  #ifndef MSDOS
! 	char	*tname = mktemp("/tmp/jfilterXXXXXX"),
  		combuf[128];
  #endif /* MSDOS */
  	Window	*save_wind = curwind;
--- 748,755 ----
  {
  	Mark	*m = CurMark();
  #ifndef MSDOS
! 	static char	tnambuf[20];
! 	char	*tname,
  		combuf[128];
  #endif /* MSDOS */
  	Window	*save_wind = curwind;
***************
*** 760,765 ****
--- 761,768 ----
  	File	*fp;
  
  #ifndef MSDOS
+ 	strcpy (tnambuf, "/tmp/jfilterXXXXXX");
+ 	tname = mktemp(tnambuf);
  	fp = open_file(tname, iobuff, F_WRITE, COMPLAIN, QUIET);
  #else /* MSDOS */
  	p0 = openforpipe();
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/10/88)

I hesitate to call this a bug, because the code is so deliberate.  If anyone
can justify this for me, I'd love to hear from them.  Turning off
match-regular-expressions doesn't turn off all the magic characters, which
certainly surprised people round here when they tried to search for a string
containing a `$'.  The code in question, however, explicitly only disables
".[*", leaving ^, $, \{, \}, \(, \), \|, \digit, \<, \> enabled ?  I can
almost understand the \? constructs, people who use Unix learn that \ is
magic, but ^ and $ ?  Anyway, here's my current fix, I'd like to hear your
opinion.

RCS file: re.c,v
retrieving revision 1.1
diff -c -r1.1 re.c
*** /tmp/,RCSt1a02049	Sat Sep 10 12:14:34 1988
--- re.c	Sat Sep 10 11:25:17 1988
***************
*** 153,159 ****
  		if (c != '*')
  			last_p = comp_p;
  
! 		if (kind == NORM && index(".[*", c) != 0)
  			goto defchar;
  		switch (c) {
  		case '\\':
--- 153,159 ----
  		if (c != '*')
  			last_p = comp_p;
  
! 		if (kind == NORM)
  			goto defchar;
  		switch (c) {
  		case '\\':

-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/10/88)

Termcap (at least on Suns) supports a km: "I've got a meta-key" entry, which
is easy to add to jove, and makes life easier.

RCS file: term.c,v
retrieving revision 1.1
diff -c -r1.1 term.c
*** /tmp/,RCSt1a02098	Sat Sep 10 12:54:56 1988
--- term.c	Sat Sep 10 11:26:51 1988
***************
*** 201,206 ****
--- 201,209 ----
  	if (BL == 0)
  		BL = "\007";
  
+ 	if (tgetflag("km") > 0)	/* has meta-key */
+ 		MetaKey = 1;
+ 
  #ifdef ID_CHAR
  	disp_opt_init();
  #endif

-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/10/88)

Televideo terminals and some others (e.g. the Newbury's round here) have a
FUNCT key which sends `^Ax\r' if held down while pressing `x'.  This little
function allows you to use this as a meta-key if you bind tvi-function-key to
C-a.  (Of course you'll want to bind beginning-of-line somewhere else, like
ESC C-a.)

RCS file: misc.c,v
retrieving revision 1.1
diff -c -r1.1 misc.c
*** /tmp/,RCSt1a02142	Sat Sep 10 13:06:44 1988
--- misc.c	Sat Sep 10 11:19:49 1988
***************
*** 312,317 ****
--- 312,331 ----
    	SetLine(newline);
  }
  
+ void
+ TVIFunc()
+ {
+ 	int cmd, c;
+ 
+ 	cmd = getch();
+ 	if ((c = getch()) != '\r') {
+ 		Ungetc(c);	/* Oops, wasn't ^A x \r after all. */
+ 		complain("[Bad function sequence]");
+ 	}
+ 	Ungetc(cmd);
+ 	HandlePref(pref1map);	/* like ESC x */
+ }
+ 
  #ifdef ANSICODES
  void
  MoveToCursor(line, col)

RCS file: funcdefs.c,v
retrieving revision 1.1
diff -c -r1.1 funcdefs.c
*** /tmp/,RCSt1a02148	Sat Sep 10 13:07:27 1988
--- funcdefs.c	Sat Sep 10 11:18:06 1988
***************
*** 203,208 ****
--- 203,209 ----
  	StrLength(),
  	TransChar(),
  	TransLines(),
+ 	TVIFunc(),
  	SaveFile(),
  	WtModBuf(),
  	WriteFile(),
***************
*** 565,570 ****
--- 566,572 ----
  	DefMajor(TEXT), "text-mode", WIRED_CMD(0),
  	FUNCTION, "transpose-characters", WIRED_CMD(TransChar),
  	FUNCTION, "transpose-lines", WIRED_CMD(TransLines),
+ 	FUNCTION, "tvi-function-key", WIRED_CMD(TVIFunc),
  	FUNCTION, "unbind-key", WIRED_CMD(UnbindC),
  	FUNCTION, "version", WIRED_CMD(ShowVersion),
  	FUNCTION, "visible-spaces-in-window", WIRED_CMD(WVisSpace),
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/12/88)

Try this experiment in teachjove.  Go to the beginning of the paragraph after
the table of alternatives to query-replace-string.  Do a query-replace of edit
by edt, say.  At the first match type C-w, then C-x C-c without making any
more changes, the word appears to have been deleted.  At the next match just
hit return to leave query-replace.  Now type C-l C-l (or try to insert
something near the beginning of the line where the word was deleted), the
deleted word re-appears.  This patch to re1.c appears to fix the problem.

RCS file: re1.c,v
retrieving revision 1.1
diff -c -r1.1 re1.c
*** /tmp/,RCSt1a03758	Mon Sep 12 12:47:01 1988
--- re1.c	Mon Sep 12 12:37:38 1988
***************
*** 93,98 ****
--- 93,99 ----
  				case CTL('W'):
  					re_dosub(linebuf, YES);
  					numdone += 1;
+ 					modify();
  					offset = curchar = REbom;
  					makedirty(curline);
  					/* Fall into ... */
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/12/88)

In query-replace-string, if there is nothing to undo, C-u skips the current
replacement.  A more friendly action would seem to be to ring the bell, and
let you have another go at this one:  (your line numbers will vary)

RCS file: re1.c,v
retrieving revision 1.2
diff -c -r1.2 re1.c
*** /tmp/,RCSt1a03827	Mon Sep 12 13:06:59 1988
--- re1.c	Mon Sep 12 12:52:08 1988
***************
*** 107,114 ****
  
  				case CTL('U'):
  				case 'U':
! 					if (UNDO_lp == 0)
! 						continue;
  					lp = UNDO_lp;
  					lp->l_dline = UNDO_da | DIRTY;
  					offset = 0;
--- 109,118 ----
  
  				case CTL('U'):
  				case 'U':
! 					if (UNDO_lp == 0) {
! 						rbell();
! 						goto reswitch;
! 					}
  					lp = UNDO_lp;
  					lp->l_dline = UNDO_da | DIRTY;
  					offset = 0;

-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England

cudcv@warwick.ac.uk (Rob McMahon) (09/12/88)

(I hope people don't get the impression that I don't like jove, I think it's a
fine replacement for "real" emacs (GNU emacs) where that is unusable because
of its size.  This string of articles is me tidying up the rough edges before
I let people loose on it.  It's a string of articles so that people can pick
and choose about what patches they want to take.)

In query-replace-string, C-w is undoable by C-u if you don't change more than
the single line that contained the match.  It gets it a bit wrong if you
change more than this, so you might treat this change with a bit of suspicion.
I think it's useful in spite of that.  (I've applied the patch to fix C-w not
deleting before this.)

RCS file: re1.c,v
retrieving revision 1.2
diff -c -r1.2 re1.c
*** /tmp/,RCSt1a03880	Mon Sep 12 13:17:57 1988
--- re1.c	Mon Sep 12 12:52:08 1988
***************
*** 96,101 ****
--- 96,103 ----
  					modify();
  					offset = curchar = REbom;
  					makedirty(curline);
+ 					UNDO_da = curline->l_dline;
+ 					UNDO_lp = curline;
  					/* Fall into ... */
  
  				case CTL('R'):
-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv@uk.ac.warwick             ARPA:   cudcv@warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England