Fix visit docs for Racket & support racket-xp (#3373)

* Fix visit docs for Racket & support racket-xp

- Fix Racket's +lookup/documentation in the same way as
  f20f477a44
- Support the +xp feature which enables racket-xp. When it's not
  enabled, default handlers to the traditional racket-repl
  (which requires users to run code first)

* PR feedback

* Replace add-hook! with add-hook
This commit is contained in:
sorawee 2020-06-13 00:03:11 -07:00 committed by GitHub
parent 991a205ebd
commit 0f3bd57101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View file

@ -21,7 +21,7 @@ This module provide integration for [[https://github.com/greghendershott/racket-
This module has no dedicated maintainers. This module has no dedicated maintainers.
** Module Flags ** Module Flags
This module provides no flags. + =+xp= Enables the explore mode, which "analyzes expanded code to explain and explore."
** Plugins ** Plugins
+ [[https://github.com/greghendershott/racket-mode][racket-mode]] + [[https://github.com/greghendershott/racket-mode][racket-mode]]

View file

@ -10,3 +10,20 @@
(let ((buf (get-buffer "*Racket REPL*"))) (let ((buf (get-buffer "*Racket REPL*")))
(bury-buffer buf) (bury-buffer buf)
buf))))) buf)))))
;;;###autoload
(defun +racket-lookup-documentation (thing)
"A `+lookup/documentation' handler for Racket."
(let ((buf (if racket-xp-mode
(racket-xp-describe thing)
(racket-repl-describe thing))))
(when buf
(pop-to-buffer buf)
t)))
;;;###autoload
(defun +racket-lookup-definition (_thing)
"A `+lookup/definition' handler for Racket."
(if racket-xp-mode
(call-interactively #'racket-xp-visit-definition)
(call-interactively #'racket-repl-visit-definition)))

View file

@ -13,8 +13,8 @@
:config :config
(set-repl-handler! 'racket-mode #'+racket/open-repl) (set-repl-handler! 'racket-mode #'+racket/open-repl)
(set-lookup-handlers! 'racket-mode (set-lookup-handlers! 'racket-mode
:definition #'racket-xp-visit-definition :definition #'+racket-lookup-definition
:documentation #'racket-xp-describe) :documentation #'+racket-lookup-documentation)
(set-docsets! 'racket-mode "Racket") (set-docsets! 'racket-mode "Racket")
(set-pretty-symbols! 'racket-mode (set-pretty-symbols! 'racket-mode
:lambda "lambda" :lambda "lambda"
@ -27,9 +27,12 @@
#'rainbow-delimiters-mode #'rainbow-delimiters-mode
#'highlight-quoted-mode) #'highlight-quoted-mode)
(when (featurep! +xp)
(add-hook 'racket-mode-hook #'racket-xp-mode))
(unless (or (featurep! :editor parinfer) (unless (or (featurep! :editor parinfer)
(featurep! :editor lispy)) (featurep! :editor lispy))
(add-hook! 'racket-mode-hook #'racket-smart-open-bracket-mode)) (add-hook 'racket-mode-hook #'racket-smart-open-bracket-mode))
(map! :localleader (map! :localleader
:map racket-mode-map :map racket-mode-map