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: Wed, 01 Mar 2006 12:04:35 -0700
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

Tim Johnson wrote:
> Here's a snippet showing the conditional: (only slightly tested)
> (add-hook 'scheme-mode-hook
>              (lambda ()
> (if (string-match ;; case insensitive
>                    ".LSP"
> (upcase(current-buffer-name)) ;; force upper case
>                    (- (length (current-buffer-name)) 4)) ;; end of name?
>              ;; code follows
>              ()
>   ))) ;; end 'add-hook

Here's a better way to match the file name:

(add-hook 'scheme-mode-hook
          (lambda ()
            (let ((case-fold-search nil))
              (if (string-match "\\.LSP\\'" buffer-file-name)
                  ;; code follows
                  ()
                )))) ;; end 'add-hook

--
Kevin





reply via email to

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