Skip to content

Commit

Permalink
Mark idris-list-holes-on-load as obsolete in favour of `idris-list-…
Browse files Browse the repository at this point in the history
…holes`

Why:
The `idris-list-holes-on-load` was defined as interactive and such
as invokable by user but with nondeterministic behaviour affected
by `idris-hole-show-on-load`.
Removing it in future will simplify the public api of idris-mode
and reduce maintainance costs.

This commit also updates docs for `idris-prover-success-hook`
and `idris-load-file-success-hook` to make explicit that
they are also affected by the `idris-hole-show-on-load` variable.
  • Loading branch information
keram committed Dec 12, 2022
1 parent ef67682 commit 9e931bf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
14 changes: 2 additions & 12 deletions idris-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,8 @@
(setq idris-process-current-working-directory new-working-directory))
(error "Failed to switch the working directory %s" eval-result)))))

(defun idris-list-holes-on-load ()
"Use the user's settings from customize to determine whether to list the holes."
(interactive)
(when idris-hole-show-on-load (idris-list-holes)))

(defcustom idris-load-file-success-hook '(idris-list-holes-on-load
idris-set-current-pretty-print-width)
"Functions to call when loading a file is successful"
:type 'hook
:options '(idris-list-holes-on-load
idris-set-current-pretty-print-width)
:group 'idris)
(define-obsolete-function-alias 'idris-list-holes-on-load 'idris-list-holes "2022-12-15"
"Use the user's settings from customize to determine whether to list the holes.")

(defun idris-possibly-make-dirty (beginning end _length)
;; If there is a load-to-here marker and a currently loaded region, only
Expand Down
6 changes: 0 additions & 6 deletions idris-prover.el
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,6 @@ the length reported by Idris."
t)
(_ nil)))

(defcustom idris-prover-success-hook '(idris-list-holes-on-load)
"Functions to call when completing a proof"
:type 'hook
:options '(idris-list-holes-on-load)
:group 'idris-prover)

(defun idris-perhaps-insert-proof-script (proof)
"Prompt the user as to whether PROOF should be inserted into the buffer."
(save-window-excursion
Expand Down
28 changes: 23 additions & 5 deletions idris-settings.el
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ customize the display of non-code text."
:group 'idris)

(defcustom idris-hole-list-show-expanded t
"Show the hole list fully expanded by default. This may be useful
on wide monitors with lots of space for the hole buffer."
"Show the hole list fully expanded by default.
This may be useful on wide monitors with lots of space for the hole buffer."
:type 'boolean
:group 'idris-hole-list)

Expand All @@ -251,6 +251,24 @@ change to ordinary prover interaction."
:group 'idris
:options '(idris-set-current-pretty-print-width))

(defcustom idris-load-file-success-hook '(idris-list-holes
idris-set-current-pretty-print-width)
"Functions to call when loading a file is successful.
When `idris-hole-show-on-load' is set to nil the function `idris-list-holes'
will be removed from the list automatically and will not be executed."
:type 'hook
:options '(idris-list-holes
idris-set-current-pretty-print-width)
:group 'idris)

(defcustom idris-prover-success-hook '(idris-list-holes)
"Functions to call when completing a proof.
When `idris-hole-show-on-load' is set to nil the function `idris-list-holes'
will be removed from the list automatically and will not be executed."
:type 'hook
:options '(idris-list-holes)
:group 'idris-prover)

;;;; REPL settings

(defgroup idris-repl nil "Idris REPL" :prefix 'idris :group 'idris)
Expand Down Expand Up @@ -299,10 +317,10 @@ Set to `nil' for no banner."
"File to save the persistent REPL history to.
By default we assume Idris' default configuration home is:
$HOME/.idris/idris-history.eld.
If you have installed/configured Idris differently, or are
If you have installed/configured Idris differently, or are
using Idris2, then you may wish to customise this variable."

:type 'string
Expand Down
9 changes: 9 additions & 0 deletions inferior-idris.el
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ directory variables.")
(add-hook 'idris-event-hooks 'idris-log-hook-function)
(add-hook 'idris-event-hooks 'idris-warning-event-hook-function)
(add-hook 'idris-event-hooks 'idris-prover-event-hook-function)

(unless idris-hole-show-on-load
(remove-hook 'idris-load-file-success-hook 'idris-list-holes-on-load)
(remove-hook 'idris-load-file-success-hook 'idris-list-holes)
;; TODO: In future decouple prover sucess hook from being affected by
;; idris-hole-show-on-load variable
(remove-hook 'idris-prover-success-hook 'idris-list-holes-on-load)
(remove-hook 'idris-prover-success-hook 'idris-list-holes))

(set-process-filter idris-connection 'idris-output-filter)
(set-process-sentinel idris-connection 'idris-sentinel)
(set-process-query-on-exit-flag idris-connection t)
Expand Down

0 comments on commit 9e931bf

Please sign in to comment.