From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Plugger Newsgroups: gmane.emacs.help Subject: find-file-hook for a specific file? Date: Wed, 16 Feb 2011 16:32:49 -0800 (PST) Organization: http://groups.google.com Message-ID: <9de0075a-31b5-4a59-b0de-6939e1288809@glegroupsg2000goo.googlegroups.com> Reply-To: gnu.emacs.help@googlegroups.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1297913334 3644 80.91.229.12 (17 Feb 2011 03:28:54 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 17 Feb 2011 03:28:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 17 04:28:51 2011 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.69) (envelope-from ) id 1PpuXy-0003jm-OC for geh-help-gnu-emacs@m.gmane.org; Thu, 17 Feb 2011 04:28:50 +0100 Original-Received: from localhost ([127.0.0.1]:59376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpuXy-0001o8-5O for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Feb 2011 22:28:50 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 12 Original-NNTP-Posting-Host: 66.189.44.92 Original-X-Trace: posting.google.com 1297902769 11888 127.0.0.1 (17 Feb 2011 00:32:49 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 17 Feb 2011 00:32:49 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.189.44.92; posting-account=5HbENQkAAABuj03KxZ0yTr0OvbgI92ff User-Agent: G2/1.0 Original-Xref: usenet.stanford.edu gnu.emacs.help:185014 X-Mailman-Approved-At: Wed, 16 Feb 2011 22:28:24 -0500 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:79181 Archived-At: How can I get a find-file hook function to run for only a specific file? Conceptually, I'd like this: (find-file "myfile.txt" 'myfile-hook-function) I want myfile-hook-function to run only on the first call to find-file, i.e. when the file is opened and loaded, but not if the file is already loaded. I do this now: (add-hook 'find-file-hook 'myfile-hook-function) (find-file "myfile.txt") (remove-hook 'find-file-hook 'myfile-hook-function) This works, but it seems hokey.