From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: wenbinye@gmail.com Newsgroups: gmane.emacs.help Subject: Re: the hand that feeds you Date: 27 Jul 2006 23:50:30 -0700 Organization: http://groups.google.com Message-ID: <1154069430.432231.310060@i3g2000cwc.googlegroups.com> References: <1154035859.849298@elch.in-berlin.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1154072436 6861 80.91.229.2 (28 Jul 2006 07:40:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 28 Jul 2006 07:40:36 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 28 09:40:35 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1G6MxX-0002Os-4Q for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Jul 2006 09:40:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1G6MxW-0008AI-MY for geh-help-gnu-emacs@m.gmane.org; Fri, 28 Jul 2006 03:40:34 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!i3g2000cwc.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 28 Original-NNTP-Posting-Host: 218.17.227.208 Original-X-Trace: posting.google.com 1154069435 4165 127.0.0.1 (28 Jul 2006 06:50:35 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 28 Jul 2006 06:50:35 +0000 (UTC) In-Reply-To: <1154035859.849298@elch.in-berlin.de> User-Agent: G2/0.2 X-HTTP-UserAgent: Opera/9.00 (X11; Linux i686; U; en),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i3g2000cwc.googlegroups.com; posting-host=218.17.227.208; posting-account=3wOHJA0AAAAYp1ktKqTr4LI0QMFE1g-B Original-Xref: shelby.stanford.edu gnu.emacs.help:140697 Original-To: help-gnu-emacs@gnu.org 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:36322 Archived-At: how about define the function like this: (defvar kill-myself nil) (defun kill-myself () (unless kill-myself (insert "only once") (setq kill-myself t))) Andreas Seik wrote: > Hello Newsgroup, > > i need code in a hook that is executed only once, > so i tested the following: > > > (defvar my-hook '()) > (defun kill-myself () > (insert "only once")(remove-hook 'my-hook 'kill-myself)) > (add-hook 'my-hook 'kill-myself) > (run-hooks 'my-hook);; i think it might crash here, but it does not > (run-hooks 'my-hook) > > it, seems to work, but i do not trust it. > is it not "biting the hand that feeds you" > > thank you > Andreas