aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-01-17 14:28:13 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2018-01-17 14:28:13 -0800
commit31a16c0ccab9a4b69c79920244b9c623bee7bffe (patch)
treee40c375a5191a36e24bf5e4408e2edba440ab012
parent8841922689769960fa074fbb053cb8507f2f3ed9 (diff)
parent59df78a7806764586e084eafd0842f43a741037a (diff)
downloaduemacs-31a16c0ccab9a4b69c79920244b9c623bee7bffe.tar.gz
Merge branch 'experimental'
I'm not entirely happy with the new paragraph heuristics, but I've been using them for a while and have grown used to them and have grown to rely on the behavior. Since there probably aren't all that many other people who use uemacs, let's just merge that behavior and see if anybody else even notices. The "NBSP to SP on keyboard input" is similarly convenient to me, and might be offensive to others. Let's see. * experimental: Turn NBSP into regular SP on input Try updated rule for "is new paragraph" Make some minor code legibility changes
-rw-r--r--basic.c51
-rw-r--r--posix.c3
2 files changed, 31 insertions, 23 deletions
diff --git a/basic.c b/basic.c
index 5071047..010288c 100644
--- a/basic.c
+++ b/basic.c
@@ -270,6 +270,28 @@ int backline(int f, int n)
}
#if WORDPRO
+static int is_new_para(void)
+{
+ int i, len;
+
+ len = llength(curwp->w_dotp);
+
+ for (i = 0; i < len; i++) {
+ int c = lgetc(curwp->w_dotp, i);
+ if (c == ' ' || c == TAB) {
+#if PKCODE
+ if (justflag)
+ continue;
+#endif
+ return 1;
+ }
+ if (!isletter(c))
+ return 1;
+ return 0;
+ }
+ return 1;
+}
+
/*
* go back to the beginning of the current paragraph
* here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
@@ -294,19 +316,11 @@ int gotobop(int f, int n)
/* and scan back until we hit a <NL><NL> or <NL><TAB>
or a <NL><SPACE> */
- while (lback(curwp->w_dotp) != curbp->b_linep)
- if (llength(curwp->w_dotp) != 0 &&
-#if PKCODE
- ((justflag == TRUE) ||
-#endif
- (lgetc(curwp->w_dotp, curwp->w_doto) != TAB &&
- lgetc(curwp->w_dotp, curwp->w_doto) != ' '))
-#if PKCODE
- )
-#endif
- curwp->w_dotp = lback(curwp->w_dotp);
- else
+ while (lback(curwp->w_dotp) != curbp->b_linep) {
+ if (is_new_para())
break;
+ curwp->w_dotp = lback(curwp->w_dotp);
+ }
/* and then forward until we are in a word */
suc = forwchar(FALSE, 1);
@@ -343,18 +357,9 @@ int gotoeop(int f, int n)
/* and scan forword until we hit a <NL><NL> or <NL><TAB>
or a <NL><SPACE> */
while (curwp->w_dotp != curbp->b_linep) {
- if (llength(curwp->w_dotp) != 0 &&
-#if PKCODE
- ((justflag == TRUE) ||
-#endif
- (lgetc(curwp->w_dotp, curwp->w_doto) != TAB &&
- lgetc(curwp->w_dotp, curwp->w_doto) != ' '))
-#if PKCODE
- )
-#endif
- curwp->w_dotp = lforw(curwp->w_dotp);
- else
+ if (is_new_para())
break;
+ curwp->w_dotp = lforw(curwp->w_dotp);
}
/* and then backward until we are in a word */
diff --git a/posix.c b/posix.c
index 97edd9f..74ba7b9 100644
--- a/posix.c
+++ b/posix.c
@@ -213,6 +213,9 @@ int ttgetc(void)
}
bytes = utf8_to_unicode(buffer, 0, pending, &c);
+ /* Hackety hack! Turn no-break space into regular space */
+ if (c == 0xa0)
+ c = ' ';
done:
pending -= bytes;
memmove(buffer, buffer+bytes, pending);