comparison lisp/progmodes/tcl.el @ 51056:5dbeffb17d8e

(tcl-indent-exp): Remove dead code. (tcl-tab-always-indent): Default to tab-always-indent.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sat, 17 May 2003 22:43:51 +0000
parents 2aec3e4bf957
children 168bf1dc1b53
comparison
equal deleted inserted replaced
51055:b3d9bd5b31b8 51056:5dbeffb17d8e
1 ;;; tcl.el --- Tcl code editing commands for Emacs 1 ;;; tcl.el --- Tcl code editing commands for Emacs
2 2
3 ;; Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 3 ;; Copyright (C) 1994,98,1999,2000,01,02,2003 Free Software Foundation, Inc.
4 4
5 ;; Maintainer: FSF 5 ;; Maintainer: FSF
6 ;; Author: Tom Tromey <tromey@redhat.com> 6 ;; Author: Tom Tromey <tromey@redhat.com>
7 ;; Chris Lindblad <cjl@lcs.mit.edu> 7 ;; Chris Lindblad <cjl@lcs.mit.edu>
8 ;; Keywords: languages tcl modes 8 ;; Keywords: languages tcl modes
9 ;; Version: $Revision: 1.72 $ 9 ;; Version: $Revision: 1.73 $
10 10
11 ;; This file is part of GNU Emacs. 11 ;; This file is part of GNU Emacs.
12 12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify 13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by 14 ;; it under the terms of the GNU General Public License as published by
120 "Major mode for editing Tcl source in Emacs" 120 "Major mode for editing Tcl source in Emacs"
121 :group 'languages) 121 :group 'languages)
122 122
123 (defcustom tcl-indent-level 4 123 (defcustom tcl-indent-level 4
124 "*Indentation of Tcl statements with respect to containing block." 124 "*Indentation of Tcl statements with respect to containing block."
125 :group 'tcl
126 :type 'integer) 125 :type 'integer)
127 126
128 (defcustom tcl-continued-indent-level 4 127 (defcustom tcl-continued-indent-level 4
129 "*Indentation of continuation line relative to first line of command." 128 "*Indentation of continuation line relative to first line of command."
130 :group 'tcl
131 :type 'integer) 129 :type 'integer)
132 130
133 (defcustom tcl-auto-newline nil 131 (defcustom tcl-auto-newline nil
134 "*Non-nil means automatically newline before and after braces you insert." 132 "*Non-nil means automatically newline before and after braces you insert."
135 :group 'tcl
136 :type 'boolean) 133 :type 'boolean)
137 134
138 (defcustom tcl-tab-always-indent t 135 (defcustom tcl-tab-always-indent tab-always-indent
139 "*Control effect of TAB key. 136 "*Control effect of TAB key.
140 If t (the default), always indent current line. 137 If t (the default), always indent current line.
141 If nil and point is not in the indentation area at the beginning of 138 If nil and point is not in the indentation area at the beginning of
142 the line, a TAB is inserted. 139 the line, a TAB is inserted.
143 Other values cause the first possible action from the following list 140 Other values cause the first possible action from the following list
147 2. Delete an empty comment. 144 2. Delete an empty comment.
148 3. Move forward to start of comment, indenting if necessary. 145 3. Move forward to start of comment, indenting if necessary.
149 4. Move forward to end of line, indenting if necessary. 146 4. Move forward to end of line, indenting if necessary.
150 5. Create an empty comment. 147 5. Create an empty comment.
151 6. Move backward to start of comment, indenting if necessary." 148 6. Move backward to start of comment, indenting if necessary."
152 :group 'tcl
153 :type '(choice (const :tag "Always" t) 149 :type '(choice (const :tag "Always" t)
154 (const :tag "Beginning only" nil) 150 (const :tag "Beginning only" nil)
155 (const :tag "Maybe move or make or delete comment" 'tcl))) 151 (const :tag "Maybe move or make or delete comment" 'tcl)))
156 152
157 153
161 done; `quote', meaning that `\"' quoting should be done; `smart', 157 done; `quote', meaning that `\"' quoting should be done; `smart',
162 meaning that the choice between `backslash' and `quote' should be 158 meaning that the choice between `backslash' and `quote' should be
163 made depending on the number of hashes inserted; or nil, meaning that 159 made depending on the number of hashes inserted; or nil, meaning that
164 no quoting should be done. Any other value for this variable is 160 no quoting should be done. Any other value for this variable is
165 taken to mean `smart'. The default is nil." 161 taken to mean `smart'. The default is nil."
166 :group 'tcl
167 :type '(choice (const backslash) (const quote) (const smart) (const nil))) 162 :type '(choice (const backslash) (const quote) (const smart) (const nil)))
168 163
169 (defcustom tcl-help-directory-list nil 164 (defcustom tcl-help-directory-list nil
170 "*List of topmost directories containing TclX help files." 165 "*List of topmost directories containing TclX help files."
171 :group 'tcl
172 :type '(repeat directory)) 166 :type '(repeat directory))
173 167
174 (defcustom tcl-use-smart-word-finder t 168 (defcustom tcl-use-smart-word-finder t
175 "*If not nil, use smart way to find current word, for Tcl help feature." 169 "*If not nil, use smart way to find current word, for Tcl help feature."
176 :group 'tcl
177 :type 'boolean) 170 :type 'boolean)
178 171
179 (defcustom tcl-application "wish" 172 (defcustom tcl-application "wish"
180 "*Name of Tcl program to run in inferior Tcl mode." 173 "*Name of Tcl program to run in inferior Tcl mode."
181 :group 'tcl
182 :type 'string) 174 :type 'string)
183 175
184 (defcustom tcl-command-switches nil 176 (defcustom tcl-command-switches nil
185 "*List of switches to supply to the `tcl-application' program." 177 "*List of switches to supply to the `tcl-application' program."
186 :group 'tcl
187 :type '(repeat string)) 178 :type '(repeat string))
188 179
189 (defcustom tcl-prompt-regexp "^\\(% \\|\\)" 180 (defcustom tcl-prompt-regexp "^\\(% \\|\\)"
190 "*If not nil, a regexp that will match the prompt in the inferior process. 181 "*If not nil, a regexp that will match the prompt in the inferior process.
191 If nil, the prompt is the name of the application with \">\" appended. 182 If nil, the prompt is the name of the application with \">\" appended.
192 183
193 The default is \"^\\(% \\|\\)\", which will match the default primary 184 The default is \"^\\(% \\|\\)\", which will match the default primary
194 and secondary prompts for tclsh and wish." 185 and secondary prompts for tclsh and wish."
195 :group 'tcl
196 :type 'regexp) 186 :type 'regexp)
197 187
198 (defcustom inferior-tcl-source-command "source %s\n" 188 (defcustom inferior-tcl-source-command "source %s\n"
199 "*Format-string for building a Tcl command to load a file. 189 "*Format-string for building a Tcl command to load a file.
200 This format string should use `%s' to substitute a file name 190 This format string should use `%s' to substitute a file name
201 and should result in a Tcl expression that will command the 191 and should result in a Tcl expression that will command the
202 inferior Tcl to load that file. The filename will be appropriately 192 inferior Tcl to load that file. The filename will be appropriately
203 quoted for Tcl." 193 quoted for Tcl."
204 :group 'tcl
205 :type 'string) 194 :type 'string)
206 195
207 ;; 196 ;;
208 ;; Keymaps, abbrevs, syntax tables. 197 ;; Keymaps, abbrevs, syntax tables.
209 ;; 198 ;;
876 (interactive) 865 (interactive)
877 (let ((indent-stack (list nil)) 866 (let ((indent-stack (list nil))
878 (contain-stack (list (point))) 867 (contain-stack (list (point)))
879 (case-fold-search nil) 868 (case-fold-search nil)
880 outer-loop-done inner-loop-done state ostate 869 outer-loop-done inner-loop-done state ostate
881 this-indent last-sexp continued-line 870 this-indent continued-line
882 (next-depth 0) 871 (next-depth 0)
883 last-depth) 872 last-depth)
884 (save-excursion 873 (save-excursion
885 (forward-sexp 1)) 874 (forward-sexp 1))
886 (save-excursion 875 (save-excursion
896 (not (and (eobp) (setq outer-loop-done t)))) 885 (not (and (eobp) (setq outer-loop-done t))))
897 (setq ostate state) 886 (setq ostate state)
898 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point)) 887 (setq state (parse-partial-sexp (point) (progn (end-of-line) (point))
899 nil nil state)) 888 nil nil state))
900 (setq next-depth (car state)) 889 (setq next-depth (car state))
901 (if (and (car (cdr (cdr state)))
902 (>= (car (cdr (cdr state))) 0))
903 (setq last-sexp (car (cdr (cdr state)))))
904 (if (or (nth 4 ostate)) 890 (if (or (nth 4 ostate))
905 (tcl-indent-line)) 891 (tcl-indent-line))
906 (if (or (nth 3 state)) 892 (if (or (nth 3 state))
907 (forward-line 1) 893 (forward-line 1)
908 (setq inner-loop-done t))) 894 (setq inner-loop-done t)))
915 ;; doesn't indicate that they ended. 901 ;; doesn't indicate that they ended.
916 (while (> last-depth (nth 6 state)) 902 (while (> last-depth (nth 6 state))
917 (setq indent-stack (cdr indent-stack) 903 (setq indent-stack (cdr indent-stack)
918 contain-stack (cdr contain-stack) 904 contain-stack (cdr contain-stack)
919 last-depth (1- last-depth))) 905 last-depth (1- last-depth)))
920 (if (/= last-depth next-depth)
921 (setq last-sexp nil))
922 ;; Add levels for any parens that were started in this line. 906 ;; Add levels for any parens that were started in this line.
923 (while (< last-depth next-depth) 907 (while (< last-depth next-depth)
924 (setq indent-stack (cons nil indent-stack) 908 (setq indent-stack (cons nil indent-stack)
925 contain-stack (cons nil contain-stack) 909 contain-stack (cons nil contain-stack)
926 last-depth (1+ last-depth))) 910 last-depth (1+ last-depth)))