Standardize REPL commands & improve SPC o r

- SPC o r now prompts for a REPL to open when none was found for the
  current buffer.
- REPL handlers must now follow the naming convention "*/open*-repl".
  e.g. +python/open-ipython-repl, +emacs-lisp/open-repl, etc.
- +eval/open-repl has been split in two:
  - +eval/open-repl-other-window
  - +eval/open-repl-same-window
This commit is contained in:
Henrik Lissner 2019-02-18 01:56:38 -05:00
parent 4437d80133
commit 94b16cba6c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
19 changed files with 83 additions and 52 deletions

View file

@ -79,7 +79,7 @@ library/userland functions"
;; Commands
;;;###autoload
(defun +emacs-lisp/repl ()
(defun +emacs-lisp/open-repl ()
"Open the Emacs Lisp REPL (`ielm')."
(interactive)
(pop-to-buffer

View file

@ -14,7 +14,7 @@
(add-to-list 'auto-mode-alist '("\\.Cask\\'" . emacs-lisp-mode))
(after! elisp-mode
(set-repl-handler! 'emacs-lisp-mode #'+emacs-lisp/repl)
(set-repl-handler! 'emacs-lisp-mode #'+emacs-lisp/open-repl)
(set-eval-handler! 'emacs-lisp-mode #'+emacs-lisp-eval)
(set-lookup-handlers! 'emacs-lisp-mode
:definition #'elisp-def

View file

@ -1,14 +1,10 @@
;;; lang/haskell/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +haskell-repl-buffer (&optional arg)
"Returns the appropriate Haskell REPL buffer."
(if (featurep! +intero)
(intero-repl-buffer arg)
(haskell-session-interactive-buffer (haskell-session))))
;;;###autoload
(defun +haskell/repl (&optional arg)
(defun +haskell/open-repl (&optional arg)
"Opens a Haskell REPL."
(interactive "P")
(display-buffer (+haskell-repl-buffer arg)))
(display-buffer
(if (featurep! +intero)
(intero-repl-buffer arg)
(haskell-session-interactive-buffer (haskell-session)))))

View file

@ -16,7 +16,7 @@
interactive-haskell-mode))
(set-lookup-handlers! 'haskell-mode :definition #'haskell-mode-jump-to-def-or-tag)
(set-file-template! 'haskell-mode :trigger #'haskell-auto-insert-module-template :project t)
(set-repl-handler! '(haskell-mode haskell-cabal-mode literate-haskell-mode) #'+haskell-repl-buffer)
(set-repl-handler! '(haskell-mode haskell-cabal-mode literate-haskell-mode) #'+haskell/open-repl)
(add-to-list 'completion-ignored-extensions ".hi")

View file

@ -34,5 +34,5 @@ sudo pacman --needed --noconfirm -S nodejs npm
** Commands
| command | key / ex command | description |
|----------------------------------+------------------+------------------------------------------------------------|
| ~+javascript/repl~ | =:repl= | Open the NodeJS REPL (or send the current selection to it) |
| ~+javascript/open-repl~ | =:repl= | Open the NodeJS REPL (or send the current selection to it) |
| ~+javascript/skewer-this-buffer~ | =SPC m S= | Attaches a browser to the current buffer |

View file

@ -36,7 +36,7 @@ ignore the cache."
;; Commands
;;;###autoload
(defun +javascript/repl ()
(defun +javascript/open-repl ()
"Open a Javascript REPL. Meaning either `skewer-repl', if any of the
skewer-*-mode's are enabled, or `nodejs-repl' otherwise."
(interactive)

View file

@ -52,7 +52,7 @@
mode-name "JS2")
(set-electric! 'js2-mode :chars '(?\} ?\) ?. ?:))
(set-repl-handler! 'js2-mode #'+javascript/repl)
(set-repl-handler! 'js2-mode #'+javascript/open-repl)
(map! :map js2-mode-map
:localleader

View file

@ -1,7 +1,7 @@
;;; lang/lua/autoload.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +lua/repl ()
(defun +lua/open-repl ()
"Open Lua REPL."
(interactive)
(lua-start-process "lua" "lua")

View file

@ -15,7 +15,7 @@
:config
(set-lookup-handlers! 'lua-mode :documentation 'lua-search-documentation)
(set-electric! 'lua-mode :words '("else" "end"))
(set-repl-handler! 'lua-mode #'+lua/repl)
(set-repl-handler! 'lua-mode #'+lua/open-repl)
(set-company-backend! 'lua-mode '(company-lua company-yasnippet)))

View file

@ -4,7 +4,7 @@
"TODO")
;;;###autoload
(defun +python/repl ()
(defun +python/open-repl ()
"Open the Python REPL."
(interactive)
(unless python-shell-interpreter
@ -28,7 +28,7 @@
(interactive)
(let ((python-shell-interpreter "ipython")
(python-shell-interpreter-args +python-jupyter-repl-args))
(+python/repl)))
(+python/open-repl)))
;;;###autoload
(defun +python/open-jupyter-repl ()
@ -37,7 +37,7 @@
(add-to-list 'python-shell-completion-native-disabled-interpreters "jupyter")
(let ((python-shell-interpreter "jupyter")
(python-shell-interpreter-args (format "console %s" +python-jupyter-repl-args)))
(+python/repl)))
(+python/open-repl)))
(defun +python--extract-version (prefix str)
(when str

View file

@ -26,7 +26,7 @@ called.")
:config
(set-env! "PYTHONPATH" "PYENV_ROOT" "ANACONDA_HOME")
(set-electric! 'python-mode :chars '(?:))
(set-repl-handler! 'python-mode #'+python/repl)
(set-repl-handler! 'python-mode #'+python/open-repl)
(set-pretty-symbols! 'python-mode
;; Functional

View file

@ -8,15 +8,15 @@ This module adds support for shell scripting languages.
+ REPL support
* Table of Contents :TOC:
- [[#install][Install]]
- [[#appendix][Appendix]]
- [[#commands][Commands]]
- [[Install][Install]]
- [[Appendix][Appendix]]
- [[Commands][Commands]]
* Install
This module has no dependencies.
* Appendix
** Commands
| command | key / ex command | description |
|------------+------------------+-------------------------------------------------------|
| ~+sh/repl~ | =:repl= | Open a terminal (or send the current selection to it) |
| command | key / ex command | description |
|-----------------+------------------+-------------------------------------------------------|
| ~+sh/open-repl~ | =:repl= | Open a terminal (or send the current selection to it) |

View file

@ -27,7 +27,7 @@
(defvar sh-shell-file)
;;;###autoload
(defun +sh/repl ()
(defun +sh/open-repl ()
"Open a shell REPL."
(let* ((dest-sh (symbol-name sh-shell))
(sh-shell-file dest-sh))

View file

@ -15,7 +15,7 @@
:mode ("/bspwmrc\\'" . sh-mode)
:config
(set-electric! 'sh-mode :words '("else" "elif" "fi" "done" "then" "do" "esac" ";;"))
(set-repl-handler! 'sh-mode #'+sh/repl)
(set-repl-handler! 'sh-mode #'+sh/open-repl)
(setq sh-indent-after-continuation 'always)