|
From: | Nate Thern |
Subject: | Re: Restricting 'add-hook to a specific file extension |
Date: | Wed, 01 Mar 2006 17:42:24 -0600 |
User-agent: | Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0 |
1) newlisp-mode++ is a minor mode for use inside the major mode scheme-mode 2) (require 'newlisp-mode++) => loads newlisp-mode++ into memory3) 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* wantthe 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 wayto restrict the add-hook action to only a file with a .lsp extension?Thanks tim
[Prev in Thread] | Current Thread | [Next in Thread] |