* Forcing a mode
@ 2006-08-31 13:40 CloudStrife
2006-08-31 15:09 ` Aaron Bingham
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: CloudStrife @ 2006-08-31 13:40 UTC (permalink / raw)
I have some tcl files that donot have .tcl extension in file name. So
when i open them in emacs the tcl mode is not turned on. can i enforce
this onto the file.
Cloud
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Forcing a mode
2006-08-31 13:40 Forcing a mode CloudStrife
@ 2006-08-31 15:09 ` Aaron Bingham
2006-08-31 21:33 ` Colin S. Miller
[not found] ` <mailman.6088.1157036963.9609.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 8+ messages in thread
From: Aaron Bingham @ 2006-08-31 15:09 UTC (permalink / raw)
Cc: help-gnu-emacs
CloudStrife wrote:
>I have some tcl files that donot have .tcl extension in file name. So
>when i open them in emacs the tcl mode is not turned on. can i enforce
>this onto the file.
>
Hi Cloud,
I don't know quite what you mean by "enforce this onto a file". Do you
mean you want to manually set the mode after you open the file, or do
you want to tell Emacs to permanently treat the file as Tcl?
If the former, simply use M-x tcl-mode.
Regards,
--
--------------------------------------------------------------------
Aaron Bingham
Senior Software Engineer
Cenix BioScience GmbH
--------------------------------------------------------------------
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Forcing a mode
[not found] ` <mailman.6088.1157036963.9609.help-gnu-emacs@gnu.org>
@ 2006-08-31 15:27 ` Phillip Lord
2006-08-31 21:11 ` Will Parsons
2006-09-01 5:39 ` CloudStrife
1 sibling, 1 reply; 8+ messages in thread
From: Phillip Lord @ 2006-08-31 15:27 UTC (permalink / raw)
>>>>> "AB" == Aaron Bingham <bingham@cenix-bioscience.com> writes:
AB> CloudStrife wrote:
>> I have some tcl files that donot have .tcl extension in file
>> name. So when i open them in emacs the tcl mode is not turned
>> on. can i enforce this onto the file.
>>
AB> Hi Cloud,
AB> I don't know quite what you mean by "enforce this onto a file".
AB> Do you mean you want to manually set the mode after you open the
AB> file, or do you want to tell Emacs to permanently treat the file
AB> as Tcl?
AB> If the former, simply use M-x tcl-mode.
I think he wants this to happen automatically.
You can do this with file variables. Sticking
;; -*- mode: tcl -*-
as the first line of the file should work.
Or
;; Local Variables: ***
;; mode: tcl ***
at the end should work. You can replace ";;" with what ever tcl uses
as a comment.
Phil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Forcing a mode
2006-08-31 15:27 ` Phillip Lord
@ 2006-08-31 21:11 ` Will Parsons
2006-09-01 0:58 ` Barry Margolin
2006-09-01 13:43 ` rgb
0 siblings, 2 replies; 8+ messages in thread
From: Will Parsons @ 2006-08-31 21:11 UTC (permalink / raw)
Phillip Lord wrote:
>>>>>> "AB" == Aaron Bingham <bingham@cenix-bioscience.com> writes:
>
> AB> CloudStrife wrote:
>
> >> I have some tcl files that donot have .tcl extension in file
> >> name. So when i open them in emacs the tcl mode is not turned
> >> on. can i enforce this onto the file.
> >>
[snip]
> I think he wants this to happen automatically.
>
> You can do this with file variables. Sticking
>
>
> ;; -*- mode: tcl -*-
>
> as the first line of the file should work.
I've always used:
#-*-tcl-*-
Is there any reason the longer form with "mode: " should be preferred?
> Or
>
> ;; Local Variables: ***
> ;; mode: tcl ***
>
> at the end should work. You can replace ";;" with what ever tcl uses
> as a comment.
I didn't know about that one.
(Note that Tcl scripts typically begin something like:
#!/bin/sh
# ....
# \
exec tclsh "$0" ${1+"$@"}
so Emacs cannot deduce the mode from the shebang.)
- Will
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Forcing a mode
2006-08-31 13:40 Forcing a mode CloudStrife
2006-08-31 15:09 ` Aaron Bingham
@ 2006-08-31 21:33 ` Colin S. Miller
[not found] ` <mailman.6088.1157036963.9609.help-gnu-emacs@gnu.org>
2 siblings, 0 replies; 8+ messages in thread
From: Colin S. Miller @ 2006-08-31 21:33 UTC (permalink / raw)
CloudStrife wrote:
> I have some tcl files that donot have .tcl extension in file name. So
> when i open them in emacs the tcl mode is not turned on. can i enforce
> this onto the file.
> Cloud
>
Cloud,
If they have another ending, say, .tc,
adding
(add-to-list 'auto-mode-alist '("\\.tc\\'" . tcl-mode) 't)
to your .emacs file should associate files ending with '.tc'
with tcl-mode.
HTH,
Colin S. Miller
--
Replace the obvious in my email address with the first three letters of the hostname to reply.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Forcing a mode
2006-08-31 21:11 ` Will Parsons
@ 2006-09-01 0:58 ` Barry Margolin
2006-09-01 13:43 ` rgb
1 sibling, 0 replies; 8+ messages in thread
From: Barry Margolin @ 2006-09-01 0:58 UTC (permalink / raw)
In article <slrnefek3h.onm.oudeis@isis.thalatta>,
Will Parsons <oudeis@nodomain.invalid> wrote:
> Phillip Lord wrote:
> > You can do this with file variables. Sticking
> >
> >
> > ;; -*- mode: tcl -*-
> >
> > as the first line of the file should work.
>
> I've always used:
>
> #-*-tcl-*-
>
> Is there any reason the longer form with "mode: " should be preferred?
Your version is the archaic syntax, which was used when the only thing
you could configure in the mode line was the major mode. It was later
generalized to allow a number of options to be configured, so the
<option>:<value> syntax was created, with the old -*-<mode>-*- retained
for compatibility.
It should continue to be supported forever, so if you prefer it there's
nothing really wrong with it.
--
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 ***
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Forcing a mode
[not found] ` <mailman.6088.1157036963.9609.help-gnu-emacs@gnu.org>
2006-08-31 15:27 ` Phillip Lord
@ 2006-09-01 5:39 ` CloudStrife
1 sibling, 0 replies; 8+ messages in thread
From: CloudStrife @ 2006-09-01 5:39 UTC (permalink / raw)
Aaron Bingham wrote:
> CloudStrife wrote:
>
> >I have some tcl files that donot have .tcl extension in file name. So
> >when i open them in emacs the tcl mode is not turned on. can i enforce
> >this onto the file.
> >
> Hi Cloud,
>
> I don't know quite what you mean by "enforce this onto a file". Do you
> mean you want to manually set the mode after you open the file, or do
> you want to tell Emacs to permanently treat the file as Tcl?
>
> If the former, simply use M-x tcl-mode.
>
> Regards,
>
> --
> --------------------------------------------------------------------
> Aaron Bingham
> Senior Software Engineer
> Cenix BioScience GmbH
> --------------------------------------------------------------------
Hi Aaron
I asked for setting the mode manually after i open the file, whose fix
have written
Thanks a lot
Cloud
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Forcing a mode
2006-08-31 21:11 ` Will Parsons
2006-09-01 0:58 ` Barry Margolin
@ 2006-09-01 13:43 ` rgb
1 sibling, 0 replies; 8+ messages in thread
From: rgb @ 2006-09-01 13:43 UTC (permalink / raw)
> (Note that Tcl scripts typically begin something like:
>
> #!/bin/sh
> # ....
> # \
> exec tclsh "$0" ${1+"$@"}
>
> so Emacs cannot deduce the mode from the shebang.)
On Tandem platforms there are no filename extensions.
Moreover, because over 90% of source files I work on are
legacy and most Tandem programmers have never heard
of Emacs, I can't go around changing source files to add
these cookies everywhere I consult.
So I had to write something that does just what you want.
I ripped redundant/irrelevent stuff out, below.
Hopefully I didn't break anything in the meanwhile.
Someone interested in the full version should see my
emacswiki page.
(defadvice set-auto-mode ; RGB 2003
(after my-determine-language last () activate)
"If language is fundamental-mode Emacs didn't detect it.
Some 1st line language indicators are used to do recognition."
(if (eq major-mode 'fundamental-mode)
(let ((mode nil))
(save-excursion ; don't trash bookmarks
(goto-char (point-min))
(if (looking-at
(concat
"\\(\\?TACL \\|==\\| *#set\\|\\?SECTION +\\"
"(\\S-+\\s-+\\"
"(macro\\|routine\\|alias\\|text\\)\\)\\b\\)"))
(setq mode 'tacl-mode)
(if (looking-at "\\?SECTION +.+,TANDEM\\b")
(setq mode 'ddl-mode)
(if (looking-at "\\?ANSI\\b")
(setq mode 'cobol-mode)
(if (looking-at "#[-*#=\n]")
(setq mode 'acimake-mode)
(if (or (looking-at "\\?pep")
(looking-at "[!*] SCHEMA")
(looking-at "!FILE CREATED BY GENFWD"))
(setq mode 'tal-mode)))))))
(if mode
(funcall mode)))))
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2006-09-01 13:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-31 13:40 Forcing a mode CloudStrife
2006-08-31 15:09 ` Aaron Bingham
2006-08-31 21:33 ` Colin S. Miller
[not found] ` <mailman.6088.1157036963.9609.help-gnu-emacs@gnu.org>
2006-08-31 15:27 ` Phillip Lord
2006-08-31 21:11 ` Will Parsons
2006-09-01 0:58 ` Barry Margolin
2006-09-01 13:43 ` rgb
2006-09-01 5:39 ` CloudStrife
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.