aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/sh-script.el
diff options
context:
space:
mode:
authorRichard M. Stallman2003-09-22 15:39:47 +0000
committerRichard M. Stallman2003-09-22 15:39:47 +0000
commit1bf87f6ba3ce879fbf15d2fd5fbfe366c4c63d65 (patch)
tree6159c79f51bff0874aee17bf0c9fac54163ca026 /lisp/progmodes/sh-script.el
parentdfe02f1424a3d154f897722f42ff25f9c3480638 (diff)
downloademacs-1bf87f6ba3ce879fbf15d2fd5fbfe366c4c63d65.tar.gz
emacs-1bf87f6ba3ce879fbf15d2fd5fbfe366c4c63d65.zip
(sh-mode-default-syntax-table): Renamed from sh-mode-syntax-table.
Call sh-mode-syntax-table directly. (sh-mode-syntax-table-input): New variable. (sh-require-final-newline): Don't use eval. (sh-builtins, sh-leading-keywords, sh-other-keywords) (sh-variables, sh-font-lock-keywords): Don't use eval. (sh-set-shell): When setting require-final-newline, treat value = `require-final-newline' as don't change it. Set sh-mode-syntax-table locally based on sh-mode-syntax-table-input and sh-mode-default-syntax-table.
Diffstat (limited to 'lisp/progmodes/sh-script.el')
-rw-r--r--lisp/progmodes/sh-script.el158
1 files changed, 81 insertions, 77 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 7fcbef2670d..dd6fb7ce7b0 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -393,8 +393,15 @@ the car and cdr are the same symbol.")
393 393
394 394
395 395
396(defvar sh-mode-syntax-table 396(defun sh-mode-syntax-table (table &rest list)
397 '((sh eval sh-mode-syntax-table () 397 "Copy TABLE and set syntax for successive CHARs according to strings S."
398 (setq table (copy-syntax-table table))
399 (while list
400 (modify-syntax-entry (pop list) (pop list) table))
401 table)
402
403(defvar sh-mode-default-syntax-table
404 (sh-mode-syntax-table ()
398 ?\# "<" 405 ?\# "<"
399 ?\n ">#" 406 ?\n ">#"
400 ?\" "\"\"" 407 ?\" "\"\""
@@ -409,9 +416,10 @@ the car and cdr are the same symbol.")
409 ?, "_" 416 ?, "_"
410 ?< "." 417 ?< "."
411 ?> ".") 418 ?> ".")
412 (csh eval identity sh) 419 "Default syntax table for shell mode.")
413 (rc eval identity sh))
414 420
421(defvar sh-mode-syntax-table-input
422 '((sh . nil))
415 "Syntax-table used in Shell-Script mode. See `sh-feature'.") 423 "Syntax-table used in Shell-Script mode. See `sh-feature'.")
416 424
417(defvar sh-mode-map 425(defvar sh-mode-map
@@ -480,8 +488,8 @@ the car and cdr are the same symbol.")
480(defcustom sh-require-final-newline 488(defcustom sh-require-final-newline
481 '((csh . t) 489 '((csh . t)
482 (pdksh . t) 490 (pdksh . t)
483 (rc eval . require-final-newline) 491 (rc . require-final-newline)
484 (sh eval . require-final-newline)) 492 (sh . require-final-newline))
485 "*Value of `require-final-newline' in Shell-Script mode buffers. 493 "*Value of `require-final-newline' in Shell-Script mode buffers.
486See `sh-feature'." 494See `sh-feature'."
487 :type '(repeat (cons (symbol :tag "Shell") 495 :type '(repeat (cons (symbol :tag "Shell")
@@ -561,61 +569,61 @@ documents - you must insert literal tabs by hand.")
561;; customized this out of sheer bravado. not for the faint of heart. 569;; customized this out of sheer bravado. not for the faint of heart.
562;; but it *did* have an asterisk in the docstring! 570;; but it *did* have an asterisk in the docstring!
563(defcustom sh-builtins 571(defcustom sh-builtins
564 '((bash eval sh-append posix 572 '((bash sh-append posix
565 "." "alias" "bg" "bind" "builtin" "compgen" "complete" 573 "." "alias" "bg" "bind" "builtin" "compgen" "complete"
566 "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history" 574 "declare" "dirs" "disown" "enable" "fc" "fg" "help" "history"
567 "jobs" "kill" "let" "local" "popd" "printf" "pushd" "source" 575 "jobs" "kill" "let" "local" "popd" "printf" "pushd" "source"
568 "suspend" "typeset" "unalias") 576 "suspend" "typeset" "unalias")
569 577
570 ;; The next entry is only used for defining the others 578 ;; The next entry is only used for defining the others
571 (bourne eval sh-append shell 579 (bourne sh-append shell
572 "eval" "export" "getopts" "newgrp" "pwd" "read" "readonly" 580 "eval" "export" "getopts" "newgrp" "pwd" "read" "readonly"
573 "times" "ulimit") 581 "times" "ulimit")
574 582
575 (csh eval sh-append shell 583 (csh sh-append shell
576 "alias" "chdir" "glob" "history" "limit" "nice" "nohup" "rehash" 584 "alias" "chdir" "glob" "history" "limit" "nice" "nohup" "rehash"
577 "setenv" "source" "time" "unalias" "unhash") 585 "setenv" "source" "time" "unalias" "unhash")
578 586
579 (dtksh eval identity wksh) 587 (dtksh sh-append wksh)
580 588
581 (es "access" "apids" "cd" "echo" "eval" "false" "let" "limit" "local" 589 (es "access" "apids" "cd" "echo" "eval" "false" "let" "limit" "local"
582 "newpgrp" "result" "time" "umask" "var" "vars" "wait" "whatis") 590 "newpgrp" "result" "time" "umask" "var" "vars" "wait" "whatis")
583 591
584 (jsh eval sh-append sh 592 (jsh sh-append sh
585 "bg" "fg" "jobs" "kill" "stop" "suspend") 593 "bg" "fg" "jobs" "kill" "stop" "suspend")
586 594
587 (jcsh eval sh-append csh 595 (jcsh sh-append csh
588 "bg" "fg" "jobs" "kill" "notify" "stop" "suspend") 596 "bg" "fg" "jobs" "kill" "notify" "stop" "suspend")
589 597
590 (ksh88 eval sh-append bourne 598 (ksh88 sh-append bourne
591 "alias" "bg" "false" "fc" "fg" "jobs" "kill" "let" "print" "time" 599 "alias" "bg" "false" "fc" "fg" "jobs" "kill" "let" "print" "time"
592 "typeset" "unalias" "whence") 600 "typeset" "unalias" "whence")
593 601
594 (oash eval sh-append sh 602 (oash sh-append sh
595 "checkwin" "dateline" "error" "form" "menu" "newwin" "oadeinit" 603 "checkwin" "dateline" "error" "form" "menu" "newwin" "oadeinit"
596 "oaed" "oahelp" "oainit" "pp" "ppfile" "scan" "scrollok" "wattr" 604 "oaed" "oahelp" "oainit" "pp" "ppfile" "scan" "scrollok" "wattr"
597 "wclear" "werase" "win" "wmclose" "wmmessage" "wmopen" "wmove" 605 "wclear" "werase" "win" "wmclose" "wmmessage" "wmopen" "wmove"
598 "wmtitle" "wrefresh") 606 "wmtitle" "wrefresh")
599 607
600 (pdksh eval sh-append ksh88 608 (pdksh sh-append ksh88
601 "bind") 609 "bind")
602 610
603 (posix eval sh-append sh 611 (posix sh-append sh
604 "command") 612 "command")
605 613
606 (rc "builtin" "cd" "echo" "eval" "limit" "newpgrp" "shift" "umask" "wait" 614 (rc "builtin" "cd" "echo" "eval" "limit" "newpgrp" "shift" "umask" "wait"
607 "whatis") 615 "whatis")
608 616
609 (sh eval sh-append bourne 617 (sh sh-append bourne
610 "hash" "test" "type") 618 "hash" "test" "type")
611 619
612 ;; The next entry is only used for defining the others 620 ;; The next entry is only used for defining the others
613 (shell "cd" "echo" "eval" "set" "shift" "umask" "unset" "wait") 621 (shell "cd" "echo" "eval" "set" "shift" "umask" "unset" "wait")
614 622
615 (wksh eval sh-append ksh88 623 (wksh sh-append ksh88
616 "Xt[A-Z][A-Za-z]*") 624 "Xt[A-Z][A-Za-z]*")
617 625
618 (zsh eval sh-append ksh88 626 (zsh sh-append ksh88
619 "autoload" "bindkey" "builtin" "chdir" "compctl" "declare" "dirs" 627 "autoload" "bindkey" "builtin" "chdir" "compctl" "declare" "dirs"
620 "disable" "disown" "echotc" "enable" "functions" "getln" "hash" 628 "disable" "disown" "echotc" "enable" "functions" "getln" "hash"
621 "history" "integer" "limit" "local" "log" "popd" "pushd" "r" 629 "history" "integer" "limit" "local" "log" "popd" "pushd" "r"
@@ -635,7 +643,7 @@ implemented as aliases. See `sh-feature'."
635 643
636 644
637(defcustom sh-leading-keywords 645(defcustom sh-leading-keywords
638 '((bash eval sh-append sh 646 '((bash sh-append sh
639 "time") 647 "time")
640 648
641 (csh "else") 649 (csh "else")
@@ -658,33 +666,33 @@ flow of control or syntax. See `sh-feature'."
658 666
659 667
660(defcustom sh-other-keywords 668(defcustom sh-other-keywords
661 '((bash eval sh-append bourne 669 '((bash sh-append bourne
662 "bye" "logout" "select") 670 "bye" "logout" "select")
663 671
664 ;; The next entry is only used for defining the others 672 ;; The next entry is only used for defining the others
665 (bourne eval sh-append sh 673 (bourne sh-append sh
666 "function") 674 "function")
667 675
668 (csh eval sh-append shell 676 (csh sh-append shell
669 "breaksw" "default" "end" "endif" "endsw" "foreach" "goto" 677 "breaksw" "default" "end" "endif" "endsw" "foreach" "goto"
670 "if" "logout" "onintr" "repeat" "switch" "then" "while") 678 "if" "logout" "onintr" "repeat" "switch" "then" "while")
671 679
672 (es "break" "catch" "exec" "exit" "fn" "for" "forever" "fork" "if" 680 (es "break" "catch" "exec" "exit" "fn" "for" "forever" "fork" "if"
673 "return" "throw" "while") 681 "return" "throw" "while")
674 682
675 (ksh88 eval sh-append bourne 683 (ksh88 sh-append bourne
676 "select") 684 "select")
677 685
678 (rc "break" "case" "exec" "exit" "fn" "for" "if" "in" "return" "switch" 686 (rc "break" "case" "exec" "exit" "fn" "for" "if" "in" "return" "switch"
679 "while") 687 "while")
680 688
681 (sh eval sh-append shell 689 (sh sh-append shell
682 "done" "esac" "fi" "for" "in" "return") 690 "done" "esac" "fi" "for" "in" "return")
683 691
684 ;; The next entry is only used for defining the others 692 ;; The next entry is only used for defining the others
685 (shell "break" "case" "continue" "exec" "exit") 693 (shell "break" "case" "continue" "exec" "exit")
686 694
687 (zsh eval sh-append bash 695 (zsh sh-append bash
688 "select")) 696 "select"))
689 "*List of keywords not in `sh-leading-keywords'. 697 "*List of keywords not in `sh-leading-keywords'.
690See `sh-feature'." 698See `sh-feature'."
@@ -698,7 +706,7 @@ See `sh-feature'."
698 706
699 707
700(defvar sh-variables 708(defvar sh-variables
701 '((bash eval sh-append sh 709 '((bash sh-append sh
702 "allow_null_glob_expansion" "auto_resume" "BASH" "BASH_ENV" 710 "allow_null_glob_expansion" "auto_resume" "BASH" "BASH_ENV"
703 "BASH_VERSINFO" "BASH_VERSION" "cdable_vars" "COMP_CWORD" 711 "BASH_VERSINFO" "BASH_VERSION" "cdable_vars" "COMP_CWORD"
704 "COMP_LINE" "COMP_POINT" "COMP_WORDS" "COMPREPLY" "DIRSTACK" 712 "COMP_LINE" "COMP_POINT" "COMP_WORDS" "COMPREPLY" "DIRSTACK"
@@ -714,31 +722,31 @@ See `sh-feature'."
714 "pushd_silent" "PWD" "RANDOM" "REPLY" "SECONDS" "SHELLOPTS" 722 "pushd_silent" "PWD" "RANDOM" "REPLY" "SECONDS" "SHELLOPTS"
715 "SHLVL" "TIMEFORMAT" "TMOUT" "UID") 723 "SHLVL" "TIMEFORMAT" "TMOUT" "UID")
716 724
717 (csh eval sh-append shell 725 (csh sh-append shell
718 "argv" "cdpath" "child" "echo" "histchars" "history" "home" 726 "argv" "cdpath" "child" "echo" "histchars" "history" "home"
719 "ignoreeof" "mail" "noclobber" "noglob" "nonomatch" "path" "prompt" 727 "ignoreeof" "mail" "noclobber" "noglob" "nonomatch" "path" "prompt"
720 "shell" "status" "time" "verbose") 728 "shell" "status" "time" "verbose")
721 729
722 (es eval sh-append shell 730 (es sh-append shell
723 "apid" "cdpath" "CDPATH" "history" "home" "ifs" "noexport" "path" 731 "apid" "cdpath" "CDPATH" "history" "home" "ifs" "noexport" "path"
724 "pid" "prompt" "signals") 732 "pid" "prompt" "signals")
725 733
726 (jcsh eval sh-append csh 734 (jcsh sh-append csh
727 "notify") 735 "notify")
728 736
729 (ksh88 eval sh-append sh 737 (ksh88 sh-append sh
730 "ENV" "ERRNO" "FCEDIT" "FPATH" "HISTFILE" "HISTSIZE" "LINENO" 738 "ENV" "ERRNO" "FCEDIT" "FPATH" "HISTFILE" "HISTSIZE" "LINENO"
731 "OLDPWD" "PPID" "PS3" "PS4" "PWD" "RANDOM" "REPLY" "SECONDS" 739 "OLDPWD" "PPID" "PS3" "PS4" "PWD" "RANDOM" "REPLY" "SECONDS"
732 "TMOUT") 740 "TMOUT")
733 741
734 (oash eval sh-append sh 742 (oash sh-append sh
735 "FIELD" "FIELD_MAX" "LAST_KEY" "OALIB" "PP_ITEM" "PP_NUM") 743 "FIELD" "FIELD_MAX" "LAST_KEY" "OALIB" "PP_ITEM" "PP_NUM")
736 744
737 (rc eval sh-append shell 745 (rc sh-append shell
738 "apid" "apids" "cdpath" "CDPATH" "history" "home" "ifs" "path" "pid" 746 "apid" "apids" "cdpath" "CDPATH" "history" "home" "ifs" "path" "pid"
739 "prompt" "status") 747 "prompt" "status")
740 748
741 (sh eval sh-append shell 749 (sh sh-append shell
742 "CDPATH" "IFS" "OPTARG" "OPTIND" "PS1" "PS2") 750 "CDPATH" "IFS" "OPTARG" "OPTIND" "PS1" "PS2")
743 751
744 ;; The next entry is only used for defining the others 752 ;; The next entry is only used for defining the others
@@ -747,7 +755,7 @@ See `sh-feature'."
747 "LINES" "LOGNAME" "MAIL" "MAILCHECK" "MAILPATH" "PAGER" "PATH" 755 "LINES" "LOGNAME" "MAIL" "MAILCHECK" "MAILPATH" "PAGER" "PATH"
748 "SHELL" "TERM" "TERMCAP" "TERMINFO" "VISUAL") 756 "SHELL" "TERM" "TERMCAP" "TERMINFO" "VISUAL")
749 757
750 (tcsh eval sh-append csh 758 (tcsh sh-append csh
751 "addsuffix" "ampm" "autocorrect" "autoexpand" "autolist" 759 "addsuffix" "ampm" "autocorrect" "autoexpand" "autolist"
752 "autologout" "chase_symlinks" "correct" "dextract" "edit" "el" 760 "autologout" "chase_symlinks" "correct" "dextract" "edit" "el"
753 "fignore" "gid" "histlit" "HOST" "HOSTTYPE" "HPATH" 761 "fignore" "gid" "histlit" "HOST" "HOSTTYPE" "HPATH"
@@ -758,7 +766,7 @@ See `sh-feature'."
758 "tperiod" "tty" "uid" "version" "visiblebell" "watch" "who" 766 "tperiod" "tty" "uid" "version" "visiblebell" "watch" "who"
759 "wordchars") 767 "wordchars")
760 768
761 (zsh eval sh-append ksh88 769 (zsh sh-append ksh88
762 "BAUD" "bindcmds" "cdpath" "DIRSTACKSIZE" "fignore" "FIGNORE" "fpath" 770 "BAUD" "bindcmds" "cdpath" "DIRSTACKSIZE" "fignore" "FIGNORE" "fpath"
763 "HISTCHARS" "hostcmds" "hosts" "HOSTS" "LISTMAX" "LITHISTSIZE" 771 "HISTCHARS" "hostcmds" "hosts" "HOSTS" "LISTMAX" "LITHISTSIZE"
764 "LOGCHECK" "mailpath" "manpath" "NULLCMD" "optcmds" "path" "POSTEDIT" 772 "LOGCHECK" "mailpath" "manpath" "NULLCMD" "optcmds" "path" "POSTEDIT"
@@ -787,17 +795,17 @@ See `sh-feature'.")
787 795
788 796
789(defvar sh-font-lock-keywords 797(defvar sh-font-lock-keywords
790 '((csh eval sh-append shell 798 '((csh sh-append shell
791 '("\\${?[#?]?\\([A-Za-z_][A-Za-z0-9_]*\\|0\\)" 1 799 '("\\${?[#?]?\\([A-Za-z_][A-Za-z0-9_]*\\|0\\)" 1
792 font-lock-variable-name-face)) 800 font-lock-variable-name-face))
793 801
794 (es eval sh-append executable-font-lock-keywords 802 (es sh-append executable-font-lock-keywords
795 '("\\$#?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\)" 1 803 '("\\$#?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\)" 1
796 font-lock-variable-name-face)) 804 font-lock-variable-name-face))
797 805
798 (rc eval identity es) 806 (rc sh-append es)
799 807
800 (sh eval sh-append shell 808 (sh sh-append shell
801 ;; Variable names. 809 ;; Variable names.
802 '("\\$\\({#?\\)?\\([A-Za-z_][A-Za-z0-9_]*\\|[-#?@!]\\)" 2 810 '("\\$\\({#?\\)?\\([A-Za-z_][A-Za-z0-9_]*\\|[-#?@!]\\)" 2
803 font-lock-variable-name-face) 811 font-lock-variable-name-face)
@@ -807,15 +815,15 @@ See `sh-feature'.")
807 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))) 815 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)))
808 816
809 ;; The next entry is only used for defining the others 817 ;; The next entry is only used for defining the others
810 (shell eval sh-append executable-font-lock-keywords 818 (shell sh-append executable-font-lock-keywords
811 ;; Using font-lock-string-face here confuses sh-get-indent-info. 819 ;; Using font-lock-string-face here confuses sh-get-indent-info.
812 '("\\\\$" 0 font-lock-warning-face) 820 '("\\\\$" 0 font-lock-warning-face)
813 '("\\\\[^A-Za-z0-9]" 0 font-lock-string-face) 821 '("\\\\[^A-Za-z0-9]" 0 font-lock-string-face)
814 '("\\${?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\|[$*_]\\)" 1 822 '("\\${?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\|[$*_]\\)" 1
815 font-lock-variable-name-face)) 823 font-lock-variable-name-face))
816 (rpm eval sh-append rpm2 824 (rpm sh-append rpm2
817 '("%{?\\(\\sw+\\)" 1 font-lock-keyword-face)) 825 '("%{?\\(\\sw+\\)" 1 font-lock-keyword-face))
818 (rpm2 eval sh-append shell 826 (rpm2 sh-append shell
819 '("^\\(\\sw+\\):" 1 font-lock-variable-name-face))) 827 '("^\\(\\sw+\\):" 1 font-lock-variable-name-face)))
820 "Default expressions to highlight in Shell Script modes. See `sh-feature'.") 828 "Default expressions to highlight in Shell Script modes. See `sh-feature'.")
821 829
@@ -1478,16 +1486,23 @@ Calls the value of `sh-set-shell-hook' if set."
1478 (setq sh-shell-file 1486 (setq sh-shell-file
1479 (executable-set-magic shell (sh-feature sh-shell-arg) 1487 (executable-set-magic shell (sh-feature sh-shell-arg)
1480 no-query-flag insert-flag))) 1488 no-query-flag insert-flag)))
1481 (setq require-final-newline (sh-feature sh-require-final-newline) 1489 (let ((tem (sh-feature sh-require-final-newline)))
1482;;; local-abbrev-table (sh-feature sh-abbrevs) 1490 (unless (eq tem 'require-final-newline)
1491 (setq require-final-newline tem)))
1492 (setq
1483 comment-start-skip "#+[\t ]*" 1493 comment-start-skip "#+[\t ]*"
1494;;; local-abbrev-table (sh-feature sh-abbrevs)
1484 mode-line-process (format "[%s]" sh-shell) 1495 mode-line-process (format "[%s]" sh-shell)
1485 sh-shell-variables nil 1496 sh-shell-variables nil
1486 sh-shell-variables-initialized nil 1497 sh-shell-variables-initialized nil
1487 imenu-generic-expression (sh-feature sh-imenu-generic-expression) 1498 imenu-generic-expression (sh-feature sh-imenu-generic-expression)
1488 imenu-case-fold-search nil) 1499 imenu-case-fold-search nil)
1489 (set-syntax-table (or (sh-feature sh-mode-syntax-table) 1500 (make-local-variable 'sh-mode-syntax-table)
1490 (standard-syntax-table))) 1501 (let ((tem (sh-feature sh-mode-syntax-table-input)))
1502 (setq sh-mode-syntax-table
1503 (if tem (apply 'sh-mode-syntax-table tem)
1504 sh-mode-default-syntax-table)))
1505 (set-syntax-table sh-mode-syntax-table)
1491 (dolist (var (sh-feature sh-variables)) 1506 (dolist (var (sh-feature sh-variables))
1492 (sh-remember-variable var)) 1507 (sh-remember-variable var))
1493 (make-local-variable 'indent-line-function) 1508 (make-local-variable 'indent-line-function)
@@ -1513,7 +1528,7 @@ Calls the value of `sh-set-shell-hook' if set."
1513 1528
1514 1529
1515 1530
1516(defun sh-feature (list &optional function) 1531(defun sh-feature (alist &optional function)
1517 "Index ALIST by the current shell. 1532 "Index ALIST by the current shell.
1518If ALIST isn't a list where every element is a cons, it is returned as is. 1533If ALIST isn't a list where every element is a cons, it is returned as is.
1519Else indexing follows an inheritance logic which works in two ways: 1534Else indexing follows an inheritance logic which works in two ways:
@@ -1522,45 +1537,41 @@ Else indexing follows an inheritance logic which works in two ways:
1522 the alist contains no value for the current shell. 1537 the alist contains no value for the current shell.
1523 The ultimate default is always `sh'. 1538 The ultimate default is always `sh'.
1524 1539
1525 - If the value thus looked up is a list starting with `eval' its `cdr' is 1540 - If the value thus looked up is a list starting with `sh-append',
1526 first evaluated. If that is also a list and the first argument is a 1541 we call the function `sh-append' with the rest of the list as
1527 symbol in ALIST it is not evaluated, but rather recursively looked up in 1542 arguments, and use the value. However, the next element of the
1528 ALIST to allow the function called to define the value for one shell to be 1543 list is not used as-is; instead, we look it up recursively
1529 derived from another shell. While calling the function, is the car of the 1544 in ALIST to allow the function called to define the value for
1530 alist element is the current shell. 1545 one shell to be derived from another shell.
1531 The value thus determined is physically replaced into the alist. 1546 The value thus determined is physically replaced into the alist.
1532 1547
1533Optional FUNCTION is applied to the determined value and the result is cached 1548Optional FUNCTION is applied to the determined value and the result is cached
1534in ALIST." 1549in ALIST."
1535 (or (if (consp list) 1550 (or (if (consp alist)
1536 (let ((l list)) 1551 (let ((l alist))
1537 (while (and l (consp (car l))) 1552 (while (and l (consp (car l)))
1538 (setq l (cdr l))) 1553 (setq l (cdr l)))
1539 (if l list))) 1554 (if l alist)))
1540 (if function 1555 (if function
1541 (cdr (assoc (setq function (cons sh-shell function)) list))) 1556 (cdr (assoc (setq function (cons sh-shell function)) alist)))
1542 (let ((sh-shell sh-shell) 1557 (let ((sh-shell sh-shell)
1543 elt val) 1558 elt val)
1544 (while (and sh-shell 1559 (while (and sh-shell
1545 (not (setq elt (assq sh-shell list)))) 1560 (not (setq elt (assq sh-shell alist))))
1546 (setq sh-shell (cdr (assq sh-shell sh-ancestor-alist)))) 1561 (setq sh-shell (cdr (assq sh-shell sh-ancestor-alist))))
1547 ;; If the shell is not known, treat it as sh. 1562 ;; If the shell is not known, treat it as sh.
1548 (unless elt 1563 (unless elt
1549 (setq elt (assq 'sh list))) 1564 (setq elt (assq 'sh alist)))
1550 (if (and (consp (setq val (cdr elt))) 1565 (if (and (consp (setq val (cdr elt)))
1551 (eq (car val) 'eval)) 1566 (eq (car val) 'sh-append))
1552 (setcdr elt 1567 (setcdr elt
1553 (setq val 1568 (setq val
1554 (eval (if (consp (setq val (cdr val))) 1569 (apply 'sh-append
1555 (let ((sh-shell (car (cdr val)))) 1570 (let ((sh-shell (car (cdr val))))
1556 (if (assq sh-shell list) 1571 (sh-feature alist))
1557 (setcar (cdr val) 1572 (cddr val)))))
1558 (list 'quote
1559 (sh-feature list))))
1560 val)
1561 val)))))
1562 (if function 1573 (if function
1563 (nconc list 1574 (nconc alist
1564 (list (cons function 1575 (list (cons function
1565 (setq sh-shell (car function) 1576 (setq sh-shell (car function)
1566 val (funcall (cdr function) val)))))) 1577 val (funcall (cdr function) val))))))
@@ -1601,13 +1612,6 @@ in ALIST."
1601;; (symbol-value sh-shell))) 1612;; (symbol-value sh-shell)))
1602 1613
1603 1614
1604(defun sh-mode-syntax-table (table &rest list)
1605 "Copy TABLE and set syntax for successive CHARs according to strings S."
1606 (setq table (copy-syntax-table table))
1607 (while list
1608 (modify-syntax-entry (pop list) (pop list) table))
1609 table)
1610
1611(defun sh-append (ancestor &rest list) 1615(defun sh-append (ancestor &rest list)
1612 "Return list composed of first argument (a list) physically appended to rest." 1616 "Return list composed of first argument (a list) physically appended to rest."
1613 (nconc list ancestor)) 1617 (nconc list ancestor))