cdiffs for Jove 4.9 -- C-mode enhancements

Brandon S. Allbery allbery at ncoast.ORG
Tue Mar 14 11:15:05 AEST 1989


[Does anyone know Jon Payne's current email address?  It's considered
courteous to send copies of diffs to the author of the original program; and
the "jpayne at cs.rochester.edu" address had a time limit on it which has
expired.  Thanks in advance.  ++bsa]

The following context diffs to Jon Payne's Jove editor, version 4.9, add
some functionality to C-mode.

The added features are:

(1) The c-indentation-increment is now implemented in auto-indent mode.
(2) When the indent is not a multiple of 8, spaces before an indent are
    automatically converted to tabs.  This is perhaps more stylistic than
    necessary, but I dislike tabstops which are stored as "space-space-space-
    space-tab" when c-indentation-increment is 4 (my usual).
(3) backward-delete-character (C-H) now converts a tab to 8 spaces before
    deleting, so that you don't need to backspace and then tab to back up
    when c-indentation-increment is not 8.  This is only done when the tab
    is part of the line's indentation, never in the middle of a line.

Actually, whenever I say "8" in the above text, the value of physical-tabstop
is used within the patches; I'm not a tab chauvinist.  Also, the changes
only affect C mode; C-H still deletes a tab in e.g. Text mode.

To apply this, cd to your Jove source directory and type "patch < thisfile".
Enjoy!

++Brandon
-------------------------------------------------------------------------------
*** c.c.orig	Sat Feb 25 10:20:38 1989
--- c.c	Fri Feb 24 16:51:02 1989
***************
*** 342,347
  {
  	Bufpos	*bp;
  	int	indent = 0;
  	if (bp = m_paren('}', BACKWARD, NO, YES)) {
  		Bufpos	save;
  

--- 342,352 -----
  {
  	Bufpos	*bp;
  	int	indent = 0;
+ #ifdef BSAHAX
+ 	int	here;
+ 
+ 	here = calc_pos(linebuf, curchar);
+ #endif
  	if (bp = m_paren('}', BACKWARD, NO, YES)) {
  		Bufpos	save;
  
***************
*** 351,356
  		indent = calc_pos(linebuf, curchar);
  		SetDot(&save);
  	}
  	if (incrmt) {
  		if (indent == 0)
  			incrmt = tabstop;

--- 356,366 -----
  		indent = calc_pos(linebuf, curchar);
  		SetDot(&save);
  	}
+ #ifdef BSAHAX
+ 	if (incrmt != 0 && here > indent)
+ 		indent = here;
+ #else
+ 	/* following code seems to undo increment?! */
  	if (incrmt) {
  		if (indent == 0)
  			incrmt = tabstop;
***************
*** 357,362
  		else
  			incrmt = (tabstop - (indent%tabstop));
  	}
  	n_indent(indent + incrmt);
  	return bp;
  }

--- 367,373 -----
  		else
  			incrmt = (tabstop - (indent%tabstop));
  	}
+ #endif
  	n_indent(indent + incrmt);
  	return bp;
  }
*** delete.c.orig	Sat Feb 25 10:21:00 1989
--- delete.c	Sat Feb 25 10:01:25 1989
***************
*** 106,111
  }
  
  /* Delete character backward */
  
  void
  DelPChar()

--- 106,112 -----
  }
  
  /* Delete character backward */
+ /* BSAHAX:  now does an untabify in C-mode.  Perhaps should use c-indent. */
  
  void
  DelPChar()
***************
*** 110,115
  void
  DelPChar()
  {
  	if (MinorMode(OverWrite)) {
  		int	count = min(arg_value(), curchar);
  

--- 111,126 -----
  void
  DelPChar()
  {
+ #ifdef BSAHAX
+ 	if (MajorMode(CMODE) && linebuf[curchar - 1] == '\t' && arg_value() >= 0 && in_indent()) {
+ 		int count = arg_value();
+ 		del_char(BACKWARD, count);
+ 		set_arg_value(tabstop);
+ 		LastKeyStruck = ' ';
+ 		SelfInsert();
+ 		set_arg_value(count);
+ 	}
+ #endif
  	if (MinorMode(OverWrite)) {
  		int	count = min(arg_value(), curchar);
  
*** insert.c.orig	Sat Feb 25 10:22:06 1989
--- insert.c	Sat Feb 25 10:04:16 1989
***************
*** 113,118
  
  	ToIndent();
  	dotcol = calc_pos(linebuf, curchar);
  	if (goal < dotcol) {
  		DelWtSpace();
  		dotcol = 0;

--- 113,120 -----
  
  	ToIndent();
  	dotcol = calc_pos(linebuf, curchar);
+ 	/* always undo current indent, so as to fix tabification */
+ #ifndef BSAHAX
  	if (goal < dotcol) {
  #endif
  		DelWtSpace();
***************
*** 114,119
  	ToIndent();
  	dotcol = calc_pos(linebuf, curchar);
  	if (goal < dotcol) {
  		DelWtSpace();
  		dotcol = 0;
  	}

--- 116,122 -----
  	/* always undo current indent, so as to fix tabification */
  #ifndef BSAHAX
  	if (goal < dotcol) {
+ #endif
  		DelWtSpace();
  		dotcol = 0;
  #ifndef BSAHAX
***************
*** 116,121
  	if (goal < dotcol) {
  		DelWtSpace();
  		dotcol = 0;
  	}
  
  	for (;;) {

--- 119,125 -----
  #endif
  		DelWtSpace();
  		dotcol = 0;
+ #ifndef BSAHAX
  	}
  #endif
  
***************
*** 117,122
  		DelWtSpace();
  		dotcol = 0;
  	}
  
  	for (;;) {
  		incrmt = (tabstop - (dotcol % tabstop));

--- 121,127 -----
  		dotcol = 0;
  #ifndef BSAHAX
  	}
+ #endif
  
  	for (;;) {
  		incrmt = (tabstop - (dotcol % tabstop));
***************
*** 225,230
  		return;
  	}
  #endif
  	if (MajorMode(CMODE) && strlen(linebuf) == 0)
  		(void) c_indent(CIndIncrmt);
  	else

--- 230,238 -----
  		return;
  	}
  #endif
+ #ifdef BSAHAX
+ 	if (MajorMode(CMODE) && in_indent())
+ #else
  	if (MajorMode(CMODE) && strlen(linebuf) == 0)
  #endif
  		(void) c_indent(CIndIncrmt);
***************
*** 226,231
  	}
  #endif
  	if (MajorMode(CMODE) && strlen(linebuf) == 0)
  		(void) c_indent(CIndIncrmt);
  	else
  		SelfInsert();

--- 234,240 -----
  	if (MajorMode(CMODE) && in_indent())
  #else
  	if (MajorMode(CMODE) && strlen(linebuf) == 0)
+ #endif
  		(void) c_indent(CIndIncrmt);
  	else
  		SelfInsert();
***************
*** 761,763
  	return bp;
  }
  #endif /* LISP */

--- 770,785 -----
  	return bp;
  }
  #endif /* LISP */
+ 
+ #ifdef BSAHAX
+ 
+ in_indent() {
+ 	register char *c;
+ 
+ 	for (c = linebuf; *c != '\0'; c++)
+ 		if (*c != ' ' && *c != '\t' && *c != '\f')
+ 			return 0;
+ 	return 1;
+ }
+ 
+ #endif
*** tune.h.orig	Sat Feb 25 10:22:22 1989
--- tune.h	Fri Feb 24 16:18:14 1989
***************
*** 128,133
  #endif
  #endif
  
  #define DFLT_MODE	0666	/* file will be created with this mode */
  
  #ifdef BSD4_3

--- 128,135 -----
  #endif
  #endif
  
+ #define BSAHAX		/* my enhanced C mode */
+ 
  #define DFLT_MODE	0666	/* file will be created with this mode */
  
  #ifdef BSD4_3
-- 
Brandon S. Allbery, moderator of comp.sources.misc	     allbery at ncoast.org
uunet!hal.cwru.edu!ncoast!allbery		    ncoast!allbery at hal.cwru.edu
      Send comp.sources.misc submissions to comp-sources-misc@<backbone>
NCoast Public Access UN*X - (216) 781-6201, 300/1200/2400 baud, login: makeuser



More information about the Comp.sources.bugs mailing list