From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: view-mode exit hook? Date: Tue, 18 Dec 2007 14:47:59 -0800 Message-ID: References: <47684103.4000400@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1198018207 31804 80.91.229.12 (18 Dec 2007 22:50:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Dec 2007 22:50:07 +0000 (UTC) Cc: Emacs-Devel To: "martin rudalics" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 18 23:50:20 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J4lGP-0004gu-LC for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2007 23:50:13 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J4lG6-0001cD-Ee for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2007 17:49:54 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J4lFi-0001Ay-Sx for emacs-devel@gnu.org; Tue, 18 Dec 2007 17:49:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J4lFh-00018t-I1 for emacs-devel@gnu.org; Tue, 18 Dec 2007 17:49:30 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J4lFh-00018T-59 for emacs-devel@gnu.org; Tue, 18 Dec 2007 17:49:29 -0500 Original-Received: from agminet01.oracle.com ([141.146.126.228]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J4lFg-000288-Kq for emacs-devel@gnu.org; Tue, 18 Dec 2007 17:49:28 -0500 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id lBIMn7dX000468; Tue, 18 Dec 2007 16:49:08 -0600 Original-Received: from acsmt350.oracle.com (acsmt350.oracle.com [141.146.40.150]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id lBHAfnaa005349; Tue, 18 Dec 2007 15:49:07 -0700 Original-Received: from dhcp-amer-whq-csvpn-gw3-141-144-81-149.vpn.oracle.com by acsmt351.oracle.com with ESMTP id 3451600161198018074; Tue, 18 Dec 2007 14:47:54 -0800 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: <47684103.4000400@gmx.at> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:85266 Archived-At: > > What is the recommended way to run some code when view-mode exits? > > For entering view-mode, `view-mode-hook' can be used (it is run by > > `view-mode-enable'), but I don't see anything equivalent for > > exiting. Are users supposed to advise view-mode code (e.g. > > `view-mode-exit'), or is there a better, recommended course of > > action? > > > > My use case: When view-mode is entered, my own code fits the > > frame (assuming it's one-window-p) to the viewed buffer. My > > tweaked version of `display-buffer' takes care of that. But > > when view-mode is exited, the frame is not re-fit to the > > buffer that is now displayed there. I'm looking for a way to > > call my function `fit-frame', preferably via a hook run after > > view-mode has exited and the other buffer is displayed in the > > frame, that is, at the very end of `view-mode-exit'. > > > > Even better, perhaps, would be for view-mode to restore the > > frame config after it exits. That way, the frame would return > > to its prior state for the buffer that was shown there > > previously. That is preferable for two reasons: > > (1) no need to explicitly re-fit the buffer and (2) if the > > user had manually resized the frame for the prior buffer, > > returning to that buffer would not override the user's frame > > size preference by fitting it. > > `view-mode-hook' is hardly suitable for observing window configuration > changes. When `view-mode-hook' is called, the window used for viewing > might be already there or not exist yet. `temp-buffer-setup-hook' seems > more useful here. `view-mode-hook' could be used, however, to put a > function on `post-command-hook' which sets `view-exit-action' > appropriately. Since `view-exit-action' is called before exiting > `view-mode' it could call `fit-frame'. I wasn't suggesting to use `view-mode-hook'. As I noted, that is run only upon entering the mode. I don't know whether view-mode manages to keep track of window configs - I thought it did, but that's beside the point here. What would be needed in this case would be restoring the frame config, not a window config. _If_ that were feasible. If the frame cannot be restored, I'm happy to deal with this by fitting the frame again upon view-mode exit, even though that is less desirable for a user than putting back the frame parameters s?he had before view-mode. I don't want to go near `view-exit-action', if I can avoid it. That code is far too complicated for a mortal such as I. I did think that I could recuperate the current value of `view-exit-action' and then tack my function call onto it, but that seems quite ugly. I'd sooner advise `view-mode-exit', I think (and I don't like to use advice either). I was looking for a simple and clean way to go, such as a hook. Does it make sense for Emacs to have a `view-mode-exit-hook'? What is the recommended approach in a situation such as mine?