-/* $OpenBSD: basic.c,v 1.52 2023/03/08 04:43:11 guenther Exp $ */
+/* $OpenBSD: basic.c,v 1.53 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain */
int c, i, col = 0;
char tmp[5];
-
for (i = 0; i < llength(dlp); i++) {
c = lgetc(dlp, i);
- if (c == '\t'
-#ifdef NOTAB
- && !(curbp->b_flag & BFNOTAB)
-#endif
- ) {
+ if (c == '\t') {
col |= 0x07;
col++;
} else if (ISCTRL(c) != FALSE) {
-/* $OpenBSD: cmode.c,v 1.20 2022/12/26 19:16:02 jmc Exp $ */
+/* $OpenBSD: cmode.c,v 1.21 2023/04/17 09:49:04 op Exp $ */
/*
* This file is in the public domain.
*
for (lo = 0; lo < llength(lp); lo++) {
if (!isspace(c = lgetc(lp, lo)))
break;
- if (c == '\t'
-#ifdef NOTAB
- && !(curbp->b_flag & BFNOTAB)
-#endif /* NOTAB */
- ) {
+ if (c == '\t') {
nicol |= 0x07;
}
nicol++;
for (i = 0; i < lo; ++i) {
c = lgetc(lp, i);
- if (c == '\t'
-#ifdef NOTAB
- && !(bp->b_flag & BFNOTAB)
-#endif /* NOTAB */
- ) {
+ if (c == '\t') {
col |= 0x07;
col++;
} else if (ISCTRL(c) != FALSE)
-/* $OpenBSD: def.h,v 1.178 2023/03/30 19:00:02 op Exp $ */
+/* $OpenBSD: def.h,v 1.179 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain. */
#define BFCHG 0x01 /* Changed. */
#define BFBAK 0x02 /* Need to make a backup. */
-#ifdef NOTAB
#define BFNOTAB 0x04 /* no tab mode */
-#endif
#define BFOVERWRITE 0x08 /* overwrite mode */
#define BFREADONLY 0x10 /* read only mode */
#define BFDIRTY 0x20 /* Buffer was modified elsewhere */
/* modes.c X */
int indentmode(int, int);
int fillmode(int, int);
-#ifdef NOTAB
int notabmode(int, int);
-#endif /* NOTAB */
int overwrite_mode(int, int);
int set_default_mode(int,int);
-/* $OpenBSD: display.c,v 1.50 2023/03/08 04:43:11 guenther Exp $ */
+/* $OpenBSD: display.c,v 1.51 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain. */
vp = vscreen[vtrow];
if (vtcol >= ncol)
vp->v_text[ncol - 1] = '$';
- else if (c == '\t'
-#ifdef NOTAB
- && !(curbp->b_flag & BFNOTAB)
-#endif
- ) {
+ else if (c == '\t') {
do {
vtputc(' ');
} while (vtcol < ncol && (vtcol & 0x07) != 0);
vp = vscreen[vtrow];
if (vtcol >= ncol)
vp->v_text[ncol - 1] = '$';
- else if (c == '\t'
-#ifdef NOTAB
- && !(curbp->b_flag & BFNOTAB)
-#endif
- ) {
+ else if (c == '\t') {
do {
vtpute(' ');
} while (((vtcol + lbound) & 0x07) != 0 && vtcol < ncol);
i = 0;
while (i < curwp->w_doto) {
c = lgetc(lp, i++);
- if (c == '\t'
-#ifdef NOTAB
- && !(curbp->b_flag & BFNOTAB)
-#endif
- ) {
+ if (c == '\t') {
curcol |= 0x07;
curcol++;
} else if (ISCTRL(c) != FALSE)
-/* $OpenBSD: funmap.c,v 1.65 2022/12/26 19:16:02 jmc Exp $ */
+/* $OpenBSD: funmap.c,v 1.66 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain */
{enewline, "newline", 1},
{lfindent, "newline-and-indent", 1},
{forwline, "next-line", 1},
-#ifdef NOTAB
{notabmode, "no-tab-mode", 0},
-#endif /* NOTAB */
{notmodified, "not-modified", 0},
{openline, "open-line", 1},
{nextwind, "other-window", 0},
{shellcommand, "shell-command", 1},
{piperegion, "shell-command-on-region", 1},
{shrinkwind, "shrink-window", 1},
-#ifdef NOTAB
{space_to_tabstop, "space-to-tabstop", 0},
-#endif /* NOTAB */
{splitwind, "split-window-vertically", 0},
{definemacro, "start-kbd-macro", 0},
{spawncli, "suspend-emacs", 0},
-/* $OpenBSD: keymap.c,v 1.60 2022/10/20 18:59:24 op Exp $ */
+/* $OpenBSD: keymap.c,v 1.61 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain. */
}
};
-#ifdef NOTAB
static PF notab_tab[] = {
space_to_tabstop /* ^I */
};
}
}
};
-#endif /* NOTAB */
static struct KEYMAPE (1) overwmap = {
0,
static struct maps_s map_table[] = {
{(KEYMAP *) &fillmap, "fill",},
{(KEYMAP *) &indntmap, "indent",},
-#ifdef NOTAB
{(KEYMAP *) ¬abmap, "notab",},
-#endif /* NOTAB */
{(KEYMAP *) &overwmap, "overwrite",},
{(KEYMAP *) &metamap, "esc prefix",},
{(KEYMAP *) &cXmap, "c-x prefix",},
-/* $OpenBSD: match.c,v 1.22 2021/03/01 10:51:14 lum Exp $ */
+/* $OpenBSD: match.c,v 1.23 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain. */
bufo = 0;
for (cp = 0; cp < llength(clp); cp++) {
c = lgetc(clp, cp);
- if (c != '\t'
-#ifdef NOTAB
- || (curbp->b_flag & BFNOTAB)
-#endif
- )
+ if (c != '\t')
if (ISCTRL(c)) {
buf[bufo++] = '^';
buf[bufo++] = CCHR(c);
-.\" $OpenBSD: mg.1,v 1.128 2023/03/29 07:29:17 op Exp $
+.\" $OpenBSD: mg.1,v 1.129 2023/04/17 09:49:04 op Exp $
.\" This file is in the public domain.
.\"
-.Dd $Mdocdate: March 29 2023 $
+.Dd $Mdocdate: April 17 2023 $
.Dt MG 1
.Os
.Sh NAME
Move forward
.Va n
lines.
-.\" .It no-tab-mode
-.\" Toggle notab mode.
-.\" In this mode, spaces are inserted rather than tabs.
+.It no-tab-mode
+Toggle notab mode.
+In this mode, spaces are inserted rather than tabs.
.It not-modified
Turn off the modified flag in the current buffer.
.It open-line
-/* $OpenBSD: modes.c,v 1.21 2017/05/30 07:05:22 florian Exp $ */
+/* $OpenBSD: modes.c,v 1.22 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain. */
return (changemode(f, n, "fill"));
}
-#ifdef NOTAB
int
notabmode(int f, int n)
{
curbp->b_flag ^= BFNOTAB;
return (TRUE);
}
-#endif /* NOTAB */
int
overwrite_mode(int f, int n)
else
defb_flag |= BFOVERWRITE;
}
-#ifdef NOTAB
if (strcmp(modebuf, "notab") == 0) {
if (n <= 0)
defb_flag &= ~BFNOTAB;
else
defb_flag |= BFNOTAB;
}
-#endif /* NOTAB */
return (TRUE);
}
-/* $OpenBSD: paragraph.c,v 1.47 2023/03/08 04:43:11 guenther Exp $ */
+/* $OpenBSD: paragraph.c,v 1.48 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain. */
if (i == curwp->w_doto)
return selfinsert(f, n);
c = lgetc(curwp->w_dotp, i);
- if (c == '\t'
-#ifdef NOTAB
- && !(curbp->b_flag & BFNOTAB)
-#endif
- )
+ if (c == '\t')
col |= 0x07;
else if (ISCTRL(c) != FALSE)
++col;
-/* $OpenBSD: util.c,v 1.45 2023/03/08 04:43:11 guenther Exp $ */
+/* $OpenBSD: util.c,v 1.46 2023/04/17 09:49:04 op Exp $ */
/* This file is in the public domain. */
for (i = 0; i < wp->w_doto; ++i) {
c = lgetc(wp->w_dotp, i);
- if (c == '\t'
-#ifdef NOTAB
- && !(wp->w_bufp->b_flag & BFNOTAB)
-#endif /* NOTAB */
- ) {
+ if (c == '\t') {
col |= 0x07;
col++;
} else if (ISCTRL(c) != FALSE)
return (TRUE);
}
+/*
+ * Raw indent routine. Use spaces and tabs to fill the given number of
+ * cols, but respect no-tab-mode.
+ */
+int
+doindent(int cols)
+{
+ int n;
+ if (curbp->b_flag & BFNOTAB)
+ return (linsert(cols, ' '));
+ if ((n = cols / 8) != 0 && linsert(n, '\t') == FALSE)
+ return (FALSE);
+ if ((n = cols % 8) != 0 && linsert(n, ' ') == FALSE)
+ return (FALSE);
+ return (TRUE);
+}
/*
* Insert a newline, then enough tabs and spaces to duplicate the indentation
++nicol;
}
(void)delwhite(FFRAND, 1);
- if (lnewline() == FALSE || ((
-#ifdef NOTAB
- curbp->b_flag & BFNOTAB) ? linsert(nicol, ' ') == FALSE : (
-#endif /* NOTAB */
- ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE) ||
- ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE)))) {
+
+ if (lnewline() == FALSE || doindent(nicol) == FALSE) {
s = FALSE;
break;
}
int
indent(int f, int n)
{
- int soff, i;
+ int soff;
if (n < 0)
return (FALSE);
/* insert appropriate whitespace */
soff = curwp->w_doto;
(void)gotobol(FFRAND, 1);
- if (
-#ifdef NOTAB
- (curbp->b_flag & BFNOTAB) ? linsert(n, ' ') == FALSE :
-#endif /* NOTAB */
- (((i = n / 8) != 0 && linsert(i, '\t') == FALSE) ||
- ((i = n % 8) != 0 && linsert(i, ' ') == FALSE)))
+ if (doindent(n) == FALSE)
return (FALSE);
forwchar(FFRAND, soff);
return (s);
}
-#ifdef NOTAB
int
space_to_tabstop(int f, int n)
{
return (TRUE);
return (linsert((n << 3) - (curwp->w_doto & 7), ' '));
}
-#endif /* NOTAB */
/*
* Move the dot to the first non-whitespace character of the current line.