comparison lisp/progmodes/tcl.el @ 44320:40a69f39b79f

Change maintainer. (tcl-electric-hash-style): Change default to nil. (tcl-imenu-generic-expression): Use tcl-proc-regexp. (tcl-do-auto-fill): Remove. (tcl-auto-fill-mode): Rewrite using comment-auto-fill-only-comments.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 01 Apr 2002 21:01:04 +0000
parents 443cf26a410a
children 1acfacdf062a
comparison
equal deleted inserted replaced
44319:6e4027f837d9 44320:40a69f39b79f
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, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
4 4
5 ;; Maintainer: Tom Tromey <tromey@redhat.com> 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.67 $ 9 ;; Version: $Revision: 1.68 $
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
58 ;; Carl Witty <cwitty@ai.mit.edu> 58 ;; Carl Witty <cwitty@ai.mit.edu>
59 ;; T. V. Raman <raman@crl.dec.com> 59 ;; T. V. Raman <raman@crl.dec.com>
60 ;; Jesper Pedersen <blackie@imada.ou.dk> 60 ;; Jesper Pedersen <blackie@imada.ou.dk>
61 ;; dfarmer@evolving.com (Doug Farmer) 61 ;; dfarmer@evolving.com (Doug Farmer)
62 ;; "Chris Alfeld" <calfeld@math.utah.edu> 62 ;; "Chris Alfeld" <calfeld@math.utah.edu>
63 ;; Ben Wing <wing@666.com> 63 ;; Ben Wing <ben@xemacs.org>
64 64
65 ;; KNOWN BUGS: 65 ;; KNOWN BUGS:
66 ;; * In Tcl "#" is not always a comment character. This can confuse 66 ;; * In Tcl "#" is not always a comment character. This can confuse tcl.el
67 ;; tcl.el in certain circumstances. For now the only workaround is 67 ;; in certain circumstances. For now the only workaround is to use
68 ;; to enclose offending hash characters in quotes or precede it with 68 ;; font-lock which will mark the # chars accordingly or enclose offending
69 ;; a backslash. Note that using braces won't work -- quotes change 69 ;; hash characters in quotes or precede them with a backslash. Note that
70 ;; the syntax class of characters between them, while braces do not. 70 ;; using braces won't work -- quotes change the syntax class of characters
71 ;; The electric-# mode helps alleviate this problem somewhat. 71 ;; between them, while braces do not. If you don't use font-lock, the
72 ;; electric-# mode helps alleviate this problem somewhat.
72 ;; * indent-tcl-exp is untested. 73 ;; * indent-tcl-exp is untested.
73 74
74 ;; TODO: 75 ;; TODO:
75 ;; * make add-log-tcl-defun smarter. should notice if we are in the 76 ;; * make add-log-tcl-defun smarter. should notice if we are in the
76 ;; middle of a defun, or between defuns. should notice if point is 77 ;; middle of a defun, or between defuns. should notice if point is
152 :type '(choice (const :tag "Always" t) 153 :type '(choice (const :tag "Always" t)
153 (const :tag "Beginning only" nil) 154 (const :tag "Beginning only" nil)
154 (const :tag "Maybe move or make or delete comment" 'tcl))) 155 (const :tag "Maybe move or make or delete comment" 'tcl)))
155 156
156 157
157 (defcustom tcl-electric-hash-style 'smart 158 (defcustom tcl-electric-hash-style nil ;; 'smart
158 "*Style of electric hash insertion to use. 159 "*Style of electric hash insertion to use.
159 Possible values are `backslash', meaning that `\\' quoting should be 160 Possible values are `backslash', meaning that `\\' quoting should be
160 done; `quote', meaning that `\"' quoting should be done; `smart', 161 done; `quote', meaning that `\"' quoting should be done; `smart',
161 meaning that the choice between `backslash' and `quote' should be 162 meaning that the choice between `backslash' and `quote' should be
162 made depending on the number of hashes inserted; or nil, meaning that 163 made depending on the number of hashes inserted; or nil, meaning that
163 no quoting should be done. Any other value for this variable is 164 no quoting should be done. Any other value for this variable is
164 taken to mean `smart'. The default is `smart'." 165 taken to mean `smart'. The default is nil."
165 :group 'tcl 166 :group 'tcl
166 :type '(choice (const backslash) (const quote) (const smart) (const nil))) 167 :type '(choice (const backslash) (const quote) (const smart) (const nil)))
167 168
168 (defcustom tcl-help-directory-list nil 169 (defcustom tcl-help-directory-list nil
169 "*List of topmost directories containing TclX help files." 170 "*List of topmost directories containing TclX help files."
506 () 507 ()
507 (tcl-set-font-lock-keywords)) 508 (tcl-set-font-lock-keywords))
508 509
509 510
510 (defvar tcl-imenu-generic-expression 511 (defvar tcl-imenu-generic-expression
511 '((nil "^proc[ \t]+\\([-A-Za-z0-9_:+*]+\\)" 1)) 512 `((nil ,(concat tcl-proc-regexp "\\([-A-Za-z0-9_:+*]+\\)") 2))
512 "Imenu generic expression for `tcl-mode'. See `imenu-generic-expression'.") 513 "Imenu generic expression for `tcl-mode'. See `imenu-generic-expression'.")
513 514
514 515
515 516
516 ;; 517 ;;
536 `tcl-tab-always-indent' 537 `tcl-tab-always-indent'
537 Controls action of TAB key. 538 Controls action of TAB key.
538 `tcl-auto-newline' 539 `tcl-auto-newline'
539 Non-nil means automatically newline before and after braces, brackets, 540 Non-nil means automatically newline before and after braces, brackets,
540 and semicolons inserted in Tcl code. 541 and semicolons inserted in Tcl code.
541 `tcl-electric-hash-style'
542 Controls action of `#' key.
543 `tcl-use-smart-word-finder' 542 `tcl-use-smart-word-finder'
544 If not nil, use a smarter, Tcl-specific way to find the current 543 If not nil, use a smarter, Tcl-specific way to find the current
545 word when looking up help on a Tcl command. 544 word when looking up help on a Tcl command.
546 545
547 Turning on Tcl mode calls the value of the variable `tcl-mode-hook' 546 Turning on Tcl mode calls the value of the variable `tcl-mode-hook'
1274 (save-restriction 1273 (save-restriction
1275 (narrow-to-region p-start p-end) 1274 (narrow-to-region p-start p-end)
1276 (fill-paragraph ignore))))) 1275 (fill-paragraph ignore)))))
1277 t) 1276 t)
1278 1277
1279 (defun tcl-do-auto-fill ()
1280 "Auto-fill function for Tcl mode. Only auto-fills in a comment."
1281 (if (> (current-column) fill-column)
1282 (let ((fill-prefix "# ")
1283 in-comment col)
1284 (save-excursion
1285 (setq in-comment (tcl-in-comment))
1286 (if in-comment
1287 (setq col (1- (current-column)))))
1288 (if in-comment
1289 (progn
1290 (do-auto-fill)
1291 (save-excursion
1292 (back-to-indentation)
1293 (delete-region (point) (line-beginning-position))
1294 (indent-to-column col)))))))
1295
1296 1278
1297 1279
1298 ;; 1280 ;;
1299 ;; Help-related code. 1281 ;; Help-related code.
1300 ;; 1282 ;;
1466 "inferior-tcl") 1448 "inferior-tcl")
1467 tcl-application file tcl-command-switches) 1449 tcl-application file tcl-command-switches)
1468 (if and-go (switch-to-tcl t))))))) 1450 (if and-go (switch-to-tcl t)))))))
1469 1451
1470 (defun tcl-auto-fill-mode (&optional arg) 1452 (defun tcl-auto-fill-mode (&optional arg)
1471 "Like `auto-fill-mode', but controls filling of Tcl comments." 1453 "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
1472 (interactive "P") 1454 (interactive "P")
1473 ;; Following code taken from "auto-fill-mode" (simple.el). 1455 (auto-fill-mode arg)
1474 (prog1 1456 (if auto-fill-function
1475 (setq auto-fill-function 1457 (set (make-local-variable 'comment-auto-fill-only-comments) t)
1476 (if (if (null arg) 1458 (kill-local-variable 'comment-auto-fill-only-comments)))
1477 (not auto-fill-function)
1478 (> (prefix-numeric-value arg) 0))
1479 'tcl-do-auto-fill
1480 nil))
1481 (force-mode-line-update)))
1482 1459
1483 (defun tcl-electric-hash (&optional count) 1460 (defun tcl-electric-hash (&optional count)
1484 "Insert a `#' and quote if it does not start a real comment. 1461 "Insert a `#' and quote if it does not start a real comment.
1485 Prefix arg is number of `#'s to insert. 1462 Prefix arg is number of `#'s to insert.
1486 See variable `tcl-electric-hash-style' for description of quoting 1463 See variable `tcl-electric-hash-style' for description of quoting