From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Restricting 'add-hook to a specific file extension Date: Sat, 25 Feb 2006 23:28:57 -0500 Organization: Symantec Message-ID: References: NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1141188526 16326 80.91.229.2 (1 Mar 2006 04:48:46 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 1 Mar 2006 04:48:46 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 01 05:48:44 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 1FEJG9-0003l1-3C for geh-help-gnu-emacs@m.gmane.org; Wed, 01 Mar 2006 05:48:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FEJG8-0000fo-Ex for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Feb 2006 23:48:20 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsfeed.gamma.ru!Gamma.RU!newspeer.monmouth.com!newscon06.news.prodigy.com!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Sat, 25 Feb 2006 22:28:58 -0600 Original-Newsgroups: gnu.emacs.help Mail-Copies-To: nobody User-Agent: MT-NewsWatcher/3.4 (PPC Mac OS X) X-Copies-To: never Original-Lines: 30 Original-NNTP-Posting-Host: 24.128.234.87 Original-X-Trace: sv3-lKooS2KWMginiKVfPz9puTsR7pelncIxoydvF2NGCKVSvXSklEZa16AGi2D9qpS+Wu7jGQG68U+GecZ!280DB65Es2qv9HCVo/9yWlmVvy+h4SVVEynYJDvoaKp+h47wrwF6eVraeC/NtqHnT6frqI6Y2Yau!VRDCraF0guKi/Z0b6cZwzucrpEq7MUdqzA== Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Original-Xref: shelby.stanford.edu gnu.emacs.help:137807 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:33433 Archived-At: In article , Tim Johnson wrote: > Is there a way to restrict 'add-hook to a specific file extension? > > Below is code from my .emacs: > > (require 'newlisp-mode++) ;; uses 'add-hook to extend 'scheme-mode > (add-to-list 'auto-mode-alist '("\\.lsp\\'" . scheme-mode)) > (autoload 'scheme-mode "scheme" "Turn on scheme mode" t) > (add-hook 'scheme-mode-hook 'turn-on-font-lock) > > I only want 'newlisp-mode++ to be used when the file extension is ".lsp". If > the file extension is ".scm", I would want 'scheme-mode, but I would *not* > want > the code from 'newlisp-mode++ to take effect. > > One solution is derived-mode, but I've had no luck with it. For the time > being > (until I've had another 6 months or so of elisp under my belt), is there a > way > to restrict the add-hook action to only a file with a .lsp extension? Have the function you put in the hook check the filename suffix. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***