larsbrinkhoff / forth-mode

Wants to be the SLIME of Forth
GNU General Public License v3.0
61 stars 17 forks source link

SwiftForth oddness #20

Closed ellerh closed 7 years ago

ellerh commented 7 years ago

When I start Emacs like so: touch /tmp/x.fs emacs -Q -nw -L /scratch/forth/forth-mode/ -l forth-interaction-mode -eval '(progn (setq forth-executable "swiftforth") (setq process-coding-system-alist (quote (("swiftforth" . raw-text-dos)))) (run-forth))'

then type "include /tmp/x.fs" in the *forth* buffer, I get this:

SwiftForth i386-Linux 3.6.3 29-Jun-2016
include /tmp/x.fs
include /t File not found
larsbrinkhoff commented 7 years ago

Using the evalutation version, I get

SwiftForth i386-Linux 3.6.3 29-Jun-2016
include /tmp/x.fs
include /tmp/x.fs Can't read file
larsbrinkhoff commented 7 years ago

If I add some code to /tmp/x.fs, it works.

There may be another problem that truncates the echoed Forth output to just include /t. I still have work to do in the forth-interaction-send function to make it more reliable.

ellerh commented 7 years ago

include /tmp/x.fs Can't read file

Actually, I also get this is the file is empty (also outside of Emacs).

A slightly better test case is: printf ': foo ;' > /tmp/x.fs && emacs -Q -nw -L /scratch/forth/forth-mode/ -l forth-interaction-mode -eval '(progn (setq forth-executable "swiftforth") (setq process-coding-system-alist (quote (("swiftforth" . raw-text-dos)))) (run-forth) (insert "include /tmp/x.fs"))'

larsbrinkhoff commented 7 years ago

When I press Enter in this new test case, the end result is:

SwiftForth i386-Linux 3.6.3 29-Jun-2016
include /tmp/x.fs
include /tmp/x.fs  ok

And entering words indicates that foo was defined.

larsbrinkhoff commented 7 years ago

I'm guessing SwiftForth turns off terminal echoing, but running in comint mode doesn't honour that.

ellerh commented 7 years ago

Found the problem: the width end height argument to set-process-window-size in run-forth are in reverse order. And I used an 80x20 xterm and the *forth* window was then only 11 lines and SwiftForth interpreted that as 11 columns. You can reproduce without Emacs by running SwifthForth in narrow xterm with 10 columns or so.

Looks like a device personality would be very useful to avoid such "surprises".

larsbrinkhoff commented 7 years ago

Yes, reproduced with a narrow xterm. I suppose this is the GET-SIZE vector being called.

larsbrinkhoff commented 7 years ago

Try this:

:noname 100 100 ; 'get-size !
larsbrinkhoff commented 7 years ago

Hopefully, b69527c fixes this.

ellerh commented 7 years ago

So SwiftForth truncates all lines that are longer than the width returned by GET-SIZE. I guess forth-interaction-send should keep that in mind.

An idea would be to temporarily increase the width e.g. with set-process-window-size.

larsbrinkhoff commented 7 years ago

@ellerh Can you test the swiftforth branch?

ellerh commented 7 years ago

swiftforth.el is loaded with require so it seems that the coding sytem etc. is not initialized when restarting the subprocess.

larsbrinkhoff commented 7 years ago

Right. I'll close this issue and create a new one for that problem.