From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nate Thern Newsgroups: gmane.emacs.help Subject: Re: Restricting 'add-hook to a specific file extension Date: Wed, 01 Mar 2006 17:42:24 -0600 Organization: Raytheon Company Message-ID: <44063160.1030704@yahoo.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1141400284 22247 80.91.229.2 (3 Mar 2006 15:38:04 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 3 Mar 2006 15:38:04 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 03 16:38:04 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 1FFCLt-0006Qw-Ki for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Mar 2006 16:37:57 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FFCLu-0001ld-CJ for geh-help-gnu-emacs@m.gmane.org; Fri, 03 Mar 2006 10:37:58 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bos-service1.raytheon.com!dfw-service2.ext.ray.com.POSTED!53ab2750!not-for-mail User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0 X-Accept-Language: en-us, en Original-Newsgroups: gnu.emacs.help Original-Lines: 52 Original-NNTP-Posting-Host: 138.126.240.231 Original-X-Complaints-To: news@ext.ray.com Original-X-Trace: dfw-service2.ext.ray.com 1141256546 138.126.240.231 (Wed, 01 Mar 2006 17:42:26 CST) Original-NNTP-Posting-Date: Wed, 01 Mar 2006 17:42:26 CST Original-Xref: shelby.stanford.edu gnu.emacs.help:137853 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:33477 Archived-At: I'd like some help understanding this question (because I'm ignorant, not because it wasn't posed well). Tell me if this is correct: 1) newlisp-mode++ is a minor mode for use inside the major mode scheme-mode 2) (require 'newlisp-mode++) => loads newlisp-mode++ into memory 3) any time scheme-mode is the major mode, newlisp-mode++ will be an active minor mode (it's my understanding that minor modes do not generally behave this way - they have to be explicitely loaded or hooked) If 3) is true, then it would be impossible to edit both file1.scm in scheme-mode only and file2.lsp in scheme-mode w/ newlisp-mode++, right? So I don't think 3) is true. If 3) is not true then why wouldn't this work?: (defun new-lisp+scheme-mode () "Make scheme-mode the major mode and newlisp-mode++ a minor mode" (interactive "") (scheme-mode) (newlisp-mode++ 1)) (add-to-list 'auto-mode-alist '("\\.lsp$" . new-lisp+scheme-mode)) ... After thinking about it for a while, I think that newlisp-mode++ must be code which modifies the code of scheme-mode, so 1) is false. So, what events is newlisp-mode++ hooking to, and why is a minor mode or derived mode not an option? 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? > > Thanks > tim >