punassuming / ranger.el

Bringing the goodness of ranger to dired!
699 stars 52 forks source link

ranger-travel: Making window-configuration-change-hook buffer-local while locally let-bound! ido-find-file: Lisp nesting exceeds ‘max-lisp-eval-depth’ #158

Open braham-snyder opened 7 years ago

braham-snyder commented 7 years ago

edit: forgot to confirm that, unsurprisingly, this is not an issue in deer

edit: seeing this with both ido-find-file and counsel-find-file--do most people not run into this behavior since they're using helm, and opening subdirectories within its prompt?

@therockmandolinist since you mentioned you're using this package with counsel as well: do you happen to know any workarounds to this behavior outside of using deer instead of ranger?

edit: So one really simple workaround is to make ranger-travel use--instead of find-file-- counsel-find-file's definition with find-file just replaced with ranger-find-file. I've only tested this briefly thus far, but it seems to be working just fine for now (and additionally solved another bug I was encountering with ranger-override-dired, where dired would not be overridden). That said, there must be a slightly cleaner way to accomplish effectively the same thing.

punassuming commented 7 years ago

@braham-snyder, I switched the usage for ido and ivy to use a read-file-name variant, directly with ranger-find-file. Let me know if this address the issue.

carlton87 commented 7 years ago

@ralesi Just today I encountered a similar (or maybe the same?) issue. But for me it freezes my Emacs completely and irrevocably not only when I try to use ranger-travel but also if I just try to enter a parent or child directory (opening files in the current directory works though). Sometimes but not always I can see the message

Making window-configuration-change-hook buffer-local while locally let-bound!

in the minibuffer when Emacs is frozen. I just started using Spacemacs (with the emacs-w64 binaries) under Windows 10 (64bit). I use ivy as completion frontend.

alpox commented 7 years ago

I have the exact same behavior as @carlton87 so here my +1 for it. I use Spacemacs on Ubuntu 16.04 (Unity) with helm as completion frontend.

braham-snyder commented 7 years ago

I'm in fact seeing the same message upon navigating into a child directory in ranger, but the operation succeeds (albeit quite slowly -- takes about 2 seconds). (I really only use ranger (vs. deer) for browsing images at the moment (partly just out of habit from when it froze for me, partly due to occasional windowing bugs with my config), so I don't run into this much.) Setting debug-on-message to the message showed me this backtrace (which may or may not be relevant to your freezes):

Debugger entered--Lisp error: "Making window-configuration-change-hook buffer-local while locally let-bound!"
  make-local-variable(window-configuration-change-hook)
  add-hook(window-configuration-change-hook evil--jumps-window-configuration-hook nil t)
  #[nil "\203\301\302\303\304\305$\210\301\306\307\304\305$\210\301\310\311\304\305$\207\312\302\303\305#\210\312\306\307\305#\210\312\310\311\305#\207" [evil-local-mode add-hook pre-command-hook evil--jump-hook nil t next-error-hook evil-set-jump window-configuration-change-hook evil--jumps-window-configuration-hook remove-hook] 5]()
  run-hooks(evil-local-mode-hook evil-local-mode-on-hook)
  evil-local-mode(1)
  evil-initialize()
  evil-mode-enable-in-buffers()
  run-hooks(after-change-major-mode-hook)
  run-mode-hooks(dired-mode-hook)
  dired-mode("/Users/Shared/SC Info/" "-alGh")
  dired-internal-noselect("/Users/Shared/SC Info/" nil)
  dired-noselect("/Users/Shared/SC Info")
  ranger-dir-buffer("/Users/Shared/SC Info" t)
  ranger-setup-preview()
  ranger-setup()
  ranger-mode()
  ranger-find-file("/Users/Shared/")
  ranger()
  ranger-still-dired()
  ranger-window-check()
  #<subr set-window-buffer>(nil #<buffer Shared> nil)
  ad-Advice-set-window-buffer(#<subr set-window-buffer> nil #<buffer Shared>)
  apply(ad-Advice-set-window-buffer #<subr set-window-buffer> (nil #<buffer Shared>))
  set-window-buffer(nil #<buffer Shared>)
  #[(buffer-or-name &optional norecord force-same-window) "\306!\211\307 =\204s\310 \203#\n\203\311\312!\210\202s\313    \"\210\202s\314 \315=\203=\n\2035\311\316!\210\202s\313    \"\210\202s   \317 \236
\320=\205L\321 \322\"\323\324    \"\210\f\203r
\315=\204b\203r\325\326 \fA@\315#\210\327\324\330\f8\"\210*\204|\331\326 !\210    q)\207" [buffer-or-name buffer force-same-window norecord entry switch-to-buffer-preserve-window-point window-normalize-buffer-to-switch-to window-buffer window-minibuffer-p user-error "Cannot switch buffers in minibuffer window" pop-to-buffer window-dedicated-p t "Cannot switch buffers in a dedicated window" window-prev-buffers already-displayed get-buffer-window 0 set-window-buffer nil set-window-start selected-window set-window-point 2 select-window displayed] 5 2686308 (let ((force-same-window (cond ((window-minibuffer-p) nil) ((not (eq ... t)) (quote force-same-window)) ((cond (... ...) (... ...) (... ...) (t ...)))))) (list (read-buffer-to-switch "Switch to buffer: ") nil force-same-window))](#<buffer Shared> nil nil)
  ad-Advice-switch-to-buffer(#[(buffer-or-name &optional norecord force-same-window) "\306!\211\307 =\204s\310 \203#\n\203\311\312!\210\202s\313 \"\210\202s\314 \315=\203=\n\2035\311\316!\210\202s\313    \"\210\202s   \317 \236
\320=\205L\321 \322\"\323\324    \"\210\f\203r
\315=\204b\203r\325\326 \fA@\315#\210\327\324\330\f8\"\210*\204|\331\326 !\210    q)\207" [buffer-or-name buffer force-same-window norecord entry switch-to-buffer-preserve-window-point window-normalize-buffer-to-switch-to window-buffer window-minibuffer-p user-error "Cannot switch buffers in minibuffer window" pop-to-buffer window-dedicated-p t "Cannot switch buffers in a dedicated window" window-prev-buffers already-displayed get-buffer-window 0 set-window-buffer nil set-window-start selected-window set-window-point 2 select-window displayed] 5 2686308 (let ((force-same-window (cond ((window-minibuffer-p) nil) ((not (eq ... t)) (quote force-same-window)) ((cond (... ...) (... ...) (... ...) (t ...)))))) (list (read-buffer-to-switch "Switch to buffer: ") nil force-same-window))] #<buffer Shared>)
  apply(ad-Advice-switch-to-buffer #[(buffer-or-name &optional norecord force-same-window) "\306!\211\307 =\204s\310 \203#\n\203\311\312!\210\202s\313   \"\210\202s\314 \315=\203=\n\2035\311\316!\210\202s\313    \"\210\202s   \317 \236
\320=\205L\321 \322\"\323\324    \"\210\f\203r
\315=\204b\203r\325\326 \fA@\315#\210\327\324\330\f8\"\210*\204|\331\326 !\210    q)\207" [buffer-or-name buffer force-same-window norecord entry switch-to-buffer-preserve-window-point window-normalize-buffer-to-switch-to window-buffer window-minibuffer-p user-error "Cannot switch buffers in minibuffer window" pop-to-buffer window-dedicated-p t "Cannot switch buffers in a dedicated window" window-prev-buffers already-displayed get-buffer-window 0 set-window-buffer nil set-window-start selected-window set-window-point 2 select-window displayed] 5 2686308 (let ((force-same-window (cond ((window-minibuffer-p) nil) ((not (eq ... t)) (quote force-same-window)) ((cond (... ...) (... ...) (... ...) (t ...)))))) (list (read-buffer-to-switch "Switch to buffer: ") nil force-same-window))] #<buffer Shared>)
  switch-to-buffer(#<buffer Shared>)
  ranger-find-file()
  funcall-interactively(ranger-find-file)
  call-interactively(ranger-find-file nil nil)
  command-execute(ranger-find-file)

Have either of you tried SIGUSR2 to see a backtrace?

Also, for what it's worth, regarding ranger-travel's definition:

          (ranger-find-file (read-file-name prompt))

seems to be a simpler solution for ivy (ivy-mode sets completing-read-function, which read-file-name (etc.) use internally (or something along those lines)).

It's possible ranger-travel could be merely (ranger-find-file (read-file-name "Travel: ")), which, IIUC, should automatically use the user's enabled completion package (e.g., if they've enabled helm-mode). That said, I don't know enough about helm to know whether helm-read-file-name (currently used in ranger-travel) offers any additional functionality for helm users beyond read-file-name with helm-mode enabled.

carlton87 commented 7 years ago

@braham-snyder With debug-on-message I get the following backtrace when opening a ranger buffer (but before doing anything that causes the freeze):

  Debugger entered--Lisp error: "Making window-configuration-change-hook buffer-local while locally let-bound!"
  make-local-variable(window-configuration-change-hook)
  add-hook(window-configuration-change-hook evil--jumps-window-configuration-hook nil t)
  #[nil "\203\301\302\303\304\305$\210\301\306\307\304\305$\210\301\310\311\304\305$\207\312\302\303\305#\210\312\306\307\305#\210\312\310\311\305#\207" [evil-local-mode add-hook pre-command-hook evil--jump-hook nil t next-error-hook evil-set-jump window-configuration-change-hook evil--jumps-window-configuration-hook remove-hook] 5]()
  run-hooks(evil-local-mode-hook evil-local-mode-on-hook)
  evil-local-mode(1)
  evil-initialize()
  evil-mode-enable-in-buffers()
  run-hooks(after-change-major-mode-hook)
  run-mode-hooks(dired-mode-hook)
  dired-mode("d:/" "-alGh")
  dired-internal-noselect("d:/" nil)
  dired-noselect("d:/")
  ranger-dir-buffer("d:/" nil)
  ranger-make-parent((("d:/HOME/" . "d:/") . 1))
  mapc(ranger-make-parent ((("d:/HOME/" . "d:/") . 1)))
  ranger-setup-parents()
  ranger-setup()
  ranger-mode()
  ranger-find-file("~/")
  ranger()
  funcall-interactively(ranger)
  call-interactively(ranger nil nil)
  command-execute(ranger)

Unfortunately I can't use SIGUSR2 cause it seems to be impossible to kill a Windows process from an msys terminal with a kill command and Windows itself doesn't seem to have SIGUSR2.

`

datross commented 6 years ago

Same as @carlton87. It totally freezes. I'm on spacemacs 0.200.10. An the problem happens only when emacs window is maximazed.

npit commented 6 years ago

Same issue, freezing in 0.200.13.