Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spacemacs, purpose-x-magit-multi-on, Lisp nesting exceeds ‘max-lisp-eval-depth’ #178

Closed
duianto opened this issue Mar 3, 2021 · 14 comments

Comments

@duianto
Copy link

duianto commented Mar 3, 2021

(purpose-x-magit-multi-on) is causing an issue when trying to open a magit buffer in Spacemacs,
after reloading the configuration: SPC f e R

magit-status: Lisp nesting exceeds ‘max-lisp-eval-depth’

When debugging is enabled: SPC t D
And one tries to open a magit buffer.

Then the Backtrace buffer shows:

Debugger entered--Lisp error: (error "Variable binding depth exceeds max-specpdl-size")

followed by 793 lines of:

  purpose-x-magit-display-buffer-function(#<buffer magit: .emacs.d>)

followed by:

  magit-display-buffer(#<buffer magit: .emacs.d>)
  magit-setup-buffer-internal(magit-status-mode nil ((magit-buffer-diff-args ("--no-ext-diff")) (magit-buffer-diff-files nil) (magit-buffer-log-args ("-n256" "--decorate")) (magit-buffer-log-files nil)))
  magit-status-setup-buffer("c:/Users/username/AppData/Roaming/.emacs.d/layers/...")
  magit-status(nil ((3 . 2) (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." . magit-toplevel) . "c:/Users/username/AppData/Roaming/.emacs.d/") (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." "rev-parse" "--show-toplevel") . "C:/Users/username/AppData/Roaming/.emacs.d")))
  funcall-interactively(magit-status nil ((3 . 2) (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." . magit-toplevel) . "c:/Users/username/AppData/Roaming/.emacs.d/") (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." "rev-parse" "--show-toplevel") . "C:/Users/username/AppData/Roaming/.emacs.d")))
  call-interactively(magit-status nil nil)
  command-execute(magit-status)

Pressing q in the backtrace buffer changes it to:

Debugger entered--Lisp error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
  magit-status-setup-buffer("c:/Users/username/AppData/Roaming/.emacs.d/layers/...")
  magit-status(nil ((3 . 2) (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." . magit-toplevel) . "c:/Users/username/AppData/Roaming/.emacs.d/") (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." "rev-parse" "--show-toplevel") . "C:/Users/username/AppData/Roaming/.emacs.d")))
  funcall-interactively(magit-status nil ((3 . 2) (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." . magit-toplevel) . "c:/Users/username/AppData/Roaming/.emacs.d/") (("c:/Users/username/AppData/Roaming/.emacs.d/layers/..." "rev-parse" "--show-toplevel") . "C:/Users/username/AppData/Roaming/.emacs.d")))
  call-interactively(magit-status nil nil)
  command-execute(magit-status)

The issue doesn't occur when these two lines are commented out:
https://github.com/syl20bnr/spacemacs/blob/6d8101c20e600c9498398d3a1c412ab5e68f86f4/layers/%2Bspacemacs/spacemacs-purpose/packages.el#L160-L161

      (with-eval-after-load 'magit
        (purpose-x-magit-multi-on)))))
Windows 10, System Info (Click to expand)
#### System Info :computer:
- OS: windows-nt
- Emacs: 27.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 6d8101c20)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
```elisp
(auto-completion autohotkey emacs-lisp git helm html markdown multiple-cursors
                 (org :variables org-agenda-files
                      '("c:/Users/username/org/"))
                 shell spell-checking syntax-checking treemacs version-control)
```
- System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2 HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS JSON PDUMPER LCMS2 GMP
@duianto duianto changed the title Spurpose-x-magit-multi-on Spacemacs, purpose-x-magit-multi-on, Lisp nesting exceeds ‘max-lisp-eval-depth’ Mar 3, 2021
@wyuenho
Copy link
Collaborator

wyuenho commented Mar 3, 2021

What's the value of purpose-x-magit-display-buffer-function when you type M-x describe-variable purpose-x-magit-display-buffer-function ?

@duianto
Copy link
Author

duianto commented Mar 3, 2021

That variable isn't found.

Only these three variables are found when searching for: purpose x magit

purpose-x-magit-multi-conf
purpose-x-magit-single-conf
purpose-x-old-magit-display-buffer-function

The purpose-x-old-magit-display-buffer-function variable has the following values

Before reloading the configuration:

purpose-x-old-magit-display-buffer-function is a variable defined in ‘window-purpose-x.el’.
Its value is nil

After opening a magit buffer:

purpose-x-old-magit-display-buffer-function is a variable defined in ‘window-purpose-x.el’.
Its value is ‘magit-display-buffer-traditional’

After reloading the configuration:

purpose-x-old-magit-display-buffer-function is a variable defined in ‘window-purpose-x.el’.
Its value is ‘purpose-x-magit-display-buffer-function’

@wyuenho
Copy link
Collaborator

wyuenho commented Mar 3, 2021

Sorry, I mean the value of magit-display-buffer-function.

After reloading the configuration:
purpose-x-old-magit-display-buffer-function is a variable defined in ‘window-purpose-x.el’.
Its value is ‘purpose-x-magit-display-buffer-function’

That's the problem. You did not call purpose-x-magit-off before calling purpose-x-magit-multi-on a second time. Just make sure purpose-x-magit-multi-on is only called once and you should be ok.

@duianto
Copy link
Author

duianto commented Mar 3, 2021

It seems to have the same value all the time:

magit-display-buffer-function is a variable defined in ‘magit-mode.el’.
Its value is ‘purpose-x-magit-display-buffer-function’
Original value was
‘magit-display-buffer-traditional’

This seems to work:

      (with-eval-after-load 'magit
        (when purpose-x-old-magit-display-buffer-function
          (purpose-x-magit-off))
        (purpose-x-magit-multi-on)))))

At first I thought that there was a purpose-x-magit-multi-off command,
but there doesn't seem to be such a command, but it also works.
(I retested it to make sure and it also works)

(with-eval-after-load 'magit
        (when purpose-x-old-magit-display-buffer-function
          (purpose-x-magit-multi-off))
        (purpose-x-magit-multi-on))

Is this something that could be checked/handled when purpose-x-magit-multi-on is called.
so that it's turned off first, if it already is on.

Or possibly show a message that it has to be turned off before calling it again.

@wyuenho
Copy link
Collaborator

wyuenho commented Mar 3, 2021

You don't need to put purpose-x-magit-multi-on inside a with-eval-after-load, it's already done for you, so you only need to call it once after loading window-purpose.

Leftover state not being cleaned up after turning on and off purpose mode and extensions is pretty much the same as #166.

@duianto
Copy link
Author

duianto commented Mar 3, 2021

with-eval-after-load 'magit was added in this commit: syl20bnr/spacemacs@af0d0e7

[purpose] Fix undefined magit-display-buffer-function during startup

With purpose and the new layer verification algorithm in place
it looks like the default load order changed causing
purpose-x-magit-multi-on to access magit-display-buffer-function
before is has been loaded.

@wyuenho
Copy link
Collaborator

wyuenho commented Mar 3, 2021

It's redundant but It shouldn't matter as it's only called once there regardless. What you need to do is to find out why purpose-x-magit-multi-on had been called twice before magit was loaded.

@duianto
Copy link
Author

duianto commented Mar 3, 2021

It's redundant

👍 saw that it was added here 17 days ago: cac0f8b

The Spacemacs commit was from 19 days ago.

I'll remove the Spacemacs (with-eval-after-load 'magit when I fix the max-lisp-eval-depth issue.

This also works:

        (unless purpose-x-old-magit-display-buffer-function
          (purpose-x-magit-multi-on))

Is it better to turn it off first: purpose-x-magit-off
or to only call purpose-x-magit-multi-on once per Emacs session?

@wyuenho
Copy link
Collaborator

wyuenho commented Mar 3, 2021

Just call purpose-x-magit-multi-on once per emacs session for now, and if you must, always call purpose-x-magit-off, before making another call to purpose-x-magit-multi-on again. The same goes for single-on.

In the future, once #82 gets moving, these functions should become idempotent again.

duianto added a commit to syl20bnr/spacemacs that referenced this issue Mar 4, 2021
problem:
trying to open a magit buffer after
reloading the configuration: `SPC f e R`

shows the message:
>Lisp nesting exceeds ‘max-lisp-eval-depth’

cause:
purpose-x-magit-multi-on can't be called twice,
without turning it off first: purpose-x-magit-off

Spacemacs, purpose-x-magit-multi-on, Lisp nesting exceeds ‘max-lisp-eval-depth’
bmag/emacs-purpose#178

solution:
in this case we'll only call: purpose-x-magit-multi-on
once per Emacs session.

notes:
this also removes the call to: with-eval-after-load 'magit
because it's handled upstream:
https://github.com/bmag/emacs-purpose/blob/c85dd3c9f70cd593d6bc79c40855a240e55b2575/window-purpose-x.el#L243
@duianto
Copy link
Author

duianto commented Mar 4, 2021

Thanks for the help.

A magit buffer can now be opened after reloading the configuration in Spacemacs.
The redundant with-eval-after-load call has also been removed.

@duianto duianto closed this as completed Mar 4, 2021
@bmag
Copy link
Owner

bmag commented Mar 4, 2021

The cause of the endless recursion is this combination:

  1. purpose-x-magit-display-buffer-function calls purpose-x-old-magit-display-buffer-function, which should point to the original value of magit-display-buffer-function.
  2. the second activation of purpose-x-magit-{single,multi}-on overrides purpose-x-old-magit-display-buffer-function to point to purpose-x-magit-display-buffer-function (because on second activation, this is the value of magit-display-buffer-function).

I fixed it in #179. Now purpose-x-old-magit-display-buffer-function is changed only if its previous value is non-nil, so a second activation (without purpose-x-magit-off in the middle) won't override the backup value.

@bmag
Copy link
Owner

bmag commented Mar 4, 2021

I'll try to work on #166 in the coming week

@wyuenho
Copy link
Collaborator

wyuenho commented Mar 4, 2021

Argh, we need to stop fixing things in both Spacemacs and purpose.

syl20bnr/spacemacs@91f92d8#commitcomment-47842211

They can already call purpose-x-magit-off before calling purpose-x-magit-on as suggested by the Spacemacs docs.

@duianto
Copy link
Author

duianto commented Mar 4, 2021

@bmag Thanks for the fix:
Fix #178: x-magit: don't override backup variable on double activation by bmag #179

And thanks @wyuenho for the troubleshooting.

It's enough to just call (purpose-x-magit-multi-on) now.

aam-at pushed a commit to aam-at/spacemacs that referenced this issue Mar 23, 2021
problem:
trying to open a magit buffer after
reloading the configuration: `SPC f e R`

shows the message:
>Lisp nesting exceeds ‘max-lisp-eval-depth’

cause:
purpose-x-magit-multi-on can't be called twice,
without turning it off first: purpose-x-magit-off

Spacemacs, purpose-x-magit-multi-on, Lisp nesting exceeds ‘max-lisp-eval-depth’
bmag/emacs-purpose#178

solution:
in this case we'll only call: purpose-x-magit-multi-on
once per Emacs session.

notes:
this also removes the call to: with-eval-after-load 'magit
because it's handled upstream:
https://github.com/bmag/emacs-purpose/blob/c85dd3c9f70cd593d6bc79c40855a240e55b2575/window-purpose-x.el#L243
wang-d pushed a commit to wang-d/spacemacs that referenced this issue Jul 22, 2021
problem:
trying to open a magit buffer after
reloading the configuration: `SPC f e R`

shows the message:
>Lisp nesting exceeds ‘max-lisp-eval-depth’

cause:
purpose-x-magit-multi-on can't be called twice,
without turning it off first: purpose-x-magit-off

Spacemacs, purpose-x-magit-multi-on, Lisp nesting exceeds ‘max-lisp-eval-depth’
bmag/emacs-purpose#178

solution:
in this case we'll only call: purpose-x-magit-multi-on
once per Emacs session.

notes:
this also removes the call to: with-eval-after-load 'magit
because it's handled upstream:
https://github.com/bmag/emacs-purpose/blob/c85dd3c9f70cd593d6bc79c40855a240e55b2575/window-purpose-x.el#L243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants