Visiting a file which has auto save data

Has it ever happened to you that you had to open a file that had autosave data next to it in a #filename.ext# file? Emacs shows a warning, namely:

filename.ext has auto save data; consider M-x recover-this-file

The warning is fine and all, but what was driving me nuts was the 1 second delay that I had to wait to see the contents of the file (at least in GNU Emacs 23.2.1). The delay could be skipped by pressing a key, but that is also annoying. This happens again and again if you close the file and open it again, which is even more annoying.

This only ends if you manually delete the save-file, or you save your original file to make it newer then the save-file. Let me remind you that just pressing C-x-C-s only works if you have modified the buffer. Also if for some reason the save-file modification time is in the future, then this technique doesn't work at all, you have to manually remove the save-file.

A quick, but ugly solution:

Adding this code to your .emacs removes the 1-second delay when you open a file which has save data. The warning message is still displayed. The code was tested in GNU Emacs 23.2.1.

(defadvice after-find-file (around dont-wait activate)
  "Don't do delays (this advice temporarely overrides the sit-for function)"
  (flet ((sit-for (&rest dummy) t))


The code that prints the warning message can be found in files.el, on line 2137. The code that waits for the 1 second delay is on line 2153. It calls the sit-for' function. Even if I could control all the parameters of this function, getting the not-serious variable to become true (non-nil), and showing the warning message at the same time is not possible because of the way the code is built.

So the only solution is to modify the function after-find-file. copy-pasting the defun into my .emacs, and just removing the call to the sit-for function would work, because it overwrites the function-cell of the global symbol after-find-file, but this is probably not compatible with different versions of emacs.

A slightly cleaner way to patch existing functions is to use advices. You can learn about advices in the Advising Functions' chapter in the ELISP reference manual. I used an around-advice which lets me write code around the original function definition.

The modification that has to be done is to temporarily rebind the sit-for function to do nothing while the after-find-file function is running. The let special form does temporary rebinding, but it doesn't rebind the function cell of symbol. On the other hand flet lets you make temporary function definitions. Here I define a function that takes any number of arguments, and just returns true. in the body of the flet I write ad-do-it as a placeholder for the original function. After the closing parenthesis of the flet macro the local binding to the dummy function disappears, and the sit-for function again works as expected.

Related Work:

A different solution to killing the 1-second delay, is to disable the find-file warning messages. This solution is hinted at by emacswiki - Autosave, but no explicit solution is given. An explicit solution which overrides the NOWARN argument of the find-file-noselect function (which is called by find-file), using an around-advice, is like this:

(defadvice find-file-noselect (around nowarn activate)
  "Turn off warnings"
  (ad-set-arg 1 t)

It is sensible to force the user to choose between restoring the autosave or not. The warning message is very easy to ignore, and it is even more easier to ignore if the delay is missing. A way to force the user to decide between restoring the auto save data or not is found here: http://osdir.com/ml/help-gnu-emacs-gnu/2009-07/msg00114.html. This doesn't solve the problem that when the user explicitly chooses not to restore the auto save data, and doesn't update the original file, he is going to be asked again the next time he opens this file. Also, using that code does not eliminate the delay, which becomes completely useless as an attention-raising tool when combined with that code. Both my code and the linked code can be used at the same time to solve this.

Another way to provide an obvious visual feedback, and to force the user to recover a file with autosave data is to use this: http://osdir.com/ml/help-gnu-emacs-gnu/2009-07/msg00150.html.

Punctuation marks following links that I don't control are backup links in case the original goes down. I hate link rot.


  1. Best Online Casinos for Canadian Players: Casino Site 2021
    ‎Bonus Deals · 카지노사이트 ‎Games · ‎Slots · ‎Casino Games · ‎Featured dafabet Slots · ‎Reviews 1xbet

  2. Solved: Why Solved In The Casino - Jordan15
    Solved. When you try a gambling game, the dealer does not have a chance of winning 벳 365 코리아 우회 and you cannot win air jordan 18 retro yellow or air jordan 18 retro red on sale lose. 먹튀탐정 You need to make a 카드 카운팅 bet to win

  3. The King Casino - Atlantic City, NJ | Jancasino
    Come on in https://jancasino.com/review/merit-casino/ the King Casino 도레미시디 출장샵 for fun, no wagering requirements, delicious dining, and enjoyable casino 1xbet login gaming all at the febcasino.com heart of Atlantic https://tricktactoe.com/ City.

  4. If you go for the common bonus, the utmost you’ll be able to|be capable of|have the power to} get is $3,000. Since we’re all about crypto at present, we suggest going for the crypto bonus if you’re after a more significant provide. There’s a $3,750 crypto on line casino bonus up for grabs these who|for many who|for people who} deposit using crypto. The BitStarz mobile on line casino is totally aware of smaller screens, 카지노 사이트 even though fact} that|although} there is no a|there is not any} devoted app.

  5. Many on line casino strategies let you know to keep away from each popular slot sport. Those, they are saying, are the video games with the worse severe|the extra serious} payout percentage among all these on the on line casino floor. That's because of|as a outcome of} though find a way to|you presumably can}'t win at slot machines each time, picking a great slot machine is the best way|one of the simplest ways|the best way} to enhance your odds and let the RTP of the on line casino slot do the ‘hard work' for you. Knowing means to|tips on how to} choose a slot machine wants more than you guessing when a slot 온라인 카지노 machine will hit.

  6. Residents risk prosecution or even imprisonment if caught partaking in the behaviour within or outside the country. North Korea’s 온라인 카지노 access to overseas forex has been impacted by a collection of international sanctions over its nuclear weapons program, together with bans on key exports such as coal, textiles and seafood. North Korean chief Kim Jong Un has been constructing resorts, swimming swimming pools and other luxurious leisure services in what experts say is a bid to capture variety of the} particular person wealth generated by rising private markets for items and companies.

  7. Some of the video games you have to ensure can be found earlier than you enroll with them embody card 카지노사이트 video games, slots, and cube video games. Also, ensure they feature new video games and work with trusted providers. Some prime providers you should to} a glance at|try} embody Gamomat, Pragmatic Play, NetEnt, and Evolution. All these are huge names, so that you can|so as to|to have the ability to} count on plenty of new and thrilling video games. At all on-line casinos with a license, the circumstances are 90% related. The solely difference might be|that might be|which may be} is that not all of them have a loyalty program.

  8. Discover the simplicity of the HALTER LoadAssistant during a personalized workshop for your company in one of many HALTER Technology Centers or at our reference buyer in your space. Attend certainly one of Plastic Shower Caps our occasions where we'll show you everything you need to|you should|you have to} learn about CNC robots and bettering performace of CNC machines. "We are reaching our manufacturing goal with only one CNC operator." If you've have} several of} fashions to mill, put each model in its own file.