2

I'm running ratpoison. I was running emacs started through a keybinding (hence no xterm). Then I hit Ctrl-Z by mistake and emacs disappeared (emacs iconify-or-deiconify-frame). I know it is still there, as when I leave ratpoison and go to mwm emacs comes back to the foreground. However, starting an xterm and running %emacs bash tells me bash: fg: %emacs: no such job.

How can I de-iconify emacs in ratpoison?

  1. similar problem within Gnome
  2. bugreport

(this post was heavily edited)

  • It has nothing to do with terminal forground/background. Ctrl+Z in emacs minimizes the window. You need a way to list minimized windows, and unminimize. If you use a task manager (such as ps) you will see that emacs is not stopped. – ctrl-alt-delor Jun 12 '14 at 11:54
4

Background a process in subshell #1 and get it back to foreground on subshell #2 is not possible at all (if you don't use extra tools like: reptyr).


In your case you even did not start it from terminal and Ctrl+Z has a different behavior if you are not in a terminal. I think your Ctrl+Z is doing some other "magic", ratpoison-default-keybindings even do not list it. Maybe you should figure out, what Ctrl+Z is bound to on your setup.

EDIT
From Emacs Manual:

When Emacs communicates directly with an X server and creates its own dedicated X windows, C-z has a different meaning. Suspending an application that uses its own X windows is not meaningful or useful. Instead, C-z runs the command iconify-or-deiconify-frame, which temporarily iconifies (or "minimizes") the selected Emacs frame (see section P. Frames and X Windows). Then you can use the window manager to get back to a shell window.

You should just be able to Alt+Tab through open applications to emacs. Maybe under ratpoison there is another way to get back minimized frames. Or add Alt-Tab to ratpoison, edit your .ratpoisonrc:

definekey top M-Tab next
definekey top M-ISO_Left_Tab prev

and restart rp.

| improve this answer | |
  • As far as I know, Ctrl-Z is not bound to anything set up by me. It surely isn't in my ~/.ratpoisonrc. – dmvianna Jun 12 '14 at 5:07
  • I beg you pardon? I don't see anything relevant there. And I checked and emacs is not under any other frame. – dmvianna Jun 12 '14 at 5:15
  • 1
    So it could be a emacs-gui specific hotkey/keybinding? – xx4h Jun 12 '14 at 5:23
  • 1
    How do you minimize/maximize frames in ratpoision? that's the way to go. – xx4h Jun 12 '14 at 5:40
  • 4
    "No such thing in ratpoison." -- there's your issue. In doing something to iconify itself, emacs lost its window, and the window manager does not provide a means of restoring it. – goldilocks Jun 12 '14 at 8:08
3

Ctrl+Z is the Emacs command to minimize a window (Emacs calls windows “frames”). It is technically unrelated to the use of Ctrl+Z to suspend a command in a terminal window (but the shortcut was chosen by the Emacs designers because they are somewhat similar actions).

Normally, window managers display a list of minimized windows somewhere. Originally, “somewhere” was meant to be an icon on the desktop, which is why minimization is also called iconification. Many window manager provide some other way to unminimize a minimized window, for example by selecting from a list.

If your window manager doesn't provide this feature, you can do it from the command line. Very recent versions of wmctrl can do it with wmctrl -x -Y Emacs. Recent versions of xdotool can do it with xdotool search --classname Emacs windowmap.

If you started an Emacs server, you can restore the Emacs window with emacsclient -c '(make-frame-visible)'.

To avoid future mishaps, you can add the following lines to your ~/.emacs to get a confirmation prompt before minimizing:

(defadvice iconify-frame (around iconify-frame-confirm)
  (if (y-or-n-p "Really iconify this frame?")
    ad-do-it))

I don't override the C-z binding because it is useful in terminals. You may want to replace iconification with something else that's useful with Ratpoison. Also be sure to start an Emacs server so that you can issue commands with emacsclient: put (server-start) in your .emacs.

| improve this answer | |
  • I can't build these in my system, so I can't test, but if no other answer appears I'll mark it as the solution. It sounds like it would work. Thanks! – dmvianna Jun 13 '14 at 2:39
2

I'm looking at the source of RatPoison in its git repo. Basically, when it gets an event that a window has been iconized, it withdraws it and puts it into a global list. Look in the unmap_notify function in events.c and at withdraw_window in manage.c.

withdraw_window puts the window into some kind of global list: see the line list_move_tail(&win->node, &rp_unmapped_window); in withdraw_window.

Maybe it's not difficult to hack a new action, assigned to some key binding, to pop a window from this rp_unmapped_window list, and do the XLib calls to de-iconize it, thereby bringing it back to life. (Without doing anything fancy such as rendering a list of these iconized windows for random selection.)

| improve this answer | |
2

Default ratpoison keybindings:

Ctrl+t Ctrl+Enter hides a window in ratpoison.

Emacs Gui under ratpoison is also hidden after Ctrl+z.

Ctrl+t Enter brings the hidden window back.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.