;; 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:
;; 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:
(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)))
()
(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
;;
`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.
(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)
(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)
;; 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.
(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.
"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)
(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
;;
(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.