In Emacs terminology, these are two different steps:
- Associate files with the
.ts
extension with the major mode typescript-mode
.
- Run the function
tss-setup-current-buffer
when Typescript mode starts.
To choose which major mode to use for certain file names, add an entry to the variable auto-mode-alist
. Put the following line in your init file:
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
\.ts\'
is a regular expression that matches file names with the .ts
extension.
To run the function tss-setup-current-buffer
whenever Typescript mode starts (I presume that you want to run it even for Typescript mode files that don't have the .ts
extension), add it to the Typescript mode startup hook.
(add-hook 'typescript-mode-hook 'tss-setup-current-buffer)
Depending on how you installed typescript.el
and tss.el
, you may also need to declare that the functions typescript-mode
and tss-setup-current-buffer
have to be loaded from those files. This avoids having to load typescript.el
and tss.el
as soon as Emacs start: they will be loaded on demand, when you first open a .ts
file or run typescript-mode
explicitly.
(autoload 'typescript-mode "Major mode for typescript files" t)
(autoload 'tss-setup-current-buffer "Set up the current file for TSS" t)