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: doc on define-minor-mode hook variable(s) Date: Mon, 6 Mar 2006 11:10:47 -0800 Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1141684021 30963 80.91.229.6 (6 Mar 2006 22:27:01 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 6 Mar 2006 22:27:01 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 06 23:26:38 2006 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1FGLKS-0005Nf-00 for ; Mon, 06 Mar 2006 20:25:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FGLKc-00068i-V5 for ged-emacs-devel@m.gmane.org; Mon, 06 Mar 2006 14:25:22 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FGL6t-0006f0-At for emacs-devel@gnu.org; Mon, 06 Mar 2006 14:11:11 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FGL6k-0006aJ-8m for emacs-devel@gnu.org; Mon, 06 Mar 2006 14:11:06 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FGL6j-0006a6-Kj for emacs-devel@gnu.org; Mon, 06 Mar 2006 14:11:01 -0500 Original-Received: from [141.146.126.228] (helo=agminet01.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1FGL8z-0005KB-VZ for emacs-devel@gnu.org; Mon, 06 Mar 2006 14:13:22 -0500 Original-Received: from rgmsgw301.us.oracle.com (rgmsgw301.us.oracle.com [138.1.186.50]) by agminet01.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id k26JAmao026552 for ; Mon, 6 Mar 2006 13:10:49 -0600 Original-Received: from rgmsgw301.us.oracle.com (localhost [127.0.0.1]) by rgmsgw301.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id k26JAm3L018240 for ; Mon, 6 Mar 2006 12:10:48 -0700 Original-Received: from dradamslap (dhcp-amer-csvpn-gw2-141-144-75-227.vpn.oracle.com [141.144.75.227]) by rgmsgw301.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with SMTP id k26JAloL018232 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Mon, 6 Mar 2006 12:10:48 -0700 Original-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE 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:51298 Archived-At: > In the past, hook variables were used, and the new notion > that a hook need not be associated with a variable should > be explained in the doc. A hook IS a variable--that is to say, a symbol whose value is used. It is a mistake to think that a hook is not a variable. You quoted me, but I got the idea from Stefan - possibly I misunderstood him. IIUC, what Stefan meant was this (he will correct me): - What makes a hook a hook is its use: if `run-hooks' uses it, then it's a hook. - A symbol used as a hook need not necessarily be bound before it is run. That is, you can call `run-hooks' on a symbol that has never been bound - nothing happens. - Such an unbound symbol is not a variable. Of course, to do anything useful as a hook, it must be bound. - The way to set up a symbol to serve as a useful hook is to use `add-hook'. Binding the symbol is not the way to go. - For these reasons (I think), Stefan doesn't like to refer to "variable" in this context: 1) The symbol can be run as an (inert) hook without being bound. 2) Simply binding a symbol is not the way to make it useful as a hook. I don't know or care what terminology is used to describe the behavior of hooks - I'm just learning. To me, reading the `define-minor-mode' doc about `MODE-hook', I expected to find existing (bound) variables named `MODE-hook' after calling `define-minor-mode'. When I searched for them, I found none and I wondered what the doc really meant. It turns out (IIUC) that the doc simply meant that the created minor mode command does (run-hooks 'MODE-hook). And, given an understanding of hooks (which, in my case was incomplete), this means: 1. IF someone does (add-hook `MODE-hook' ) THEN will be run when the mode is entered and exited. 2. OTHERWISE, nothing will happen, because (run-hooks 'MODE-hook) does nothing if `MODE-hook' is not bound or is bound to nil. I should say, instead of speaking of binding, "if either `add-hook' was never called on it or `remove-hook' was called to remove everything that `add-hook' had added". I called this an "empty" hook, but Stefan didn't like that term. IOW, in Stefan's terminology (IIUC): because `run-hooks' runs it, the hook exists, even though the hook symbol might not be bound (so, no variable). All this was not clear to me when I read the `define-minor-mode' doc. I think it would be good if it were explained (using whatever terminology you like) in the Hooks nodes of the manuals. Again, I don't claim that my understanding is correct on this. My message really is that I was confused by the current doc. Do with that feedback what you will.