Skip to content

Commit

Permalink
Mark idris-print-definition-of-name as obsolete in favour of
Browse files Browse the repository at this point in the history
`idris-print-definition-of-name-at-point` and define new "internal"
function `idris--print-definition-of-name` to be used by the new `idris-print-definition-of-name-at-point`
and also from interactive context menu.

Why:
This allow us to have custom behaviour for "printing definitions" for Idris 1 and 2
in one place.
  • Loading branch information
keram committed Jan 5, 2023
1 parent 3e7cbb3 commit 7697b8b
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions idris-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,25 @@ This sets the load position to point, if there is one."
(when name
(idris-info-for-name :type-of name))))

(defun idris-print-definition-of-name (thing)
"Display the definition of the function or type of the THING at point."
(defun idris--print-definition-of-name (name)
"Fetch from the Idris compiler and display the definition of the NAME."
(if (>=-protocol-version 2 1)
(idris-info-for-name :interpret (concat ":printdef " name))
(idris-info-for-name :print-definition name)))

(defun idris-print-definition-of-name-at-point (name)
"Display the definition of the function or type of the NAME at point.
Idris 2 as of 05/01/2023 does not yet fully support
printing definition of a type at point."
(interactive "P")
(let ((name (if thing (read-string "Print definition: ")
(idris-name-at-point))))
(when name
(if (>=-protocol-version 2 1)
(idris-info-for-name :interpret (concat ":printdef " name))
(idris-info-for-name :print-definition name)))))
(let ((name* (if name
(read-string "Print definition: ")
(idris-name-at-point))))
(when name*
(idris--print-definition-of-name name*))))

(define-obsolete-function-alias 'idris-print-definition-of-name 'idris-print-definition-of-name-at-point "2023-01-05")

(defun idris-who-calls-name (name)
"Show the callers of NAME in a tree."
Expand Down Expand Up @@ -1321,7 +1331,7 @@ of the term to replace."
(list "Get definition"
(lambda ()
(interactive)
(idris-info-for-name :print-definition ref)))
(idris--print-definition-of-name ref)))
(list "Who calls?"
(lambda ()
(interactive)
Expand Down

0 comments on commit 7697b8b

Please sign in to comment.