From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sergey Pariev Newsgroups: gmane.emacs.help Subject: Re: Save on losing focus in Emacs Date: Mon, 02 Jul 2007 19:04:43 -0000 Organization: http://groups.google.com Message-ID: <1183403083.468639.223920@q75g2000hsh.googlegroups.com> References: <1183296351.525348.241650@k29g2000hsd.googlegroups.com> <93lke0b30s.fsf@freenet.de> <1183312602.898349.319670@q69g2000hsb.googlegroups.com> <85fy47zxwb.fsf@lola.goethe.zz> <87ved33kwu.fsf@baldur.tsdh.de> <873b07qith.fsf@lion.rapttech.com.au> <87tzsn16sh.fsf@baldur.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: sea.gmane.org 1183405240 24859 80.91.229.12 (2 Jul 2007 19:40:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Jul 2007 19:40:40 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 02 21:40:39 2007 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1I5RlE-0000Pu-Iu for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Jul 2007 21:40:36 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1I5RlE-0003bA-99 for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Jul 2007 15:40:36 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!postnews.google.com!q75g2000hsh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Original-NNTP-Posting-Host: 194.187.207.34 Original-X-Trace: posting.google.com 1183403083 26161 127.0.0.1 (2 Jul 2007 19:04:43 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 2 Jul 2007 19:04:43 +0000 (UTC) In-Reply-To: <87tzsn16sh.fsf@baldur.tsdh.de> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.4) Gecko/20060601 Firefox/2.0.0.4 (Ubuntu-edgy),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: q75g2000hsh.googlegroups.com; posting-host=194.187.207.34; posting-account=qAPS8A0AAAD600Q2Zqm01uK896f7rN3Q Original-Xref: shelby.stanford.edu gnu.emacs.help:149841 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:45428 Archived-At: Thanks to all you guys for the insightful responses. I'd like to apologize if my example was unclear - English is not my native language, so it could easily be. Anyway, I'm think I'll try to setup frequent enough autosave to get behaviour I need. The other ways looks too unpredictable, and, given that I want it to work both at home (on Linux) and at work ( on Windoze) :) , that's too much variables for me. Regards, Sergey. Tassilo Horn : > Tim X writes: > > Hi Tim, > > > However, two functions which may be useful are visible-frame-list and > > filtered-frame-list. To make use of these, I think you would dneed to > > use run-with -idle-timer. Yo could possibly define a function that > > looks to see if visible-frame-list returns anything. If it doesn't, > > then save any buffers with unsaved changes. > > One problem might be that the timer has to run very often to save > immediately after losing focus. > > > The problem with this is that if you have a big enough display, you > > may have both your emacs frame and some other application both > > 'visible', but focus is in the other application. In which case, this > > wouldn't work. > > Hm, I use a tiling window manager, so most of the time all frames are > visible unless they're on another workspace. > > > Alternatively, you might be able to use mouse-position to determine > > when the mouse is not in an emacs frame - the docs don't seem very > > clear on this and you may need to experiment to see what this function > > actually returns if it is called when the mouse focus is on another > > app. Its likely emacs will report the last frame the mouse was focused > > on. > > I don't use a mouse frequently. Most of the time the pointer is in a > corner of the screen. > > > P.S. I do find the OPs example a bit odd. I've used Emacs to develop with for > > years and often need to switch to a browser or some other app and I've never > > ever lost any work. > > You got him wrong. Let's assume you edit a html-page in emacs and switch > to the browser to view you changes. But, damn, you forgot to save the > buffer, so you have to switch back to emacs, `C-x C-s' and switch back > to the browser and refresh again. If it had saved your changes > automatically when losing focus, that would not be needed. > > Bye, > Tassilo > -- > Chuck Norris sleeps with a pillow under his gun.