1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-19 00:13:33 +00:00

For those of us who prefer vi over vim there are no good options

for editing Python code. This patch (based on one by rokuyama at
rk.phys.keio.ac.jp) that adds the EXPANDTAB option to nvi (defaults
to off) which adds an expandtab option to nvi.

PR:		235446
Approved by:	johans (maintainer timeout, 6 weeks), matthew (mentor, implicit)
This commit is contained in:
Craig Leres 2019-03-21 17:17:48 +00:00
parent da182da5e4
commit e25fd523c5
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=496476
2 changed files with 259 additions and 2 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= nvi
PORTVERSION= 1.81.6
PORTREVISION= 11
PORTREVISION= 12
CATEGORIES= editors
MASTER_SITES= ftp://ftp.stack.nl/pub/users/johans/nvi/
@ -12,9 +12,10 @@ COMMENT= Development snapshot of the world-renown nvi editor
CONFLICTS_INSTALL= nvi-m17n-[0-9]* xnview-[0-9]*
OPTIONS_DEFINE= WIDECHAR
OPTIONS_DEFINE= EXPANDTAB WIDECHAR
OPTIONS_DEFAULT=WIDECHAR
WIDECHAR_DESC= Enable wide-character support (UTF-8)
EXPANDTAB_DESC= Apply the expandtab option patch
WRKSRC= ${WRKDIR}/${DISTNAME}/build.unix
GNU_CONFIGURE= yes
@ -24,6 +25,7 @@ CONFIGURE_ARGS+= --with-db-prefix=${LOCALBASE} \
--program-prefix=n
CONFIGURE_SCRIPT= ../dist/configure
EXPANDTAB_EXTRA_PATCHES= ${PATCHDIR}/extra-patch-expandtab
WIDECHAR_CONFIGURE_ON= --enable-widechar
CPPFLAGS+= -I${BDB_INCLUDE_DIR} -I${LOCALBASE}/include -I${NCURSESINC}

View File

@ -0,0 +1,255 @@
Adapted from:
http://flex.phys.tohoku.ac.jp/~okuyama/nvi-m17n-expandtab.html
http://flex.phys.tohoku.ac.jp/~okuyama/src/nvi-m17n-expandtab.patch
diff -u ../common/options.c.orig ../common/options.c
--- ../common/options.c.orig 2007-11-18 16:41:42.000000000 +0000
+++ ../common/options.c 2019-02-01 23:18:48.173808000 +0000
@@ -78,6 +78,10 @@
{L("edcompatible"),NULL, OPT_0BOOL, 0},
/* O_ESCAPETIME 4.4BSD */
{L("escapetime"), NULL, OPT_NUM, 0},
+#ifdef O_EXPANDTAB
+/* O_EXPANDTAB NetBSD 5.0 */
+ {L("expandtab"), NULL, OPT_0BOOL, 0},
+#endif
/* O_ERRORBELLS 4BSD */
{L("errorbells"), NULL, OPT_0BOOL, 0},
/* O_EXRC System V (undocumented) */
diff -u ../common/options_def.h.orig ../common/options_def.h
--- ../common/options_def.h.orig 2007-11-18 16:43:54.000000000 +0000
+++ ../common/options_def.h 2019-02-01 23:18:48.174244000 +0000
@@ -13,71 +13,72 @@
#define O_TMP_DIRECTORY 11
#define O_EDCOMPATIBLE 12
#define O_ESCAPETIME 13
-#define O_ERRORBELLS 14
-#define O_EXRC 15
-#define O_EXTENDED 16
-#define O_FILEC 17
-#define O_FILEENCODING 18
-#define O_FLASH 19
-#define O_HARDTABS 20
-#define O_ICLOWER 21
-#define O_IGNORECASE 22
-#define O_INPUTENCODING 23
-#define O_KEYTIME 24
-#define O_LEFTRIGHT 25
-#define O_LINES 26
-#define O_LISP 27
-#define O_LIST 28
-#define O_LOCKFILES 29
-#define O_MAGIC 30
-#define O_MATCHTIME 31
-#define O_MESG 32
-#define O_MODELINE 33
-#define O_MSGCAT 34
-#define O_NOPRINT 35
-#define O_NUMBER 36
-#define O_OCTAL 37
-#define O_OPEN 38
-#define O_OPTIMIZE 39
-#define O_PARAGRAPHS 40
-#define O_PATH 41
-#define O_PRINT 42
-#define O_PROMPT 43
-#define O_READONLY 44
-#define O_RECDIR 45
-#define O_REDRAW 46
-#define O_REMAP 47
-#define O_REPORT 48
-#define O_RULER 49
-#define O_SCROLL 50
-#define O_SEARCHINCR 51
-#define O_SECTIONS 52
-#define O_SECURE 53
-#define O_SHELL 54
-#define O_SHELLMETA 55
-#define O_SHIFTWIDTH 56
-#define O_SHOWMATCH 57
-#define O_SHOWMODE 58
-#define O_SIDESCROLL 59
-#define O_SLOWOPEN 60
-#define O_SOURCEANY 61
-#define O_TABSTOP 62
-#define O_TAGLENGTH 63
-#define O_TAGS 64
-#define O_TERM 65
-#define O_TERSE 66
-#define O_TILDEOP 67
-#define O_TIMEOUT 68
-#define O_TTYWERASE 69
-#define O_VERBOSE 70
-#define O_W1200 71
-#define O_W300 72
-#define O_W9600 73
-#define O_WARN 74
-#define O_WINDOW 75
-#define O_WINDOWNAME 76
-#define O_WRAPLEN 77
-#define O_WRAPMARGIN 78
-#define O_WRAPSCAN 79
-#define O_WRITEANY 80
-#define O_OPTIONCOUNT 81
+#define O_EXPANDTAB 14
+#define O_ERRORBELLS 15
+#define O_EXRC 16
+#define O_EXTENDED 17
+#define O_FILEC 18
+#define O_FILEENCODING 19
+#define O_FLASH 20
+#define O_HARDTABS 21
+#define O_ICLOWER 22
+#define O_IGNORECASE 23
+#define O_INPUTENCODING 24
+#define O_KEYTIME 25
+#define O_LEFTRIGHT 26
+#define O_LINES 27
+#define O_LISP 28
+#define O_LIST 29
+#define O_LOCKFILES 30
+#define O_MAGIC 31
+#define O_MATCHTIME 32
+#define O_MESG 33
+#define O_MODELINE 34
+#define O_MSGCAT 35
+#define O_NOPRINT 36
+#define O_NUMBER 37
+#define O_OCTAL 38
+#define O_OPEN 39
+#define O_OPTIMIZE 40
+#define O_PARAGRAPHS 41
+#define O_PATH 42
+#define O_PRINT 43
+#define O_PROMPT 44
+#define O_READONLY 45
+#define O_RECDIR 46
+#define O_REDRAW 47
+#define O_REMAP 48
+#define O_REPORT 49
+#define O_RULER 50
+#define O_SCROLL 51
+#define O_SEARCHINCR 52
+#define O_SECTIONS 53
+#define O_SECURE 54
+#define O_SHELL 55
+#define O_SHELLMETA 56
+#define O_SHIFTWIDTH 57
+#define O_SHOWMATCH 58
+#define O_SHOWMODE 59
+#define O_SIDESCROLL 60
+#define O_SLOWOPEN 61
+#define O_SOURCEANY 62
+#define O_TABSTOP 63
+#define O_TAGLENGTH 64
+#define O_TAGS 65
+#define O_TERM 66
+#define O_TERSE 67
+#define O_TILDEOP 68
+#define O_TIMEOUT 69
+#define O_TTYWERASE 70
+#define O_VERBOSE 71
+#define O_W1200 72
+#define O_W300 73
+#define O_W9600 74
+#define O_WARN 75
+#define O_WINDOW 76
+#define O_WINDOWNAME 77
+#define O_WRAPLEN 78
+#define O_WRAPMARGIN 79
+#define O_WRAPSCAN 80
+#define O_WRITEANY 81
+#define O_OPTIONCOUNT 82
diff -u ../ex/ex_shift.c.orig ../ex/ex_shift.c
--- ../ex/ex_shift.c.orig 2007-11-18 16:41:42.000000000 +0000
+++ ../ex/ex_shift.c 2019-02-02 00:56:44.320820000 +0000
@@ -131,10 +131,19 @@
* Build a new indent string and count the number of
* characters it uses.
*/
+#ifdef O_EXPANDTAB
+/* NetBSD 5.0 */
+ tbp = bp;
+ newidx = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+#endif
for (tbp = bp, newidx = 0;
newcol >= O_VAL(sp, O_TABSTOP); ++newidx) {
*tbp++ = '\t';
newcol -= O_VAL(sp, O_TABSTOP);
+#ifdef O_EXPANDTAB
+ }
+#endif
}
for (; newcol > 0; --newcol, ++newidx)
*tbp++ = ' ';
diff -u ../ex/ex_txt.c.orig ../ex/ex_txt.c
--- ../ex/ex_txt.c.orig 2007-11-18 16:41:42.000000000 +0000
+++ ../ex/ex_txt.c 2019-02-01 23:18:48.174717000 +0000
@@ -403,8 +403,17 @@
*
* Count up spaces/tabs needed to get to the target.
*/
+#ifdef O_EXPANDTAB
+/* NetBSD 5.0 */
+ cno = 0;
+ tabs = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+#endif
for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs)
cno += COL_OFF(cno, ts);
+#ifdef O_EXPANDTAB
+ }
+#endif
spaces = scno - cno;
/* Make sure there's enough room. */
diff -u ../vi/v_txt.c.orig ../vi/v_txt.c
--- ../vi/v_txt.c.orig 2007-11-18 16:41:42.000000000 +0000
+++ ../vi/v_txt.c 2019-02-01 23:18:48.175305000 +0000
@@ -1720,12 +1720,26 @@
* If there are no spaces, or no tabs after spaces and less than
* ts spaces, it's already minimal.
*/
+#ifdef O_EXPANDTAB
+/* NetBSD 5.0 */
+
+ /* Keep analysing if expandtabs is set. */
+ if (!O_ISSET(sp, O_EXPANDTAB))
+#endif
if (!spaces || !tab_after_sp && spaces < ts)
return;
/* Count up spaces/tabs needed to get to the target. */
+#ifdef O_EXPANDTAB
+ cno = 0;
+ tabs = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+#endif
for (cno = 0, tabs = 0; cno + COL_OFF(cno, ts) <= scno; ++tabs)
cno += COL_OFF(cno, ts);
+#ifdef O_EXPANDTAB
+ }
+#endif
spaces = scno - cno;
/*
@@ -1957,9 +1971,17 @@
if (current >= target)
spaces = tabs = 0;
else {
+#ifdef O_EXPANDTAB
+ cno = current;
+ tabs = 0;
+ if (!O_ISSET(sp, O_EXPANDTAB)) {
+#endif
for (cno = current,
tabs = 0; cno + COL_OFF(cno, ts) <= target; ++tabs)
cno += COL_OFF(cno, ts);
+#ifdef O_EXPANDTAB
+ }
+#endif
spaces = target - cno;
}