Mercurial > emacs
annotate lisp/progmodes/sh-script.el @ 15084:01518892abad
(compilation-error-regexp-alist): Add regexp
for Microsoft VC++ error messages containing drive letters.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 26 Apr 1996 19:45:16 +0000 |
parents | 30c4f64f3579 |
children | 4431e88ce8d2 |
rev | line source |
---|---|
6463 | 1 ;;; sh-script.el --- shell-script editing commands for Emacs |
14169 | 2 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
3 ;; Copyright (C) 1993, 1994, 1995, 1996 by Free Software Foundation, Inc. |
6463 | 4 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
5 ;; Author: Daniel.Pfeiffer@Informatik.START.dbp.de, fax (+49 69) 7588-2389 |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
6 ;; Version: 2.0e |
6463 | 7 ;; Maintainer: FSF |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
8 ;; Keywords: languages, unix |
6463 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
14169 | 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
6463 | 26 |
27 ;;; Commentary: | |
28 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
29 ;; Major mode for editing shell scripts. Bourne, C and rc shells as well |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
30 ;; as various derivatives are supported and easily derived from. Structured |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
31 ;; statements can be inserted with one command or abbrev. Completion is |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
32 ;; available for filenames, variables known from the script, the shell and |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
33 ;; the environment as well as commands. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
34 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
35 ;;; Known Bugs: |
6463 | 36 |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
37 ;; - In Bourne the keyword `in' is not anchored to case, for, select ... |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
38 ;; - Variables in `"' strings aren't fontified because there's no way of |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
39 ;; syntactically distinguishing those from `'' strings. |
8257
bbf6304598d9
"Comment out" autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
8121
diff
changeset
|
40 |
6463 | 41 ;;; Code: |
42 | |
43 ;; page 1: variables and settings | |
44 ;; page 2: mode-command and utility functions | |
45 ;; page 3: statement syntax-commands for various shells | |
46 ;; page 4: various other commands | |
47 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
48 (require 'executable) |
6463 | 49 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
50 (defvar sh-ancestor-alist |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
51 '((ash . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
52 (bash . jsh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
53 (dtksh . ksh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
54 (es . rc) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
55 (itcsh . tcsh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
56 (jcsh . csh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
57 (jsh . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
58 (ksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
59 (ksh88 . jsh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
60 (oash . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
61 (pdksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
62 (posix . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
63 (tcsh . csh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
64 (wksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
65 (wsh . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
66 (zsh . ksh88)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
67 "*Alist showing the direct ancestor of various shells. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
68 This is the basis for `sh-feature'. See also `sh-alias-alist'. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
69 By default we have the following three hierarchies: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
70 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
71 csh C Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
72 jcsh C Shell with Job Control |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
73 tcsh Toronto C Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
74 itcsh ? Toronto C Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
75 rc Plan 9 Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
76 es Extensible Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
77 sh Bourne Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
78 ash ? Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
79 jsh Bourne Shell with Job Control |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
80 bash GNU Bourne Again Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
81 ksh88 Korn Shell '88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
82 ksh Korn Shell '93 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
83 dtksh CDE Desktop Korn Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
84 pdksh Public Domain Korn Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
85 wksh Window Korn Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
86 zsh Z Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
87 oash SCO OA (curses) Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
88 posix IEEE 1003.2 Shell Standard |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
89 wsh ? Shell") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
90 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
91 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
92 (defvar sh-alias-alist |
14892
7bf0ea276354
(sh-alias-alist): Recognize lignux.
Richard M. Stallman <rms@gnu.org>
parents:
14886
diff
changeset
|
93 (nconc (if (eq system-type 'lignux) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
94 '((csh . tcsh) |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
95 (ksh . pdksh))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
96 ;; for the time being |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
97 '((ksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
98 (sh5 . sh))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
99 "*Alist for transforming shell names to what they really are. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
100 Use this where the name of the executable doesn't correspond to the type of |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
101 shell it really is.") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
102 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
103 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
104 (defvar sh-shell-file (or (getenv "SHELL") "/bin/sh") |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
105 "*The executable file name for the shell being programmed.") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
106 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
107 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
108 (defvar sh-shell-arg |
14886
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
109 ;; bash does not need any options when run in a shell script, |
14876
b39dde411ac8
(sh-shell-arg): Don't add any options for bash, ksh.
Richard M. Stallman <rms@gnu.org>
parents:
14849
diff
changeset
|
110 '((bash) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
111 (csh . "-f") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
112 (pdksh) |
14886
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
113 ;; Bill_Mann@praxisint.com says -p with ksh can do harm. |
14876
b39dde411ac8
(sh-shell-arg): Don't add any options for bash, ksh.
Richard M. Stallman <rms@gnu.org>
parents:
14849
diff
changeset
|
114 (ksh88) |
14886
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
115 ;; -p means don't initialize functions from the environment. |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
116 (rc . "-p") |
14886
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
117 ;; Someone proposed -motif, but we don't want to encourage |
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
118 ;; use of a non-free widget set. |
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
119 (wksh) |
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
120 ;; -f means don't run .zshrc. |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
121 (zsh . "-f")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
122 "*Single argument string for the magic number. See `sh-feature'.") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
123 |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
124 (defvar sh-shell-variables nil |
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
125 "Alist of shell variable names that should be included in completion. |
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
126 These are used for completion in addition to all the variables named |
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
127 in `process-environment'. Each element looks like (VAR . VAR), where |
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
128 the car and cdr are the same symbol.") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
129 |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
130 (defvar sh-shell-variables-initialized nil |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
131 "Non-nil if `sh-shell-variables' is initialized.") |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
132 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
133 (defun sh-canonicalize-shell (shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
134 "Convert a shell name SHELL to the one we should handle it as." |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
135 (or (symbolp shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
136 (setq shell (intern shell))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
137 (or (cdr (assq shell sh-alias-alist)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
138 shell)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
139 |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
140 (defvar sh-shell (sh-canonicalize-shell (file-name-nondirectory sh-shell-file)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
141 "The shell being programmed. This is set by \\[sh-set-shell].") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
142 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
143 ;;; I turned off this feature because it doesn't permit typing commands |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
144 ;;; in the usual way without help. |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
145 ;;;(defvar sh-abbrevs |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
146 ;;; '((csh eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
147 ;;; "switch" 'sh-case |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
148 ;;; "getopts" 'sh-while-getopts) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
149 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
150 ;;; (es eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
151 ;;; "function" 'sh-function) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
152 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
153 ;;; (ksh88 eval sh-abbrevs sh |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
154 ;;; "select" 'sh-select) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
155 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
156 ;;; (rc eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
157 ;;; "case" 'sh-case |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
158 ;;; "function" 'sh-function) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
159 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
160 ;;; (sh eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
161 ;;; "case" 'sh-case |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
162 ;;; "function" 'sh-function |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
163 ;;; "until" 'sh-until |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
164 ;;; "getopts" 'sh-while-getopts) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
165 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
166 ;;; ;; The next entry is only used for defining the others |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
167 ;;; (shell "for" sh-for |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
168 ;;; "loop" sh-indexed-loop |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
169 ;;; "if" sh-if |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
170 ;;; "tmpfile" sh-tmp-file |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
171 ;;; "while" sh-while) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
172 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
173 ;;; (zsh eval sh-abbrevs ksh88 |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
174 ;;; "repeat" 'sh-repeat)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
175 ;;; "Abbrev-table used in Shell-Script mode. See `sh-feature'. |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
176 ;;;Due to the internal workings of abbrev tables, the shell name symbol is |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
177 ;;;actually defined as the table for the like of \\[edit-abbrevs].") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
178 |
6463 | 179 |
180 | |
181 (defvar sh-mode-syntax-table | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
182 '((csh eval identity sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
183 (sh eval sh-mode-syntax-table () |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
184 ;; #'s meanings depend on context which can't be expressed here |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
185 ;; ?\# "<" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
186 ;; ?\^l ">#" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
187 ;; ?\n ">#" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
188 ?\" "\"\"" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
189 ?\' "\"'" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
190 ?\` ".`" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
191 ?$ "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
192 ?! "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
193 ?% "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
194 ?: "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
195 ?. "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
196 ?^ "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
197 ?~ "_") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
198 (rc eval sh-mode-syntax-table sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
199 ?\" "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
200 ?\` ".")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
201 "Syntax-table used in Shell-Script mode. See `sh-feature'.") |
6463 | 202 |
203 | |
204 | |
205 (defvar sh-mode-map | |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
206 (let ((map (make-sparse-keymap)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
207 (menu-map (make-sparse-keymap "Insert"))) |
6463 | 208 (define-key map "\C-c(" 'sh-function) |
209 (define-key map "\C-c\C-w" 'sh-while) | |
210 (define-key map "\C-c\C-u" 'sh-until) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
211 (define-key map "\C-c\C-t" 'sh-tmp-file) |
6463 | 212 (define-key map "\C-c\C-s" 'sh-select) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
213 (define-key map "\C-c\C-r" 'sh-repeat) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
214 (define-key map "\C-c\C-o" 'sh-while-getopts) |
6463 | 215 (define-key map "\C-c\C-l" 'sh-indexed-loop) |
216 (define-key map "\C-c\C-i" 'sh-if) | |
217 (define-key map "\C-c\C-f" 'sh-for) | |
218 (define-key map "\C-c\C-c" 'sh-case) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
219 |
6463 | 220 (define-key map "=" 'sh-assignment) |
221 (define-key map "\C-c+" 'sh-add) | |
13469
5bda9e4d85eb
(sh-mode-map): Put sh-execute-region on C-M-x.
Richard M. Stallman <rms@gnu.org>
parents:
13391
diff
changeset
|
222 (define-key map "\C-\M-x" 'sh-execute-region) |
5bda9e4d85eb
(sh-mode-map): Put sh-execute-region on C-M-x.
Richard M. Stallman <rms@gnu.org>
parents:
13391
diff
changeset
|
223 (define-key map "\C-c\C-x" 'executable-interpret) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
224 (define-key map "<" 'sh-maybe-here-document) |
12864
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
225 (define-key map "(" 'skeleton-pair-insert-maybe) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
226 (define-key map "{" 'skeleton-pair-insert-maybe) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
227 (define-key map "[" 'skeleton-pair-insert-maybe) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
228 (define-key map "'" 'skeleton-pair-insert-maybe) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
229 (define-key map "`" 'skeleton-pair-insert-maybe) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
230 (define-key map "\"" 'skeleton-pair-insert-maybe) |
6463 | 231 |
232 (define-key map "\t" 'sh-indent-line) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
233 (substitute-key-definition 'complete-tag 'comint-dynamic-complete |
6463 | 234 map (current-global-map)) |
235 (substitute-key-definition 'newline-and-indent 'sh-newline-and-indent | |
236 map (current-global-map)) | |
237 (substitute-key-definition 'delete-backward-char | |
238 'backward-delete-char-untabify | |
239 map (current-global-map)) | |
240 (define-key map "\C-c:" 'sh-set-shell) | |
241 (substitute-key-definition 'beginning-of-defun | |
242 'sh-beginning-of-compound-command | |
243 map (current-global-map)) | |
244 (substitute-key-definition 'backward-sentence 'sh-beginning-of-command | |
245 map (current-global-map)) | |
246 (substitute-key-definition 'forward-sentence 'sh-end-of-command | |
247 map (current-global-map)) | |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
248 (define-key map [menu-bar insert] (cons "Insert" menu-map)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
249 (define-key menu-map [sh-while] '("While Loop" . sh-while)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
250 (define-key menu-map [sh-until] '("Until Loop" . sh-until)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
251 (define-key menu-map [sh-tmp-file] '("Temporary File" . sh-tmp-file)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
252 (define-key menu-map [sh-select] '("Select Statement" . sh-select)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
253 (define-key menu-map [sh-repeat] '("Repeat Loop" . sh-repeat)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
254 (define-key menu-map [sh-while-getopts] |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
255 '("Options Loop" . sh-while-getopts)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
256 (define-key menu-map [sh-indexed-loop] |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
257 '("Indexed Loop" . sh-indexed-loop)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
258 (define-key menu-map [sh-if] '("If Statement" . sh-if)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
259 (define-key menu-map [sh-for] '("For Loop" . sh-for)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
260 (define-key menu-map [sh-case] '("Case Statement" . sh-case)) |
6463 | 261 map) |
262 "Keymap used in Shell-Script mode.") | |
263 | |
264 | |
265 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
266 (defvar sh-dynamic-complete-functions |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
267 '(shell-dynamic-complete-environment-variable |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
268 shell-dynamic-complete-command |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
269 comint-dynamic-complete-filename) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
270 "*Functions for doing TAB dynamic completion.") |
6463 | 271 |
272 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
273 (defvar sh-require-final-newline |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
274 '((csh . t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
275 (pdksh . t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
276 (rc eval . require-final-newline) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
277 (sh eval . require-final-newline)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
278 "*Value of `require-final-newline' in Shell-Script mode buffers. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
279 See `sh-feature'.") |
6463 | 280 |
281 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
282 (defvar sh-comment-prefix |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
283 '((csh . "\\(^\\|[^$]\\|\\$[^{]\\)") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
284 (rc eval identity csh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
285 (sh . "\\(^\\|[ \t|&;()]\\)")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
286 "*Regexp matching what may come before a comment `#'. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
287 This must contain one \\(grouping\\) since it is the basis for fontifying |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
288 comments as well as for `comment-start-skip'. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
289 See `sh-feature'.") |
6463 | 290 |
291 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
292 (defvar sh-assignment-regexp |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
293 '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
294 ;; actually spaces are only supported in let/(( ... )) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
295 (ksh88 . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*\\([-+*/%&|~^]\\|<<\\|>>\\)?=") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
296 (rc . "\\<\\([a-zA-Z0-9_*]+\\)[ \t]*=") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
297 (sh . "\\<\\([a-zA-Z0-9_]+\\)=")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
298 "*Regexp for the variable name and what may follow in an assignment. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
299 First grouping matches the variable name. This is upto and including the `=' |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
300 sign. See `sh-feature'.") |
6463 | 301 |
302 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
303 (defvar sh-indentation 4 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
304 "The width for further indentation in Shell-Script mode.") |
6463 | 305 |
306 | |
307 (defvar sh-remember-variable-min 3 | |
308 "*Don't remember variables less than this length for completing reads.") | |
309 | |
310 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
311 (defvar sh-header-marker nil |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
312 "When non-`nil' is the end of header for prepending by \\[sh-execute-region]. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
313 That command is also used for setting this variable.") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
314 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
315 |
6463 | 316 (defvar sh-beginning-of-command |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
317 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~a-zA-Z0-9:]\\)" |
6463 | 318 "*Regexp to determine the beginning of a shell command. |
319 The actual command starts at the beginning of the second \\(grouping\\).") | |
320 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
321 |
6463 | 322 (defvar sh-end-of-command |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
323 "\\([/~a-zA-Z0-9:]\\)[ \t]*\\([;#)}`|&]\\|$\\)" |
6463 | 324 "*Regexp to determine the end of a shell command. |
325 The actual command ends at the end of the first \\(grouping\\).") | |
326 | |
327 | |
328 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
329 (defvar sh-here-document-word "EOF" |
6463 | 330 "Word to delimit here documents.") |
331 | |
12863 | 332 (defvar sh-test |
333 '((sh "[ ]" . 3) | |
334 (ksh88 "[[ ]]" . 4)) | |
335 "Initial input in Bourne if, while and until skeletons. See `sh-feature'.") | |
336 | |
6463 | 337 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
338 (defvar sh-builtins |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
339 '((bash eval sh-append posix |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
340 "alias" "bg" "bind" "builtin" "declare" "dirs" "enable" "fc" "fg" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
341 "help" "history" "jobs" "kill" "let" "local" "popd" "pushd" "source" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
342 "suspend" "typeset" "unalias") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
343 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
344 ;; The next entry is only used for defining the others |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
345 (bourne eval sh-append shell |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
346 "eval" "export" "getopts" "newgrp" "pwd" "read" "readonly" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
347 "times" "ulimit") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
348 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
349 (csh eval sh-append shell |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
350 "alias" "chdir" "glob" "history" "limit" "nice" "nohup" "rehash" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
351 "setenv" "source" "time" "unalias" "unhash") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
352 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
353 (dtksh eval identity wksh) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
354 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
355 (es "access" "apids" "cd" "echo" "eval" "false" "let" "limit" "local" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
356 "newpgrp" "result" "time" "umask" "var" "vars" "wait" "whatis") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
357 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
358 (jsh eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
359 "bg" "fg" "jobs" "kill" "stop" "suspend") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
360 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
361 (jcsh eval sh-append csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
362 "bg" "fg" "jobs" "kill" "notify" "stop" "suspend") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
363 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
364 (ksh88 eval sh-append bourne |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
365 "alias" "bg" "false" "fc" "fg" "jobs" "kill" "let" "print" "time" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
366 "typeset" "unalias" "whence") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
367 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
368 (oash eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
369 "checkwin" "dateline" "error" "form" "menu" "newwin" "oadeinit" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
370 "oaed" "oahelp" "oainit" "pp" "ppfile" "scan" "scrollok" "wattr" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
371 "wclear" "werase" "win" "wmclose" "wmmessage" "wmopen" "wmove" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
372 "wmtitle" "wrefresh") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
373 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
374 (pdksh eval sh-append ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
375 "bind") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
376 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
377 (posix eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
378 "command") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
379 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
380 (rc "builtin" "cd" "echo" "eval" "limit" "newpgrp" "shift" "umask" "wait" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
381 "whatis") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
382 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
383 (sh eval sh-append bourne |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
384 "hash" "test" "type") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
385 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
386 ;; The next entry is only used for defining the others |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
387 (shell "cd" "echo" "eval" "set" "shift" "umask" "unset" "wait") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
388 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
389 (wksh eval sh-append ksh88 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
390 "Xt[A-Z][A-Za-z]*") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
391 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
392 (zsh eval sh-append ksh88 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
393 "autoload" "bindkey" "builtin" "chdir" "compctl" "declare" "dirs" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
394 "disable" "disown" "echotc" "enable" "functions" "getln" "hash" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
395 "history" "integer" "limit" "local" "log" "popd" "pushd" "r" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
396 "readonly" "rehash" "sched" "setopt" "source" "suspend" "true" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
397 "ttyctl" "type" "unfunction" "unhash" "unlimit" "unsetopt" "vared" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
398 "which")) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
399 "*List of all shell builtins for completing read and fontification. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
400 Note that on some systems not all builtins are available or some are |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
401 implemented as aliases. See `sh-feature'.") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
402 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
403 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
404 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
405 (defvar sh-leading-keywords |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
406 '((csh "else") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
407 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
408 (es "true" "unwind-protect" "whatis") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
409 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
410 (rc "else") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
411 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
412 (sh "do" "elif" "else" "if" "then" "trap" "type" "until" "while")) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
413 "*List of keywords that may be immediately followed by a builtin or keyword. |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
414 Given some confusion between keywords and builtins depending on shell and |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
415 system, the distinction here has been based on whether they influence the |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
416 flow of control or syntax. See `sh-feature'.") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
417 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
418 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
419 (defvar sh-other-keywords |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
420 '((bash eval sh-append bourne |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
421 "bye" "logout") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
422 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
423 ;; The next entry is only used for defining the others |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
424 (bourne eval sh-append shell |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
425 "done" "esac" "fi" "for" "function" "in" "return") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
426 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
427 (csh eval sh-append shell |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
428 "breaksw" "default" "end" "endif" "endsw" "foreach" "goto" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
429 "if" "logout" "onintr" "repeat" "switch" "then" "while") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
430 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
431 (es "break" "catch" "exec" "exit" "fn" "for" "forever" "fork" "if" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
432 "return" "throw" "while") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
433 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
434 (ksh88 eval sh-append bourne |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
435 "select") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
436 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
437 (rc "break" "case" "exec" "exit" "fn" "for" "if" "in" "return" "switch" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
438 "while") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
439 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
440 ;; The next entry is only used for defining the others |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
441 (shell "break" "case" "continue" "exec" "exit") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
442 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
443 (zsh eval sh-append bash |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
444 "select")) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
445 "*List of keywords not in `sh-leading-keywords'. |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
446 See `sh-feature'.") |
6463 | 447 |
448 | |
449 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
450 (defvar sh-variables |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
451 '((bash eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
452 "allow_null_glob_expansion" "auto_resume" "BASH" "BASH_VERSION" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
453 "cdable_vars" "ENV" "EUID" "FCEDIT" "FIGNORE" "glob_dot_filenames" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
454 "histchars" "HISTFILE" "HISTFILESIZE" "history_control" "HISTSIZE" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
455 "hostname_completion_file" "HOSTTYPE" "IGNOREEOF" "ignoreeof" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
456 "LINENO" "MAIL_WARNING" "noclobber" "nolinks" "notify" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
457 "no_exit_on_failed_exec" "NO_PROMPT_VARS" "OLDPWD" "OPTERR" "PPID" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
458 "PROMPT_COMMAND" "PS4" "pushd_silent" "PWD" "RANDOM" "REPLY" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
459 "SECONDS" "SHLVL" "TMOUT" "UID") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
460 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
461 (csh eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
462 "argv" "cdpath" "child" "echo" "histchars" "history" "home" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
463 "ignoreeof" "mail" "noclobber" "noglob" "nonomatch" "path" "prompt" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
464 "shell" "status" "time" "verbose") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
465 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
466 (es eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
467 "apid" "cdpath" "CDPATH" "history" "home" "ifs" "noexport" "path" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
468 "pid" "prompt" "signals") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
469 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
470 (jcsh eval sh-append csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
471 "notify") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
472 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
473 (ksh88 eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
474 "ENV" "ERRNO" "FCEDIT" "FPATH" "HISTFILE" "HISTSIZE" "LINENO" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
475 "OLDPWD" "PPID" "PS3" "PS4" "PWD" "RANDOM" "REPLY" "SECONDS" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
476 "TMOUT") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
477 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
478 (oash eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
479 "FIELD" "FIELD_MAX" "LAST_KEY" "OALIB" "PP_ITEM" "PP_NUM") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
480 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
481 (rc eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
482 "apid" "apids" "cdpath" "CDPATH" "history" "home" "ifs" "path" "pid" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
483 "prompt" "status") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
484 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
485 (sh eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
486 "CDPATH" "IFS" "OPTARG" "OPTIND" "PS1" "PS2") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
487 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
488 ;; The next entry is only used for defining the others |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
489 (shell "COLUMNS" "EDITOR" "HOME" "HUSHLOGIN" "LANG" "LC_COLLATE" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
490 "LC_CTYPE" "LC_MESSAGES" "LC_MONETARY" "LC_NUMERIC" "LC_TIME" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
491 "LINES" "LOGNAME" "MAIL" "MAILCHECK" "MAILPATH" "PAGER" "PATH" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
492 "SHELL" "TERM" "TERMCAP" "TERMINFO" "VISUAL") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
493 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
494 (tcsh eval sh-append csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
495 "addsuffix" "ampm" "autocorrect" "autoexpand" "autolist" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
496 "autologout" "chase_symlinks" "correct" "dextract" "edit" "el" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
497 "fignore" "gid" "histlit" "HOST" "HOSTTYPE" "HPATH" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
498 "ignore_symlinks" "listjobs" "listlinks" "listmax" "matchbeep" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
499 "nobeep" "NOREBIND" "oid" "printexitvalue" "prompt2" "prompt3" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
500 "pushdsilent" "pushdtohome" "recexact" "recognize_only_executables" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
501 "rmstar" "savehist" "SHLVL" "showdots" "sl" "SYSTYPE" "tcsh" "term" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
502 "tperiod" "tty" "uid" "version" "visiblebell" "watch" "who" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
503 "wordchars") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
504 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
505 (zsh eval sh-append ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
506 "BAUD" "bindcmds" "cdpath" "DIRSTACKSIZE" "fignore" "FIGNORE" "fpath" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
507 "HISTCHARS" "hostcmds" "hosts" "HOSTS" "LISTMAX" "LITHISTSIZE" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
508 "LOGCHECK" "mailpath" "manpath" "NULLCMD" "optcmds" "path" "POSTEDIT" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
509 "prompt" "PROMPT" "PROMPT2" "PROMPT3" "PROMPT4" "psvar" "PSVAR" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
510 "READNULLCMD" "REPORTTIME" "RPROMPT" "RPS1" "SAVEHIST" "SPROMPT" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
511 "STTY" "TIMEFMT" "TMOUT" "TMPPREFIX" "varcmds" "watch" "WATCH" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
512 "WATCHFMT" "WORDCHARS" "ZDOTDIR")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
513 "List of all shell variables available for completing read. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
514 See `sh-feature'.") |
6463 | 515 |
516 | |
517 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
518 (defvar sh-font-lock-keywords |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
519 '((csh eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
520 '("\\${?[#?]?\\([A-Za-z_][A-Za-z0-9_]*\\|0\\)" 1 |
12863 | 521 font-lock-variable-name-face)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
522 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
523 (es eval sh-append executable-font-lock-keywords |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
524 '("\\$#?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\)" 1 |
12863 | 525 font-lock-variable-name-face)) |
6463 | 526 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
527 (rc eval identity es) |
6463 | 528 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
529 (sh eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
530 '("\\$\\({#?\\)?\\([A-Za-z_][A-Za-z0-9_]*\\|[-#?@!]\\)" 2 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
531 font-lock-variable-name-face)) |
6463 | 532 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
533 ;; The next entry is only used for defining the others |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
534 (shell eval sh-append executable-font-lock-keywords |
14849
e36c046e28b1
(sh-font-lock-keywords): Highlight \ only with non-alphanumeric char.
Richard M. Stallman <rms@gnu.org>
parents:
14418
diff
changeset
|
535 '("\\\\[^A-Za-z0-9]" 0 font-lock-string-face) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
536 '("\\${?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\|[$*_]\\)" 1 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
537 font-lock-variable-name-face))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
538 "*Rules for highlighting shell scripts. See `sh-feature'.") |
6463 | 539 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
540 (defvar sh-font-lock-keywords-1 |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
541 '((sh "[ \t]in\\>")) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
542 "*Additional rules for highlighting shell scripts. See `sh-feature'.") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
543 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
544 (defvar sh-font-lock-keywords-2 () |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
545 "*Yet more rules for highlighting shell scripts. See `sh-feature'.") |
6463 | 546 |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
547 (defvar sh-font-lock-keywords-only t |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
548 "*Value of `font-lock-keywords-only' for highlighting shell scripts. |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
549 Default value is `t' because Emacs' syntax is not expressive enough to |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
550 detect that $# does not start a comment. Thus comments are fontified by |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
551 regexp which means that a single apostrophe in a comment turns everything |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
552 upto the next one or end of buffer into a string.") |
6463 | 553 |
554 ;; mode-command and utility functions | |
555 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
556 ;;;###autoload |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
557 (put 'sh-mode 'mode-class 'special) |
14221
cd28284abca4
(sh-mode): Add autoload cookie.
Erik Naggum <erik@naggum.no>
parents:
14211
diff
changeset
|
558 |
cd28284abca4
(sh-mode): Add autoload cookie.
Erik Naggum <erik@naggum.no>
parents:
14211
diff
changeset
|
559 ;;;###autoload |
6463 | 560 (defun sh-mode () |
561 "Major mode for editing shell scripts. | |
562 This mode works for many shells, since they all have roughly the same syntax, | |
563 as far as commands, arguments, variables, pipes, comments etc. are concerned. | |
564 Unless the file's magic number indicates the shell, your usual shell is | |
565 assumed. Since filenames rarely give a clue, they are not further analyzed. | |
566 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
567 This mode adapts to the variations between shells (see `sh-set-shell') by |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
568 means of an inheritance based feature lookup (see `sh-feature'). This |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
569 mechanism applies to all variables (including skeletons) that pertain to |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
570 shell-specific features. |
6463 | 571 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
572 The default style of this mode is that of Rosenblatt's Korn shell book. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
573 The syntax of the statements varies with the shell being used. The |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
574 following commands are available, based on the current shell's syntax: |
6463 | 575 |
576 \\[sh-case] case statement | |
577 \\[sh-for] for loop | |
578 \\[sh-function] function definition | |
579 \\[sh-if] if statement | |
580 \\[sh-indexed-loop] indexed loop from 1 to n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
581 \\[sh-while-getopts] while getopts loop |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
582 \\[sh-repeat] repeat loop |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
583 \\[sh-select] select loop |
6463 | 584 \\[sh-until] until loop |
585 \\[sh-while] while loop | |
586 | |
587 \\[backward-delete-char-untabify] Delete backward one position, even if it was a tab. | |
588 \\[sh-newline-and-indent] Delete unquoted space and indent new line same as this one. | |
589 \\[sh-end-of-command] Go to end of successive commands. | |
590 \\[sh-beginning-of-command] Go to beginning of successive commands. | |
591 \\[sh-set-shell] Set this buffer's shell, and maybe its magic number. | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
592 \\[sh-execute-region] Have optional header and region be executed in a subshell. |
6463 | 593 |
594 \\[sh-maybe-here-document] Without prefix, following an unquoted < inserts here document. | |
595 {, (, [, ', \", ` | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
596 Unless quoted with \\, insert the pairs {}, (), [], or '', \"\", ``. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
597 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
598 If you generally program a shell different from your login shell you can |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
599 set `sh-shell-file' accordingly. If your shell's file name doesn't correctly |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
600 indicate what shell it is use `sh-alias-alist' to translate. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
601 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
602 If your shell gives error messages with line numbers, you can use \\[executable-interpret] |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
603 with your script for an edit-interpret-debug cycle." |
6463 | 604 (interactive) |
605 (kill-all-local-variables) | |
606 (use-local-map sh-mode-map) | |
607 (make-local-variable 'indent-line-function) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
608 (make-local-variable 'indent-region-function) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
609 (make-local-variable 'skeleton-end-hook) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
610 (make-local-variable 'paragraph-start) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
611 (make-local-variable 'paragraph-separate) |
6463 | 612 (make-local-variable 'comment-start) |
613 (make-local-variable 'comment-start-skip) | |
614 (make-local-variable 'require-final-newline) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
615 (make-local-variable 'sh-header-marker) |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
616 (make-local-variable 'sh-shell-file) |
6463 | 617 (make-local-variable 'sh-shell) |
12864
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
618 (make-local-variable 'skeleton-pair-alist) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
619 (make-local-variable 'skeleton-pair-filter) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
620 (make-local-variable 'comint-dynamic-complete-functions) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
621 (make-local-variable 'comint-prompt-regexp) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
622 (make-local-variable 'font-lock-keywords) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
623 (make-local-variable 'font-lock-defaults) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
624 (make-local-variable 'skeleton-filter) |
12887
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
625 (make-local-variable 'skeleton-newline-indent-rigidly) |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
626 (make-local-variable 'sh-shell-variables) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
627 (make-local-variable 'sh-shell-variables-initialized) |
6463 | 628 (setq major-mode 'sh-mode |
629 mode-name "Shell-script" | |
630 indent-line-function 'sh-indent-line | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
631 ;; not very clever, but enables wrapping skeletons around regions |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
632 indent-region-function (lambda (b e) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
633 (save-excursion |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
634 (goto-char b) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
635 (skip-syntax-backward "-") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
636 (setq b (point)) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
637 (goto-char e) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
638 (skip-syntax-backward "-") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
639 (indent-rigidly b (point) sh-indentation))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
640 skeleton-end-hook (lambda () |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
641 (or (eolp) (newline) (indent-relative))) |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
642 paragraph-start (concat page-delimiter "\\|$") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
643 paragraph-separate paragraph-start |
6463 | 644 comment-start "# " |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
645 comint-dynamic-complete-functions sh-dynamic-complete-functions |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
646 ;; we can't look if previous line ended with `\' |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
647 comint-prompt-regexp "^[ \t]*" |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
648 font-lock-defaults |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
649 `((sh-font-lock-keywords |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
650 sh-font-lock-keywords-1 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
651 sh-font-lock-keywords-2) |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
652 ,sh-font-lock-keywords-only |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
653 nil |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
654 ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w"))) |
12864
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
655 skeleton-pair-alist '((?` _ ?`)) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
656 skeleton-pair-filter 'sh-quoted-p |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
657 skeleton-further-elements '((< '(- (min sh-indentation |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
658 (current-column))))) |
12887
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
659 skeleton-filter 'sh-feature |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
660 skeleton-newline-indent-rigidly t) |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
661 (save-excursion |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
662 ;; parse or insert magic number for exec() and set all variables depending |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
663 ;; on the shell thus determined |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
664 (goto-char (point-min)) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
665 (sh-set-shell |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
666 (if (looking-at "#![\t ]*\\([^\t\n ]+\\)") |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
667 (match-string 1) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
668 sh-shell-file))) |
6463 | 669 (run-hooks 'sh-mode-hook)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
670 ;;;###autoload |
6463 | 671 (defalias 'shell-script-mode 'sh-mode) |
672 | |
673 | |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
674 (defun sh-font-lock-keywords (&optional keywords) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
675 "Function to get simple fontification based on `sh-font-lock-keywords'. |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
676 This adds rules for comments and assignments." |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
677 (sh-feature sh-font-lock-keywords |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
678 (lambda (list) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
679 `((,(concat (sh-feature sh-comment-prefix) "\\(#.*\\)") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
680 2 font-lock-comment-face t) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
681 (,(sh-feature sh-assignment-regexp) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
682 1 font-lock-variable-name-face) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
683 ,@keywords |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
684 ,@list)))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
685 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
686 (defun sh-font-lock-keywords-1 (&optional builtins) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
687 "Function to get better fontification including keywords." |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
688 (let ((keywords (concat "\\([;(){}`|&]\\|^\\)[ \t]*\\(\\(\\(" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
689 (mapconcat 'identity |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
690 (sh-feature sh-leading-keywords) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
691 "\\|") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
692 "\\)[ \t]+\\)?\\(" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
693 (mapconcat 'identity |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
694 (append (sh-feature sh-leading-keywords) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
695 (sh-feature sh-other-keywords)) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
696 "\\|") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
697 "\\)"))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
698 (sh-font-lock-keywords |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
699 `(,@(if builtins |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
700 `((,(concat keywords "[ \t]+\\)?\\(" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
701 (mapconcat 'identity (sh-feature sh-builtins) "\\|") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
702 "\\)\\>") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
703 (2 font-lock-keyword-face nil t) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
704 (6 font-lock-function-name-face)) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
705 ,@(sh-feature sh-font-lock-keywords-2))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
706 (,(concat keywords "\\)\\>") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
707 2 font-lock-keyword-face) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
708 ,@(sh-feature sh-font-lock-keywords-1))))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
709 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
710 (defun sh-font-lock-keywords-2 () |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
711 "Function to get better fontification including keywords and builtins." |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
712 (sh-font-lock-keywords-1 t)) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
713 |
6463 | 714 |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
715 (defun sh-set-shell (shell &optional no-query-flag insert-flag) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
716 "Set this buffer's shell to SHELL (a string). |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
717 Makes this script executable via `executable-set-magic'. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
718 Calls the value of `sh-set-shell-hook' if set." |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
719 (interactive (list (completing-read "Name or path of shell: " |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
720 interpreter-mode-alist |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
721 (lambda (x) (eq (cdr x) 'sh-mode))) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
722 (eq executable-query 'function) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
723 t)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
724 (setq sh-shell (intern (file-name-nondirectory shell)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
725 sh-shell (or (cdr (assq sh-shell sh-alias-alist)) |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
726 sh-shell)) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
727 (setq sh-shell-file (executable-set-magic shell (sh-feature sh-shell-arg))) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
728 (setq require-final-newline (sh-feature sh-require-final-newline) |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
729 ;;; local-abbrev-table (sh-feature sh-abbrevs) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
730 font-lock-keywords nil ; force resetting |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
731 font-lock-syntax-table nil |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
732 comment-start-skip (concat (sh-feature sh-comment-prefix) "#+[\t ]*") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
733 mode-line-process (format "[%s]" sh-shell) |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
734 sh-shell-variables nil |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
735 sh-shell-variables-initialized nil |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
736 shell (sh-feature sh-variables)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
737 (set-syntax-table (sh-feature sh-mode-syntax-table)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
738 (while shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
739 (sh-remember-variable (car shell)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
740 (setq shell (cdr shell))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
741 (and (boundp 'font-lock-mode) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
742 font-lock-mode |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
743 (font-lock-mode (font-lock-mode 0))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
744 (run-hooks 'sh-set-shell-hook)) |
6463 | 745 |
746 | |
747 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
748 (defun sh-feature (list &optional function) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
749 "Index ALIST by the current shell. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
750 If ALIST isn't a list where every element is a cons, it is returned as is. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
751 Else indexing follows an inheritance logic which works in two ways: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
752 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
753 - Fall back on successive ancestors (see `sh-ancestor-alist') as long as |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
754 the alist contains no value for the current shell. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
755 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
756 - If the value thus looked up is a list starting with `eval' its `cdr' is |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
757 first evaluated. If that is also a list and the first argument is a |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
758 symbol in ALIST it is not evaluated, but rather recursively looked up in |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
759 ALIST to allow the function called to define the value for one shell to be |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
760 derived from another shell. While calling the function, is the car of the |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
761 alist element is the current shell. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
762 The value thus determined is physically replaced into the alist. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
763 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
764 Optional FUNCTION is applied to the determined value and the result is cached |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
765 in ALIST." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
766 (or (if (consp list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
767 (let ((l list)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
768 (while (and l (consp (car l))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
769 (setq l (cdr l))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
770 (if l list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
771 (if function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
772 (cdr (assoc (setq function (cons sh-shell function)) list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
773 (let ((sh-shell sh-shell) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
774 elt val) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
775 (while (and sh-shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
776 (not (setq elt (assq sh-shell list)))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
777 (setq sh-shell (cdr (assq sh-shell sh-ancestor-alist)))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
778 (if (and (consp (setq val (cdr elt))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
779 (eq (car val) 'eval)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
780 (setcdr elt |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
781 (setq val |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
782 (eval (if (consp (setq val (cdr val))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
783 (let ((sh-shell (car (cdr val))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
784 function) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
785 (if (assq sh-shell list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
786 (setcar (cdr val) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
787 (list 'quote |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
788 (sh-feature list)))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
789 val) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
790 val))))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
791 (if function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
792 (nconc list |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
793 (list (cons function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
794 (setq sh-shell (car function) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
795 val (funcall (cdr function) val)))))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
796 val))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
797 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
798 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
799 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
800 ;;; I commented this out because nobody calls it -- rms. |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
801 ;;;(defun sh-abbrevs (ancestor &rest list) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
802 ;;; "Iff it isn't, define the current shell as abbrev table and fill that. |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
803 ;;;Abbrev table will inherit all abbrevs from ANCESTOR, which is either an abbrev |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
804 ;;;table or a list of (NAME1 EXPANSION1 ...). In addition it will define abbrevs |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
805 ;;;according to the remaining arguments NAMEi EXPANSIONi ... |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
806 ;;;EXPANSION may be either a string or a skeleton command." |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
807 ;;; (or (if (boundp sh-shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
808 ;;; (symbol-value sh-shell)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
809 ;;; (progn |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
810 ;;; (if (listp ancestor) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
811 ;;; (nconc list ancestor)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
812 ;;; (define-abbrev-table sh-shell ()) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
813 ;;; (if (vectorp ancestor) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
814 ;;; (mapatoms (lambda (atom) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
815 ;;; (or (eq atom 0) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
816 ;;; (define-abbrev (symbol-value sh-shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
817 ;;; (symbol-name atom) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
818 ;;; (symbol-value atom) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
819 ;;; (symbol-function atom)))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
820 ;;; ancestor)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
821 ;;; (while list |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
822 ;;; (define-abbrev (symbol-value sh-shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
823 ;;; (car list) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
824 ;;; (if (stringp (car (cdr list))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
825 ;;; (car (cdr list)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
826 ;;; "") |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
827 ;;; (if (symbolp (car (cdr list))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
828 ;;; (car (cdr list)))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
829 ;;; (setq list (cdr (cdr list))))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
830 ;;; (symbol-value sh-shell))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
831 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
832 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
833 (defun sh-mode-syntax-table (table &rest list) |
14005
dd4a20edf654
(sh-mode-syntax-table): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
13707
diff
changeset
|
834 "Copy TABLE and set syntax for successive CHARs according to strings S." |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
835 (setq table (copy-syntax-table table)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
836 (while list |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
837 (modify-syntax-entry (car list) (car (cdr list)) table) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
838 (setq list (cdr (cdr list)))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
839 table) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
840 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
841 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
842 (defun sh-append (ancestor &rest list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
843 "Return list composed of first argument (a list) physically appended to rest." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
844 (nconc list ancestor)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
845 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
846 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
847 (defun sh-modify (skeleton &rest list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
848 "Modify a copy of SKELETON by replacing I1 with REPL1, I2 with REPL2 ..." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
849 (setq skeleton (copy-sequence skeleton)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
850 (while list |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
851 (setcar (or (nthcdr (car list) skeleton) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
852 (error "Index %d out of bounds" (car list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
853 (car (cdr list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
854 (setq list (nthcdr 2 list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
855 skeleton) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
856 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
857 |
6463 | 858 (defun sh-indent-line () |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
859 "Indent as far as preceding non-empty line, then by steps of `sh-indentation'. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
860 Lines containing only comments are considered empty." |
6463 | 861 (interactive) |
862 (let ((previous (save-excursion | |
14211
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
863 (while (and (not (bobp)) |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
864 (progn |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
865 (forward-line -1) |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
866 (back-to-indentation) |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
867 (or (eolp) |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
868 (eq (following-char) ?#))))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
869 (current-column))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
870 current) |
6463 | 871 (save-excursion |
872 (indent-to (if (eq this-command 'newline-and-indent) | |
873 previous | |
874 (if (< (current-column) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
875 (setq current (progn (back-to-indentation) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
876 (current-column)))) |
6463 | 877 (if (eolp) previous 0) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
878 (delete-region (point) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
879 (progn (beginning-of-line) (point))) |
6463 | 880 (if (eolp) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
881 (max previous (* (1+ (/ current sh-indentation)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
882 sh-indentation)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
883 (* (1+ (/ current sh-indentation)) sh-indentation)))))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
884 (if (< (current-column) (current-indentation)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
885 (skip-chars-forward " \t")))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
886 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
887 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
888 (defun sh-execute-region (start end &optional flag) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
889 "Pass optional header and region to a subshell for noninteractive execution. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
890 The working directory is that of the buffer, and only environment variables |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
891 are already set which is why you can mark a header within the script. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
892 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
893 With a positive prefix ARG, instead of sending region, define header from |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
894 beginning of buffer to point. With a negative prefix ARG, instead of sending |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
895 region, clear header." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
896 (interactive "r\nP") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
897 (if flag |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
898 (setq sh-header-marker (if (> (prefix-numeric-value flag) 0) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
899 (point-marker))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
900 (if sh-header-marker |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
901 (save-excursion |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
902 (let (buffer-undo-list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
903 (goto-char sh-header-marker) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
904 (append-to-buffer (current-buffer) start end) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
905 (shell-command-on-region (point-min) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
906 (setq end (+ sh-header-marker |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
907 (- end start))) |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
908 sh-shell-file) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
909 (delete-region sh-header-marker end))) |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
910 (shell-command-on-region start end (concat sh-shell-file " -"))))) |
6463 | 911 |
912 | |
913 (defun sh-remember-variable (var) | |
914 "Make VARIABLE available for future completing reads in this buffer." | |
915 (or (< (length var) sh-remember-variable-min) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
916 (getenv var) |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
917 (assoc var sh-shell-variables) |
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
918 (setq sh-shell-variables (cons (cons var var) sh-shell-variables))) |
6463 | 919 var) |
920 | |
921 | |
922 | |
923 (defun sh-quoted-p () | |
924 "Is point preceded by an odd number of backslashes?" | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
925 (eq -1 (% (save-excursion (skip-chars-backward "\\\\")) 2))) |
6463 | 926 |
927 ;; statement syntax-commands for various shells | |
928 | |
929 ;; You are welcome to add the syntax or even completely new statements as | |
930 ;; appropriate for your favorite shell. | |
931 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
932 (define-skeleton sh-case |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
933 "Insert a case/switch statement. See `sh-feature'." |
6463 | 934 (csh "expression: " |
935 "switch( " str " )" \n | |
936 > "case " (read-string "pattern: ") ?: \n | |
937 > _ \n | |
938 "breaksw" \n | |
939 ( "other pattern, %s: " | |
940 < "case " str ?: \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
941 > _ \n |
6463 | 942 "breaksw" \n) |
943 < "default:" \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
944 > _ \n |
6463 | 945 resume: |
946 < < "endsw") | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
947 (es) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
948 (rc "expression: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
949 "switch( " str " ) {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
950 > "case " (read-string "pattern: ") \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
951 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
952 ( "other pattern, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
953 < "case " str \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
954 > _ \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
955 < "case *" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
956 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
957 resume: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
958 < < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
959 (sh "expression: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
960 "case " str " in" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
961 > (read-string "pattern: ") ?\) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
962 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
963 ";;" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
964 ( "other pattern, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
965 < str ?\) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
966 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
967 ";;" \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
968 < "*)" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
969 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
970 resume: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
971 < < "esac")) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
972 (put 'sh-case 'menu-enable '(sh-feature sh-case)) |
6463 | 973 |
974 | |
975 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
976 (define-skeleton sh-for |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
977 "Insert a for loop. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
978 (csh eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
979 1 "foreach " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
980 3 " ( " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
981 5 " )" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
982 15 "end") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
983 (es eval sh-modify rc |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
984 3 " = ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
985 (rc eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
986 1 "for( " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
987 5 " ) {" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
988 15 ?}) |
6463 | 989 (sh "Index variable: " |
990 "for " str " in " _ "; do" \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
991 > _ | ?$ & (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
992 < "done")) |
6463 | 993 |
994 | |
995 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
996 (define-skeleton sh-indexed-loop |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
997 "Insert an indexed loop from 1 to n. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
998 (bash eval identity posix) |
6463 | 999 (csh "Index variable: " |
1000 "@ " str " = 1" \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1001 "while( $" str " <= " (read-string "upper limit: ") " )" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1002 > _ ?$ str \n |
6463 | 1003 "@ " str "++" \n |
1004 < "end") | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1005 (es eval sh-modify rc |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1006 3 " =") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1007 (ksh88 "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1008 "integer " str "=0" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1009 "while (( ( " str " += 1 ) <= " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1010 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1011 " )); do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1012 > _ ?$ (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1013 < "done") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1014 (posix "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1015 str "=1" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1016 "while [ $" str " -le " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1017 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1018 " ]; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1019 > _ ?$ str \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1020 str ?= (sh-add (sh-remember-variable str) 1) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1021 < "done") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1022 (rc "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1023 "for( " str " in" " `{awk 'BEGIN { for( i=1; i<=" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1024 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1025 "; i++ ) print i }'}) {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1026 > _ ?$ (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1027 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1028 (sh "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1029 "for " str " in `awk 'BEGIN { for( i=1; i<=" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1030 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1031 "; i++ ) print i }'`; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1032 > _ ?$ (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1033 < "done")) |
6463 | 1034 |
1035 | |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1036 (defun sh-shell-initialize-variables () |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1037 "Scan the buffer for variable assignments. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1038 Add these variables to `sh-shell-variables'." |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1039 (message "Scanning buffer `%s' for variable assignments..." (buffer-name)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1040 (save-excursion |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1041 (goto-char (point-min)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1042 (setq sh-shell-variables-initialized t) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1043 (while (search-forward "=" nil t) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1044 (sh-assignment 0))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1045 (message "Scanning buffer `%s' for variable assignments...done" |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1046 (buffer-name))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1047 |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1048 (defvar sh-add-buffer) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1049 |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1050 (defun sh-add-completer (string predicate code) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1051 "Do completion using `sh-shell-variables', but initialize it first. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1052 This function is designed for use as the \"completion table\", |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1053 so it takes three arguments: |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1054 STRING, the current buffer contents; |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1055 PREDICATE, the predicate for filtering possible matches; |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1056 CODE, which says what kind of things to do. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1057 CODE can be nil, t or `lambda'. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1058 nil means to return the best completion of STRING, or nil if there is none. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1059 t means to return a list of all possible completions of STRING. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1060 `lambda' means to return t if STRING is a valid completion as it stands." |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1061 (let ((sh-shell-variables |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1062 (save-excursion |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1063 (set-buffer sh-add-buffer) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1064 (or sh-shell-variables-initialized |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1065 (sh-shell-initialize-variables)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1066 (nconc (mapcar (lambda (var) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1067 (let ((name |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1068 (substring var 0 (string-match "=" var)))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1069 (cons name name))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1070 process-environment) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1071 sh-shell-variables)))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1072 (cond ((null code) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1073 (try-completion string sh-shell-variables predicate)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1074 ((eq code t) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1075 (all-completions string sh-shell-variables predicate)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1076 ((eq code 'lambda) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1077 (assoc string sh-shell-variables))))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1078 |
6463 | 1079 (defun sh-add (var delta) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1080 "Insert an addition of VAR and prefix DELTA for Bourne (type) shell." |
6463 | 1081 (interactive |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1082 (let ((sh-add-buffer (current-buffer))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1083 (list (completing-read "Variable: " 'sh-add-completer) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1084 (prefix-numeric-value current-prefix-arg)))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1085 (insert (sh-feature '((bash . "$[ ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1086 (ksh88 . "$(( ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1087 (posix . "$(( ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1088 (rc . "`{expr $") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1089 (sh . "`expr $") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1090 (zsh . "$[ "))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1091 (sh-remember-variable var) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1092 (if (< delta 0) " - " " + ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1093 (number-to-string (abs delta)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1094 (sh-feature '((bash . " ]") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1095 (ksh88 . " ))") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1096 (posix . " ))") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1097 (rc . "}") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1098 (sh . "`") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1099 (zsh . " ]"))))) |
6463 | 1100 |
1101 | |
1102 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1103 (define-skeleton sh-function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1104 "Insert a function definition. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1105 (bash eval sh-modify ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1106 3 "() {") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1107 (ksh88 "name: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1108 "function " str " {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1109 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1110 < "}") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1111 (rc eval sh-modify ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1112 1 "fn ") |
6463 | 1113 (sh () |
1114 "() {" \n | |
1115 > _ \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1116 < "}")) |
6463 | 1117 |
1118 | |
1119 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1120 (define-skeleton sh-if |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1121 "Insert an if statement. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1122 (csh "condition: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1123 "if( " str " ) then" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1124 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1125 ( "other condition, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1126 < "else if( " str " ) then" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1127 > _ \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1128 < "else" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1129 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1130 resume: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1131 < "endif") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1132 (es "condition: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1133 "if { " str " } {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1134 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1135 ( "other condition, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1136 < "} { " str " } {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1137 > _ \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1138 < "} {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1139 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1140 resume: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1141 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1142 (rc eval sh-modify csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1143 3 " ) {" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1144 8 '( "other condition, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1145 < "} else if( " str " ) {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1146 > _ \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1147 10 "} else {" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1148 17 ?}) |
6463 | 1149 (sh "condition: " |
12863 | 1150 '(setq input (sh-feature sh-test)) |
1151 "if " str "; then" \n | |
6463 | 1152 > _ \n |
1153 ( "other condition, %s: " | |
12863 | 1154 < "elif " str "; then" \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1155 > _ \n) |
6463 | 1156 < "else" \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1157 > _ \n |
6463 | 1158 resume: |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1159 < "fi")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1160 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1161 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1162 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1163 (define-skeleton sh-repeat |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1164 "Insert a repeat loop definition. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1165 (es nil |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1166 "forever {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1167 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1168 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1169 (zsh "factor: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1170 "repeat " str "; do"\n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1171 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1172 < "done")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1173 (put 'sh-repeat 'menu-enable '(sh-feature sh-repeat)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1174 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1175 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1176 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1177 (define-skeleton sh-select |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1178 "Insert a select statement. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1179 (ksh88 "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1180 "select " str " in " _ "; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1181 > ?$ str \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1182 < "done")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1183 (put 'sh-select 'menu-enable '(sh-feature sh-select)) |
6463 | 1184 |
1185 | |
1186 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1187 (define-skeleton sh-tmp-file |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1188 "Insert code to setup temporary file handling. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1189 (bash eval identity ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1190 (csh (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1191 "set tmp = /tmp/" str ".$$" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1192 "onintr exit" \n _ |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1193 (and (goto-char (point-max)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1194 (not (bolp)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1195 ?\n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1196 "exit:\n" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1197 "rm $tmp* >&/dev/null" >) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1198 (es (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1199 "local( signals = $signals sighup sigint; tmp = /tmp/" str ".$pid ) {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1200 > "catch @ e {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1201 > "rm $tmp^* >[2]/dev/null" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1202 "throw $e" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1203 < "} {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1204 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1205 < ?} \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1206 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1207 (ksh88 eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1208 6 "EXIT") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1209 (rc (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1210 "tmp = /tmp/" str ".$pid" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1211 "fn sigexit { rm $tmp^* >[2]/dev/null }") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1212 (sh (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1213 "TMP=/tmp/" str ".$$" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1214 "trap \"rm $TMP* 2>/dev/null\" " ?0)) |
6463 | 1215 |
1216 | |
1217 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1218 (define-skeleton sh-until |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1219 "Insert an until loop. See `sh-feature'." |
6463 | 1220 (sh "condition: " |
12863 | 1221 '(setq input (sh-feature sh-test)) |
1222 "until " str "; do" \n | |
6463 | 1223 > _ \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1224 < "done")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1225 (put 'sh-until 'menu-enable '(sh-feature sh-until)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1226 |
6463 | 1227 |
1228 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1229 (define-skeleton sh-while |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1230 "Insert a while loop. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1231 (csh eval sh-modify sh |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1232 2 "while( " |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1233 4 " )" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1234 10 "end") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1235 (es eval sh-modify rc |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1236 2 "while { " |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1237 4 " } {") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1238 (rc eval sh-modify csh |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1239 4 " ) {" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1240 10 ?}) |
6463 | 1241 (sh "condition: " |
12863 | 1242 '(setq input (sh-feature sh-test)) |
1243 "while " str "; do" \n | |
6463 | 1244 > _ \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1245 < "done")) |
6463 | 1246 |
1247 | |
1248 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1249 (define-skeleton sh-while-getopts |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1250 "Insert a while getopts loop. See `sh-feature'. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1251 Prompts for an options string which consists of letters for each recognized |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1252 option followed by a colon `:' if the option accepts an argument." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1253 (bash eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1254 18 "${0##*/}") |
12863 | 1255 (csh nil |
1256 "while( 1 )" \n | |
1257 > "switch( \"$1\" )" \n | |
1258 '(setq input '("- x" . 2)) | |
1259 > > | |
1260 ( "option, %s: " | |
1261 < "case " '(eval str) | |
1262 '(if (string-match " +" str) | |
1263 (setq v1 (substring str (match-end 0)) | |
1264 str (substring str 0 (match-beginning 0))) | |
1265 (setq v1 nil)) | |
1266 str ?: \n | |
1267 > "set " v1 & " = $2" | -4 & _ \n | |
1268 (if v1 "shift") & \n | |
1269 "breaksw" \n) | |
1270 < "case --:" \n | |
1271 > "shift" \n | |
1272 < "default:" \n | |
1273 > "break" \n | |
1274 resume: | |
1275 < < "endsw" \n | |
1276 "shift" \n | |
1277 < "end") | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1278 (ksh88 eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1279 16 "print" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1280 18 "${0##*/}" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1281 36 "OPTIND-1") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1282 (posix eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1283 18 "$(basename $0)") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1284 (sh "optstring: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1285 "while getopts :" str " OPT; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1286 > "case $OPT in" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1287 > > |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1288 '(setq v1 (append (vconcat str) nil)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1289 ( (prog1 (if v1 (char-to-string (car v1))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1290 (if (eq (nth 1 v1) ?:) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1291 (setq v1 (nthcdr 2 v1) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1292 v2 "\"$OPTARG\"") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1293 (setq v1 (cdr v1) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1294 v2 nil))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1295 < str "|+" str ?\) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1296 > _ v2 \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1297 ";;" \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1298 < "*)" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1299 > "echo" " \"usage: " "`basename $0`" |
15027
30c4f64f3579
(sh-while-getopts): Punctuate help message better.
Richard M. Stallman <rms@gnu.org>
parents:
14892
diff
changeset
|
1300 " [+-" '(setq v1 (point)) str |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1301 '(save-excursion |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1302 (while (search-backward ":" v1 t) |
15027
30c4f64f3579
(sh-while-getopts): Punctuate help message better.
Richard M. Stallman <rms@gnu.org>
parents:
14892
diff
changeset
|
1303 (replace-match " ARG] [+-" t t))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1304 (if (eq (preceding-char) ?-) -5) |
15027
30c4f64f3579
(sh-while-getopts): Punctuate help message better.
Richard M. Stallman <rms@gnu.org>
parents:
14892
diff
changeset
|
1305 "] [--] ARGS...\"" \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1306 "exit 2" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1307 < < "esac" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1308 < "done" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1309 "shift " (sh-add "OPTIND" -1))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1310 (put 'sh-while-getopts 'menu-enable '(sh-feature sh-while-getopts)) |
6463 | 1311 |
1312 | |
1313 | |
1314 (defun sh-assignment (arg) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1315 "Remember preceding identifier for future completion and do self-insert." |
6463 | 1316 (interactive "p") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1317 (self-insert-command arg) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1318 (if (<= arg 1) |
6463 | 1319 (sh-remember-variable |
1320 (save-excursion | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1321 (if (re-search-forward (sh-feature sh-assignment-regexp) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1322 (prog1 (point) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1323 (beginning-of-line 1)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1324 t) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1325 (match-string 1)))))) |
6463 | 1326 |
1327 | |
1328 | |
1329 (defun sh-maybe-here-document (arg) | |
1330 "Inserts self. Without prefix, following unquoted `<' inserts here document. | |
1331 The document is bounded by `sh-here-document-word'." | |
1332 (interactive "*P") | |
1333 (self-insert-command (prefix-numeric-value arg)) | |
1334 (or arg | |
1335 (not (eq (char-after (- (point) 2)) last-command-char)) | |
1336 (save-excursion | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1337 (backward-char 2) |
6463 | 1338 (sh-quoted-p)) |
1339 (progn | |
1340 (insert sh-here-document-word) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1341 (or (eolp) (looking-at "[ \t]") (insert ? )) |
6463 | 1342 (end-of-line 1) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1343 (while |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1344 (sh-quoted-p) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1345 (end-of-line 2)) |
6463 | 1346 (newline) |
1347 (save-excursion (insert ?\n sh-here-document-word))))) | |
1348 | |
1349 | |
1350 ;; various other commands | |
1351 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1352 (autoload 'comint-dynamic-complete "comint" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1353 "Dynamically perform completion at point." t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1354 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1355 (autoload 'shell-dynamic-complete-command "shell" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1356 "Dynamically complete the command at point." t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1357 |
6463 | 1358 (autoload 'comint-dynamic-complete-filename "comint" |
1359 "Dynamically complete the filename at point." t) | |
1360 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1361 (autoload 'shell-dynamic-complete-environment-variable "shell" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1362 "Dynamically complete the environment variable at point." t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1363 |
6463 | 1364 |
1365 | |
12887
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1366 (defun sh-newline-and-indent () |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1367 "Strip unquoted whitespace, insert newline, and indent like current line." |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1368 (interactive "*") |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1369 (indent-to (prog1 (current-indentation) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1370 (delete-region (point) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1371 (progn |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1372 (or (zerop (skip-chars-backward " \t")) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1373 (if (sh-quoted-p) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1374 (forward-char))) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1375 (point))) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1376 (newline)))) |
6463 | 1377 |
1378 | |
1379 | |
1380 (defun sh-beginning-of-command () | |
1381 "Move point to successive beginnings of commands." | |
1382 (interactive) | |
1383 (if (re-search-backward sh-beginning-of-command nil t) | |
1384 (goto-char (match-beginning 2)))) | |
1385 | |
1386 | |
1387 (defun sh-end-of-command () | |
1388 "Move point to successive ends of commands." | |
1389 (interactive) | |
1390 (if (re-search-forward sh-end-of-command nil t) | |
1391 (goto-char (match-end 1)))) | |
1392 | |
13707 | 1393 (provide 'sh-script) |
6463 | 1394 ;; sh-script.el ends here |