Skip to content

Commit

Permalink
Fix lisp nesting in jsonian-no-so-long-mode (#28)
Browse files Browse the repository at this point in the history
Adds new variable `jsonian--so-long-predicate` that stores the
original function stored in `so-long-predicate` before setting it to a
lambda (which now calls the stored old function).

Calling `jsonian-unload-function` reinstates the old function.
  • Loading branch information
Walheimat authored Jul 5, 2022
1 parent d031099 commit ad861d1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions jsonian.el
Original file line number Diff line number Diff line change
Expand Up @@ -1405,9 +1405,15 @@ designed to be installed with `advice-add' and `:before-until'."
(jsonian-narrow-to-defun arg))
correct))

(defvar jsonian--so-long-predicate nil
"The function originally assigned to `so-long-predicate'.")

(defun jsonian-unload-function ()
"Unload `jsonian'."
(advice-remove #'narrow-to-defun #'jsonian--correct-narrow-to-defun))
(advice-remove #'narrow-to-defun #'jsonian--correct-narrow-to-defun)
(defvar so-long-predicate)
(when jsonian--so-long-predicate
(setq so-long-predicate jsonian--so-long-predicate)))


;; Foreign integration
Expand Down Expand Up @@ -1435,10 +1441,11 @@ designed to be installed with `advice-add' and `:before-until'."
(unless (boundp 'so-long-predicate)
(user-error "`so-long' mode needs to be loaded"))
(defvar so-long-predicate)
(setq jsonian--so-long-predicate so-long-predicate)
(setq so-long-predicate
(lambda ()
(unless (eq major-mode 'jsonian-mode)
(funcall so-long-predicate)))))
(funcall jsonian--so-long-predicate)))))


;; Miscellaneous utility functions
Expand Down

0 comments on commit ad861d1

Please sign in to comment.