Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hitting Ctrl-Z in emacs freezes everything

Tags:

emacs

I'm using Linux, and alternate between emacs and sublime text. In sublime text, Ctrl-Z is undo. This means sometimes I sometimes hit Ctrl-Z in emacs; unfortunately when I do this, the whole process simply freezes. I assume this has to do with the typical Ctrl-Z behavior of suspending a process; however I'm running Emacs in a GUI, so why it would have this behavior is a bit beyond me. Is there any way to change this?

like image 578
limp_chimp Avatar asked Jan 28 '15 21:01

limp_chimp


1 Answers

I would suggest the following over simply disabling the binding entirely:

(global-unset-key (kbd "C-z"))

(global-set-key (kbd "C-z C-z") 'my-suspend-frame)

(defun my-suspend-frame ()
  "In a GUI environment, do nothing; otherwise `suspend-frame'."
  (interactive)
  (if (display-graphic-p)
      (message "suspend-frame disabled for graphical displays.")
    (suspend-frame)))

Or you could just bind the function directly to C-z, but I find it super-useful to open up that as a prefix binding for other commands -- given how very infrequently I actually need to call suspend-frame, I find a double C-z C-z just as convenient.

like image 132
phils Avatar answered Oct 09 '22 06:10

phils