Mercurial > emacs
annotate lisp/progmodes/sh-script.el @ 22923:970b3bad71fd
(Fsplit_window): Doc fix.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 06 Aug 1998 05:48:33 +0000 |
parents | 1fb9133a2851 |
children | d29b6b51866f |
rev | line source |
---|---|
6463 | 1 ;;; sh-script.el --- shell-script editing commands for Emacs |
14169 | 2 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
3 ;; Copyright (C) 1993, 94, 95, 96, 1997 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 |
17068
d1391b21626f
(sh-mode-hook, sh-set-shell-hook): Add defvars.
Karl Heuer <kwzh@gnu.org>
parents:
16839
diff
changeset
|
50 (defvar sh-mode-hook nil |
d1391b21626f
(sh-mode-hook, sh-set-shell-hook): Add defvars.
Karl Heuer <kwzh@gnu.org>
parents:
16839
diff
changeset
|
51 "*Hook run by `sh-mode'.") |
d1391b21626f
(sh-mode-hook, sh-set-shell-hook): Add defvars.
Karl Heuer <kwzh@gnu.org>
parents:
16839
diff
changeset
|
52 |
d1391b21626f
(sh-mode-hook, sh-set-shell-hook): Add defvars.
Karl Heuer <kwzh@gnu.org>
parents:
16839
diff
changeset
|
53 (defvar sh-set-shell-hook nil |
d1391b21626f
(sh-mode-hook, sh-set-shell-hook): Add defvars.
Karl Heuer <kwzh@gnu.org>
parents:
16839
diff
changeset
|
54 "*Hook run by `sh-set-shell'.") |
d1391b21626f
(sh-mode-hook, sh-set-shell-hook): Add defvars.
Karl Heuer <kwzh@gnu.org>
parents:
16839
diff
changeset
|
55 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
56 (defgroup sh nil |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
57 "Shell programming utilities" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
58 :group 'unix |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
59 :group 'languages) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
60 |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
61 (defgroup sh-script nil |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
62 "Shell script mode" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
63 :group 'sh |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
64 :prefix "sh-") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
65 |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
66 |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
67 (defcustom sh-ancestor-alist |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
68 '((ash . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
69 (bash . jsh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
70 (dtksh . ksh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
71 (es . rc) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
72 (itcsh . tcsh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
73 (jcsh . csh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
74 (jsh . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
75 (ksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
76 (ksh88 . jsh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
77 (oash . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
78 (pdksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
79 (posix . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
80 (tcsh . csh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
81 (wksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
82 (wsh . sh) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
83 (zsh . ksh88)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
84 "*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
|
85 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
|
86 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
|
87 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
88 csh C Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
89 jcsh C Shell with Job Control |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
90 tcsh Toronto C Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
91 itcsh ? Toronto C Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
92 rc Plan 9 Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
93 es Extensible Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
94 sh Bourne Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
95 ash ? Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
96 jsh Bourne Shell with Job Control |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
97 bash GNU Bourne Again Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
98 ksh88 Korn Shell '88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
99 ksh Korn Shell '93 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
100 dtksh CDE Desktop Korn Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
101 pdksh Public Domain Korn Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
102 wksh Window Korn Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
103 zsh Z Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
104 oash SCO OA (curses) Shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
105 posix IEEE 1003.2 Shell Standard |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
106 wsh ? Shell" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
107 :type '(repeat (cons symbol symbol)) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
108 :group 'sh-script) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
109 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
110 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
111 (defcustom sh-alias-alist |
15950
c4ae4ea7fa7a
(sh-alias-alist): Use gnu/linux, not lignux.
Richard M. Stallman <rms@gnu.org>
parents:
15677
diff
changeset
|
112 (nconc (if (eq system-type 'gnu/linux) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
113 '((csh . tcsh) |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
114 (ksh . pdksh))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
115 ;; for the time being |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
116 '((ksh . ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
117 (sh5 . sh))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
118 "*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
|
119 Use this where the name of the executable doesn't correspond to the type of |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
120 shell it really is." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
121 :type '(repeat (cons symbol symbol)) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
122 :group 'sh-script) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
123 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
124 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
125 (defcustom sh-shell-file |
16810
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
126 (or |
16839
daaa2c5bb40a
(sh-shell-file): Downcase and remove extension on shells in NT.
Richard M. Stallman <rms@gnu.org>
parents:
16810
diff
changeset
|
127 ;; On MSDOS and Windows, collapse $SHELL to lower-case and remove |
daaa2c5bb40a
(sh-shell-file): Downcase and remove extension on shells in NT.
Richard M. Stallman <rms@gnu.org>
parents:
16810
diff
changeset
|
128 ;; the executable extension, so comparisons with the list of |
16810
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
129 ;; known shells work. |
16839
daaa2c5bb40a
(sh-shell-file): Downcase and remove extension on shells in NT.
Richard M. Stallman <rms@gnu.org>
parents:
16810
diff
changeset
|
130 (and (memq system-type '(ms-dos windows-nt)) |
21925
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
131 (let* ((shell (getenv "SHELL")) |
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
132 (shell-base |
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
133 (and shell (file-name-nondirectory shell)))) |
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
134 ;; shell-script mode doesn't support DOS/Windows shells, |
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
135 ;; so use the default instead. |
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
136 (if (or (null shell) |
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
137 (member (downcase shell-base) |
21980
e73c0672d7b3
(sh-shell-file): Add cmdproxy to MS shells.
Richard M. Stallman <rms@gnu.org>
parents:
21925
diff
changeset
|
138 '("command.com" "cmd.exe" "4dos.com" "ndos.com" |
e73c0672d7b3
(sh-shell-file): Add cmdproxy to MS shells.
Richard M. Stallman <rms@gnu.org>
parents:
21925
diff
changeset
|
139 "cmdproxy.exe"))) |
21925
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
140 "/bin/sh" |
3e498c36ccce
(sh-shell-file): If $SHELL evaluates to
Eli Zaretskii <eliz@gnu.org>
parents:
21669
diff
changeset
|
141 (file-name-sans-extension (downcase shell))))) |
16810
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
142 (getenv "SHELL") |
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
143 "/bin/sh") |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
144 "*The executable file name for the shell being programmed." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
145 :type 'string |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
146 :group 'sh-script) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
147 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
148 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
149 (defcustom 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
|
150 ;; 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
|
151 '((bash) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
152 (csh . "-f") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
153 (pdksh) |
14886
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
154 ;; 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
|
155 (ksh88) |
14886
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
156 ;; -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
|
157 (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
|
158 ;; 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
|
159 ;; 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
|
160 (wksh) |
96423e733197
(sh-shell-arg): Add no options for bash, ksh, or wksh.
Richard M. Stallman <rms@gnu.org>
parents:
14876
diff
changeset
|
161 ;; -f means don't run .zshrc. |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
162 (zsh . "-f")) |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
163 "*Single argument string for the magic number. See `sh-feature'." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
164 :type '(repeat (cons (symbol :tag "Shell") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
165 (choice (const :tag "No Arguments" nil) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
166 (string :tag "Arguments") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
167 (cons :format "Evaluate: %v" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
168 (const :format "" eval) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
169 sexp)))) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
170 :group 'sh-script) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
171 |
20395
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
172 (defcustom sh-imenu-generic-expression |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
173 (list |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
174 (cons 'sh |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
175 (concat |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
176 "\\(^\\s-*function\\s-+[A-Za-z_][A-Za-z_0-9]*\\)" |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
177 "\\|" |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
178 "\\(^\\s-*[A-Za-z_][A-Za-z_0-9]*\\s-*()\\)"))) |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
179 "*Regular expression for recognizing shell function definitions. |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
180 See `sh-feature'." |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
181 :type '(repeat (cons (symbol :tag "Shell") |
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
182 regexp)) |
21669
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20900
diff
changeset
|
183 :group 'sh-script |
9861518505cb
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20900
diff
changeset
|
184 :version "20.3") |
20395
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
185 |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
186 (defvar sh-shell-variables nil |
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
187 "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
|
188 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
|
189 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
|
190 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
|
191 |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
192 (defvar sh-shell-variables-initialized nil |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
193 "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
|
194 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
195 (defun sh-canonicalize-shell (shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
196 "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
|
197 (or (symbolp shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
198 (setq shell (intern shell))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
199 (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
|
200 shell)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
201 |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
202 (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
|
203 "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
|
204 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
205 ;;; 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
|
206 ;;; 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
|
207 ;;;(defvar sh-abbrevs |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
208 ;;; '((csh eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
209 ;;; "switch" 'sh-case |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
210 ;;; "getopts" 'sh-while-getopts) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
211 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
212 ;;; (es eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
213 ;;; "function" 'sh-function) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
214 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
215 ;;; (ksh88 eval sh-abbrevs sh |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
216 ;;; "select" 'sh-select) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
217 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
218 ;;; (rc eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
219 ;;; "case" 'sh-case |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
220 ;;; "function" 'sh-function) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
221 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
222 ;;; (sh eval sh-abbrevs shell |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
223 ;;; "case" 'sh-case |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
224 ;;; "function" 'sh-function |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
225 ;;; "until" 'sh-until |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
226 ;;; "getopts" 'sh-while-getopts) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
227 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
228 ;;; ;; 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
|
229 ;;; (shell "for" sh-for |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
230 ;;; "loop" sh-indexed-loop |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
231 ;;; "if" sh-if |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
232 ;;; "tmpfile" sh-tmp-file |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
233 ;;; "while" sh-while) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
234 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
235 ;;; (zsh eval sh-abbrevs ksh88 |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
236 ;;; "repeat" 'sh-repeat)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
237 ;;; "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
|
238 ;;;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
|
239 ;;;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
|
240 |
6463 | 241 |
242 | |
243 (defvar sh-mode-syntax-table | |
16535
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
244 '((sh eval sh-mode-syntax-table () |
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
245 ?\# "<" |
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
246 ?\^l ">#" |
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
247 ?\n ">#" |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
248 ?\" "\"\"" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
249 ?\' "\"'" |
16535
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
250 ?\` "\"`" |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
251 ?! "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
252 ?% "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
253 ?: "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
254 ?. "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
255 ?^ "_" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
256 ?~ "_") |
16535
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
257 (csh eval identity sh) |
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
258 (rc eval identity sh)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
259 "Syntax-table used in Shell-Script mode. See `sh-feature'.") |
6463 | 260 |
261 | |
262 | |
263 (defvar sh-mode-map | |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
264 (let ((map (make-sparse-keymap)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
265 (menu-map (make-sparse-keymap "Insert"))) |
6463 | 266 (define-key map "\C-c(" 'sh-function) |
267 (define-key map "\C-c\C-w" 'sh-while) | |
268 (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
|
269 (define-key map "\C-c\C-t" 'sh-tmp-file) |
6463 | 270 (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
|
271 (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
|
272 (define-key map "\C-c\C-o" 'sh-while-getopts) |
6463 | 273 (define-key map "\C-c\C-l" 'sh-indexed-loop) |
274 (define-key map "\C-c\C-i" 'sh-if) | |
275 (define-key map "\C-c\C-f" 'sh-for) | |
276 (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
|
277 |
6463 | 278 (define-key map "=" 'sh-assignment) |
279 (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
|
280 (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
|
281 (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
|
282 (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
|
283 (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
|
284 (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
|
285 (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
|
286 (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
|
287 (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
|
288 (define-key map "\"" 'skeleton-pair-insert-maybe) |
6463 | 289 |
290 (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
|
291 (substitute-key-definition 'complete-tag 'comint-dynamic-complete |
6463 | 292 map (current-global-map)) |
293 (substitute-key-definition 'newline-and-indent 'sh-newline-and-indent | |
294 map (current-global-map)) | |
295 (substitute-key-definition 'delete-backward-char | |
296 'backward-delete-char-untabify | |
297 map (current-global-map)) | |
298 (define-key map "\C-c:" 'sh-set-shell) | |
299 (substitute-key-definition 'beginning-of-defun | |
300 'sh-beginning-of-compound-command | |
301 map (current-global-map)) | |
302 (substitute-key-definition 'backward-sentence 'sh-beginning-of-command | |
303 map (current-global-map)) | |
304 (substitute-key-definition 'forward-sentence 'sh-end-of-command | |
305 map (current-global-map)) | |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
306 (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
|
307 (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
|
308 (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
|
309 (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
|
310 (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
|
311 (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
|
312 (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
|
313 '("Options Loop" . sh-while-getopts)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
314 (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
|
315 '("Indexed Loop" . sh-indexed-loop)) |
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
316 (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
|
317 (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
|
318 (define-key menu-map [sh-case] '("Case Statement" . sh-case)) |
6463 | 319 map) |
320 "Keymap used in Shell-Script mode.") | |
321 | |
322 | |
323 | |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
324 (defcustom sh-dynamic-complete-functions |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
325 '(shell-dynamic-complete-environment-variable |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
326 shell-dynamic-complete-command |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
327 comint-dynamic-complete-filename) |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
328 "*Functions for doing TAB dynamic completion." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
329 :type '(repeat function) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
330 :group 'sh-script) |
6463 | 331 |
332 | |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
333 (defcustom sh-require-final-newline |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
334 '((csh . t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
335 (pdksh . t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
336 (rc eval . require-final-newline) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
337 (sh eval . require-final-newline)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
338 "*Value of `require-final-newline' in Shell-Script mode buffers. |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
339 See `sh-feature'." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
340 :type '(repeat (cons (symbol :tag "Shell") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
341 (choice (const :tag "require" t) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
342 (cons :format "Evaluate: %v" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
343 (const :format "" eval) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
344 sexp)))) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
345 :group 'sh-script) |
6463 | 346 |
347 | |
17531
b891e41b4011
(sh-case): Make this a simple define-skeleton
Richard M. Stallman <rms@gnu.org>
parents:
17501
diff
changeset
|
348 (defcustom sh-assignment-regexp |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
349 '((csh . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*[-+*/%^]?=") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
350 ;; actually spaces are only supported in let/(( ... )) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
351 (ksh88 . "\\<\\([a-zA-Z0-9_]+\\)\\(\\[.+\\]\\)?[ \t]*\\([-+*/%&|~^]\\|<<\\|>>\\)?=") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
352 (rc . "\\<\\([a-zA-Z0-9_*]+\\)[ \t]*=") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
353 (sh . "\\<\\([a-zA-Z0-9_]+\\)=")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
354 "*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
|
355 First grouping matches the variable name. This is upto and including the `=' |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
356 sign. See `sh-feature'." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
357 :type '(repeat (cons (symbol :tag "Shell") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
358 (choice regexp |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
359 (cons :format "Evaluate: %v" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
360 (const :format "" eval) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
361 sexp)))) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
362 :group 'sh-script) |
6463 | 363 |
364 | |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
365 (defcustom sh-indentation 4 |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
366 "The width for further indentation in Shell-Script mode." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
367 :type 'integer |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
368 :group 'sh-script) |
6463 | 369 |
370 | |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
371 (defcustom sh-remember-variable-min 3 |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
372 "*Don't remember variables less than this length for completing reads." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
373 :type 'integer |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
374 :group 'sh-script) |
6463 | 375 |
376 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
377 (defvar sh-header-marker nil |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
378 "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
|
379 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
|
380 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
381 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
382 (defcustom sh-beginning-of-command |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
383 "\\([;({`|&]\\|\\`\\|[^\\]\n\\)[ \t]*\\([/~a-zA-Z0-9:]\\)" |
6463 | 384 "*Regexp to determine the beginning of a shell command. |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
385 The actual command starts at the beginning of the second \\(grouping\\)." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
386 :type 'regexp |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
387 :group 'sh-script) |
6463 | 388 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
389 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
390 (defcustom sh-end-of-command |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
391 "\\([/~a-zA-Z0-9:]\\)[ \t]*\\([;#)}`|&]\\|$\\)" |
6463 | 392 "*Regexp to determine the end of a shell command. |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
393 The actual command ends at the end of the first \\(grouping\\)." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
394 :type 'regexp |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
395 :group 'sh-script) |
6463 | 396 |
397 | |
398 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
399 (defvar sh-here-document-word "EOF" |
6463 | 400 "Word to delimit here documents.") |
401 | |
12863 | 402 (defvar sh-test |
403 '((sh "[ ]" . 3) | |
404 (ksh88 "[[ ]]" . 4)) | |
405 "Initial input in Bourne if, while and until skeletons. See `sh-feature'.") | |
406 | |
6463 | 407 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
408 ;; customized this out of sheer bravado. not for the faint of heart. |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
409 ;; but it *did* have an asterisk in the docstring! |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
410 (defcustom sh-builtins |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
411 '((bash eval sh-append posix |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
412 "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
|
413 "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
|
414 "suspend" "typeset" "unalias") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
415 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
416 ;; 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
|
417 (bourne eval sh-append shell |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
418 "eval" "export" "getopts" "newgrp" "pwd" "read" "readonly" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
419 "times" "ulimit") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
420 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
421 (csh eval sh-append shell |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
422 "alias" "chdir" "glob" "history" "limit" "nice" "nohup" "rehash" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
423 "setenv" "source" "time" "unalias" "unhash") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
424 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
425 (dtksh eval identity wksh) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
426 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
427 (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
|
428 "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
|
429 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
430 (jsh eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
431 "bg" "fg" "jobs" "kill" "stop" "suspend") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
432 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
433 (jcsh eval sh-append csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
434 "bg" "fg" "jobs" "kill" "notify" "stop" "suspend") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
435 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
436 (ksh88 eval sh-append bourne |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
437 "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
|
438 "typeset" "unalias" "whence") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
439 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
440 (oash eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
441 "checkwin" "dateline" "error" "form" "menu" "newwin" "oadeinit" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
442 "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
|
443 "wclear" "werase" "win" "wmclose" "wmmessage" "wmopen" "wmove" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
444 "wmtitle" "wrefresh") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
445 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
446 (pdksh eval sh-append ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
447 "bind") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
448 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
449 (posix eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
450 "command") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
451 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
452 (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
|
453 "whatis") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
454 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
455 (sh eval sh-append bourne |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
456 "hash" "test" "type") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
457 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
458 ;; 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
|
459 (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
|
460 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
461 (wksh eval sh-append ksh88 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
462 "Xt[A-Z][A-Za-z]*") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
463 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
464 (zsh eval sh-append ksh88 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
465 "autoload" "bindkey" "builtin" "chdir" "compctl" "declare" "dirs" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
466 "disable" "disown" "echotc" "enable" "functions" "getln" "hash" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
467 "history" "integer" "limit" "local" "log" "popd" "pushd" "r" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
468 "readonly" "rehash" "sched" "setopt" "source" "suspend" "true" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
469 "ttyctl" "type" "unfunction" "unhash" "unlimit" "unsetopt" "vared" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
470 "which")) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
471 "*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
|
472 Note that on some systems not all builtins are available or some are |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
473 implemented as aliases. See `sh-feature'." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
474 :type '(repeat (cons (symbol :tag "Shell") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
475 (choice (repeat string) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
476 (cons :format "Evaluate: %v" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
477 (const :format "" eval) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
478 sexp)))) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
479 :group 'sh-script) |
12505
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 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
482 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
483 (defcustom sh-leading-keywords |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
484 '((csh "else") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
485 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
486 (es "true" "unwind-protect" "whatis") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
487 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
488 (rc "else") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
489 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
490 (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
|
491 "*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
|
492 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
|
493 system, the distinction here has been based on whether they influence the |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
494 flow of control or syntax. See `sh-feature'." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
495 :type '(repeat (cons (symbol :tag "Shell") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
496 (choice (repeat string) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
497 (cons :format "Evaluate: %v" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
498 (const :format "" eval) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
499 sexp)))) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
500 :group 'sh-script) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
501 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
502 |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
503 (defcustom sh-other-keywords |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
504 '((bash eval sh-append bourne |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
505 "bye" "logout") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
506 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
507 ;; The next entry is only used for defining the others |
16810
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
508 (bourne eval sh-append sh |
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
509 "function") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
510 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
511 (csh eval sh-append shell |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
512 "breaksw" "default" "end" "endif" "endsw" "foreach" "goto" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
513 "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
|
514 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
515 (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
|
516 "return" "throw" "while") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
517 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
518 (ksh88 eval sh-append bourne |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
519 "select") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
520 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
521 (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
|
522 "while") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
523 |
16810
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
524 (sh eval sh-append shell |
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
525 "done" "esac" "fi" "for" "in" "return") |
20dc495230a0
(sh-shell-file): On MSDOS, collapse $SHELL to lower
Richard M. Stallman <rms@gnu.org>
parents:
16552
diff
changeset
|
526 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
527 ;; 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
|
528 (shell "break" "case" "continue" "exec" "exit") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
529 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
530 (zsh eval sh-append bash |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
531 "select")) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
532 "*List of keywords not in `sh-leading-keywords'. |
17407
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
533 See `sh-feature'." |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
534 :type '(repeat (cons (symbol :tag "Shell") |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
535 (choice (repeat string) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
536 (cons :format "Evaluate: %v" |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
537 (const :format "" eval) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
538 sexp)))) |
ae0ba78d6c07
Add defgroup's; change use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
17356
diff
changeset
|
539 :group 'sh-script) |
6463 | 540 |
541 | |
542 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
543 (defvar sh-variables |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
544 '((bash eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
545 "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
|
546 "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
|
547 "histchars" "HISTFILE" "HISTFILESIZE" "history_control" "HISTSIZE" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
548 "hostname_completion_file" "HOSTTYPE" "IGNOREEOF" "ignoreeof" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
549 "LINENO" "MAIL_WARNING" "noclobber" "nolinks" "notify" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
550 "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
|
551 "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
|
552 "SECONDS" "SHLVL" "TMOUT" "UID") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
553 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
554 (csh eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
555 "argv" "cdpath" "child" "echo" "histchars" "history" "home" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
556 "ignoreeof" "mail" "noclobber" "noglob" "nonomatch" "path" "prompt" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
557 "shell" "status" "time" "verbose") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
558 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
559 (es eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
560 "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
|
561 "pid" "prompt" "signals") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
562 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
563 (jcsh eval sh-append csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
564 "notify") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
565 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
566 (ksh88 eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
567 "ENV" "ERRNO" "FCEDIT" "FPATH" "HISTFILE" "HISTSIZE" "LINENO" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
568 "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
|
569 "TMOUT") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
570 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
571 (oash eval sh-append sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
572 "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
|
573 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
574 (rc eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
575 "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
|
576 "prompt" "status") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
577 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
578 (sh eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
579 "CDPATH" "IFS" "OPTARG" "OPTIND" "PS1" "PS2") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
580 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
581 ;; 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
|
582 (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
|
583 "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
|
584 "LINES" "LOGNAME" "MAIL" "MAILCHECK" "MAILPATH" "PAGER" "PATH" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
585 "SHELL" "TERM" "TERMCAP" "TERMINFO" "VISUAL") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
586 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
587 (tcsh eval sh-append csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
588 "addsuffix" "ampm" "autocorrect" "autoexpand" "autolist" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
589 "autologout" "chase_symlinks" "correct" "dextract" "edit" "el" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
590 "fignore" "gid" "histlit" "HOST" "HOSTTYPE" "HPATH" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
591 "ignore_symlinks" "listjobs" "listlinks" "listmax" "matchbeep" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
592 "nobeep" "NOREBIND" "oid" "printexitvalue" "prompt2" "prompt3" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
593 "pushdsilent" "pushdtohome" "recexact" "recognize_only_executables" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
594 "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
|
595 "tperiod" "tty" "uid" "version" "visiblebell" "watch" "who" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
596 "wordchars") |
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 (zsh eval sh-append ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
599 "BAUD" "bindcmds" "cdpath" "DIRSTACKSIZE" "fignore" "FIGNORE" "fpath" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
600 "HISTCHARS" "hostcmds" "hosts" "HOSTS" "LISTMAX" "LITHISTSIZE" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
601 "LOGCHECK" "mailpath" "manpath" "NULLCMD" "optcmds" "path" "POSTEDIT" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
602 "prompt" "PROMPT" "PROMPT2" "PROMPT3" "PROMPT4" "psvar" "PSVAR" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
603 "READNULLCMD" "REPORTTIME" "RPROMPT" "RPS1" "SAVEHIST" "SPROMPT" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
604 "STTY" "TIMEFMT" "TMOUT" "TMPPREFIX" "varcmds" "watch" "WATCH" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
605 "WATCHFMT" "WORDCHARS" "ZDOTDIR")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
606 "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
|
607 See `sh-feature'.") |
6463 | 608 |
609 | |
610 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
611 (defvar sh-font-lock-keywords |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
612 '((csh eval sh-append shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
613 '("\\${?[#?]?\\([A-Za-z_][A-Za-z0-9_]*\\|0\\)" 1 |
12863 | 614 font-lock-variable-name-face)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
615 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
616 (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
|
617 '("\\$#?\\([A-Za-z_][A-Za-z0-9_]*\\|[0-9]+\\)" 1 |
12863 | 618 font-lock-variable-name-face)) |
6463 | 619 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
620 (rc eval identity es) |
6463 | 621 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
622 (sh eval sh-append shell |
20900
bab0b53038ee
(sh-font-lock-keywords): Fontify sh-style function names in declarations.
Richard M. Stallman <rms@gnu.org>
parents:
20886
diff
changeset
|
623 ;; Variable names. |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
624 '("\\$\\({#?\\)?\\([A-Za-z_][A-Za-z0-9_]*\\|[-#?@!]\\)" 2 |
20900
bab0b53038ee
(sh-font-lock-keywords): Fontify sh-style function names in declarations.
Richard M. Stallman <rms@gnu.org>
parents:
20886
diff
changeset
|
625 font-lock-variable-name-face) |
bab0b53038ee
(sh-font-lock-keywords): Fontify sh-style function names in declarations.
Richard M. Stallman <rms@gnu.org>
parents:
20886
diff
changeset
|
626 ;; Function names. |
bab0b53038ee
(sh-font-lock-keywords): Fontify sh-style function names in declarations.
Richard M. Stallman <rms@gnu.org>
parents:
20886
diff
changeset
|
627 '("^\\(\\sw+\\)[ \t]*(" 1 font-lock-function-name-face) |
bab0b53038ee
(sh-font-lock-keywords): Fontify sh-style function names in declarations.
Richard M. Stallman <rms@gnu.org>
parents:
20886
diff
changeset
|
628 '("\\<\\(function\\)\\>[ \t]*\\(\\sw+\\)?" |
bab0b53038ee
(sh-font-lock-keywords): Fontify sh-style function names in declarations.
Richard M. Stallman <rms@gnu.org>
parents:
20886
diff
changeset
|
629 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))) |
6463 | 630 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
631 ;; 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
|
632 (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
|
633 '("\\\\[^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
|
634 '("\\${?\\([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
|
635 font-lock-variable-name-face))) |
18024
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
636 "Default expressions to highlight in Shell Script modes. See `sh-feature'.") |
6463 | 637 |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
638 (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
|
639 '((sh "[ \t]in\\>")) |
18024
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
640 "Subdued level highlighting for Shell Script modes.") |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
641 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
642 (defvar sh-font-lock-keywords-2 () |
18024
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
643 "Gaudy level highlighting for Shell Script modes.") |
6463 | 644 |
18024
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
645 (defconst sh-font-lock-syntactic-keywords |
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
646 ;; Mark a `#' character as having punctuation syntax in a variable reference. |
20420
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
647 ;; Really we should do this properly. From Chet Ramey and Brian Fox: |
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
648 ;; "A `#' begins a comment when it is unquoted and at the beginning of a |
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
649 ;; word. In the shell, words are separated by metacharacters." |
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
650 ;; To do this in a regexp would be slow as it would be anchored to the right. |
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
651 ;; But I can't be bothered to write a function to do it properly and |
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
652 ;; efficiently. So we only do it properly for `#' in variable references and |
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
653 ;; do it efficiently by anchoring the regexp to the left. |
6cb3b9732db5
Deal with `#'s in variable references.
Simon Marshall <simon@gnu.org>
parents:
20395
diff
changeset
|
654 '(("\\${?[^}#\n\t ]*\\(##?\\)" 1 (1 . nil)))) |
6463 | 655 |
656 ;; mode-command and utility functions | |
657 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
658 ;;;###autoload |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
659 (put 'sh-mode 'mode-class 'special) |
14221
cd28284abca4
(sh-mode): Add autoload cookie.
Erik Naggum <erik@naggum.no>
parents:
14211
diff
changeset
|
660 |
cd28284abca4
(sh-mode): Add autoload cookie.
Erik Naggum <erik@naggum.no>
parents:
14211
diff
changeset
|
661 ;;;###autoload |
6463 | 662 (defun sh-mode () |
663 "Major mode for editing shell scripts. | |
664 This mode works for many shells, since they all have roughly the same syntax, | |
665 as far as commands, arguments, variables, pipes, comments etc. are concerned. | |
666 Unless the file's magic number indicates the shell, your usual shell is | |
667 assumed. Since filenames rarely give a clue, they are not further analyzed. | |
668 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
669 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
|
670 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
|
671 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
|
672 shell-specific features. |
6463 | 673 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
674 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
|
675 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
|
676 following commands are available, based on the current shell's syntax: |
6463 | 677 |
678 \\[sh-case] case statement | |
679 \\[sh-for] for loop | |
680 \\[sh-function] function definition | |
681 \\[sh-if] if statement | |
682 \\[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
|
683 \\[sh-while-getopts] while getopts loop |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
684 \\[sh-repeat] repeat loop |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
685 \\[sh-select] select loop |
6463 | 686 \\[sh-until] until loop |
687 \\[sh-while] while loop | |
688 | |
689 \\[backward-delete-char-untabify] Delete backward one position, even if it was a tab. | |
690 \\[sh-newline-and-indent] Delete unquoted space and indent new line same as this one. | |
691 \\[sh-end-of-command] Go to end of successive commands. | |
692 \\[sh-beginning-of-command] Go to beginning of successive commands. | |
693 \\[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
|
694 \\[sh-execute-region] Have optional header and region be executed in a subshell. |
6463 | 695 |
696 \\[sh-maybe-here-document] Without prefix, following an unquoted < inserts here document. | |
697 {, (, [, ', \", ` | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
698 Unless quoted with \\, insert the pairs {}, (), [], or '', \"\", ``. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
699 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
700 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
|
701 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
|
702 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
|
703 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
704 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
|
705 with your script for an edit-interpret-debug cycle." |
6463 | 706 (interactive) |
707 (kill-all-local-variables) | |
708 (use-local-map sh-mode-map) | |
709 (make-local-variable 'indent-line-function) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
710 (make-local-variable 'indent-region-function) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
711 (make-local-variable 'skeleton-end-hook) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
712 (make-local-variable 'paragraph-start) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
713 (make-local-variable 'paragraph-separate) |
6463 | 714 (make-local-variable 'comment-start) |
715 (make-local-variable 'comment-start-skip) | |
716 (make-local-variable 'require-final-newline) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
717 (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
|
718 (make-local-variable 'sh-shell-file) |
6463 | 719 (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
|
720 (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
|
721 (make-local-variable 'skeleton-pair-filter) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
722 (make-local-variable 'comint-dynamic-complete-functions) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
723 (make-local-variable 'comint-prompt-regexp) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
724 (make-local-variable 'font-lock-defaults) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
725 (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
|
726 (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
|
727 (make-local-variable 'sh-shell-variables) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
728 (make-local-variable 'sh-shell-variables-initialized) |
20395
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
729 (make-local-variable 'imenu-generic-expression) |
6463 | 730 (setq major-mode 'sh-mode |
731 mode-name "Shell-script" | |
732 indent-line-function 'sh-indent-line | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
733 ;; 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
|
734 indent-region-function (lambda (b e) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
735 (save-excursion |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
736 (goto-char b) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
737 (skip-syntax-backward "-") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
738 (setq b (point)) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
739 (goto-char e) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
740 (skip-syntax-backward "-") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
741 (indent-rigidly b (point) sh-indentation))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
742 skeleton-end-hook (lambda () |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
743 (or (eolp) (newline) (indent-relative))) |
13705
4111cc3136d1
(sh-mode-map): Make the code more legible.
Karl Heuer <kwzh@gnu.org>
parents:
13510
diff
changeset
|
744 paragraph-start (concat page-delimiter "\\|$") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
745 paragraph-separate paragraph-start |
6463 | 746 comment-start "# " |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
747 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
|
748 ;; 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
|
749 comint-prompt-regexp "^[ \t]*" |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
750 font-lock-defaults |
18024
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
751 '((sh-font-lock-keywords |
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
752 sh-font-lock-keywords-1 sh-font-lock-keywords-2) |
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
753 nil nil |
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
754 ((?/ . "w") (?~ . "w") (?. . "w") (?- . "w") (?_ . "w")) nil |
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
755 (font-lock-syntactic-keywords . sh-font-lock-syntactic-keywords)) |
12864
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
756 skeleton-pair-alist '((?` _ ?`)) |
3b9dcd964c66
(sh-mode-map): Use new name skeleton-pair-insert-maybe.
Karl Heuer <kwzh@gnu.org>
parents:
12863
diff
changeset
|
757 skeleton-pair-filter 'sh-quoted-p |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
758 skeleton-further-elements '((< '(- (min sh-indentation |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
759 (current-column))))) |
12887
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
760 skeleton-filter 'sh-feature |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
761 skeleton-newline-indent-rigidly t) |
22783
1fb9133a2851
(sh-mode): parse-sexp-ignore-comments = t.
Richard M. Stallman <rms@gnu.org>
parents:
21980
diff
changeset
|
762 (make-local-variable 'parse-sexp-ignore-comments) |
1fb9133a2851
(sh-mode): parse-sexp-ignore-comments = t.
Richard M. Stallman <rms@gnu.org>
parents:
21980
diff
changeset
|
763 (setq parse-sexp-ignore-comments t) |
16552
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
764 ;; Parse or insert magic number for exec, and set all variables depending |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
765 ;; on the shell thus determined. |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
766 (let ((interpreter |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
767 (save-excursion |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
768 (goto-char (point-min)) |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
769 (if (looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)") |
18024
58afe194f1bd
Update for syntax-table text properties.
Simon Marshall <simon@gnu.org>
parents:
17531
diff
changeset
|
770 (match-string 2))))) |
16552
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
771 (if interpreter |
17260
e32d514a22cc
(sh-set-shell): If file has no #! line,
Richard M. Stallman <rms@gnu.org>
parents:
17213
diff
changeset
|
772 (sh-set-shell interpreter nil nil) |
20385
e1ea41eba8be
(sh-mode): Set `comment-start-skip' always.
Dave Love <fx@gnu.org>
parents:
19578
diff
changeset
|
773 (progn |
e1ea41eba8be
(sh-mode): Set `comment-start-skip' always.
Dave Love <fx@gnu.org>
parents:
19578
diff
changeset
|
774 ;; If we don't know the shell for this file, set the syntax |
e1ea41eba8be
(sh-mode): Set `comment-start-skip' always.
Dave Love <fx@gnu.org>
parents:
19578
diff
changeset
|
775 ;; table anyway, for the user's normal choice of shell. |
e1ea41eba8be
(sh-mode): Set `comment-start-skip' always.
Dave Love <fx@gnu.org>
parents:
19578
diff
changeset
|
776 (set-syntax-table (sh-feature sh-mode-syntax-table)) |
e1ea41eba8be
(sh-mode): Set `comment-start-skip' always.
Dave Love <fx@gnu.org>
parents:
19578
diff
changeset
|
777 ;; And avoid indent-new-comment-line (at least) losing. |
e1ea41eba8be
(sh-mode): Set `comment-start-skip' always.
Dave Love <fx@gnu.org>
parents:
19578
diff
changeset
|
778 (setq comment-start-skip "#+[\t ]*")))) |
6463 | 779 (run-hooks 'sh-mode-hook)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
780 ;;;###autoload |
6463 | 781 (defalias 'shell-script-mode 'sh-mode) |
782 | |
783 | |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
784 (defun sh-font-lock-keywords (&optional keywords) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
785 "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
|
786 This adds rules for comments and assignments." |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
787 (sh-feature sh-font-lock-keywords |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
788 (lambda (list) |
16535
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
789 `((,(sh-feature sh-assignment-regexp) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
790 1 font-lock-variable-name-face) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
791 ,@keywords |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
792 ,@list)))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
793 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
794 (defun sh-font-lock-keywords-1 (&optional builtins) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
795 "Function to get better fontification including keywords." |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
796 (let ((keywords (concat "\\([;(){}`|&]\\|^\\)[ \t]*\\(\\(\\(" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
797 (mapconcat 'identity |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
798 (sh-feature sh-leading-keywords) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
799 "\\|") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
800 "\\)[ \t]+\\)?\\(" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
801 (mapconcat 'identity |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
802 (append (sh-feature sh-leading-keywords) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
803 (sh-feature sh-other-keywords)) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
804 "\\|") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
805 "\\)"))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
806 (sh-font-lock-keywords |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
807 `(,@(if builtins |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
808 `((,(concat keywords "[ \t]+\\)?\\(" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
809 (mapconcat 'identity (sh-feature sh-builtins) "\\|") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
810 "\\)\\>") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
811 (2 font-lock-keyword-face nil t) |
16478 | 812 (6 font-lock-builtin-face)) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
813 ,@(sh-feature sh-font-lock-keywords-2))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
814 (,(concat keywords "\\)\\>") |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
815 2 font-lock-keyword-face) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
816 ,@(sh-feature sh-font-lock-keywords-1))))) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
817 |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
818 (defun sh-font-lock-keywords-2 () |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
819 "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
|
820 (sh-font-lock-keywords-1 t)) |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
821 |
6463 | 822 |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
823 (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
|
824 "Set this buffer's shell to SHELL (a string). |
16552
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
825 Makes this script executable via `executable-set-magic', and sets up the |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
826 proper starting #!-line, if INSERT-FLAG is non-nil. |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
827 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
|
828 (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
|
829 interpreter-mode-alist |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
830 (lambda (x) (eq (cdr x) 'sh-mode))) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
831 (eq executable-query 'function) |
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
832 t)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
833 (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
|
834 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
|
835 sh-shell)) |
16552
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
836 (if insert-flag |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
837 (setq sh-shell-file |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
838 (executable-set-magic shell (sh-feature sh-shell-arg) |
fe3d32bca2c5
(sh-set-shell): Pass args no-query-flag
Richard M. Stallman <rms@gnu.org>
parents:
16535
diff
changeset
|
839 no-query-flag insert-flag))) |
14148
fa30f7528502
(sh-mode): Don't move point.
Richard M. Stallman <rms@gnu.org>
parents:
14119
diff
changeset
|
840 (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
|
841 ;;; local-abbrev-table (sh-feature sh-abbrevs) |
17356
9f345ed0683e
(sh-mode): Set font-lock-comment-start-regexp via font-lock-defaults.
Richard M. Stallman <rms@gnu.org>
parents:
17260
diff
changeset
|
842 ;; Packages should not need to set these variables directly. sm. |
9f345ed0683e
(sh-mode): Set font-lock-comment-start-regexp via font-lock-defaults.
Richard M. Stallman <rms@gnu.org>
parents:
17260
diff
changeset
|
843 ; font-lock-keywords nil ; force resetting |
9f345ed0683e
(sh-mode): Set font-lock-comment-start-regexp via font-lock-defaults.
Richard M. Stallman <rms@gnu.org>
parents:
17260
diff
changeset
|
844 ; font-lock-syntax-table nil |
16535
d5eeca7cdaf2
(sh-mode-syntax-table): Turn on comment syntax for #,
Richard M. Stallman <rms@gnu.org>
parents:
16533
diff
changeset
|
845 comment-start-skip "#+[\t ]*" |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
846 mode-line-process (format "[%s]" sh-shell) |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
847 sh-shell-variables nil |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
848 sh-shell-variables-initialized nil |
20395
2bd6621697d5
(sh-imenu-generic-expression): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
20385
diff
changeset
|
849 imenu-generic-expression (sh-feature sh-imenu-generic-expression) |
20459 | 850 imenu-case-fold-search nil |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
851 shell (sh-feature sh-variables)) |
20886
7aa1fdcd551a
(sh-set-shell): Use standard-syntax-table if none other is specified.
Richard M. Stallman <rms@gnu.org>
parents:
20771
diff
changeset
|
852 (set-syntax-table (or (sh-feature sh-mode-syntax-table) |
7aa1fdcd551a
(sh-set-shell): Use standard-syntax-table if none other is specified.
Richard M. Stallman <rms@gnu.org>
parents:
20771
diff
changeset
|
853 (standard-syntax-table))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
854 (while shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
855 (sh-remember-variable (car shell)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
856 (setq shell (cdr shell))) |
17356
9f345ed0683e
(sh-mode): Set font-lock-comment-start-regexp via font-lock-defaults.
Richard M. Stallman <rms@gnu.org>
parents:
17260
diff
changeset
|
857 ;; Packages should not need to toggle Font Lock mode. sm. |
9f345ed0683e
(sh-mode): Set font-lock-comment-start-regexp via font-lock-defaults.
Richard M. Stallman <rms@gnu.org>
parents:
17260
diff
changeset
|
858 ; (and (boundp 'font-lock-mode) |
9f345ed0683e
(sh-mode): Set font-lock-comment-start-regexp via font-lock-defaults.
Richard M. Stallman <rms@gnu.org>
parents:
17260
diff
changeset
|
859 ; font-lock-mode |
9f345ed0683e
(sh-mode): Set font-lock-comment-start-regexp via font-lock-defaults.
Richard M. Stallman <rms@gnu.org>
parents:
17260
diff
changeset
|
860 ; (font-lock-mode (font-lock-mode 0))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
861 (run-hooks 'sh-set-shell-hook)) |
6463 | 862 |
863 | |
864 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
865 (defun sh-feature (list &optional function) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
866 "Index ALIST by the current shell. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
867 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
|
868 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
|
869 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
870 - 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
|
871 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
|
872 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
873 - 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
|
874 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
|
875 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
|
876 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
|
877 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
|
878 alist element is the current shell. |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
879 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
|
880 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
881 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
|
882 in ALIST." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
883 (or (if (consp list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
884 (let ((l list)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
885 (while (and l (consp (car l))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
886 (setq l (cdr l))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
887 (if l list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
888 (if function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
889 (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
|
890 (let ((sh-shell sh-shell) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
891 elt val) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
892 (while (and sh-shell |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
893 (not (setq elt (assq sh-shell list)))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
894 (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
|
895 (if (and (consp (setq val (cdr elt))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
896 (eq (car val) 'eval)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
897 (setcdr elt |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
898 (setq val |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
899 (eval (if (consp (setq val (cdr val))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
900 (let ((sh-shell (car (cdr val))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
901 function) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
902 (if (assq sh-shell list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
903 (setcar (cdr val) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
904 (list 'quote |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
905 (sh-feature list)))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
906 val) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
907 val))))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
908 (if function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
909 (nconc list |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
910 (list (cons function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
911 (setq sh-shell (car function) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
912 val (funcall (cdr function) val)))))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
913 val))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
914 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
915 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
916 |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
917 ;;; 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
|
918 ;;;(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
|
919 ;;; "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
|
920 ;;;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
|
921 ;;;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
|
922 ;;;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
|
923 ;;;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
|
924 ;;; (or (if (boundp sh-shell) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
925 ;;; (symbol-value sh-shell)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
926 ;;; (progn |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
927 ;;; (if (listp ancestor) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
928 ;;; (nconc list ancestor)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
929 ;;; (define-abbrev-table sh-shell ()) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
930 ;;; (if (vectorp ancestor) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
931 ;;; (mapatoms (lambda (atom) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
932 ;;; (or (eq atom 0) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
933 ;;; (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
|
934 ;;; (symbol-name atom) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
935 ;;; (symbol-value atom) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
936 ;;; (symbol-function atom)))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
937 ;;; ancestor)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
938 ;;; (while list |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
939 ;;; (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
|
940 ;;; (car list) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
941 ;;; (if (stringp (car (cdr list))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
942 ;;; (car (cdr list)) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
943 ;;; "") |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
944 ;;; (if (symbolp (car (cdr list))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
945 ;;; (car (cdr list)))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
946 ;;; (setq list (cdr (cdr list))))) |
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
947 ;;; (symbol-value sh-shell))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
948 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
949 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
950 (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
|
951 "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
|
952 (setq table (copy-syntax-table table)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
953 (while list |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
954 (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
|
955 (setq list (cdr (cdr list)))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
956 table) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
957 |
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 (defun sh-append (ancestor &rest list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
960 "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
|
961 (nconc list ancestor)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
962 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
963 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
964 (defun sh-modify (skeleton &rest list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
965 "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
|
966 (setq skeleton (copy-sequence skeleton)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
967 (while list |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
968 (setcar (or (nthcdr (car list) skeleton) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
969 (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
|
970 (car (cdr list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
971 (setq list (nthcdr 2 list))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
972 skeleton) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
973 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
974 |
6463 | 975 (defun sh-indent-line () |
19480
7f11f103a0ca
(sh-indent-line): Avoid infinite loop
Richard M. Stallman <rms@gnu.org>
parents:
18382
diff
changeset
|
976 "Indent a line for Sh mode (shell script mode). |
7f11f103a0ca
(sh-indent-line): Avoid infinite loop
Richard M. Stallman <rms@gnu.org>
parents:
18382
diff
changeset
|
977 Indent as far as preceding non-empty line, then by steps of `sh-indentation'. |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
978 Lines containing only comments are considered empty." |
6463 | 979 (interactive) |
980 (let ((previous (save-excursion | |
19480
7f11f103a0ca
(sh-indent-line): Avoid infinite loop
Richard M. Stallman <rms@gnu.org>
parents:
18382
diff
changeset
|
981 (while (and (progn (beginning-of-line) |
7f11f103a0ca
(sh-indent-line): Avoid infinite loop
Richard M. Stallman <rms@gnu.org>
parents:
18382
diff
changeset
|
982 (not (bobp))) |
14211
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
983 (progn |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
984 (forward-line -1) |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
985 (back-to-indentation) |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
986 (or (eolp) |
949aa01aca87
(sh-indent-line): Cope if no previous noncomment line.
Richard M. Stallman <rms@gnu.org>
parents:
14195
diff
changeset
|
987 (eq (following-char) ?#))))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
988 (current-column))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
989 current) |
6463 | 990 (save-excursion |
991 (indent-to (if (eq this-command 'newline-and-indent) | |
992 previous | |
993 (if (< (current-column) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
994 (setq current (progn (back-to-indentation) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
995 (current-column)))) |
6463 | 996 (if (eolp) previous 0) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
997 (delete-region (point) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
998 (progn (beginning-of-line) (point))) |
6463 | 999 (if (eolp) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1000 (max previous (* (1+ (/ current sh-indentation)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1001 sh-indentation)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1002 (* (1+ (/ current sh-indentation)) sh-indentation)))))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1003 (if (< (current-column) (current-indentation)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1004 (skip-chars-forward " \t")))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1005 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1006 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1007 (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
|
1008 "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
|
1009 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
|
1010 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
|
1011 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1012 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
|
1013 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
|
1014 region, clear header." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1015 (interactive "r\nP") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1016 (if flag |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1017 (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
|
1018 (point-marker))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1019 (if sh-header-marker |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1020 (save-excursion |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1021 (let (buffer-undo-list) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1022 (goto-char sh-header-marker) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1023 (append-to-buffer (current-buffer) start end) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1024 (shell-command-on-region (point-min) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1025 (setq end (+ sh-header-marker |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1026 (- end start))) |
14119
2a05fc406f3a
(sh-alias-alist): Don't map sh to bash.
Karl Heuer <kwzh@gnu.org>
parents:
14026
diff
changeset
|
1027 sh-shell-file) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1028 (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
|
1029 (shell-command-on-region start end (concat sh-shell-file " -"))))) |
6463 | 1030 |
1031 | |
1032 (defun sh-remember-variable (var) | |
1033 "Make VARIABLE available for future completing reads in this buffer." | |
1034 (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
|
1035 (getenv var) |
14195
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1036 (assoc var sh-shell-variables) |
df3c52ae5b14
(sh-shell-variables): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
1037 (setq sh-shell-variables (cons (cons var var) sh-shell-variables))) |
6463 | 1038 var) |
1039 | |
1040 | |
1041 | |
1042 (defun sh-quoted-p () | |
1043 "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
|
1044 (eq -1 (% (save-excursion (skip-chars-backward "\\\\")) 2))) |
6463 | 1045 |
1046 ;; statement syntax-commands for various shells | |
1047 | |
1048 ;; You are welcome to add the syntax or even completely new statements as | |
1049 ;; appropriate for your favorite shell. | |
1050 | |
17531
b891e41b4011
(sh-case): Make this a simple define-skeleton
Richard M. Stallman <rms@gnu.org>
parents:
17501
diff
changeset
|
1051 (define-skeleton sh-case |
b891e41b4011
(sh-case): Make this a simple define-skeleton
Richard M. Stallman <rms@gnu.org>
parents:
17501
diff
changeset
|
1052 "Insert a case/switch statement. See `sh-feature'." |
20771
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1053 (csh "expression: " |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1054 "switch( " str " )" \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1055 > "case " (read-string "pattern: ") ?: \n |
17531
b891e41b4011
(sh-case): Make this a simple define-skeleton
Richard M. Stallman <rms@gnu.org>
parents:
17501
diff
changeset
|
1056 > _ \n |
20771
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1057 "breaksw" \n |
17531
b891e41b4011
(sh-case): Make this a simple define-skeleton
Richard M. Stallman <rms@gnu.org>
parents:
17501
diff
changeset
|
1058 ( "other pattern, %s: " |
20771
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1059 < "case " str ?: \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1060 > _ \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1061 "breaksw" \n) |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1062 < "default:" \n |
17531
b891e41b4011
(sh-case): Make this a simple define-skeleton
Richard M. Stallman <rms@gnu.org>
parents:
17501
diff
changeset
|
1063 > _ \n |
b891e41b4011
(sh-case): Make this a simple define-skeleton
Richard M. Stallman <rms@gnu.org>
parents:
17501
diff
changeset
|
1064 resume: |
20771
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1065 < < "endsw") |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1066 (es) |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1067 (rc "expression: " |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1068 "switch( " str " ) {" \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1069 > "case " (read-string "pattern: ") \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1070 > _ \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1071 ( "other pattern, %s: " |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1072 < "case " str \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1073 > _ \n) |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1074 < "case *" \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1075 > _ \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1076 resume: |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1077 < < ?}) |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1078 (sh "expression: " |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1079 "case " str " in" \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1080 > (read-string "pattern: ") ?\) \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1081 > _ \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1082 ";;" \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1083 ( "other pattern, %s: " |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1084 < str ?\) \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1085 > _ \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1086 ";;" \n) |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1087 < "*)" \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1088 > _ \n |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1089 resume: |
c6d9f48bd2f8
(sh-case): Fix paren error.
Richard M. Stallman <rms@gnu.org>
parents:
20459
diff
changeset
|
1090 < < "esac")) |
6463 | 1091 |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1092 (define-skeleton sh-for |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1093 "Insert a for loop. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1094 (csh eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1095 1 "foreach " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1096 3 " ( " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1097 5 " )" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1098 15 "end") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1099 (es eval sh-modify rc |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1100 3 " = ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1101 (rc eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1102 1 "for( " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1103 5 " ) {" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1104 15 ?}) |
6463 | 1105 (sh "Index variable: " |
1106 "for " str " in " _ "; do" \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1107 > _ | ?$ & (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1108 < "done")) |
6463 | 1109 |
1110 | |
1111 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1112 (define-skeleton sh-indexed-loop |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1113 "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
|
1114 (bash eval identity posix) |
6463 | 1115 (csh "Index variable: " |
1116 "@ " str " = 1" \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1117 "while( $" str " <= " (read-string "upper limit: ") " )" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1118 > _ ?$ str \n |
6463 | 1119 "@ " str "++" \n |
1120 < "end") | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1121 (es eval sh-modify rc |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1122 3 " =") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1123 (ksh88 "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1124 "integer " str "=0" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1125 "while (( ( " str " += 1 ) <= " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1126 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1127 " )); do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1128 > _ ?$ (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1129 < "done") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1130 (posix "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1131 str "=1" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1132 "while [ $" str " -le " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1133 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1134 " ]; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1135 > _ ?$ str \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1136 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
|
1137 < "done") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1138 (rc "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1139 "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
|
1140 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1141 "; i++ ) print i }'}) {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1142 > _ ?$ (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1143 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1144 (sh "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1145 "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
|
1146 (read-string "upper limit: ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1147 "; i++ ) print i }'`; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1148 > _ ?$ (sh-remember-variable str) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1149 < "done")) |
6463 | 1150 |
1151 | |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1152 (defun sh-shell-initialize-variables () |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1153 "Scan the buffer for variable assignments. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1154 Add these variables to `sh-shell-variables'." |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1155 (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
|
1156 (save-excursion |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1157 (goto-char (point-min)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1158 (setq sh-shell-variables-initialized t) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1159 (while (search-forward "=" nil t) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1160 (sh-assignment 0))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1161 (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
|
1162 (buffer-name))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1163 |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1164 (defvar sh-add-buffer) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1165 |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1166 (defun sh-add-completer (string predicate code) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1167 "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
|
1168 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
|
1169 so it takes three arguments: |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1170 STRING, the current buffer contents; |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1171 PREDICATE, the predicate for filtering possible matches; |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1172 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
|
1173 CODE can be nil, t or `lambda'. |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1174 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
|
1175 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
|
1176 `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
|
1177 (let ((sh-shell-variables |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1178 (save-excursion |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1179 (set-buffer sh-add-buffer) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1180 (or sh-shell-variables-initialized |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1181 (sh-shell-initialize-variables)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1182 (nconc (mapcar (lambda (var) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1183 (let ((name |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1184 (substring var 0 (string-match "=" var)))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1185 (cons name name))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1186 process-environment) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1187 sh-shell-variables)))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1188 (cond ((null code) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1189 (try-completion string sh-shell-variables predicate)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1190 ((eq code t) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1191 (all-completions string sh-shell-variables predicate)) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1192 ((eq code 'lambda) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1193 (assoc string sh-shell-variables))))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1194 |
6463 | 1195 (defun sh-add (var delta) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1196 "Insert an addition of VAR and prefix DELTA for Bourne (type) shell." |
6463 | 1197 (interactive |
14418
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1198 (let ((sh-add-buffer (current-buffer))) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1199 (list (completing-read "Variable: " 'sh-add-completer) |
7f58ca0014ef
(sh-shell-variables-initialized): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14221
diff
changeset
|
1200 (prefix-numeric-value current-prefix-arg)))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1201 (insert (sh-feature '((bash . "$[ ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1202 (ksh88 . "$(( ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1203 (posix . "$(( ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1204 (rc . "`{expr $") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1205 (sh . "`expr $") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1206 (zsh . "$[ "))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1207 (sh-remember-variable var) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1208 (if (< delta 0) " - " " + ") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1209 (number-to-string (abs delta)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1210 (sh-feature '((bash . " ]") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1211 (ksh88 . " ))") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1212 (posix . " ))") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1213 (rc . "}") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1214 (sh . "`") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1215 (zsh . " ]"))))) |
6463 | 1216 |
1217 | |
1218 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1219 (define-skeleton sh-function |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1220 "Insert a function definition. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1221 (bash eval sh-modify ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1222 3 "() {") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1223 (ksh88 "name: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1224 "function " str " {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1225 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1226 < "}") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1227 (rc eval sh-modify ksh88 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1228 1 "fn ") |
6463 | 1229 (sh () |
1230 "() {" \n | |
1231 > _ \n | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1232 < "}")) |
6463 | 1233 |
1234 | |
1235 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1236 (define-skeleton sh-if |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1237 "Insert an if statement. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1238 (csh "condition: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1239 "if( " str " ) then" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1240 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1241 ( "other condition, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1242 < "else if( " str " ) then" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1243 > _ \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1244 < "else" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1245 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1246 resume: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1247 < "endif") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1248 (es "condition: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1249 "if { " str " } {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1250 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1251 ( "other condition, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1252 < "} { " str " } {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1253 > _ \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1254 < "} {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1255 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1256 resume: |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1257 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1258 (rc eval sh-modify csh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1259 3 " ) {" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1260 8 '( "other condition, %s: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1261 < "} else if( " str " ) {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1262 > _ \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1263 10 "} else {" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1264 17 ?}) |
6463 | 1265 (sh "condition: " |
12863 | 1266 '(setq input (sh-feature sh-test)) |
1267 "if " str "; then" \n | |
6463 | 1268 > _ \n |
1269 ( "other condition, %s: " | |
12863 | 1270 < "elif " str "; then" \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1271 > _ \n) |
6463 | 1272 < "else" \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1273 > _ \n |
6463 | 1274 resume: |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1275 < "fi")) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1276 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1277 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1278 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1279 (define-skeleton sh-repeat |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1280 "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
|
1281 (es nil |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1282 "forever {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1283 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1284 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1285 (zsh "factor: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1286 "repeat " str "; do"\n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1287 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1288 < "done")) |
17501
478f9bb8575c
Remove all menu-enable properties except for sh-case.
Richard M. Stallman <rms@gnu.org>
parents:
17480
diff
changeset
|
1289 ;;;(put 'sh-repeat 'menu-enable '(sh-feature sh-repeat)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1290 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1291 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1292 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1293 (define-skeleton sh-select |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1294 "Insert a select statement. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1295 (ksh88 "Index variable: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1296 "select " str " in " _ "; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1297 > ?$ str \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1298 < "done")) |
17501
478f9bb8575c
Remove all menu-enable properties except for sh-case.
Richard M. Stallman <rms@gnu.org>
parents:
17480
diff
changeset
|
1299 ;;;(put 'sh-select 'menu-enable '(sh-feature sh-select)) |
6463 | 1300 |
1301 | |
1302 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1303 (define-skeleton sh-tmp-file |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1304 "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
|
1305 (bash eval identity ksh88) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1306 (csh (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1307 "set tmp = /tmp/" str ".$$" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1308 "onintr exit" \n _ |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1309 (and (goto-char (point-max)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1310 (not (bolp)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1311 ?\n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1312 "exit:\n" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1313 "rm $tmp* >&/dev/null" >) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1314 (es (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1315 "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
|
1316 > "catch @ e {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1317 > "rm $tmp^* >[2]/dev/null" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1318 "throw $e" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1319 < "} {" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1320 > _ \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1321 < ?} \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1322 < ?}) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1323 (ksh88 eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1324 6 "EXIT") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1325 (rc (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1326 "tmp = /tmp/" str ".$pid" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1327 "fn sigexit { rm $tmp^* >[2]/dev/null }") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1328 (sh (file-name-nondirectory (buffer-file-name)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1329 "TMP=/tmp/" str ".$$" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1330 "trap \"rm $TMP* 2>/dev/null\" " ?0)) |
6463 | 1331 |
1332 | |
1333 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1334 (define-skeleton sh-until |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1335 "Insert an until loop. See `sh-feature'." |
6463 | 1336 (sh "condition: " |
12863 | 1337 '(setq input (sh-feature sh-test)) |
1338 "until " str "; do" \n | |
6463 | 1339 > _ \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1340 < "done")) |
17501
478f9bb8575c
Remove all menu-enable properties except for sh-case.
Richard M. Stallman <rms@gnu.org>
parents:
17480
diff
changeset
|
1341 ;;;(put 'sh-until 'menu-enable '(sh-feature sh-until)) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1342 |
6463 | 1343 |
1344 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1345 (define-skeleton sh-while |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1346 "Insert a while loop. See `sh-feature'." |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1347 (csh eval sh-modify sh |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1348 2 "while( " |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1349 4 " )" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1350 10 "end") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1351 (es eval sh-modify rc |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1352 2 "while { " |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1353 4 " } {") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1354 (rc eval sh-modify csh |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1355 4 " ) {" |
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1356 10 ?}) |
6463 | 1357 (sh "condition: " |
12863 | 1358 '(setq input (sh-feature sh-test)) |
1359 "while " str "; do" \n | |
6463 | 1360 > _ \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1361 < "done")) |
6463 | 1362 |
1363 | |
1364 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1365 (define-skeleton sh-while-getopts |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1366 "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
|
1367 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
|
1368 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
|
1369 (bash eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1370 18 "${0##*/}") |
12863 | 1371 (csh nil |
1372 "while( 1 )" \n | |
1373 > "switch( \"$1\" )" \n | |
1374 '(setq input '("- x" . 2)) | |
1375 > > | |
1376 ( "option, %s: " | |
1377 < "case " '(eval str) | |
1378 '(if (string-match " +" str) | |
1379 (setq v1 (substring str (match-end 0)) | |
1380 str (substring str 0 (match-beginning 0))) | |
1381 (setq v1 nil)) | |
1382 str ?: \n | |
1383 > "set " v1 & " = $2" | -4 & _ \n | |
1384 (if v1 "shift") & \n | |
1385 "breaksw" \n) | |
1386 < "case --:" \n | |
1387 > "shift" \n | |
1388 < "default:" \n | |
1389 > "break" \n | |
1390 resume: | |
1391 < < "endsw" \n | |
1392 "shift" \n | |
1393 < "end") | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1394 (ksh88 eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1395 16 "print" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1396 18 "${0##*/}" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1397 36 "OPTIND-1") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1398 (posix eval sh-modify sh |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1399 18 "$(basename $0)") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1400 (sh "optstring: " |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1401 "while getopts :" str " OPT; do" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1402 > "case $OPT in" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1403 > > |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1404 '(setq v1 (append (vconcat str) nil)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1405 ( (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
|
1406 (if (eq (nth 1 v1) ?:) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1407 (setq v1 (nthcdr 2 v1) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1408 v2 "\"$OPTARG\"") |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1409 (setq v1 (cdr v1) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1410 v2 nil))) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1411 < str "|+" str ?\) \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1412 > _ v2 \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1413 ";;" \n) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1414 < "*)" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1415 > "echo" " \"usage: " "`basename $0`" |
15027
30c4f64f3579
(sh-while-getopts): Punctuate help message better.
Richard M. Stallman <rms@gnu.org>
parents:
14892
diff
changeset
|
1416 " [+-" '(setq v1 (point)) str |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1417 '(save-excursion |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1418 (while (search-backward ":" v1 t) |
15027
30c4f64f3579
(sh-while-getopts): Punctuate help message better.
Richard M. Stallman <rms@gnu.org>
parents:
14892
diff
changeset
|
1419 (replace-match " ARG] [+-" t t))) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1420 (if (eq (preceding-char) ?-) -5) |
15027
30c4f64f3579
(sh-while-getopts): Punctuate help message better.
Richard M. Stallman <rms@gnu.org>
parents:
14892
diff
changeset
|
1421 "] [--] ARGS...\"" \n |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1422 "exit 2" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1423 < < "esac" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1424 < "done" \n |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1425 "shift " (sh-add "OPTIND" -1))) |
6463 | 1426 |
1427 | |
1428 | |
1429 (defun sh-assignment (arg) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1430 "Remember preceding identifier for future completion and do self-insert." |
6463 | 1431 (interactive "p") |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1432 (self-insert-command arg) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1433 (if (<= arg 1) |
6463 | 1434 (sh-remember-variable |
1435 (save-excursion | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1436 (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
|
1437 (prog1 (point) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1438 (beginning-of-line 1)) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1439 t) |
13391
550ecb2269b0
(sh-shells): Eliminated variable redundant with
Karl Heuer <kwzh@gnu.org>
parents:
13389
diff
changeset
|
1440 (match-string 1)))))) |
6463 | 1441 |
1442 | |
1443 | |
1444 (defun sh-maybe-here-document (arg) | |
1445 "Inserts self. Without prefix, following unquoted `<' inserts here document. | |
1446 The document is bounded by `sh-here-document-word'." | |
1447 (interactive "*P") | |
1448 (self-insert-command (prefix-numeric-value arg)) | |
1449 (or arg | |
1450 (not (eq (char-after (- (point) 2)) last-command-char)) | |
1451 (save-excursion | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1452 (backward-char 2) |
6463 | 1453 (sh-quoted-p)) |
1454 (progn | |
1455 (insert sh-here-document-word) | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1456 (or (eolp) (looking-at "[ \t]") (insert ? )) |
6463 | 1457 (end-of-line 1) |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1458 (while |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1459 (sh-quoted-p) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1460 (end-of-line 2)) |
6463 | 1461 (newline) |
1462 (save-excursion (insert ?\n sh-here-document-word))))) | |
1463 | |
1464 | |
1465 ;; various other commands | |
1466 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1467 (autoload 'comint-dynamic-complete "comint" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1468 "Dynamically perform completion at point." t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1469 |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1470 (autoload 'shell-dynamic-complete-command "shell" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1471 "Dynamically complete the command at point." t) |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1472 |
6463 | 1473 (autoload 'comint-dynamic-complete-filename "comint" |
1474 "Dynamically complete the filename at point." t) | |
1475 | |
12505
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1476 (autoload 'shell-dynamic-complete-environment-variable "shell" |
0f970ed476cb
restructured, largely rewritten without the bugs and
Karl Heuer <kwzh@gnu.org>
parents:
12034
diff
changeset
|
1477 "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
|
1478 |
6463 | 1479 |
1480 | |
12887
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1481 (defun sh-newline-and-indent () |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1482 "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
|
1483 (interactive "*") |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1484 (indent-to (prog1 (current-indentation) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1485 (delete-region (point) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1486 (progn |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1487 (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
|
1488 (if (sh-quoted-p) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1489 (forward-char))) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1490 (point))) |
cbed067bf52d
(sh-newline-and-indent): Don't interpret prefix arg
Karl Heuer <kwzh@gnu.org>
parents:
12864
diff
changeset
|
1491 (newline)))) |
6463 | 1492 |
1493 | |
1494 | |
1495 (defun sh-beginning-of-command () | |
1496 "Move point to successive beginnings of commands." | |
1497 (interactive) | |
1498 (if (re-search-backward sh-beginning-of-command nil t) | |
1499 (goto-char (match-beginning 2)))) | |
1500 | |
1501 | |
1502 (defun sh-end-of-command () | |
1503 "Move point to successive ends of commands." | |
1504 (interactive) | |
1505 (if (re-search-forward sh-end-of-command nil t) | |
1506 (goto-char (match-end 1)))) | |
1507 | |
13707 | 1508 (provide 'sh-script) |
18382 | 1509 |
6463 | 1510 ;; sh-script.el ends here |