aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1996-01-09 23:19:53 +0000
committerKarl Heuer1996-01-09 23:19:53 +0000
commitaafd074a3e40701f0a58cd4233cdb3436b3fd203 (patch)
treedeee89357c41f01bac37b5df8ef2baa1fe213c0c
parentc895a248006828972a6ae1935c808b751c8439f7 (diff)
downloademacs-aafd074a3e40701f0a58cd4233cdb3436b3fd203.tar.gz
emacs-aafd074a3e40701f0a58cd4233cdb3436b3fd203.zip
(sh-alias-alist): Don't map sh to bash.
(sh-canonicalize-shell): New function. (sh-shell-file): Renamed from sh-shell-path. (sh-set-shell): Don't set local-abbrev-table. (sh-abbrevs): Variable and function definition commented out.
-rw-r--r--lisp/progmodes/sh-script.el153
1 files changed, 79 insertions, 74 deletions
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 4448ca5ee5c..a08ec44ac4b 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1,5 +1,5 @@
1;;; sh-script.el --- shell-script editing commands for Emacs 1;;; sh-script.el --- shell-script editing commands for Emacs
2;; Copyright (C) 1993, 1994, 1995 by Free Software Foundation, Inc. 2;; Copyright (C) 1993, 1994, 1995, 1996 by Free Software Foundation, Inc.
3 3
4;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 4;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389
5;; Version: 2.0e 5;; Version: 2.0e
@@ -90,8 +90,7 @@ sh Bourne Shell
90(defvar sh-alias-alist 90(defvar sh-alias-alist
91 (nconc (if (eq system-type 'linux) 91 (nconc (if (eq system-type 'linux)
92 '((csh . tcsh) 92 '((csh . tcsh)
93 (ksh . pdksh) 93 (ksh . pdksh)))
94 (sh . bash)))
95 ;; for the time being 94 ;; for the time being
96 '((ksh . ksh88) 95 '((ksh . ksh88)
97 (sh5 . sh))) 96 (sh5 . sh)))
@@ -100,8 +99,8 @@ Use this where the name of the executable doesn't correspond to the type of
100shell it really is.") 99shell it really is.")
101 100
102 101
103(defvar sh-shell-path (or (getenv "SHELL") "/bin/sh") 102(defvar sh-shell-file (or (getenv "SHELL") "/bin/sh")
104 "*The executable of the shell being programmed.") 103 "*The executable file name for the shell being programmed.")
105 104
106 105
107(defvar sh-shell-arg 106(defvar sh-shell-arg
@@ -116,46 +115,51 @@ shell it really is.")
116 115
117 116
118 117
119(defvar sh-shell (or (cdr (assq (intern (file-name-nondirectory sh-shell-path)) 118(defun sh-canonicalize-shell (shell)
120 sh-alias-alist)) 119 "Convert a shell name SHELL to the one we should handle it as."
121 (intern (file-name-nondirectory sh-shell-path))) 120 (or (symbolp shell)
122 "The shell being programmed. This is set by \\[sh-set-shell].") 121 (setq shell (intern shell)))
122 (or (cdr (assq shell sh-alias-alist))
123 shell))
123 124
125(defvar sh-shell (sh-canonicalize-shell (file-name-nondirectory sh-shell-file))
126 "The shell being programmed. This is set by \\[sh-set-shell].")
124 127
128;;; I turned off this feature because it doesn't permit typing commands
129;;; in the usual way without help.
130;;;(defvar sh-abbrevs
131;;; '((csh eval sh-abbrevs shell
132;;; "switch" 'sh-case
133;;; "getopts" 'sh-while-getopts)
125 134
126(defvar sh-abbrevs 135;;; (es eval sh-abbrevs shell
127 '((csh eval sh-abbrevs shell 136;;; "function" 'sh-function)
128 "switch" 'sh-case
129 "getopts" 'sh-while-getopts)
130 137
131 (es eval sh-abbrevs shell 138;;; (ksh88 eval sh-abbrevs sh
132 "function" 'sh-function) 139;;; "select" 'sh-select)
133 140
134 (ksh88 eval sh-abbrevs sh 141;;; (rc eval sh-abbrevs shell
135 "select" 'sh-select) 142;;; "case" 'sh-case
143;;; "function" 'sh-function)
136 144
137 (rc eval sh-abbrevs shell 145;;; (sh eval sh-abbrevs shell
138 "case" 'sh-case 146;;; "case" 'sh-case
139 "function" 'sh-function) 147;;; "function" 'sh-function
148;;; "until" 'sh-until
149;;; "getopts" 'sh-while-getopts)
140 150
141 (sh eval sh-abbrevs shell 151;;; ;; The next entry is only used for defining the others
142 "case" 'sh-case 152;;; (shell "for" sh-for
143 "function" 'sh-function 153;;; "loop" sh-indexed-loop
144 "until" 'sh-until 154;;; "if" sh-if
145 "getopts" 'sh-while-getopts) 155;;; "tmpfile" sh-tmp-file
156;;; "while" sh-while)
146 157
147 ;; The next entry is only used for defining the others 158;;; (zsh eval sh-abbrevs ksh88
148 (shell "for" sh-for 159;;; "repeat" 'sh-repeat))
149 "loop" sh-indexed-loop 160;;; "Abbrev-table used in Shell-Script mode. See `sh-feature'.
150 "if" sh-if 161;;;Due to the internal workings of abbrev tables, the shell name symbol is
151 "tmpfile" sh-tmp-file 162;;;actually defined as the table for the like of \\[edit-abbrevs].")
152 "while" sh-while)
153
154 (zsh eval sh-abbrevs ksh88
155 "repeat" 'sh-repeat))
156 "Abbrev-table used in Shell-Script mode. See `sh-feature'.
157Due to the internal workings of abbrev tables, the shell name symbol is
158actually defined as the table for the like of \\[edit-abbrevs].")
159 163
160 164
161 165
@@ -574,7 +578,7 @@ following commands are available, based on the current shell's syntax:
574 Unless quoted with \\, insert the pairs {}, (), [], or '', \"\", ``. 578 Unless quoted with \\, insert the pairs {}, (), [], or '', \"\", ``.
575 579
576If you generally program a shell different from your login shell you can 580If you generally program a shell different from your login shell you can
577set `sh-shell-path' accordingly. If your shell's file name doesn't correctly 581set `sh-shell-file' accordingly. If your shell's file name doesn't correctly
578indicate what shell it is use `sh-alias-alist' to translate. 582indicate what shell it is use `sh-alias-alist' to translate.
579 583
580If your shell gives error messages with line numbers, you can use \\[executable-interpret] 584If your shell gives error messages with line numbers, you can use \\[executable-interpret]
@@ -591,7 +595,7 @@ with your script for an edit-interpret-debug cycle."
591 (make-local-variable 'comment-start-skip) 595 (make-local-variable 'comment-start-skip)
592 (make-local-variable 'require-final-newline) 596 (make-local-variable 'require-final-newline)
593 (make-local-variable 'sh-header-marker) 597 (make-local-variable 'sh-header-marker)
594 (make-local-variable 'sh-shell-path) 598 (make-local-variable 'sh-shell-file)
595 (make-local-variable 'sh-shell) 599 (make-local-variable 'sh-shell)
596 (make-local-variable 'skeleton-pair-alist) 600 (make-local-variable 'skeleton-pair-alist)
597 (make-local-variable 'skeleton-pair-filter) 601 (make-local-variable 'skeleton-pair-filter)
@@ -641,7 +645,7 @@ with your script for an edit-interpret-debug cycle."
641 (sh-set-shell 645 (sh-set-shell
642 (if (looking-at "#![\t ]*\\([^\t\n ]+\\)") 646 (if (looking-at "#![\t ]*\\([^\t\n ]+\\)")
643 (match-string 1) 647 (match-string 1)
644 sh-shell-path)) 648 sh-shell-file))
645 (run-hooks 'sh-mode-hook)) 649 (run-hooks 'sh-mode-hook))
646;;;###autoload 650;;;###autoload
647(defalias 'shell-script-mode 'sh-mode) 651(defalias 'shell-script-mode 'sh-mode)
@@ -701,8 +705,8 @@ Calls the value of `sh-set-shell-hook' if set."
701 (setq sh-shell (intern (file-name-nondirectory shell)) 705 (setq sh-shell (intern (file-name-nondirectory shell))
702 sh-shell (or (cdr (assq sh-shell sh-alias-alist)) 706 sh-shell (or (cdr (assq sh-shell sh-alias-alist))
703 sh-shell) 707 sh-shell)
704 sh-shell-path (executable-set-magic shell (sh-feature sh-shell-arg)) 708 sh-shell-file (executable-set-magic shell (sh-feature sh-shell-arg))
705 local-abbrev-table (sh-feature sh-abbrevs) 709;;; local-abbrev-table (sh-feature sh-abbrevs)
706 require-final-newline (sh-feature sh-require-final-newline) 710 require-final-newline (sh-feature sh-require-final-newline)
707 font-lock-keywords nil ; force resetting 711 font-lock-keywords nil ; force resetting
708 comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*") 712 comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*")
@@ -776,36 +780,37 @@ in ALIST."
776 780
777 781
778 782
779(defun sh-abbrevs (ancestor &rest list) 783;;; I commented this out because nobody calls it -- rms.
780 "Iff it isn't, define the current shell as abbrev table and fill that. 784;;;(defun sh-abbrevs (ancestor &rest list)
781Abbrev table will inherit all abbrevs from ANCESTOR, which is either an abbrev 785;;; "Iff it isn't, define the current shell as abbrev table and fill that.
782table or a list of (NAME1 EXPANSION1 ...). In addition it will define abbrevs 786;;;Abbrev table will inherit all abbrevs from ANCESTOR, which is either an abbrev
783according to the remaining arguments NAMEi EXPANSIONi ... 787;;;table or a list of (NAME1 EXPANSION1 ...). In addition it will define abbrevs
784EXPANSION may be either a string or a skeleton command." 788;;;according to the remaining arguments NAMEi EXPANSIONi ...
785 (or (if (boundp sh-shell) 789;;;EXPANSION may be either a string or a skeleton command."
786 (symbol-value sh-shell)) 790;;; (or (if (boundp sh-shell)
787 (progn 791;;; (symbol-value sh-shell))
788 (if (listp ancestor) 792;;; (progn
789 (nconc list ancestor)) 793;;; (if (listp ancestor)
790 (define-abbrev-table sh-shell ()) 794;;; (nconc list ancestor))
791 (if (vectorp ancestor) 795;;; (define-abbrev-table sh-shell ())
792 (mapatoms (lambda (atom) 796;;; (if (vectorp ancestor)
793 (or (eq atom 0) 797;;; (mapatoms (lambda (atom)
794 (define-abbrev (symbol-value sh-shell) 798;;; (or (eq atom 0)
795 (symbol-name atom) 799;;; (define-abbrev (symbol-value sh-shell)
796 (symbol-value atom) 800;;; (symbol-name atom)
797 (symbol-function atom)))) 801;;; (symbol-value atom)
798 ancestor)) 802;;; (symbol-function atom))))
799 (while list 803;;; ancestor))
800 (define-abbrev (symbol-value sh-shell) 804;;; (while list
801 (car list) 805;;; (define-abbrev (symbol-value sh-shell)
802 (if (stringp (car (cdr list))) 806;;; (car list)
803 (car (cdr list)) 807;;; (if (stringp (car (cdr list)))
804 "") 808;;; (car (cdr list))
805 (if (symbolp (car (cdr list))) 809;;; "")
806 (car (cdr list)))) 810;;; (if (symbolp (car (cdr list)))
807 (setq list (cdr (cdr list))))) 811;;; (car (cdr list))))
808 (symbol-value sh-shell))) 812;;; (setq list (cdr (cdr list)))))
813;;; (symbol-value sh-shell)))
809 814
810 815
811(defun sh-mode-syntax-table (table &rest list) 816(defun sh-mode-syntax-table (table &rest list)
@@ -882,9 +887,9 @@ region, clear header."
882 (shell-command-on-region (point-min) 887 (shell-command-on-region (point-min)
883 (setq end (+ sh-header-marker 888 (setq end (+ sh-header-marker
884 (- end start))) 889 (- end start)))
885 sh-shell-path) 890 sh-shell-file)
886 (delete-region sh-header-marker end))) 891 (delete-region sh-header-marker end)))
887 (shell-command-on-region start end (concat sh-shell-path " -"))))) 892 (shell-command-on-region start end (concat sh-shell-file " -")))))
888 893
889 894
890(defun sh-remember-variable (var) 895(defun sh-remember-variable (var)