help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Restricting 'add-hook to a specific file extension


From: Kevin Rodgers
Subject: Re: Restricting 'add-hook to a specific file extension
Date: Mon, 27 Feb 2006 09:42:30 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

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?

(add-hook 'scheme-mode-hook
          (lambda ()
            (when (string-match "\\.lsp\\'" buffer-file-name)
              ;; do something here
              )))

--
Kevin Rodgers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]