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