]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/tcl.el
Update copyright notice.
[gnu-emacs] / lisp / progmodes / tcl.el
index 60efed8c168ae44334252e1a252d1558ca4893e7..d1be68e9d56f83e534d89c60337d9ede62882c25 100644 (file)
@@ -2,11 +2,11 @@
 
 ;; Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002  Free Software Foundation, Inc.
 
-;; Maintainer: Tom Tromey <tromey@redhat.com>
+;; Maintainer: FSF
 ;; Author: Tom Tromey <tromey@redhat.com>
 ;;    Chris Lindblad <cjl@lcs.mit.edu>
 ;; Keywords: languages tcl modes
-;; Version: $Revision: 1.65 $
+;; Version: $Revision: 1.68 $
 
 ;; This file is part of GNU Emacs.
 
 ;; Jesper Pedersen <blackie@imada.ou.dk>
 ;; dfarmer@evolving.com (Doug Farmer)
 ;; "Chris Alfeld" <calfeld@math.utah.edu>
-;; Ben Wing <wing@666.com>
+;; Ben Wing <ben@xemacs.org>
 
 ;; KNOWN BUGS:
-;; * In Tcl "#" is not always a comment character.  This can confuse
-;;   tcl.el in certain circumstances.  For now the only workaround is
-;;   to enclose offending hash characters in quotes or precede it with
-;;   a backslash.  Note that using braces won't work -- quotes change
-;;   the syntax class of characters between them, while braces do not.
-;;   The electric-# mode helps alleviate this problem somewhat.
+;; * In Tcl "#" is not always a comment character.  This can confuse tcl.el
+;;   in certain circumstances.  For now the only workaround is to use
+;;   font-lock which will mark the # chars accordingly or enclose offending
+;;   hash characters in quotes or precede them with a backslash.  Note that
+;;   using braces won't work -- quotes change the syntax class of characters
+;;   between them, while braces do not.  If you don't use font-lock, the
+;;   electric-# mode helps alleviate this problem somewhat.
 ;; * indent-tcl-exp is untested.
 
 ;; TODO:
@@ -76,7 +77,7 @@
 ;;   middle of a defun, or between defuns.  should notice if point is
 ;;   on first line of defun (or maybe even in comments before defun).
 ;; * Allow continuation lines to be indented under the first argument
-;;   of the preceeding line, like this:
+;;   of the preceding line, like this:
 ;;      [list something \
 ;;            something-else]
 ;; * There is a request that indentation work like this:
@@ -154,14 +155,14 @@ to take place:
                 (const :tag "Maybe move or make or delete comment" 'tcl)))
 
 
-(defcustom tcl-electric-hash-style 'smart
+(defcustom tcl-electric-hash-style nil ;; 'smart
   "*Style of electric hash insertion to use.
 Possible values are `backslash', meaning that `\\' quoting should be
 done; `quote', meaning that `\"' quoting should be done; `smart',
 meaning that the choice between `backslash' and `quote' should be
 made depending on the number of hashes inserted; or nil, meaning that
 no quoting should be done.  Any other value for this variable is
-taken to mean `smart'.  The default is `smart'."
+taken to mean `smart'.  The default is nil."
   :group 'tcl
   :type '(choice (const backslash) (const quote) (const smart) (const nil)))
 
@@ -506,6 +507,11 @@ Uses variables `tcl-proc-regexp' and `tcl-keyword-list'."
     ()
   (tcl-set-font-lock-keywords))
 
+
+(defvar tcl-imenu-generic-expression
+  `((nil ,(concat tcl-proc-regexp "\\([-A-Za-z0-9_:+*]+\\)") 2))
+  "Imenu generic expression for `tcl-mode'.  See `imenu-generic-expression'.")
+
 \f
 
 ;;
@@ -533,8 +539,6 @@ documentation for details):
   `tcl-auto-newline'
     Non-nil means automatically newline before and after braces, brackets,
     and semicolons inserted in Tcl code.
-  `tcl-electric-hash-style'
-    Controls action of `#' key.
   `tcl-use-smart-word-finder'
     If not nil, use a smarter, Tcl-specific way to find the current
     word when looking up help on a Tcl command.
@@ -549,8 +553,10 @@ Commands:
   (set (make-local-variable 'paragraph-start) "$\\|\f")
   (set (make-local-variable 'paragraph-separate) paragraph-start)
 
-  (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
-  (set (make-local-variable 'fill-paragraph-function) 'tcl-do-fill-paragraph)
+  (unless (and (boundp 'filladapt-mode) filladapt-mode)
+    (set (make-local-variable 'paragraph-ignore-fill-prefix) t)
+    (set (make-local-variable 'fill-paragraph-function)
+        'tcl-do-fill-paragraph))
 
   (set (make-local-variable 'indent-line-function) 'tcl-indent-line)
   (set (make-local-variable 'comment-indent-function) 'tcl-comment-indent)
@@ -571,8 +577,8 @@ Commands:
         (font-lock-syntactic-keywords . tcl-font-lock-syntactic-keywords)
         (parse-sexp-lookup-properties . t)))
 
-  (set (make-local-variable 'imenu-create-index-function)
-       'tcl-imenu-create-index-function)
+  (set (make-local-variable 'imenu-generic-expression)
+       'tcl-imenu-generic-expression)
   
   ;; Settings for new dabbrev code.
   (set (make-local-variable 'dabbrev-case-fold-search) nil)
@@ -987,23 +993,6 @@ Returns nil if line starts inside a string, t if in a comment."
 ;; Interfaces to other packages.
 ;;
 
-(defun tcl-imenu-create-index-function ()
-  "Generate alist of indices for imenu."
-  (let ((re (concat tcl-proc-regexp "\\([^ \t\n{]+\\)"))
-       alist prev-pos)
-    (goto-char (point-min))
-    (imenu-progress-message prev-pos 0)
-    (save-match-data
-      (while (re-search-forward re nil t)
-       (imenu-progress-message prev-pos)
-       ;; Position on start of proc name, not beginning of line.
-       (setq alist (cons
-                    (cons (buffer-substring (match-beginning 2) (match-end 2))
-                          (match-beginning 2))
-                    alist))))
-    (imenu-progress-message prev-pos 100)
-    (nreverse alist)))
-
 ;; FIXME Definition of function is very ad-hoc.  Should use
 ;; beginning-of-defun.  Also has incestuous knowledge about the
 ;; format of tcl-proc-regexp.
@@ -1108,7 +1097,7 @@ Prefix argument means switch to the Tcl buffer afterwards."
 (define-derived-mode inferior-tcl-mode comint-mode "Inferior Tcl"
   "Major mode for interacting with Tcl interpreter.
 
-A Tcl process can be started with M-x inferior-tcl.
+You can start a Tcl process with \\[inferior-tcl].
 
 Entry to this mode runs the normal hooks `comint-mode-hook' and
 `inferior-tcl-mode-hook', in that order.
@@ -1189,7 +1178,7 @@ first word following a semicolon, opening brace, or opening bracket."
   "Return t if point is just after the `#' beginning a real comment.
 Does not check to see if previous char is actually `#'.
 A real comment is either at the beginning of the buffer,
-preceeded only by whitespace on the line, or has a preceeding
+preceded only by whitespace on the line, or has a preceding
 semicolon, opening brace, or opening bracket on the same line."
   (save-excursion
     (backward-char)
@@ -1286,23 +1275,6 @@ simpler version that is often right, and works in Emacs 18."
             (fill-paragraph ignore)))))
   t)
 
-(defun tcl-do-auto-fill ()
-  "Auto-fill function for Tcl mode.  Only auto-fills in a comment."
-  (if (> (current-column) fill-column)
-      (let ((fill-prefix "# ")
-           in-comment col)
-       (save-excursion
-         (setq in-comment (tcl-in-comment))
-         (if in-comment
-             (setq col (1- (current-column)))))
-       (if in-comment
-           (progn
-             (do-auto-fill)
-             (save-excursion
-               (back-to-indentation)
-               (delete-region (point) (line-beginning-position))
-               (indent-to-column col)))))))
-
 \f
 
 ;;
@@ -1478,17 +1450,12 @@ Prefix argument means switch to the Tcl buffer afterwards."
        (if and-go (switch-to-tcl t)))))))
 
 (defun tcl-auto-fill-mode (&optional arg)
-  "Like `auto-fill-mode', but controls filling of Tcl comments."
+  "Like `auto-fill-mode', but sets `comment-auto-fill-only-comments'."
   (interactive "P")
-  ;; Following code taken from "auto-fill-mode" (simple.el).
-  (prog1
-      (setq auto-fill-function
-           (if (if (null arg)
-                   (not auto-fill-function)
-                 (> (prefix-numeric-value arg) 0))
-               'tcl-do-auto-fill
-             nil))
-    (force-mode-line-update)))
+  (auto-fill-mode arg)
+  (if auto-fill-function
+      (set (make-local-variable 'comment-auto-fill-only-comments) t)
+    (kill-local-variable 'comment-auto-fill-only-comments)))
 
 (defun tcl-electric-hash (&optional count)
   "Insert a `#' and quote if it does not start a real comment.