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

Already on GitHub? Sign in to your account

Error: Trying to run helm within a running helm session. #208

Closed
amelio-vazquez-reina opened this Issue Mar 3, 2013 · 13 comments

Comments

Projects
None yet
2 participants

Sometimes when working on long sessions, I am unable to use helm as I get the following error in the minibuffer:

Error: Trying to run helm within a running helm session

What's even worse, I can't even call M-x to invoke Emacs commands, since I have M-x bound to helm-M-x which again triggers the error above.

When this happens, I try pressing C-g repeatedly in all my Emacs windows (i.e. panes) to exit any potential running helm session, and sometimes it works, but other times I am unable to resolve the problem, and my only way out is to fully close Emacs.

It would be great if there was a command that I could invoke (and that I could bind to some keyboard shortcut) that kills any running helm sessions.

Do people ever encounter this problem? If so, how do they deal with it?

Owner

thierryvolpiatto commented Mar 3, 2013

ribonoous notifications@github.com writes:

Sometimes when working on long sessions, I am unable to use helm as I get the following error in the minibuffer:

Error: Trying to run helm within a running helm session

What's even worse, I can't even call M-x to invoke Emacs commands, since I have M-x bound to helm-M-x which again triggers the error above.

When this happens, I try pressing Ctrl-g repeatedly in all my
Emacs windows (i.e. panes) to exit any potential running helm session,
and sometimes it works, but other times I am unable to exit it.

It would be great if there is a command that I could invoke (and that I could bind to a command) that kills any running helm sessions.

Do people ever encounter this problem? If so, how do they deal with it?

This is a message error that is sent when you try to run a helm command within
a helm session.
If you have this message when restarting helm (not within a session),
this mean one helm command have exited badly not setting back helm-alive-p to nil.

I will have a look to this, thanks.

Can you tell me what did you do exactly if you can reproduce ?


Reply to this email directly or view it on GitHub:
#208

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

Thanks @thierryvolpiatto. I am trying to identify exactly what triggers this, but I have a hard time reproducing the error. However, I think it may happen when I do the following:

  • I am initiate a helm session (e.g. helm-buffers-list)
  • Without making any selection, I switch to another window (another pane within Emacs)
  • I maximize that buffer with a function like:
(defun toggle-maximize-buffer () "Maximize buffer"
  (interactive)
  (if (= 1 (length (window-list)))
    (jump-to-register '_)
    (progn
      (set-register '_ (list (current-window-configuration)))
      (delete-other-windows))))
  • I work on my buffers, maybe subdivide my Emacs window (pane) again, etc.
  • I try to run a helm session again

Since I have both M-x and C-x C-b bound to helm commands, I am unable to switch to the buffer running the original helm session to do Ctrl-g or make a selection to exit it.

Owner

thierryvolpiatto commented Mar 3, 2013

Ok, so the patch I installed will not fix this, this is just a wrong usage of helm.
So helm as expected detect a running helm session and don't want to start, normal.
In such cases, you have to exit all minibuffers and setq helm-alive-p to nil.
I will see if I can write a suitable helm-cleanup-all-sessions command.

Thanks.

Owner

thierryvolpiatto commented Mar 3, 2013

After thinking at it it is not needed to have a command to clean sessions, because the minibuffer will always be in use; This is just a bad usage of helm and emacs.
I suggest that in such cases, (try to don't do it again, but well just in case ;-)) you hit C-M c exit-recursive-edit`.

Thanks Thierry. I am having this problem again, and unfortunately C-M c returns "No recursive edit is in progress". When you said that I am not using helm correctly, what is exactly what I should be doing differently?

Also, is there another command that I can call to close all running helm sessions (regardless of the buffer from which I invoke it)?

Owner

thierryvolpiatto commented Mar 5, 2013

ribonoous notifications@github.com writes:

I am having this problem again, and unfortunately C-M c returns
"No recursive edit is in progress"```. When you said that I am not
using helm correctly, what is exactly what I am doing wrong?
Helm expect to be exited or quitted, what you are doing is leaving an
helm session while leaving a minibuffer active.
For which reason are you doing this ?
In emacs -Q it is the same, if you hit M-x, then switch out of
minibuffer and do something else, expect strange things to happen even
if yes it is possible.

Is there another command that I can call to close all running helm sessions (regardless of the buffer from which I invoke it)?
Try C-M c, C-], and then (setq helm-alive-p nil), but I don't
understand why helm-alive-p it not reset to nil when you hit C-M c,
you might do something else after quitting the helm-window, or coming
back to helm after a long activity in some other buffer while leaving a
minibuffer active ?


Reply to this email directly or view it on GitHub:
#208 (comment)

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

Owner

thierryvolpiatto commented Mar 5, 2013

Without making any selection, I switch to another window (another pane within Emacs)

How do you do that ? (which command)

Owner

thierryvolpiatto commented Mar 5, 2013

I work on my buffers, maybe subdivide my Emacs window (pane) again, etc.

How can you do that while the minibuffer is active ?

I work on my buffers, maybe subdivide my Emacs window (pane) again, etc.

How can you do that while the minibuffer is active ?

I have the following bindings that allow me to switch windows (panes).

(global-set-key (kbd "M-J") 'windmove-left)          ; move to left windnow
(global-set-key (kbd "M-L") 'windmove-right)         ; move " " 
(global-set-key (kbd "M-I") 'windmove-up)            ; move " "
(global-set-key (kbd "M-K") 'windmove-down)          ; move " " 
(global-set-key (kbd "M-F") 'toggle-maximize-buffer) 

The function toggle-maximize-buffer is defined a few posts above.

I can also subdivide windows with the traditional C-x 2 or C-x 3

Helm expect to be exited or quitted, what you are doing is leaving an helm session while leaving a minibuffer active. For which reason are you doing this ?

Sometimes I am working on a helm session (e.g. helm-find-files) and I start typing a pattern. I then realize I need to quickly look up something in a buffer (possibly in a part that is not visible) to complete my pattern. Closing the session will make me lose what I typed so far (navigating to a certain location, etc.). So I leave it open, and navigate to my window using the bindings I described above. I may scroll up or down, etc. and once I find what I need I come back to my helm-session and finish the pattern. Many times this works well, but others it doesn't, so it would be good if I could bring helm back to a normal state.

Owner

thierryvolpiatto commented Mar 5, 2013

ribonoous notifications@github.com writes:

Helm expect to be exited or quitted, what you are doing is leaving an helm session while leaving a minibuffer active. For which reason are you doing this ?

Sometimes I am working on a helm session (e.g. helm-find-files) and I
start typing a pattern. I then realize I need to quickly look up
something in a buffer that is not visible to complete my
pattern. Closing the session will make me lose what I typed so far
(navigating to a certain location, etc.).
No, you can do better ;-):

M-x helm-find-files

  • navigate somwhere to a certain location. [1]
  • change your mind (you want to quickly look in a not visible buffer) [2]
    C-g => helm-find-files is quitted.
    M-x helm-buffers-list
  • navigate to your buffer and do what you have to do there.
  1. If helm-buffers-list is quitted/exited here:

Switch back to [1] with:

C-u M-x helm-resume (side note: C-u can be use AFTER M-x helm-resume
when using helm-M-x)
choose your helm-find-files session in the list, you are back to [1]

  1. If helm-buffers-list is not quitted, (perhaps you did a quick look to your
    buffer with C-z)

Switch back to [1] with C-x b.

Note that if the session before helm-find-files was helm-buffers-list,
you can do in [2] C-x b to go quickly to helm-buffers-list, and if you
quickly visit with C-z your buffer(s) you can then hit again C-x b to
switch back to helm-find-files. Ouf!


Reply to this email directly or view it on GitHub:
#208 (comment)

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

Wow. That is impressive. Thanks Thierry. I will try to stick to that workflow from now on!

Owner

thierryvolpiatto commented Mar 5, 2013

ribonoous notifications@github.com writes:

Wow. That is impressive. Thanks Thierry. I will try to stick to that workflow from now on!

Good, you can now bind helm-resume to a convenient key of your choice
(the default is C-x c b), I use here f1.


Reply to this email directly or view it on GitHub:
#208 (comment)

Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment