saito@slb-sdr.UUCP (Naoki Saito) (11/20/87)
Hello! I tried to append the new stuff to the auto-mode-alist by putting the following line to my .emacs file. (append 'auto-mode-alist '(("\\.F$" . fortran-mode) ("\\.for$" . fortran-mode) ("\\.txt$" . text-mode))) But in fact, this didn't work. Of course, it's possible to put these lists in the loaddefs.el files, but I would like to do this personally. Could anyone out there give me suggestion/advise? Thanks in advance! Naoki Saito (saito%slb.sdr.com) Schlumberger-Doll Research
jbs@eddie.MIT.EDU (Jeff Siegal) (11/21/87)
In article <414@slb-sdr.UUCP> saito@slb-sdr.UUCP (Naoki Saito) writes: > > Hello! I tried to append the new stuff to the auto-mode-alist >by putting the following line to my .emacs file. > >(append 'auto-mode-alist '(("\\.F$" . fortran-mode) > ("\\.for$" . fortran-mode) > ("\\.txt$" . text-mode))) > Your expression appends the new associations to the standard list, but does not do anything with the newly created list. You need to change the value of auto-mode-alist. Also, you probably want to put your new associations before the standard ones, so you can override an existing file type. (setq auto-mode-alist (append '(("\\.F$" . fortran-mode) ("\\.for$" . fortran-mode) ("\\.txt$" . text-mode)) auto-mode-alist)) Jeff Siegal
hartzell@boulder.Colorado.EDU (George Hartzell) (11/21/87)
In article <414@slb-sdr.UUCP> saito@slb-sdr.UUCP (Naoki Saito) writes: > > Hello! I tried to append the new stuff to the auto-mode-alist >by putting the following line to my .emacs file. > >(append 'auto-mode-alist '(("\\.F$" . fortran-mode) > ("\\.for$" . fortran-mode) > ("\\.txt$" . text-mode))) > > But in fact, this didn't work. Of course, it's possible to put Try: (setq auto-mode-alist (append '(("\\.F$" . fortran-mode) ("\\.for$" . fortran-mode) ("\\.txt$" . text-mode)) auto-mode-alist)) The way that you did it just returns the new list, it never gets assigned to auto-mode-alist. I suspect that you coule switch the auto-mode-alist and (append....) in my example to put the new stuff at the end of the list if you wanted. g. George Hartzell (303) 492-4535 MCD Biology, University of Colorado-Boulder, Boulder, CO 80309 hartzell@Boulder.Colorado.EDU ..!{hao,nbires}!boulder!hartzell
jk3k+@ANDREW.CMU.EDU ("Joseph G. Keane") (11/21/87)
`append' doesn't work because it's non-destructive; it doesn't alter its arguments. The destructive version, `nconc', should be used instead. Also, `auto-mode-alist' shouldn't be quoted (this may be a typo). --Joe
kyle@xanth.UUCP (Kyle Jones) (11/22/87)
> `append' doesn't work because it's non-destructive; it doesn't alter its > arguments. The destructive version, `nconc', should be used instead. Gaa! Please don't use destructive functions for trivial things like this. Use of the destructive functions invariably leads to disaster when their use is not well planned and documented.
matt@oddjob.UChicago.EDU (My Name Here) (11/24/87)
In article <3515@xanth.UUCP> kyle@xanth.UUCP (Kyle Jones) writes:
) > `append' doesn't work because it's non-destructive; it doesn't alter its
) > arguments. The destructive version, `nconc', should be used instead.
)
) Gaa! Please don't use destructive functions for trivial things like
) this. Use of the destructive functions invariably leads to disaster
) when their use is not well planned and documented.
This seems a bit paranoid to me, especially as the code will be in
the user's .emacs file, not in a defined function. I use:
(setq search-exit-char ?\^M
backup-by-copying-when-linked t
backup-by-copying-when-mismatch t
auto-mode-alist (nconc auto-mode-alist
'(("draft$" . text-mode)
("rnmail[0-9]+$" . text-mode)
("article[0-9]*$" . text-mode)
("letter[0-9]*$" . text-mode)
("Mail/drafts/[0-9]+$" . text-mode)))
shell-pushd-regexp "pushd\\|pd")
And have never seen any ill effects.
Matt Crawfrod
steiner@topaz.rutgers.edu (Dave Steiner) (11/25/87)
Cc: steiner We have the following defined in our site-init.el file: (defun fix-auto-mode-alist (file-name-pattern major-mode-function) "Searches auto-mode-alist for a cons pair with FILE-NAME-PATTERN as its car. If found, MAJOR-MODE-FUNCTION is rplacd in place. If not found, (FILE-NAME-PATTERN . MAJOR-MODE-FUNCTION) is added to auto-mode-alist." (interactive "sFile name pattern (regexp): \nSMajor mode function: \n") (let ((temp (assoc file-name-pattern auto-mode-alist))) (if temp (setq auto-mode-alist (nconc (list (cons file-name-pattern major-mode-function)) auto-mode-alist)) (setq auto-mode-alist (nconc auto-mode-alist (list (cons file-name-pattern major-mode-function))))))) -- arpa: Steiner@TOPAZ.RUTGERS.EDU uucp: ...{ames, cbosgd, harvard, moss}!rutgers!topaz.rutgers.edu!steiner
steiner@topaz.rutgers.edu (Dave Steiner) (11/25/87)
We have the following defined in our site-init.el file: (defun fix-auto-mode-alist (file-name-pattern major-mode-function) "Searches auto-mode-alist for a cons pair with FILE-NAME-PATTERN as its car. If found, MAJOR-MODE-FUNCTION is rplacd in place. If not found, (FILE-NAME-PATTERN . MAJOR-MODE-FUNCTION) is added to auto-mode-alist." (interactive "sFile name pattern (regexp): \nSMajor mode function: \n") (let ((temp (assoc file-name-pattern auto-mode-alist))) (if temp (setq auto-mode-alist (nconc (list (cons file-name-pattern major-mode-function)) auto-mode-alist)) (setq auto-mode-alist (nconc auto-mode-alist (list (cons file-name-pattern major-mode-function))))))) -- arpa: Steiner@TOPAZ.RUTGERS.EDU uucp: ...{ames, cbosgd, harvard, moss}!rutgers!topaz.rutgers.edu!steiner
allbery@ncoast.UUCP (11/29/87)
As quoted from <414@slb-sdr.UUCP> by saito@slb-sdr.UUCP (Naoki Saito): +--------------- | Hello! I tried to append the new stuff to the auto-mode-alist | by putting the following line to my .emacs file. | | (append 'auto-mode-alist '(("\\.F$" . fortran-mode) | ("\\.for$" . fortran-mode) | ("\\.txt$" . text-mode))) | | But in fact, this didn't work. Of course, it's possible to put +--------------- The (append) form doesn't have side effects; it returns the new alist instead as a result. I see someone else suggested using (nconc) instead... but I sure wouldn't want to try it! (I have a healthy respect for code with side effects; and (nconc) is a good reason for having such respect.) The way to do it? Add another form on the outside: (setq auto-mode-alist (append 'auto-mode-alist ...)) That way, auto-mode-alist gets the new value and you haven't tempted Fate. -- Brandon S. Allbery necntc!ncoast!allbery@harvard.harvard.edu {hoptoad,harvard!necntc,cbosgd,sun!mandrill!hal,uunet!hnsurg3}!ncoast!allbery Moderator of comp.sources.misc
wohler@milk1.istc.sri.com..istc.sri.com (Bill Wohler) (12/02/87)
you were close. the following example from my .emacs should help. (setq auto-mode-alist (append auto-mode-alist '(("\\.ms$" . nroff-mode) ("\\.me$" . nroff-mode) ("\\.1$" . nroff-mode) ("\\.2$" . nroff-mode) ("\\.3$" . nroff-mode) ("\\.4$" . nroff-mode) ("\\.5$" . nroff-mode) ("\\.8$" . nroff-mode))))