comparison lisp/files.el @ 29089:cdecd2b73d56

(parse-colon-path): Doc fix. (auto-mode-alist, interpreter-mode-alist): Purecopy the cars. (set-auto-mode): Use mapc.
author Dave Love <fx@gnu.org>
date Mon, 22 May 2000 19:29:04 +0000
parents 0d91ac5f0e4e
children c3344026e42e
comparison
equal deleted inserted replaced
29088:6dce569d0615 29089:cdecd2b73d56
470 (defvar cd-path nil 470 (defvar cd-path nil
471 "Value of the CDPATH environment variable, as a list. 471 "Value of the CDPATH environment variable, as a list.
472 Not actually set up until the first time you you use it.") 472 Not actually set up until the first time you you use it.")
473 473
474 (defun parse-colon-path (cd-path) 474 (defun parse-colon-path (cd-path)
475 "Explode a colon-separated search path into a list of directory names." 475 "Explode a colon-separated search path into a list of directory names.
476 \(For values of `colon' equal to `path-separator'.)"
477 ;; We could use split-string here.
476 (and cd-path 478 (and cd-path
477 (let (cd-prefix cd-list (cd-start 0) cd-colon) 479 (let (cd-prefix cd-list (cd-start 0) cd-colon)
478 (setq cd-path (concat cd-path path-separator)) 480 (setq cd-path (concat cd-path path-separator))
479 (while (setq cd-colon (string-match path-separator cd-path cd-start)) 481 (while (setq cd-colon (string-match path-separator cd-path cd-start))
480 (setq cd-list 482 (setq cd-list
1308 (hack-local-variables)) 1310 (hack-local-variables))
1309 (error (message "File local-variables error: %s" 1311 (error (message "File local-variables error: %s"
1310 (prin1-to-string err))))) 1312 (prin1-to-string err)))))
1311 1313
1312 (defvar auto-mode-alist 1314 (defvar auto-mode-alist
1313 '(("\\.te?xt\\'" . text-mode) 1315 (mapc
1314 ("\\.c\\'" . c-mode) 1316 (lambda (elt)
1315 ("\\.h\\'" . c-mode) 1317 (cons (purecopy (car elt)) (cdr elt)))
1316 ("\\.tex\\'" . tex-mode) 1318 '(("\\.te?xt\\'" . text-mode)
1317 ("\\.ltx\\'" . latex-mode) 1319 ("\\.c\\'" . c-mode)
1318 ("\\.el\\'" . emacs-lisp-mode) 1320 ("\\.h\\'" . c-mode)
1319 ("\\.scm\\'" . scheme-mode) 1321 ("\\.tex\\'" . tex-mode)
1320 ("\\.l\\'" . lisp-mode) 1322 ("\\.ltx\\'" . latex-mode)
1321 ("\\.lisp\\'" . lisp-mode) 1323 ("\\.el\\'" . emacs-lisp-mode)
1322 ("\\.f\\'" . fortran-mode) 1324 ("\\.scm\\'" . scheme-mode)
1323 ("\\.F\\'" . fortran-mode) 1325 ("\\.l\\'" . lisp-mode)
1324 ("\\.for\\'" . fortran-mode) 1326 ("\\.lisp\\'" . lisp-mode)
1325 ("\\.p\\'" . pascal-mode) 1327 ("\\.f\\'" . fortran-mode)
1326 ("\\.pas\\'" . pascal-mode) 1328 ("\\.F\\'" . fortran-mode)
1327 ("\\.ad[abs]\\'" . ada-mode) 1329 ("\\.for\\'" . fortran-mode)
1328 ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode) 1330 ("\\.p\\'" . pascal-mode)
1329 ("\\.s?html?\\'" . html-mode) 1331 ("\\.pas\\'" . pascal-mode)
1330 ("\\.cc\\'" . c++-mode) 1332 ("\\.ad[abs]\\'" . ada-mode)
1331 ("\\.hh\\'" . c++-mode) 1333 ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode)
1332 ("\\.hpp\\'" . c++-mode) 1334 ("\\.s?html?\\'" . html-mode)
1333 ("\\.C\\'" . c++-mode) 1335 ("\\.cc\\'" . c++-mode)
1334 ("\\.H\\'" . c++-mode) 1336 ("\\.hh\\'" . c++-mode)
1335 ("\\.cpp\\'" . c++-mode) 1337 ("\\.hpp\\'" . c++-mode)
1336 ("\\.cxx\\'" . c++-mode) 1338 ("\\.C\\'" . c++-mode)
1337 ("\\.hxx\\'" . c++-mode) 1339 ("\\.H\\'" . c++-mode)
1338 ("\\.c\\+\\+\\'" . c++-mode) 1340 ("\\.cpp\\'" . c++-mode)
1339 ("\\.h\\+\\+\\'" . c++-mode) 1341 ("\\.cxx\\'" . c++-mode)
1340 ("\\.m\\'" . objc-mode) 1342 ("\\.hxx\\'" . c++-mode)
1341 ("\\.java\\'" . java-mode) 1343 ("\\.c\\+\\+\\'" . c++-mode)
1342 ("\\.mk\\'" . makefile-mode) 1344 ("\\.h\\+\\+\\'" . c++-mode)
1343 ("\\(M\\|m\\|GNUm\\)akefile\\(\\.in\\)?\\'" . makefile-mode) 1345 ("\\.m\\'" . objc-mode)
1344 ("\\.am\\'" . makefile-mode) ;For Automake. 1346 ("\\.java\\'" . java-mode)
1347 ("\\.mk\\'" . makefile-mode)
1348 ("\\(M\\|m\\|GNUm\\)akefile\\(\\.in\\)?\\'" . makefile-mode)
1349 ("\\.am\\'" . makefile-mode) ;For Automake.
1345 ;;; Less common extensions come here 1350 ;;; Less common extensions come here
1346 ;;; so more common ones above are found faster. 1351 ;;; so more common ones above are found faster.
1347 ("\\.texinfo\\'" . texinfo-mode) 1352 ("\\.texinfo\\'" . texinfo-mode)
1348 ("\\.te?xi\\'" . texinfo-mode) 1353 ("\\.te?xi\\'" . texinfo-mode)
1349 ("\\.s\\'" . asm-mode) 1354 ("\\.s\\'" . asm-mode)
1350 ("\\.S\\'" . asm-mode) 1355 ("\\.S\\'" . asm-mode)
1351 ("\\.asm\\'" . asm-mode) 1356 ("\\.asm\\'" . asm-mode)
1352 ("ChangeLog\\'" . change-log-mode) 1357 ("ChangeLog\\'" . change-log-mode)
1353 ("change\\.log\\'" . change-log-mode) 1358 ("change\\.log\\'" . change-log-mode)
1354 ("changelo\\'" . change-log-mode) 1359 ("changelo\\'" . change-log-mode)
1355 ("ChangeLog\\.[0-9]+\\'" . change-log-mode) 1360 ("ChangeLog\\.[0-9]+\\'" . change-log-mode)
1356 ;; for MSDOS and MS-Windows (which are case-insensitive) 1361 ;; for MSDOS and MS-Windows (which are case-insensitive)
1357 ("changelog\\'" . change-log-mode) 1362 ("changelog\\'" . change-log-mode)
1358 ("changelog\\.[0-9]+\\'" . change-log-mode) 1363 ("changelog\\.[0-9]+\\'" . change-log-mode)
1359 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) 1364 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode)
1360 ("\\.scm\\.[0-9]*\\'" . scheme-mode) 1365 ("\\.scm\\.[0-9]*\\'" . scheme-mode)
1361 ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode) 1366 ("\\.[ck]?sh\\'\\|\\.shar\\'\\|/\\.z?profile\\'" . sh-mode)
1362 ("\\(/\\|\\`\\)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\'" . sh-mode) 1367 ("\\(/\\|\\`\\)\\.\\(bash_profile\\|z?login\\|bash_login\\|z?logout\\)\\'" . sh-mode)
1363 ("\\(/\\|\\`\\)\\.\\(bash_logout\\|shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode) 1368 ("\\(/\\|\\`\\)\\.\\(bash_logout\\|shrc\\|[kz]shrc\\|bashrc\\|t?cshrc\\|esrc\\)\\'" . sh-mode)
1364 ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode) 1369 ("\\(/\\|\\`\\)\\.\\([kz]shenv\\|xinitrc\\|startxrc\\|xsession\\)\\'" . sh-mode)
1365 ("\\.m?spec$" . sh-mode) 1370 ("\\.m?spec$" . sh-mode)
1366 ("\\.mm\\'" . nroff-mode) 1371 ("\\.mm\\'" . nroff-mode)
1367 ("\\.me\\'" . nroff-mode) 1372 ("\\.me\\'" . nroff-mode)
1368 ("\\.ms\\'" . nroff-mode) 1373 ("\\.ms\\'" . nroff-mode)
1369 ("\\.man\\'" . nroff-mode) 1374 ("\\.man\\'" . nroff-mode)
1370 ("\\.\\(u?lpc\\|pike\\|pmod\\)\\'" . pike-mode) 1375 ("\\.\\(u?lpc\\|pike\\|pmod\\)\\'" . pike-mode)
1371 ;;; The following should come after the ChangeLog pattern 1376 ;;; The following should come after the ChangeLog pattern
1372 ;;; for the sake of ChangeLog.1, etc. 1377 ;;; for the sake of ChangeLog.1, etc.
1373 ;;; and after the .scm.[0-9] pattern too. 1378 ;;; and after the .scm.[0-9] pattern too.
1374 ("\\.[12345678]\\'" . nroff-mode) 1379 ("\\.[12345678]\\'" . nroff-mode)
1375 ("\\.TeX\\'" . tex-mode) 1380 ("\\.TeX\\'" . tex-mode)
1376 ("\\.sty\\'" . latex-mode) 1381 ("\\.sty\\'" . latex-mode)
1377 ("\\.cls\\'" . latex-mode) ;LaTeX 2e class 1382 ("\\.cls\\'" . latex-mode) ;LaTeX 2e class
1378 ("\\.clo\\'" . latex-mode) ;LaTeX 2e class option 1383 ("\\.clo\\'" . latex-mode) ;LaTeX 2e class option
1379 ("\\.bbl\\'" . latex-mode) 1384 ("\\.bbl\\'" . latex-mode)
1380 ("\\.bib\\'" . bibtex-mode) 1385 ("\\.bib\\'" . bibtex-mode)
1381 ("\\.sql\\'" . sql-mode) 1386 ("\\.sql\\'" . sql-mode)
1382 ("\\.m4\\'" . m4-mode) 1387 ("\\.m4\\'" . m4-mode)
1383 ("\\.mc\\'" . m4-mode) 1388 ("\\.mc\\'" . m4-mode)
1384 ("\\.mf\\'" . metafont-mode) 1389 ("\\.mf\\'" . metafont-mode)
1385 ("\\.mp\\'" . metapost-mode) 1390 ("\\.mp\\'" . metapost-mode)
1386 ("\\.vhdl?\\'" . vhdl-mode) 1391 ("\\.vhdl?\\'" . vhdl-mode)
1387 ("\\.article\\'" . text-mode) 1392 ("\\.article\\'" . text-mode)
1388 ("\\.letter\\'" . text-mode) 1393 ("\\.letter\\'" . text-mode)
1389 ("\\.tcl\\'" . tcl-mode) 1394 ("\\.tcl\\'" . tcl-mode)
1390 ("\\.exp\\'" . tcl-mode) 1395 ("\\.exp\\'" . tcl-mode)
1391 ("\\.itcl\\'" . tcl-mode) 1396 ("\\.itcl\\'" . tcl-mode)
1392 ("\\.itk\\'" . tcl-mode) 1397 ("\\.itk\\'" . tcl-mode)
1393 ("\\.icn\\'" . icon-mode) 1398 ("\\.icn\\'" . icon-mode)
1394 ("\\.sim\\'" . simula-mode) 1399 ("\\.sim\\'" . simula-mode)
1395 ("\\.mss\\'" . scribe-mode) 1400 ("\\.mss\\'" . scribe-mode)
1396 ("\\.f90\\'" . f90-mode) 1401 ("\\.f90\\'" . f90-mode)
1397 ("\\.pro\\'" . idlwave-mode) 1402 ("\\.pro\\'" . idlwave-mode)
1398 ("\\.lsp\\'" . lisp-mode) 1403 ("\\.lsp\\'" . lisp-mode)
1399 ("\\.awk\\'" . awk-mode) 1404 ("\\.awk\\'" . awk-mode)
1400 ("\\.prolog\\'" . prolog-mode) 1405 ("\\.prolog\\'" . prolog-mode)
1401 ("\\.tar\\'" . tar-mode) 1406 ("\\.tar\\'" . tar-mode)
1402 ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|jar\\)\\'" . archive-mode) 1407 ("\\.\\(arc\\|zip\\|lzh\\|zoo\\|jar\\)\\'" . archive-mode)
1403 ("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\|JAR\\)\\'" . archive-mode) 1408 ("\\.\\(ARC\\|ZIP\\|LZH\\|ZOO\\|JAR\\)\\'" . archive-mode)
1404 ;; Mailer puts message to be edited in 1409 ;; Mailer puts message to be edited in
1405 ;; /tmp/Re.... or Message 1410 ;; /tmp/Re.... or Message
1406 ("\\`/tmp/Re" . text-mode) 1411 ("\\`/tmp/Re" . text-mode)
1407 ("/Message[0-9]*\\'" . text-mode) 1412 ("/Message[0-9]*\\'" . text-mode)
1408 ("/drafts/[0-9]+\\'" . mh-letter-mode) 1413 ("/drafts/[0-9]+\\'" . mh-letter-mode)
1409 ("\\.zone\\'" . zone-mode) 1414 ("\\.zone\\'" . zone-mode)
1410 ;; some news reader is reported to use this 1415 ;; some news reader is reported to use this
1411 ("\\`/tmp/fol/" . text-mode) 1416 ("\\`/tmp/fol/" . text-mode)
1412 ("\\.y\\'" . c-mode) 1417 ("\\.y\\'" . c-mode)
1413 ("\\.lex\\'" . c-mode) 1418 ("\\.lex\\'" . c-mode)
1414 ("\\.oak\\'" . scheme-mode) 1419 ("\\.oak\\'" . scheme-mode)
1415 ("\\.sgml?\\'" . sgml-mode) 1420 ("\\.sgml?\\'" . sgml-mode)
1416 ("\\.xml\\'" . sgml-mode) 1421 ("\\.xml\\'" . sgml-mode)
1417 ("\\.dtd\\'" . sgml-mode) 1422 ("\\.dtd\\'" . sgml-mode)
1418 ("\\.ds\\(ss\\)?l\\'" . dsssl-mode) 1423 ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
1419 ("\\.idl\\'" . idl-mode) 1424 ("\\.idl\\'" . idl-mode)
1420 ;; .emacs following a directory delimiter 1425 ;; .emacs following a directory delimiter
1421 ;; in Unix, MSDOG or VMS syntax. 1426 ;; in Unix, MSDOG or VMS syntax.
1422 ("[]>:/\\]\\..*emacs\\'" . emacs-lisp-mode) 1427 ("[]>:/\\]\\..*emacs\\'" . emacs-lisp-mode)
1423 ("\\`\\..*emacs\\'" . emacs-lisp-mode) 1428 ("\\`\\..*emacs\\'" . emacs-lisp-mode)
1424 ;; _emacs following a directory delimiter 1429 ;; _emacs following a directory delimiter
1425 ;; in MsDos syntax 1430 ;; in MsDos syntax
1426 ("[:/]_emacs\\'" . emacs-lisp-mode) 1431 ("[:/]_emacs\\'" . emacs-lisp-mode)
1427 ("/crontab\\.X*[0-9]+\\'" . shell-script-mode) 1432 ("/crontab\\.X*[0-9]+\\'" . shell-script-mode)
1428 ("\\.ml\\'" . lisp-mode) 1433 ("\\.ml\\'" . lisp-mode)
1429 ("\\.asn$" . snmp-mode) 1434 ("\\.asn$" . snmp-mode)
1430 ("\\.mib$" . snmp-mode) 1435 ("\\.mib$" . snmp-mode)
1431 ("\\.smi$" . snmp-mode) 1436 ("\\.smi$" . snmp-mode)
1432 ("\\.as2$" . snmpv2-mode) 1437 ("\\.as2$" . snmpv2-mode)
1433 ("\\.mi2$" . snmpv2-mode) 1438 ("\\.mi2$" . snmpv2-mode)
1434 ("\\.sm2$" . snmpv2-mode) 1439 ("\\.sm2$" . snmpv2-mode)
1435 ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) 1440 ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode)
1436 ("\\.[eE]?[pP][sS]$" . ps-mode) 1441 ("\\.[eE]?[pP][sS]$" . ps-mode)
1437 ("configure\\.in\\'" . autoconf-mode) 1442 ("configure\\.in\\'" . autoconf-mode)
1438 ("BROWSE\\'" . ebrowse-tree-mode) 1443 ("BROWSE\\'" . ebrowse-tree-mode)
1439 ("\\.ebrowse\\'" . ebrowse-tree-mode)) 1444 ("\\.ebrowse\\'" . ebrowse-tree-mode)))
1440 "\ 1445 "Alist of filename patterns vs corresponding major mode functions.
1441 Alist of filename patterns vs corresponding major mode functions.
1442 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL). 1446 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL).
1443 \(NON-NIL stands for anything that is not nil; the value does not matter.) 1447 \(NON-NIL stands for anything that is not nil; the value does not matter.)
1444 Visiting a file whose name matches REGEXP specifies FUNCTION as the 1448 Visiting a file whose name matches REGEXP specifies FUNCTION as the
1445 mode function to use. FUNCTION will be called, unless it is nil. 1449 mode function to use. FUNCTION will be called, unless it is nil.
1446 1450
1448 calling FUNCTION (if it's not nil), we delete the suffix that matched 1452 calling FUNCTION (if it's not nil), we delete the suffix that matched
1449 REGEXP and search the list again for another match.") 1453 REGEXP and search the list again for another match.")
1450 1454
1451 1455
1452 (defvar interpreter-mode-alist 1456 (defvar interpreter-mode-alist
1453 '(("perl" . perl-mode) 1457 (mapc
1454 ("perl5" . perl-mode) 1458 (lambda (l)
1455 ("miniperl" . perl-mode) 1459 (cons (purecopy (car l)) (cdr l)))
1456 ("wish" . tcl-mode) 1460 '(("perl" . perl-mode)
1457 ("wishx" . tcl-mode) 1461 ("perl5" . perl-mode)
1458 ("tcl" . tcl-mode) 1462 ("miniperl" . perl-mode)
1459 ("tclsh" . tcl-mode) 1463 ("wish" . tcl-mode)
1460 ("awk" . awk-mode) 1464 ("wishx" . tcl-mode)
1461 ("mawk" . awk-mode) 1465 ("tcl" . tcl-mode)
1462 ("nawk" . awk-mode) 1466 ("tclsh" . tcl-mode)
1463 ("gawk" . awk-mode) 1467 ("awk" . awk-mode)
1464 ("scm" . scheme-mode) 1468 ("mawk" . awk-mode)
1465 ("ash" . sh-mode) 1469 ("nawk" . awk-mode)
1466 ("bash" . sh-mode) 1470 ("gawk" . awk-mode)
1467 ("csh" . sh-mode) 1471 ("scm" . scheme-mode)
1468 ("dtksh" . sh-mode) 1472 ("ash" . sh-mode)
1469 ("es" . sh-mode) 1473 ("bash" . sh-mode)
1470 ("itcsh" . sh-mode) 1474 ("csh" . sh-mode)
1471 ("jsh" . sh-mode) 1475 ("dtksh" . sh-mode)
1472 ("ksh" . sh-mode) 1476 ("es" . sh-mode)
1473 ("oash" . sh-mode) 1477 ("itcsh" . sh-mode)
1474 ("pdksh" . sh-mode) 1478 ("jsh" . sh-mode)
1475 ("rc" . sh-mode) 1479 ("ksh" . sh-mode)
1476 ("rpm" . sh-mode) 1480 ("oash" . sh-mode)
1477 ("sh" . sh-mode) 1481 ("pdksh" . sh-mode)
1478 ("sh5" . sh-mode) 1482 ("rc" . sh-mode)
1479 ("tcsh" . sh-mode) 1483 ("rpm" . sh-mode)
1480 ("wksh" . sh-mode) 1484 ("sh" . sh-mode)
1481 ("wsh" . sh-mode) 1485 ("sh5" . sh-mode)
1482 ("zsh" . sh-mode) 1486 ("tcsh" . sh-mode)
1483 ("tail" . text-mode) 1487 ("wksh" . sh-mode)
1484 ("more" . text-mode) 1488 ("wsh" . sh-mode)
1485 ("less" . text-mode) 1489 ("zsh" . sh-mode)
1486 ("pg" . text-mode) 1490 ("tail" . text-mode)
1487 ("make" . makefile-mode) ; Debian uses this 1491 ("more" . text-mode)
1488 ("guile" . scheme-mode) 1492 ("less" . text-mode)
1489 ("clisp" . lisp-mode)) 1493 ("pg" . text-mode)
1494 ("make" . makefile-mode) ; Debian uses this
1495 ("guile" . scheme-mode)
1496 ("clisp" . lisp-mode)))
1490 "Alist mapping interpreter names to major modes. 1497 "Alist mapping interpreter names to major modes.
1491 This alist applies to files whose first line starts with `#!'. 1498 This alist applies to files whose first line starts with `#!'.
1492 Each element looks like (INTERPRETER . MODE). 1499 Each element looks like (INTERPRETER . MODE).
1493 The car of each element is compared with 1500 The car of each element is compared with
1494 the name of the interpreter specified in the first line. 1501 the name of the interpreter specified in the first line.
1581 modes)))))) 1588 modes))))))
1582 ;; If we found modes to use, invoke them now, 1589 ;; If we found modes to use, invoke them now,
1583 ;; outside the save-excursion. 1590 ;; outside the save-excursion.
1584 (when modes 1591 (when modes
1585 (unless just-from-file-name 1592 (unless just-from-file-name
1586 (mapcar 'funcall (nreverse modes))) 1593 (mapc 'funcall (nreverse modes)))
1587 (setq done t)) 1594 (setq done t))
1588 ;; If we didn't find a mode from a -*- line, try using the file name. 1595 ;; If we didn't find a mode from a -*- line, try using the file name.
1589 (if (and (not done) buffer-file-name) 1596 (if (and (not done) buffer-file-name)
1590 (let ((name buffer-file-name) 1597 (let ((name buffer-file-name)
1591 (keep-going t)) 1598 (keep-going t))