unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to associate more than two file-types as C code, code included
@ 2007-12-03 22:50 Mike H
  2007-12-03 23:56 ` Lennart Borgman (gmail)
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Mike H @ 2007-12-03 22:50 UTC (permalink / raw)
  To: help-gnu-emacs

I want the files .cu and .txx to be recognized as C files..
One block of the following codes works separately, but when I put them
together.. it doesn't work.

How should I do it ?

when ((string-match "\\.cu$" fn) || (string-match "\\.txx$" fn))

will something like above work? i tried, and it doesn't...

Thanks..


(defun my-find-file-hook()
  (let ((fn (buffer-file-name)))
    (when (string-match "\\.cu$" fn)
      (c-mode))))
(add-hook 'find-file-hooks 'my-find-file-hook)

(defun my-find-file-hook()
  (let ((fn (buffer-file-name)))
    (when (string-match "\\.txx$" fn)
      (c-mode))))
(add-hook 'find-file-hooks 'my-find-file-hook)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to associate more than two file-types as C code, code included
  2007-12-03 22:50 How to associate more than two file-types as C code, code included Mike H
@ 2007-12-03 23:56 ` Lennart Borgman (gmail)
  2007-12-04 12:59 ` Peter Dyballa
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Lennart Borgman (gmail) @ 2007-12-03 23:56 UTC (permalink / raw)
  To: Mike H; +Cc: help-gnu-emacs

Mike H wrote:
> I want the files .cu and .txx to be recognized as C files..
> One block of the following codes works separately, but when I put them
> together.. it doesn't work.
> 
> How should I do it ?
> 
> when ((string-match "\\.cu$" fn) || (string-match "\\.txx$" fn))
> 
> will something like above work? i tried, and it doesn't...
> 
> Thanks..
> 
> 
> (defun my-find-file-hook()
>   (let ((fn (buffer-file-name)))
>     (when (string-match "\\.cu$" fn)
>       (c-mode))))
> (add-hook 'find-file-hooks 'my-find-file-hook)
> 
> (defun my-find-file-hook()
>   (let ((fn (buffer-file-name)))
>     (when (string-match "\\.txx$" fn)
>       (c-mode))))
> (add-hook 'find-file-hooks 'my-find-file-hook)


A much more easy way to do it is to use auto-mode-alist, do

   M-x (info "(emacs) Choosing Modes") RET

in Emacs for info.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to associate more than two file-types as C code, code included
  2007-12-03 22:50 How to associate more than two file-types as C code, code included Mike H
  2007-12-03 23:56 ` Lennart Borgman (gmail)
@ 2007-12-04 12:59 ` Peter Dyballa
       [not found] ` <mailman.4464.1196726225.18990.help-gnu-emacs@gnu.org>
       [not found] ` <mailman.4488.1196773183.18990.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Dyballa @ 2007-12-04 12:59 UTC (permalink / raw)
  To: Mike H; +Cc: help-gnu-emacs


Am 03.12.2007 um 23:50 schrieb Mike H:

> I want the files .cu and .txx to be recognized as C files..
> One block of the following codes works separately, but when I put them
> together.. it doesn't work.
>
> How should I do it ?
>
> when ((string-match "\\.cu$" fn) || (string-match "\\.txx$" fn))

I use or instead of the shell construct ||:

	(if (or (string-match "23.0.50" mEV) (string-match "22." mEV)) ...

There is also the variable auto-mode-alist that you can modify like in:

	(add-to-list 'auto-mode-alist '("\\.drv\\'" . latex-mode))

--
Greetings

   Pete

"A mathematician is a machine that turns coffee into theorems."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to associate more than two file-types as C code, code  included
       [not found] ` <mailman.4464.1196726225.18990.help-gnu-emacs@gnu.org>
@ 2007-12-04 17:27   ` Mike H
  0 siblings, 0 replies; 5+ messages in thread
From: Mike H @ 2007-12-04 17:27 UTC (permalink / raw)
  To: help-gnu-emacs

On 12월3일, 오후6시56분, "Lennart Borgman (gmail)"
<lennart.borg...@gmail.com> wrote:
> Mike H wrote:
> > I want the files .cu and .txx to be recognized as C files..
> > One block of the following codes works separately, but when I put them
> > together.. it doesn't work.
>
> > How should I do it ?
>
> > when ((string-match "\\.cu$" fn) || (string-match "\\.txx$" fn))
>
> > will something like above work? i tried, and it doesn't...
>
> > Thanks..
>
> > (defun my-find-file-hook()
> >   (let ((fn (buffer-file-name)))
> >     (when (string-match "\\.cu$" fn)
> >       (c-mode))))
> > (add-hook 'find-file-hooks 'my-find-file-hook)
>
> > (defun my-find-file-hook()
> >   (let ((fn (buffer-file-name)))
> >     (when (string-match "\\.txx$" fn)
> >       (c-mode))))
> > (add-hook 'find-file-hooks 'my-find-file-hook)
>
> A much more easy way to do it is to use auto-mode-alist, do
>
>    M-x (info "(emacs) Choosing Modes") RET
>
> in Emacs for info.- 따온 텍스트 숨기기 -
>
> - 따온 텍스트 보기 -

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to associate more than two file-types as C code, code  included
       [not found] ` <mailman.4488.1196773183.18990.help-gnu-emacs@gnu.org>
@ 2007-12-04 17:27   ` Mike H
  0 siblings, 0 replies; 5+ messages in thread
From: Mike H @ 2007-12-04 17:27 UTC (permalink / raw)
  To: help-gnu-emacs

On 12월4일, 오전7시59분, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
> Am 03.12.2007 um 23:50 schrieb Mike H:
>
> > I want the files .cu and .txx to be recognized as C files..
> > One block of the following codes works separately, but when I put them
> > together.. it doesn't work.
>
> > How should I do it ?
>
> > when ((string-match "\\.cu$" fn) || (string-match "\\.txx$" fn))
>
> I use or instead of the shell construct ||:
>
>         (if (or (string-match "23.0.50" mEV) (string-match "22." mEV)) ...
>
> There is also the variable auto-mode-alist that you can modify like in:
>
>         (add-to-list 'auto-mode-alist '("\\.drv\\'" . latex-mode))
>
> --
> Greetings
>
>    Pete
>
> "A mathematician is a machine that turns coffee into theorems."

Thanks !

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-12-04 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-03 22:50 How to associate more than two file-types as C code, code included Mike H
2007-12-03 23:56 ` Lennart Borgman (gmail)
2007-12-04 12:59 ` Peter Dyballa
     [not found] ` <mailman.4464.1196726225.18990.help-gnu-emacs@gnu.org>
2007-12-04 17:27   ` Mike H
     [not found] ` <mailman.4488.1196773183.18990.help-gnu-emacs@gnu.org>
2007-12-04 17:27   ` Mike H

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).