* Scheme Interpreter in Emacs and Readline @ 2020-04-18 10:51 Jakub Jankiewicz [not found] ` <87imhx6ocz.fsf@yahoo.com> 0 siblings, 1 reply; 4+ messages in thread From: Jakub Jankiewicz @ 2020-04-18 10:51 UTC (permalink / raw) To: emacs-devel I have problem in creating Scheme Interpreter in Node.js that can be run using Emacs run-scheme command. I use Readline library in Node.js and when I resize the window or frame it keep adding prompt to the prompt line. I've asked on StackOverflow and also on emacs mailing list but no one answered. [How to write Node.js REPL that works with GNU Emacs?][1] Is there special thing the interpreter need to be doing, so it work with Comint mode? I have the same if I run with emacs -q. Does Emacs run-scheme work with Readline? Does anyone have issues with this? Is this a bug? I would like to know if there is workaround. Kawa and Guile works fine in GNU Emacs, I was checking Kawa source code and it don't use Readline it use stdin stream and println in Java. I have this code in my .emacs file: (defun lips () "call run-scheme with guile interpreter." (interactive) (run-scheme "/home/kuba/projects/jcubic/lips/bin/lips.js")) and I have also this (autoload 'scheme-mode "cmuscheme" "Major mode for Scheme." t) (autoload 'run-scheme "cmuscheme" "Switch to interactive Scheme buffer." t) ;; this shouldn't change anything since I'm running the function with argument (setq scheme-program-name "/home/kuba/projects/jcubic/lips/bin/lips.js") (add-hook 'scheme-mode-hook 'turn-on-font-lock) ;; there was issue with double echo ;; see my Question on Emacs StackExachange ;; [How to run custom scheme written in node.js using readline in ;; emacs?][2] (setq comint-process-echoes t) (setq comint-input-ignoredups t) (setq comint-prompt-read-only t) (add-hook 'comint-mode-hook (lambda() (setq truncate-lines 1))) [1]: https://stackoverflow.com/q/60987722/387194 [2]: https://emacs.stackexchange.com/q/57521/10438 -- Jakub Jankiewicz, Web Developer https://jcubic.pl/me ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <87imhx6ocz.fsf@yahoo.com>]
* Re: Scheme Interpreter in Emacs and Readline [not found] ` <87imhx6ocz.fsf@yahoo.com> @ 2020-04-18 12:29 ` Jakub Jankiewicz 2020-04-19 0:02 ` Po Lu 0 siblings, 1 reply; 4+ messages in thread From: Jakub Jankiewicz @ 2020-04-18 12:29 UTC (permalink / raw) To: Po Lu; +Cc: emacs-devel > What do you mean by "when I resize the window or frame it keep adding > prompt to the prompt line"? I have prompt "lips> " and when I resize Emacs window on Fedora GNU/Linux (the only system I was testing this). on each resize I get new prompt so when I keep resizing I have something like this: lips> lips> lips> lips> lips> and they are all prompt because I can't delete it. Unless something wierd is happening. > It would also probbaly be helpful if you could post the source of your > Scheme interpreter. Sorry about that, my Scheme Interpreter is here: https://github.com/jcubic/lips/tree/devel Please use devel branch since it's most up to date, I still try to make it compatible with R5RS, before I release new version, it will 1.0. The executable is in bin directry (there are not much code, but it would be easier to have link that you can run insead of send this to the mailing list. https://github.com/jcubic/lips/blob/devel/bin/lips.js Just run: git clone https://github.com/jcubic/lips.git cd lips git checkout devel and run in GUI Emacs: (run-scheme "<PATH>/lips/bin/lips.js") and resize the Frame or buffer's window if you have multiple windows. And I need to add that I was looking at Node.js source code, there is lot of code but it also use Readline and Node.js works in run-js (I'm not sure if it use something else for --interactive option that was suggested when I've search how to run node in Emacs). I've tested my interpeter with same run-js and I have same issue with duplicated prompt. -- Jakub Jankiewicz, Web Developer https://jcubic.pl/me ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Scheme Interpreter in Emacs and Readline 2020-04-18 12:29 ` Jakub Jankiewicz @ 2020-04-19 0:02 ` Po Lu 2020-04-19 7:14 ` Jakub Jankiewicz 0 siblings, 1 reply; 4+ messages in thread From: Po Lu @ 2020-04-19 0:02 UTC (permalink / raw) To: Jakub Jankiewicz; +Cc: emacs-devel Jakub Jankiewicz <jcubic@onet.pl> writes: >> What do you mean by "when I resize the window or frame it keep adding >> prompt to the prompt line"? > > I have prompt "lips> " and when I resize Emacs window on Fedora GNU/Linux > (the only system I was testing this). on each resize I get new prompt so when > I keep resizing I have something like this: > > lips> lips> lips> lips> lips> > > and they are all prompt because I can't delete it. Unless something wierd is > happening. > >> It would also probbaly be helpful if you could post the source of your >> Scheme interpreter. > > Sorry about that, my Scheme Interpreter is here: > > https://github.com/jcubic/lips/tree/devel > > Please use devel branch since it's most up to date, I still try to make it > compatible with R5RS, before I release new version, it will 1.0. > > The executable is in bin directry (there are not much code, but it would be > easier to have link that you can run insead of send this to the mailing list. > > https://github.com/jcubic/lips/blob/devel/bin/lips.js > > Just run: > > git clone https://github.com/jcubic/lips.git > cd lips > git checkout devel > > and run in GUI Emacs: > > (run-scheme "<PATH>/lips/bin/lips.js") > > and resize the Frame or buffer's window if you have multiple windows. > > > And I need to add that I was looking at Node.js source code, there is lot of > code but it also use Readline and Node.js works in run-js (I'm not sure if it > use something else for --interactive option that was suggested when I've > search how to run node in Emacs). > > I've tested my interpeter with same run-js and I have same issue with > duplicated prompt. > > -- > Jakub Jankiewicz, Web Developer > https://jcubic.pl/me I'm not sure about run-js, but I turned off Readline in your interpreter, and it now works flawlessly inside comint. Since Readline is pretty much useless anyways there, it might be worth it to turn it off inside Emacs. (ie check the EMACS and INSIDE_EMACS variables, or add something like CMU's `-emacs' flag.) Bash does the same thing too; https://lists.gnu.org/archive/html/bug-bash/2015-03/msg00179.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Scheme Interpreter in Emacs and Readline 2020-04-19 0:02 ` Po Lu @ 2020-04-19 7:14 ` Jakub Jankiewicz 0 siblings, 0 replies; 4+ messages in thread From: Jakub Jankiewicz @ 2020-04-19 7:14 UTC (permalink / raw) To: Po Lu; +Cc: emacs-devel On Sun, 19 Apr 2020 08:02:02 +0800 Po Lu <luangruo@yahoo.com> wrote: > Jakub Jankiewicz <jcubic@onet.pl> writes: > > >> What do you mean by "when I resize the window or frame it keep adding > >> prompt to the prompt line"? > > > > I have prompt "lips> " and when I resize Emacs window on Fedora GNU/Linux > > (the only system I was testing this). on each resize I get new prompt so > > when I keep resizing I have something like this: > > > > lips> lips> lips> lips> lips> > > > > and they are all prompt because I can't delete it. Unless something wierd > > is happening. > > > >> It would also probbaly be helpful if you could post the source of your > >> Scheme interpreter. > > > > Sorry about that, my Scheme Interpreter is here: > > > > https://github.com/jcubic/lips/tree/devel > > > > Please use devel branch since it's most up to date, I still try to make it > > compatible with R5RS, before I release new version, it will 1.0. > > > > The executable is in bin directry (there are not much code, but it would > > be easier to have link that you can run insead of send this to the > > mailing list. > > > > https://github.com/jcubic/lips/blob/devel/bin/lips.js > > > > Just run: > > > > git clone https://github.com/jcubic/lips.git > > cd lips > > git checkout devel > > > > and run in GUI Emacs: > > > > (run-scheme "<PATH>/lips/bin/lips.js") > > > > and resize the Frame or buffer's window if you have multiple windows. > > > > > > And I need to add that I was looking at Node.js source code, there is lot > > of code but it also use Readline and Node.js works in run-js (I'm not > > sure if it use something else for --interactive option that was suggested > > when I've search how to run node in Emacs). > > > > I've tested my interpeter with same run-js and I have same issue with > > duplicated prompt. > > > > -- > > Jakub Jankiewicz, Web Developer > > https://jcubic.pl/me > > I'm not sure about run-js, but I turned off Readline in your > interpreter, and it now works flawlessly inside comint. Since Readline > is pretty much useless anyways there, it might be worth it to turn it > off inside Emacs. (ie check the EMACS and INSIDE_EMACS variables, or add > something like CMU's `-emacs' flag.) > > Bash does the same thing too; > https://lists.gnu.org/archive/html/bug-bash/2015-03/msg00179.html > I've used this: const rl = readline.createInterface({ input: process.stdin, output: process.stdout, prompt: prompt, terminal: !!process.stdin.isTTY && !(process.env.EMACS || process.env.INSIDE_EMACS) }); Thanks, it works perfetly, this will be required for any Readline Node.js interpreter or REPL that runs in GNU Emacs. -- Jakub Jankiewicz, Web Developer https://jcubic.pl/me ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-19 7:14 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-04-18 10:51 Scheme Interpreter in Emacs and Readline Jakub Jankiewicz [not found] ` <87imhx6ocz.fsf@yahoo.com> 2020-04-18 12:29 ` Jakub Jankiewicz 2020-04-19 0:02 ` Po Lu 2020-04-19 7:14 ` Jakub Jankiewicz
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).