unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
Subject: Re: Restricting 'add-hook to a specific file extension
Date: Sat, 25 Feb 2006 23:28:57 -0500	[thread overview]
Message-ID: <barmar-6F2419.23285725022006@comcast.dca.giganews.com> (raw)
In-Reply-To: mailman.5.1140910129.18076.help-gnu-emacs@gnu.org

In article <mailman.5.1140910129.18076.help-gnu-emacs@gnu.org>,
 Tim Johnson <tim@johnsons-web.com> 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 ***

       reply	other threads:[~2006-02-26  4:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.5.1140910129.18076.help-gnu-emacs@gnu.org>
2006-02-26  4:28 ` Barry Margolin [this message]
2006-02-26 23:49   ` Restricting 'add-hook to a specific file extension Tim Johnson
2006-02-27  1:26     ` Barry Margolin
2006-03-01 19:04     ` Kevin Rodgers
     [not found]     ` <mailman.125.1141286170.2835.help-gnu-emacs@gnu.org>
2006-03-06  2:59       ` Tim Johnson
2006-03-01 23:42 ` Nate Thern
2006-03-05 21:38 ` Stefan Monnier
2006-03-06  2:59   ` Tim Johnson
2006-03-06  8:41     ` Stefan Monnier
2006-03-06 17:59       ` Tim Johnson
2006-02-25 23:40 Tim Johnson
2006-02-27 16:42 ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=barmar-6F2419.23285725022006@comcast.dca.giganews.com \
    --to=barmar@alum.mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).