From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier" Newsgroups: gmane.emacs.devel Subject: Re: occur-mode-hook run too early to be useful Date: Wed, 28 Aug 2002 10:30:05 -0400 Sender: emacs-devel-admin@gnu.org Message-ID: <200208281430.g7SEU5Z04025@rum.cs.yale.edu> References: <20020828103157.9D0E.LEKTU@terra.es> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1030545332 21619 127.0.0.1 (28 Aug 2002 14:35:32 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 28 Aug 2002 14:35:32 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17k3uk-0005cK-00 for ; Wed, 28 Aug 2002 16:35:22 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 17k4QZ-0005z6-00 for ; Wed, 28 Aug 2002 17:08:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17k3w6-0007l1-00; Wed, 28 Aug 2002 10:36:46 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17k3pn-0006Y7-00 for emacs-devel@gnu.org; Wed, 28 Aug 2002 10:30:15 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17k3pg-0006XG-00 for emacs-devel@gnu.org; Wed, 28 Aug 2002 10:30:14 -0400 Original-Received: from rum.cs.yale.edu ([128.36.229.169]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17k3pg-0006XC-00 for emacs-devel@gnu.org; Wed, 28 Aug 2002 10:30:08 -0400 Original-Received: (from monnier@localhost) by rum.cs.yale.edu (8.11.6/8.11.6) id g7SEU5Z04025; Wed, 28 Aug 2002 10:30:05 -0400 X-Mailer: exmh version 2.4 06/23/2000 with nmh-1.0.4 Original-To: Juanma Barranquero X-MIME-Autoconverted: from 8bit to quoted-printable by rum.cs.yale.edu id g7SEU5Z04025 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:7056 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:7056 > The patch to fix that is trivial: just move the call to (run-hooks > 'occur-mode-hook) from `occur-mode' to the end of `occur-1', and voil=E0. >=20 > As always, though, I have a philosophical question: should be > `occur-mode-hook' be run from any other place than `occur-mode'? No. > For normal major modes the answer is no, I suppose, but `occur-mode' is > a special mode, only called from inside `occur-1'. After `occur-mode' > runs, the buffer either has the old contents (that will be obliterated > immediately afterwards) or it is empty, so in fact running > `occur-mode-hook' at that moment is only useful for non-contents-relate= d > hook functions. I want, for example, to resize the occur window after > doing M-x occur, and as it stands now it's not posible to do that throu= gh > `occur-mode-hook' (I'd have to revert to using defadvice, etc.). >=20 > So, it is OK to move the call to run-hooks to occur-1? That would be wrong. The hook should be run at the end of the major mode= 's function. Another way would be to call `occur-mode' later (which would require the occur-revert-arguments variable to be made permanent-local) or to provide another hook (like `occur-hook'). See edit-log-mode for an example where there is edit-log-mode-hook and edit-log-hook. Stefan