unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* auto-mode-alist - recognize prefix instead of sufix?
@ 2008-03-19 23:07 Christian Herenz
  2008-03-19 23:46 ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Herenz @ 2008-03-19 23:07 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

is it possible to use a major-mode on files with a certain prefix?
I know that I can do something like this:

(setq auto-mode-alist (cons '("\\.html$" . 
html-helper-mode)auto-mode-alist))

But what about opening files like foo.comments, foo.examples and so on 
in a special mode?

Thanks in advance...

Christian


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

* Re: auto-mode-alist - recognize prefix instead of sufix?
  2008-03-19 23:07 auto-mode-alist - recognize prefix instead of sufix? Christian Herenz
@ 2008-03-19 23:46 ` Lennart Borgman (gmail)
  2008-03-21  2:18   ` Kevin Rodgers
       [not found]   ` <mailman.9283.1206065927.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Lennart Borgman (gmail) @ 2008-03-19 23:46 UTC (permalink / raw)
  To: Christian Herenz; +Cc: help-gnu-emacs

Christian Herenz wrote:
> Hi,
> 
> is it possible to use a major-mode on files with a certain prefix?
> I know that I can do something like this:
> 
> (setq auto-mode-alist (cons '("\\.html$" . 
> html-helper-mode)auto-mode-alist))
> 
> But what about opening files like foo.comments, foo.examples and so on 
> in a special mode?


I never tried, but from the documentation it looks perfectly possible. 
Have you tried to use a regexp like "^foo\." ?




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

* Re: auto-mode-alist - recognize prefix instead of sufix?
  2008-03-19 23:46 ` Lennart Borgman (gmail)
@ 2008-03-21  2:18   ` Kevin Rodgers
       [not found]   ` <mailman.9283.1206065927.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Kevin Rodgers @ 2008-03-21  2:18 UTC (permalink / raw)
  To: help-gnu-emacs

Lennart Borgman (gmail) wrote:
> Christian Herenz wrote:
>> Hi,
>>
>> is it possible to use a major-mode on files with a certain prefix?
>> I know that I can do something like this:
>>
>> (setq auto-mode-alist (cons '("\\.html$" . 
>> html-helper-mode)auto-mode-alist))
>>
>> But what about opening files like foo.comments, foo.examples and so on 
>> in a special mode?
> 
> 
> I never tried, but from the documentation it looks perfectly possible. 
> Have you tried to use a regexp like "^foo\." ?

It is definitely possible, but the auto-mode-alist regexp is matched
against the whole file name sans backup suffix i.e.
(file-name-sans-version buffer-file-name).

So the regexp should be something like "\\(\\`\\|/\\)foo\.[^/]*\\'"

-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: auto-mode-alist - recognize prefix instead of sufix?
       [not found]   ` <mailman.9283.1206065927.18990.help-gnu-emacs@gnu.org>
@ 2008-03-22 15:49     ` Christian Herenz
  2008-03-22 15:57       ` Le TeXnicien de Surface
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Herenz @ 2008-03-22 15:49 UTC (permalink / raw)
  To: help-gnu-emacs


> So the regexp should be something like "\\(\\`\\|/\\)foo\.[^/]*\\'"
> 

I dont get it working :(

I have files called:
nb_edit-newentry-*************.txt (where stars numbers and letters).

What would be a correct Regexp for that?

Greets,
Christian


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

* Re: auto-mode-alist - recognize prefix instead of sufix?
  2008-03-22 15:49     ` Christian Herenz
@ 2008-03-22 15:57       ` Le TeXnicien de Surface
  2008-03-22 16:27         ` Christian Herenz
  0 siblings, 1 reply; 6+ messages in thread
From: Le TeXnicien de Surface @ 2008-03-22 15:57 UTC (permalink / raw)
  To: help-gnu-emacs

Christian Herenz écrivait :

> 
>> So the regexp should be something like "\\(\\`\\|/\\)foo\.[^/]*\\'"
>> 
> 
> I dont get it working :(
> 
> I have files called:
> nb_edit-newentry-*************.txt (where stars numbers and letters).
> 
> What would be a correct Regexp for that?
something as 
nb_edit-newentry-.*\.txt
should suffice with a direct command such as query-replace-regexp
if you need to write this regexp in a el-file double the \

hih
-- 
Le TeXnicien de Surface


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

* Re: auto-mode-alist - recognize prefix instead of sufix?
  2008-03-22 15:57       ` Le TeXnicien de Surface
@ 2008-03-22 16:27         ` Christian Herenz
  0 siblings, 0 replies; 6+ messages in thread
From: Christian Herenz @ 2008-03-22 16:27 UTC (permalink / raw)
  To: help-gnu-emacs


> nb_edit-newentry-.*\.txt
> should suffice with a direct command such as query-replace-regexp
> if you need to write this regexp in a el-file double the \
> 
> hih

thanks.... that works :)

Greets,
Christian


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

end of thread, other threads:[~2008-03-22 16:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-19 23:07 auto-mode-alist - recognize prefix instead of sufix? Christian Herenz
2008-03-19 23:46 ` Lennart Borgman (gmail)
2008-03-21  2:18   ` Kevin Rodgers
     [not found]   ` <mailman.9283.1206065927.18990.help-gnu-emacs@gnu.org>
2008-03-22 15:49     ` Christian Herenz
2008-03-22 15:57       ` Le TeXnicien de Surface
2008-03-22 16:27         ` Christian Herenz

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