Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upstream merge #9

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
43b3b35
Always display inferior process buffer after evaluation
YorkZ Nov 17, 2016
35660f9
Merge pull request #11 from YorkZ/york
Nov 17, 2016
986c779
add js-clear
Dec 13, 2016
b5d6cb8
ignore shebang (first line) of node js script
Dec 13, 2016
20e6945
could hide `undefined` output
Dec 13, 2016
2e94173
could setup $NODE_PATH automatically
Dec 13, 2016
067d52c
clean code and README
Dec 13, 2016
2f42249
fixed typo
Dec 21, 2016
048fa08
Learn from nodejs-repl
Jun 16, 2017
9113cb5
use js-comint-module-paths to search for node module
Jun 17, 2017
603aab6
fixed typo
Jun 27, 2017
2c19faf
fixed bugs. evil-mode friendly
Jun 28, 2017
eb47441
upgrade license
Aug 8, 2017
83e932e
doc and bugs
Nov 30, 2017
d775fd2
Update docs
Nov 6, 2018
8c52d90
Merge pull request #22 from re-mx/update-docs
Nov 6, 2018
6c33089
Fixed typo
Nov 6, 2018
01be9d8
Merge pull request #23 from re-mx/patch-1
Nov 6, 2018
e2cf1c7
Add GPL3 license
josteink Dec 21, 2018
3dd6b8f
Merge pull request #25 from josteink/master
Dec 22, 2018
e202057
defining our adjust-window-size-function
Jun 5, 2019
ab8953b
Merge pull request #26 from saadnpq/fix-dub-prompts
Jun 6, 2019
0dedaf4
add node_modules into repl automatically
Jan 17, 2020
06b8832
Update key bindings
DivineDominion Dec 19, 2021
7920252
Merge pull request #29 from DivineDominion/patch-1
Dec 19, 2021
fe09591
Allow to send multi-line string
linktohack Dec 1, 2022
30e521a
Merge pull request #32 from linktohack/patch-2
Dec 1, 2022
4ee2619
Fixes to run under Emacs 27.1
saffroy Mar 9, 2023
b788bf5
Merge pull request #33 from saffroy/master
Mar 11, 2023
057a8ba
Fix regression when sending multi-line string
saffroy Nov 9, 2023
3790e01
Merge pull request #34 from saffroy/master
redguardtoo Nov 16, 2023
24da61e
Add tests using Emacs ERT for multiline JS statements
saffroy Nov 25, 2023
fd08ea4
Add github workflow that runs tests across multiple Emacs versions
saffroy Nov 25, 2023
ef2cccc
Merge pull request #35 from saffroy/master
redguardtoo Nov 26, 2023
e01b753
Enable lexical binding
joshbax189 Oct 15, 2024
cc6a360
Ignore string arg to js-comint-filter-output
joshbax189 Oct 17, 2024
ed7e77a
Lint and simplify js-comint-repl
joshbax189 Oct 17, 2024
d9088c3
Add lexical-binding and requires to test
joshbax189 Oct 16, 2024
ceeb9eb
Bug: js-comint--suggest-module-path should be nil if no node_modules
joshbax189 Oct 17, 2024
addff71
Use temporary local env vars when calling comint
joshbax189 Oct 17, 2024
3d879f5
Remove unused js-comint-setup-module-paths
joshbax189 Oct 17, 2024
2eceaf3
Depend on emacs 28.1 to use with-environment-variables
joshbax189 Oct 17, 2024
18ab673
Tidy argument handling for js-comint-repl
joshbax189 Oct 17, 2024
e83eb27
Add missing customization types to fix compiler warnings
joshbax189 Oct 17, 2024
2058be8
Add unit tests for js-comint-start-or-switch-to-repl
joshbax189 Oct 17, 2024
dd6c117
Simplify js-comint--suggest-module-path
joshbax189 Oct 17, 2024
951131c
Have js-comint-start-or-switch-to-repl check local node_modules
joshbax189 Oct 17, 2024
be24e8e
Fix failing test
joshbax189 Oct 18, 2024
7ceec3d
Factor out process exit logic in tests
joshbax189 Oct 18, 2024
8f05c1b
Add declares for nvm functions.
joshbax189 Oct 18, 2024
7fbcb4b
Move (require 'nvm) into select-node-version, tidy logic
joshbax189 Oct 18, 2024
1c3b1ab
Message when changing cmd while nvm is set
joshbax189 Oct 18, 2024
6eaa359
Do not include empty strings in path
joshbax189 Oct 18, 2024
4353fe2
Switch buffers in start-or-switch-to-buffer
joshbax189 Oct 18, 2024
103e574
Merge pull request #37 from joshbax189/feat/lexical-binding
redguardtoo Oct 19, 2024
e1347ba
repl.start() takes a single object arg
joshbax189 Oct 23, 2024
b99d805
NODE_REPL_MODE does not need to be set manually
joshbax189 Oct 28, 2024
65a6972
Merge pull request #38 from joshbax189/fix/update-node-args
redguardtoo Nov 7, 2024
446cb64
Add Eask file
joshbax189 Oct 22, 2024
dd9c0ed
Update github action to use eask
joshbax189 Oct 22, 2024
3e00e75
Add lint job to catch nvm.el signature changes
joshbax189 Oct 29, 2024
61d2dbf
Add unit tests for js-comint-select-node-version using el-mock
joshbax189 Oct 29, 2024
79b6a54
Merge pull request #39 from joshbax189/feat/use-eask
redguardtoo Nov 9, 2024
5a69cdd
Exclude tests from MELPA packages
jian-lin Nov 12, 2024
a2e6f01
Merge pull request #40 from linj-fork/pr/exclude-test-files-from-melpa
redguardtoo Nov 12, 2024
9da6cfc
Add completion feature
joshbax189 Dec 5, 2024
68908b5
Merge pull request #41 from joshbax189/feat/completion
redguardtoo Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Run tests across emacs versions
on: [push, pull_request]
jobs:
test-emacs-versions:
strategy:
matrix:
emacs-version: [28, 29]
runs-on: ubuntu-latest
container: silex/emacs:${{matrix.emacs-version}}-ci-eask
steps:
- name: Check out repository code
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install test dependencies
run: eask install-deps --dev
- name: Run tests
run: eask run script test
lint:
runs-on: ubuntu-latest
container: silex/emacs:29-ci-eask
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install test dependencies
run: eask install-deps --dev
- name: Run linters
run: eask lint declare --strict
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.elc
.eask
21 changes: 21 additions & 0 deletions Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(package "js-comint"
"1.2.0"
"JavaScript interpreter in window.")

(website-url "https://github.com/redguardtoo/js-comint")
(keywords "javascript" "node" "inferior-mode" "convenience")

(package-file "js-comint.el")

(script "test" "eask test ert test/*tests.el")

(source "gnu")
(source "melpa")

(depends-on "emacs" "28.1")

(development
(depends-on "el-mock")
(depends-on "nvm")
(depends-on "company")
(depends-on "ert-async"))
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

47 changes: 31 additions & 16 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* js-comint.el (v0.0.5)
* js-comint.el (v1.2.0)
Run a JavaScript interpreter in an inferior process window

The first release, [[http://js-comint-el.sourceforge.net/][js-comint 0.0.1, is hosted on sourceforge]] but it has not been updated for five years.
Expand Down Expand Up @@ -36,16 +36,35 @@ Add js-comint to your Cask file:
(depends-on "js-comint")
#+END_SRC

** Windows
On window, you may need below setup:
#+begin_src elisp
(setq js-comint-program-command "C:/Program Files/nodejs/node.exe")
#+end_src
* Usage
After installation, do `M-x run-js` to create a comint buffer with the JavaScript interpreter.

Please note the directory =node_modules= is *automatically* searched and appended into environment variable `NODE_PATH'. So you can use third party javascript without setup. For example, after =npm install --save moment=, run below command in js-comint shell,
#+begin_src javascript
require('moment')().format('YYYY-MM-DD');
#+end_src

You can =M-x js-clear= before =M-x js-send-buffer= to get clean output.

In order to get cleaner output when using NodeJS, I suggest add below setup into =.emacs=,
#+begin_src elisp
(defun inferior-js-mode-hook-setup ()
(add-hook 'comint-output-filter-functions 'js-comint-process-output))
(add-hook 'inferior-js-mode-hook 'inferior-js-mode-hook-setup t)
#+end_src
* Customization
You can set the `inferior-js-program-command' string and the `inferior-js-program-arguments' list to the executable that runs the JS interpreter and the arguments to pass to it respectively.
You can set the `js-comint-program-command' string and the `js-comint-program-arguments' list to the executable that runs the JS interpreter and the arguments to pass to it respectively.

E.g., the default is:
#+BEGIN_SRC elisp
(setq inferior-js-program-command "node")
(setq inferior-js-program-arguments '("--interactive"))
;; You can also customize `js-comint-drop-regexp' to filter output
(setq js-comint-program-command "node")
(setq js-comint-program-arguments '("--interactive"))
#+END_SRC

Note that in the example above, the version of node that is picked up will be the first found in `exec-path'.
Expand All @@ -54,8 +73,8 @@ But you could use Rhino or SpiderMonkey or whatever you want.
E.g. to set up the Rhino JAR downloaded from https://github.com/mozilla/rhino, do

#+BEGIN_SRC elisp
(setq inferior-js-program-command "java")
(setq inferior-js-program-arguments '("-jar" "/absolute/path/to/rhino/js.jar"))
(setq js-comint-program-command "java")
(setq js-comint-program-arguments '("-jar" "/absolute/path/to/rhino/js.jar"))
#+END_SRC

If you have nvm, you can select the versions of node.js installed and run them. This is done thanks to =nvm.el=. =nvm.el= is optional. So you need *manually* install it.
Expand All @@ -65,16 +84,12 @@ To enable nvm support, run
(js-do-use-nvm)
#+END_SRC

The first time you start the JS interpreter with run-js, you will be asked to select a version of node.js. If you want to change version of node js, run `(js-select-node-version)`
The first time you start the JS interpreter with run-js, you will be asked to select a version of node.js. If you want to change version of node js, run ~(js-select-node-version)~.

You can add the following couple of lines to your .emacs to take advantage of cool key bindings for sending things to the javascript interpreter inside of Steve Yegge's most excellent js2-mode.
You can add the following couple of lines to your .emacs/init file to take advantage of key bindings for sending things to the JavaScript REPL:

#+BEGIN_SRC elisp
(add-hook 'js2-mode-hook
(lambda ()
(local-set-key (kbd "C-x C-e") 'js-send-last-sexp)
(local-set-key (kbd "C-M-x") 'js-send-last-sexp-and-go)
(local-set-key (kbd "C-c b") 'js-send-buffer)
(local-set-key (kbd "C-c C-b") 'js-send-buffer-and-go)
(local-set-key (kbd "C-c l") 'js-load-file-and-go)))
#+END_SRC
; Remap Elisp's eval-last-sexp (C-x C-e) to eval JavaScript
(define-key js-mode-map [remap eval-last-sexp] #'js-comint-send-last-sexp))
(define-key js-mode-map (kbd "C-c b") 'js-send-buffer))
#+END_SRC
Loading