Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] [X]Emacs file association (auto-mode)



>>>>> "Josh" == Josh Glover <jmglov@example.com> writes:

    Josh> Um... pretty hard, when I forget about Emacs's online
    Josh> help. Sorry. :(

Wow, you don't use the help and you still like Emacs?  I'd find it
pretty unbearable, myself.<wink>

    Josh> I tried [inter alia]:

    Josh> (setq auto-mode-alist (append (list "\\.m4$" nil 'YOW!)
    Josh>       auto-mode-alist))

That is correct, though

    (setq auto-mode-alist
          (append (list "\\.m4$" nil 'YOW!) auto-mode-alist))

is the preferred layout.  More convenient and easy to read are

    (push '("\\.m4$" nil YOW!) auto-mode-alist)
    (add-to-list 'auto-mode-alist '("\\.m4$" nil YOW!))

(For intermediate LISPers: push is a macro so it can properly update
the value of auto-mode-alist even though it's not quoted.  In both,
since the list literal is quoted, the symbol YOW! doesn't need to be
quoted.)

push is best in this case, since it's less complex than setq
... append, and add-to-list really is "add-to-set", because it only
adds it if it's not already in the list, which would fail to work as
expected if your auto-mode-alist was

    (("\\.m4$" m4-mode) ("\\.m4$" nil YOW!))

since alist processing depends on order.

The "push" version works for me immediately.  Ie

M-: (push '("\\.m4$" nil YOW!) auto-mode-alist) RET
C-x C-f junk.tex.m4 RET

gives me a fresh buffer in LaTeX mode.  I also tested an existing file
by cp Makefile.in.in Makefile.in.in.m4 and the latter comes up in
Makefile mode.

Check that this form of element for auto-mode-alist is supported in
your version of Emacs (start by checking the docstring if you haven't
done so already).


-- 
School of Systems and Information Engineering http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links