annotate lisp/progmodes/sh-script.el @ 17876:6e27f660a0be

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