Replace :eval/:repl with autodef functions

+ :eval => set-eval-handler!
+ :repl => set-repl-handler!
+ Updates all internal references.
This commit is contained in:
Henrik Lissner 2018-06-15 16:07:24 +02:00
parent 98632fe086
commit 588359cc5f
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
21 changed files with 98 additions and 72 deletions

View file

@ -0,0 +1,76 @@
;;; feature/eval/autoload/settings.el -*- lexical-binding: t; -*-
;;
;; REPLs
;;
(defvar +eval-repls nil
"An alist mapping major modes to plists that describe REPLs. Used by
`+eval/open-repl' and filled with the `:repl' setting.")
;;;###autodef
(defun set-repl-handler! (mode command)
"Define a REPL for a mode. MODE is a major mode symbol and COMMAND is a
function that creates and returns the REPL buffer."
(push (cons mode command) +eval-repls))
;; FIXME obsolete :repl
;;;###autoload
(def-setting! :repl (mode command)
"Define a REPL for a mode. MODE is a major mode symbol and COMMAND is a
function that creates and returns the REPL buffer."
:obsolete set-repl-handler!
`(push (cons ,mode ,command) +eval-repls))
;;
;; Evaluation
;;
(defvar +eval-runners nil
"Alist mapping major modes to interactive runner functions.")
;;;###autodef
(defun set-eval-handler! (mode command)
"Define a code evaluator for major mode MODE with `quickrun'.
1. If MODE is a string and COMMAND is the string, MODE is a file regexp and
COMMAND is a string key for an entry in `quickrun-file-alist'.
2. If MODE is not a string and COMMAND is a string, MODE is a major-mode symbol
and COMMAND is a key (for `quickrun--language-alist'), and will be registered
in `quickrun--major-mode-alist'.
3. If MODE is not a string and COMMAND is an alist, see `quickrun-add-command':
(quickrun-add-command MODE COMMAND :mode MODE).
4. If MODE is not a string and COMMANd is a symbol, add it to
`+eval-runners', which is used by `+eval/region'."
(cond ((symbolp command)
(push (cons mode command) +eval-runners))
((stringp command)
(after! quickrun
(push (cons mode command)
(if (stringp mode)
quickrun-file-alist
quickrun--major-mode-alist))))
((listp command)
(after! quickrun
(quickrun-add-command
(symbol-name mode)
command :mode mode)))))
;; FIXME obsolete :eval
;;;###autoload
(def-setting! :eval (mode command)
"Define a code evaluator for major mode MODE with `quickrun'.
1. If MODE is a string and COMMAND is the string, MODE is a file regexp and
COMMAND is a string key for an entry in `quickrun-file-alist'.
2. If MODE is not a string and COMMAND is a string, MODE is a major-mode symbol
and COMMAND is a key (for `quickrun--language-alist'), and will be registered
in `quickrun--major-mode-alist'.
3. If MODE is not a string and COMMAND is an alist, see `quickrun-add-command':
(quickrun-add-command MODE COMMAND :mode MODE).
4. If MODE is not a string and COMMANd is a symbol, add it to
`+eval-runners', which is used by `+eval/region'."
:obsolete set-eval-handler!
`(set-eval-handler! ,mode ,command))

View file

@ -1,50 +0,0 @@
;;; feature/eval/init.el -*- lexical-binding: t; -*-
;;
;; REPLs
;;
(defvar +eval-repls nil
"An alist mapping major modes to plists that describe REPLs. Used by
`+eval/open-repl' and filled with the `:repl' setting.")
(def-setting! :repl (mode command)
"Define a REPL for a mode. MODE is a major mode symbol and COMMAND is a
function that creates and returns the REPL buffer."
`(push (cons ,mode ,command) +eval-repls))
;;
;; Evaluation
;;
(defvar +eval-runners nil
"Alist mapping major modes to interactive runner functions.")
(def-setting! :eval (mode command)
"Define a code evaluator for major mode MODE with `quickrun'.
1. If MODE is a string and COMMAND is the string, MODE is a file regexp and
COMMAND is a string key for an entry in `quickrun-file-alist'.
2. If MODE is not a string and COMMAND is a string, MODE is a major-mode symbol
and COMMAND is a key (for `quickrun--language-alist'), and will be registered
in `quickrun--major-mode-alist'.
3. If MODE is not a string and COMMAND is an alist, see `quickrun-add-command':
(quickrun-add-command MODE COMMAND :mode MODE).
4. If MODE is not a string and COMMANd is a symbol, add it to
`+eval-runners', which is used by `+eval/region'."
(let ((command (doom-unquote command)))
(cond ((symbolp command)
`(push (cons ,mode ',command) +eval-runners))
((stringp command)
`(after! quickrun
(push (cons ,mode ',command)
,(if (stringp mode)
'quickrun-file-alist
'quickrun--major-mode-alist))))
((listp command)
`(after! quickrun
(quickrun-add-command
,(symbol-name (doom-unquote mode))
',command :mode ,mode))))))

View file

@ -31,8 +31,8 @@
(figwheel-sidecar.repl-api/cljs-repl))")
(set-popup-rule! "^\\*cider-repl" nil '((quit) (select)))
(set! :repl 'clojure-mode #'+clojure/repl)
(set! :eval 'clojure-mode #'cider-eval-region)
(set-repl-handler! 'clojure-mode #'+clojure/repl)
(set-eval-handler! 'clojure-mode #'cider-eval-region)
(set! :lookup 'clojure-mode
:definition #'cider-browse-ns-find-at-point
:documentation #'cider-browse-ns-doc-at-point)

View file

@ -6,7 +6,7 @@
(set! :lookup 'crystal-mode
:definition #'crystal-def-jump
:references #'crystal-tool-imp)
(set! :eval 'crystal-mode
(set-eval-handler! 'crystal-mode
'((:command . "crystal")
(:exec . "%c %s")
(:description . "Run Crystal script"))))

View file

@ -33,6 +33,6 @@
(set! :lookup 'elixir-mode
:definition #'alchemist-goto-definition-at-point
:documentation #'alchemist-help-search-at-point)
(set! :eval 'elixir-mode #'alchemist-eval-region)
(set! :repl 'elixir-mode #'alchemist-iex-project-run))
(set-eval-handler! 'elixir-mode #'alchemist-eval-region)
(set-repl-handler! 'elixir-mode #'alchemist-iex-project-run))

View file

@ -6,7 +6,7 @@
(after! elm-mode
(add-hook! 'elm-mode-hook #'(flycheck-mode rainbow-delimiters-mode))
(set-company-backend! 'elm-mode 'company-elm)
(set! :repl 'elm-mode #'run-elm-interactive))
(set-repl-handler! 'elm-mode #'run-elm-interactive))
(def-package! flycheck-elm

View file

@ -3,8 +3,8 @@
(def-package! elisp-mode ; built-in
:mode ("/Cask$" . emacs-lisp-mode)
:config
(set! :repl 'emacs-lisp-mode #'+emacs-lisp/repl)
(set! :eval 'emacs-lisp-mode #'+emacs-lisp-eval)
(set-repl-handler! 'emacs-lisp-mode #'+emacs-lisp/repl)
(set-eval-handler! 'emacs-lisp-mode #'+emacs-lisp-eval)
(set! :lookup 'emacs-lisp-mode :documentation 'info-lookup-symbol)
(set-docset! '(lisp-mode emacs-lisp-mode) "Emacs Lisp")

View file

@ -39,7 +39,7 @@
ess-nuke-trailing-whitespace-p t
ess-default-style 'DEFAULT)
(ess-toggle-underscore t)
(set! :repl 'ess-mode #'+ess/r-repl)
(set-repl-handler! 'ess-mode #'+ess/r-repl)
(set! :lookup 'ess-mode :documentation #'ess-display-help-on-object)
(define-key! ess-doc-map
"h" #'ess-display-help-on-object

View file

@ -6,7 +6,7 @@
(after! go-mode
(set-env! "GOPATH" "GOROOT")
(set! :repl 'go-mode #'gorepl-run)
(set-repl-handler! 'go-mode #'gorepl-run)
(set! :lookup 'go-mode
:definition #'go-guru-definition
:references #'go-guru-referrers

View file

@ -9,6 +9,6 @@
;;
(after! haskell-mode
(set! :repl 'haskell-mode #'switch-to-haskell)
(set-repl-handler! 'haskell-mode #'switch-to-haskell)
(add-to-list 'completion-ignored-extensions ".hi"))

View file

@ -4,5 +4,5 @@
:mode "\\.hy\\'"
:interpreter "hy"
:config
(set! :repl 'hy-mode #'hy-shell-start-or-switch-to-shell)
(set-repl-handler! 'hy-mode #'hy-shell-start-or-switch-to-shell)
(set-company-backend! 'hy-mode 'company-hy))

View file

@ -24,5 +24,5 @@
(def-package! groovy-mode
:mode "\\.g\\(?:radle\\|roovy\\)$"
:config
(set! :eval 'groovy-mode "groovy"))
(set-eval-handler! 'groovy-mode "groovy"))

View file

@ -22,7 +22,7 @@
(add-hook! 'js2-mode-hook #'(flycheck-mode rainbow-delimiters-mode))
(set-electric! 'js2-mode :chars '(?\} ?\) ?. ?:))
(set! :repl 'js2-mode #'+javascript/repl)
(set-repl-handler! 'js2-mode #'+javascript/repl)
;; Conform switch-case indentation to js2 normal indent
(defvaralias 'js-switch-indent-offset 'js2-basic-offset)

View file

@ -3,7 +3,7 @@
(use-package julia-mode
:interpreter "julia"
:config
(set! :repl 'julia-mode #'+julia/repl)
(set-repl-handler! 'julia-mode #'+julia/repl)
;; Borrow matlab.el's fontification of math operators
;; From <https://ogbe.net/emacsconfig.html>

View file

@ -5,7 +5,7 @@
(set! :lookup 'lua-mode :documentation 'lua-search-documentation)
(set-electric! 'lua-mode :words '("else" "end"))
(set! :repl 'lua-mode #'+lua/repl)
(set-repl-handler! 'lua-mode #'+lua/repl)
(set-company-backend! 'lua-mode '(company-lua company-yasnippet))
(def-menu! +lua/build-menu

View file

@ -17,7 +17,7 @@
;; php+html. Use the .phtml
(setq php-template-compatibility nil)
(set! :repl 'php-mode #'php-boris)
(set-repl-handler! 'php-mode #'php-boris)
(set! :lookup 'php-mode :documentation #'php-search-documentation)
;; ac-php provides custom autocompletion, php-extras provides autocompletion

View file

@ -26,7 +26,7 @@ is loaded.")
(set-env! "PYTHONPATH" "PYENV_ROOT")
(set-electric! 'python-mode :chars '(?:))
(set! :repl 'python-mode #'+python/repl)
(set-repl-handler! 'python-mode #'+python/repl)
(when (executable-find "ipython")
(setq python-shell-interpreter "ipython"

View file

@ -17,7 +17,7 @@
(set-company-backend! 'ruby-mode 'company-dabbrev-code)
(set-electric! 'ruby-mode :words '("else" "end" "elseif"))
(set-env! "RBENV_ROOT")
(set! :repl 'ruby-mode #'inf-ruby) ; `inf-ruby'
(set-repl-handler! 'ruby-mode #'inf-ruby) ; `inf-ruby'
(setq ruby-deep-indent-paren t)
;; Don't interfere with my custom RET behavior
(define-key ruby-mode-map [?\n] nil)

View file

@ -21,4 +21,4 @@
(def-package! sbt-mode
:after scala-mode
:config (set! :repl 'scala-mode #'run-scala))
:config (set-repl-handler! 'scala-mode #'run-scala))

View file

@ -17,7 +17,7 @@
:config
(add-hook! sh-mode #'(flycheck-mode highlight-numbers-mode))
(set-electric! 'sh-mode :words '("else" "elif" "fi" "done" "then" "do" "esac" ";;"))
(set! :repl 'sh-mode #'+sh/repl)
(set-repl-handler! 'sh-mode #'+sh/repl)
(setq sh-indent-after-continuation 'always)

View file

@ -1,7 +1,7 @@
;;; lang/swift/config.el -*- lexical-binding: t; -*-
;; `swift-mode'
(set! :repl 'swift-mode #'run-swift)
(set-repl-handler! 'swift-mode #'run-swift)
(def-package! flycheck-swift