I am trying to get code folding to work in Elpy. I have turned the folding module on already. However, I still seem to be unable to fold code. When I click on the first line of a while loop, I get the following message:
Debugger entered--Lisp error: (invalid-function hs-life-goes-on)
hs-life-goes-on(nil)
elpy-folding--click-text((mouse-1 (#<window 3 on while-loops.py> 94 (32 . 80) 18555047 nil 94 (4 . 5) nil (4 . 10) (7 . 14))))
funcall-interactively(elpy-folding--click-text (mouse-1 (#<window 3 on while-loops.py> 94 (32 . 80) 18555047 nil 94 (4 . 5) nil (4 . 10) (7 . 14))))
call-interactively(elpy-folding--click-text nil nil)
command-execute(elpy-folding--click-text)
When I try to use the code folding option from the Elpy drop-down menu, I get the following error:
Debugger entered--Lisp error: (invalid-function hs-life-goes-on)
hs-life-goes-on(nil)
elpy-folding-toggle-at-point()
funcall-interactively(elpy-folding-toggle-at-point)
call-interactively(elpy-folding-toggle-at-point nil nil)
command-execute(elpy-folding-toggle-at-point)
When I try to use the shortcut for the elpy-toggle-at-point
function, I also get an error similar to the one above:
Debugger entered--Lisp error: (invalid-function hs-life-goes-on)
hs-life-goes-on(nil)
elpy-folding-toggle-at-point()
funcall-interactively(elpy-folding-toggle-at-point)
call-interactively(elpy-folding-toggle-at-point record nil)
command-execute(elpy-folding-toggle-at-point record)
execute-extended-command(nil "elpy-folding-toggle-at-point" "elpy-folding-toggle-at")
funcall-interactively(execute-extended-command nil "elpy-folding-toggle-at-point" "elpy-folding-toggle-at")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
It seems that hs-life-goes-on
from hideshow.el
, which controls the "HideShow" minor mode is the problem. When I went to the function definition in hideshow.el.gz
, this is what I found:
(defmacro hs-life-goes-on (&rest body)
"Evaluate BODY forms if variable `hs-minor-mode' is non-nil.
In the dynamic context of this macro, `inhibit-point-motion-hooks'
and `case-fold-search' are both t."
(declare (debug t))
`(when hs-minor-mode
(let ((inhibit-point-motion-hooks t)
(case-fold-search t))
,@body)))
I am honestly not sure what is going on here.
As a last resort, I uninstalled Emacs and reinstalled it. I am currently using Emacs 28 on MacOS Catalina. My previous Emacs was 26.3. Both of these versions were obtained from HomeBrew. Emacs 26.3, my previous version was obtained from brew cask
. My latest one, Emacs 28, was this version compiled from HomeBrew using the --with-cocoa
option. Reinstallation did not fix the problem.
A similar question has been asked before, but the error I am getting is quite different from the one that the person asking that question got. In my case, I have also attempted to fix the problem by trying different methods to get code folding to work and managed to track down the code behind the function which seems to be breaking. That is why I think that this question is distinct enough from the aforementioned question to be posted separately on StackExchange, and should not count as a duplicate.
May I know what I can do to solve the problem?