annotate lisp/progmodes/sh-script.el @ 13408:7e92386e1cf7

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