Xref: utzoo comp.emacs:8967 gnu.emacs:3688 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!snorkelwacker!bloom-beacon!bloom-beacon!acevedo From: acevedo@james-tiptree-jr.mit.edu (Gabriel) Newsgroups: comp.emacs,gnu.emacs Subject: little kill-region hack Message-ID: <1990Aug29.022757.2855@athena.mit.edu> Date: 29 Aug 90 05:27:30 GMT Sender: daemon@athena.mit.edu (Mr Background) Distribution: comp Organization: /mit/acevedo/.organization Lines: 29 I don't know how many people are annoyed by this, but I imagine that it's a significant amount. The scenario: You are editing. Hitting keys really fast. Then all of a sudden WHOOOSH!!! half your file disappears. "Ah, no problem" you think; but you hit C-x u and get "No further undo information available"!!! Doing C-h l reveals that you [once again] hit C-w accidentally. Thank God for auto-save! Emacs has a kill limit of 8000 characters or so; kill a region larger than that, and you get the "No more undo" business. The following little modified version of `kill-region' simply checks to see the size of the region you are killing; if it's larger than 7000, it does an auto-save. (defun kill-region-safe (beg end) (interactive "*r") (if (< 7000 (- end beg)) (do-auto-save)) (copy-region-as-kill beg end) (delete-region beg end)) (define-key global-map "\C-w" 'kill-region-safe) Very simple, but VERY useful. If you accidentally destroy your file, you can just recover it right away with M-x recover-file. -- Raul