You are not logged in.

#1 2008-10-28 19:07:40

Basu
Member
From: Cornell University
Registered: 2006-12-15
Posts: 296
Website

Emacs file loading question

I use emacs and the auctex package to edit Latex files. I have a (load "auctex.el") in my .emacs which loads it at startup. However I share my emacs config with the lab machines where they don't have auctex (and I don't use Latex there anyways). How can I have auctex be loaded whenever I open a Latex/Tex file ?

Thanks,
Basu


The Bytebaker -- Computer science is not a science and it's not about computers
Check out my open source software at Github

Offline

#2 2008-10-28 20:08:53

skymt
Member
Registered: 2006-11-27
Posts: 443

Re: Emacs file loading question

The simplest way is to only load auctex if it's available:

(load "auctex.el" t)  ; The second arg to load is a flag to suppress errors

Emacs runs find-file-hook whenever it visits a file, so you could also write a hook function to look at the filename and load auctex for .tex files.

Offline

#3 2008-10-30 01:21:57

samwise
Member
From: Sydney, Australia
Registered: 2008-07-26
Posts: 53
Website

Re: Emacs file loading question

To automatically load a file try the 'autoload' function.

(autoload 'typing-of-emacs "typing.el" "The Typing Of Emacs, a game." t nil)

I do this to automatically enter latex mode when I open a .latex file:

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

The 'auto-mode-alist' is a list of file extensions and their associated modes.

So how about something along the lines of:

(autoload 'auctex-mode "auctex.el" "LaTeX editing mode" t nil)
(add-to-list 'auto-mode-alist '("\\.tex\\'" . auctex-mode))))

Hope that helps.

Edit: Whoops - saw 'emacs lisp' and got all keen. Removed a lot of stuff that wasn't relevant to the question.

Last edited by samwise (2008-10-30 01:36:34)


"He was perfect except for the fact that he was an engineer"

Offline

Board footer

Powered by FluxBB