Emacs – Disable Suspend Button

One thing that’s been a thorn in my side since I switched over to Emacs was that pesky Ctrl+Z combination that suspends the Emacs. Initially I wasn’t even sure how to get it back so I’d have to kill the process to release the file lock and launch Emacs again. It was a huge pain and I was losing work because of it. Eventually I found out that simply typing “fg” into the console would bring it back to the foreground and that made it a little less annoying. Though I still found myself doing it about 10 times a day as I often miss the X when initiating any Ctrl+X commands, or sometimes I habitually hit Ctrl+Z to undo instead of Ctrl+X Shift+U. So if this bugs the crap out of you like it did with me, here is how you can unbind the key and (optionally) bind that key sequence to Undo

Add the following to your .emacs file:

;; Unbind Pesky Sleep Button
(global-unset-key [(control z)])
(global-unset-key [(control x)(control z)])

If you’d also like to bind the undo function to this key as it is now free to use, add the following lines as well:

;; Windows Style Undo
(global-set-key [(control z)] 'undo)

Now save and close your .emacs file and then if you have any open Emacs sessions close them and restart, you should now be able to code without randomly shutting down Emacs.


Tags: , , ,

  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS

4 Responses to “Emacs – Disable Suspend Button”

  1. Eric Larson says:

    You should also look into cua-mode which will give you more traditional copy/paste keybindings. It also has a column editing mode that is insanely helpful.

  2. rho says:

    Not working in emacs 24 🙁

  3. FettesPS says:

    @rho – That’s unfortunate 🙁 I haven’t really been using emacs lately (change of jobs forced me into using Visual Studio at work). I’m sure there must be a solution to the problem though 🙂

  4. rho says:

    @FettesPS
    Thats terrible! Visual Studio! damn they don’t understand the power of emacs!
    I would quit my job i have to use the Windows ever!

    but you should try out emacs24 its just awesome! its rising again!

Leave a Reply