lang/org: add lookup handlers for src blocks
- Fixes: `set-lookup-handlers!` couldn't define :definition or :references handlers in text-mode derivatives. - Adds: support for evaluating code in jupyter blocks (#2477).
This commit is contained in:
parent
3b159dda0a
commit
5a80db875c
4 changed files with 60 additions and 9 deletions
|
@ -192,6 +192,18 @@ This can be passed nil as its second argument to unset handlers for MODES. e.g.
|
|||
'deferred
|
||||
t))))
|
||||
|
||||
(defun +lookup-dictionary-definition-backend-fn (identifier)
|
||||
"Look up dictionary definition for IDENTIFIER."
|
||||
(when (derived-mode-p 'text-mode)
|
||||
(+lookup/dictionary-definition identifier)
|
||||
'deferred))
|
||||
|
||||
(defun +lookup-thesaurus-definition-backend-fn (identifier)
|
||||
"Look up synonyms for IDENTIFIER."
|
||||
(when (derived-mode-p 'text-mode)
|
||||
(+lookup/synonyms identifier)
|
||||
'deferred))
|
||||
|
||||
(defun +lookup-xref-definitions-backend-fn (identifier)
|
||||
"Non-interactive wrapper for `xref-find-definitions'"
|
||||
(+lookup--xref-show 'xref-backend-definitions identifier #'xref--show-defs))
|
||||
|
@ -343,7 +355,7 @@ Otherwise, falls back on `find-file-at-point'."
|
|||
(list (or (doom-thing-at-point-or-region 'word)
|
||||
(read-string "Look up in dictionary: "))
|
||||
current-prefix-arg))
|
||||
(message "Looking up definition for %S" identifier)
|
||||
(message "Looking up dictionary definition for %S" identifier)
|
||||
(cond ((and IS-MAC (require 'osx-dictionary nil t))
|
||||
(osx-dictionary--view-result identifier))
|
||||
((and +lookup-dictionary-prefer-offline
|
||||
|
|
|
@ -41,7 +41,8 @@ Used by `+lookup/online'.")
|
|||
"Function to use to open search urls.")
|
||||
|
||||
(defvar +lookup-definition-functions
|
||||
'(+lookup-xref-definitions-backend-fn
|
||||
'(+lookup-dictionary-definition-backend-fn
|
||||
+lookup-xref-definitions-backend-fn
|
||||
+lookup-dumb-jump-backend-fn
|
||||
+lookup-project-search-backend-fn
|
||||
+lookup-evil-goto-definition-backend-fn)
|
||||
|
@ -73,7 +74,8 @@ argument: the identifier at point. See `set-lookup-handlers!' about adding to
|
|||
this list.")
|
||||
|
||||
(defvar +lookup-references-functions
|
||||
'(+lookup-xref-references-backend-fn
|
||||
'(+lookup-thesaurus-definition-backend-fn
|
||||
+lookup-xref-references-backend-fn
|
||||
+lookup-project-search-backend-fn)
|
||||
"Functions for `+lookup/references' to try, before resorting to `dumb-jump'.
|
||||
Stops at the first function to return non-nil or change the current
|
||||
|
@ -203,11 +205,5 @@ Dictionary.app behind the scenes to get definitions.")
|
|||
collect (cons service #'+eval-display-results-in-popup))))
|
||||
|
||||
|
||||
(when (featurep! +dictionary)
|
||||
(define-key! text-mode-map
|
||||
[remap +lookup/definition] #'+lookup/dictionary-definition
|
||||
[remap +lookup/references] #'+lookup/synonyms))
|
||||
|
||||
|
||||
;;;###package synosaurus
|
||||
(setq synosaurus-choose-method 'default) ; use ivy/helm instead of ido
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue