jonmacs / jove

Jonathan's Own Version of Emacs : a venerable (1983?), fast, small Emacs clone that was originally written for 2.8BSD on PDP-11. Some of us have been using and contributing to it since 1986.
Other
73 stars 6 forks source link

FreeBSD can't search #1

Closed bsdimp closed 4 years ago

bsdimp commented 4 years ago

^S to search doesn't work on FreeBSD.

stty raw ; jjove

however allows it to work. This indicates there's likely a bug in making the terminal raw.

make SYSDEFS="-DBSDPOSIX_STDC -DUSE_OPENPTY -DHAVE_LIBUTIL_H" EXTRALIBS=-lutil

is how I built it.

markmoraes commented 4 years ago

What version of jove are you running or did you build? (the master branch?) and what version of FreeBSD?

Would you be willing to try the head of the moraes branch (a proposed release candidate with a variety of small fixes)? That works on FreeBSD 12.1 for me (I start it up, run the sequence "^X ! ls" in the local directory, switch to the start of the buffer with the results using "^X o ESC <" and then use "^S xj RETURN" to find the xjove executable at the end.

Thanks.

markmoraes commented 4 years ago

Hmm, while ^S in moraes HEAD works on FreeBSD 12.1 and OpenBSD 6.6 (and various Linux), the problem you describe shows up in NetBSD 7.2 and 8.1 so it's still in there, will look at the termio* maze and see what I can find. (It would still be interesting/useful to know if it works or is broken under your FreeBSD environment, but not necessary since I can now repro it)

markmoraes commented 4 years ago

What is the TERM environment variable on your FreeBSD? I'm betting it is vt100, and that it changed to xterm in some more recent FreeBSD (12.1 has xterm, at least for the console in virtualbox)

TERM=vt102 jove should work for ^S (or any other TERM value other than vt100, e.g. vt220 on OpenBSD works fine)

The culprit is this (archaic) fragment in doc/jove.rc (installed to your SHAREDIR/jove.rc)

# The vt100 is the only terminal that needs flow control to throttle
# output from the computer. The following line is unlikely to be needed
# for any vt100-emulator.
set allow-^S-and-^Q off`

(and the fact that /etc/ttys and/or /etc/wscons.conf defines screens as vt100 rather than a more modern vtxxx, since I'm sure the console emulator in BSD must support the ability to insert mode, insert/delete multiple chars/lines, which appeared in "newer" terminals like vt102, vt220, vt320)

bsdimp commented 4 years ago

I built the tip of last night's master on FreeBSD 13 (3 days old). moraes branch gives me the same behavior. Also, the build instructions are wrong for BSD in the README file:

make SYSDEFS="-DBSDPOSIX_STDC -DUSE_OPENPTY -DHAS_LIBUTILS_H" EXTRALIBS=-lutil install

should be

make SYSDEFS="-DBSDPOSIX_STDC -DUSE_OPENPTY -DHAVE_LIBUTIL_H" EXTRALIBS=-lutil

I see identical behavior on 11.2. I've tried with lxterm running locally, and iTerm from a mac logging in. I'm guessing there's either some stack garbage going on which is masking some bits not being properly cleared.

Hmmm, it may be something else. I did shell escape for stty -a < /dev/pty/1. For gnu-emacs I got

speed 38400 baud; 84 rows; 490 columns;
lflags: -icanon isig -iexten -echo echoe echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
        -extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany imaxbel ignbrk
        brkint -inpck -ignpar -parmrk
oflags: opost -onlcr -ocrnl tab0 -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
        -dtrflow -mdmbuf
cchars: discard = <undef>; dsusp = <undef>; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^G; kill = ^U;
        lnext = <undef>; min = 1; quit = ^G; reprint = <undef>;
        start = <undef>; status = ^T; stop = <undef>; susp = <undef>;
        time = 0; werase = <undef>;

for jove I got

speed 38400 baud; 84 rows; 490 columns;
lflags: -icanon isig iexten -echo echoe echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
        -extproc
iflags: -istrip -icrnl -inlcr -igncr ixon -ixoff -ixany imaxbel -ignbrk
        brkint -inpck -ignpar -parmrk
oflags: -opost onlcr -ocrnl tab0 -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
        -dtrflow -mdmbuf
cchars: discard = <undef>; dsusp = <undef>; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^]; kill = ^U;
        lnext = <undef>; min = 1; quit = <undef>; reprint = ^R;
        start = ^Q; status = ^T; stop = ^S; susp = <undef>; time = 1;
        werase = ^W;

If I set 'stop' to be some character other than ^S, search works....

So lflags differences iexten (which is fine) iflags has ixon still set (which is exactly the problem, if I turn just this bit off with stty, then search works). oflags has opost turned off (which I think is fine). And the cchars are different (I think that's OKish, given that ixon is the root cause, but I've not tested all the other characters but ^R and ^T work so I think they don't matter).

TERM is xterm. That's definitely not the problem.

bsdimp commented 4 years ago

Also, NetBSD's and FreeBSD's terminal emulators are 100% different (wscons vs vt). FreeBSD's emulates a full color xterm. Though that's not the issue here since I'm coming in via the network.

bsdimp commented 4 years ago

I suspect that

unix.c:bool OKXonXoff = NO; /* VAR: XON/XOFF can be used as ordinary chars */

should actually be 'YES'. It looks like it was once 'yes' based on changing it from NO to YES (a) makes jove work and (b) the comments line up. Since only a vt100 should turn this off, per the above comments, this would result it in always being turned off unless I turned it on. Making the change I described here makes jove searching work without further hacks.

markmoraes commented 4 years ago

I agree that a better default in modern times for OKXonXoff is YES, since we can then take out the allow-... from jove.rc , I'll propose that change, thanks.

However, the jove.rc should have set this for you on any terminal other than xterm -- were you running jove after 'make install', or just running jjove after make? If the latter, then can you try './jjove -s doc' to see if it makes a difference (overrides the compiled-in SHAREDIR for local testing).

bsdimp commented 4 years ago

Ah, I was running jjove after a make... That's an odd difference... But I can confirm: if I revert the proposed change and also do -s doc with jjove, it works as well.

markmoraes commented 4 years ago

Great, thanks much for the report, suggestion and debugging help. I'll leave this open till the OKXonXoff change (which I think of as a "improve default" suggestion) and related decision on jove.rc.vt100 happen, since you've definitely uncovered bad behaviour of Jove on NetBSD as a side-effect.

bsdimp commented 4 years ago

My pleasure... Saw the call for testing by Paul Vixie and thought "Hey! I was wanting to get JOVE working on my Venix machine (which is off), but let's try FreeBSD first....

markmoraes commented 4 years ago

fixed in moraes branch, tagged as 4.17.1.9