]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/tcl.el
Don't treat JS spread as contination method call
[gnu-emacs] / lisp / progmodes / tcl.el
index 6bee2ec9e6bd5ed93a92f90f01570cefc4c39719..93f329165a4aa9a4e3b7a11e6a5adbd918673ca7 100644 (file)
@@ -1,9 +1,8 @@
 ;;; tcl.el --- Tcl code editing commands for Emacs
 
-;; Copyright (C) 1994, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;;   2006, 2007, 2008, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1998-2016 Free Software Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Author: Tom Tromey <tromey@redhat.com>
 ;;    Chris Lindblad <cjl@lcs.mit.edu>
 ;; Keywords: languages tcl modes
 
 (eval-when-compile
   (require 'imenu)
-  (require 'outline)
   (require 'dabbrev)
   (require 'add-log))
 
   :group 'languages)
 
 (defcustom tcl-indent-level 4
-  "*Indentation of Tcl statements with respect to containing block."
+  "Indentation of Tcl statements with respect to containing block."
   :type 'integer
   :group 'tcl)
 (put 'tcl-indent-level 'safe-local-variable 'integerp)
 
 (defcustom tcl-continued-indent-level 4
-  "*Indentation of continuation line relative to first line of command."
+  "Indentation of continuation line relative to first line of command."
   :type 'integer
   :group 'tcl)
 (put 'tcl-continued-indent-level 'safe-local-variable 'integerp)
 
 (defcustom tcl-auto-newline nil
-  "*Non-nil means automatically newline before and after braces you insert."
+  "Non-nil means automatically newline before and after braces you insert."
   :type 'boolean
   :group 'tcl)
 
 (defcustom tcl-tab-always-indent tab-always-indent
-  "*Control effect of TAB key.
+  "Control effect of TAB key.
 If t (the default), always indent current line.
 If nil and point is not in the indentation area at the beginning of
 the line, a TAB is inserted.
@@ -153,12 +151,12 @@ to take place:
   6. Move backward to start of comment, indenting if necessary."
   :type '(choice (const :tag "Always" t)
                 (const :tag "Beginning only" nil)
-                (const :tag "Maybe move or make or delete comment" 'tcl))
+                (other :tag "Maybe move or make or delete comment" tcl))
   :group 'tcl)
 
 
 (defcustom tcl-electric-hash-style nil ;; 'smart
-  "*Style of electric hash insertion to use.
+  "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
@@ -169,27 +167,27 @@ taken to mean `smart'.  The default is nil."
   :group 'tcl)
 
 (defcustom tcl-help-directory-list nil
-  "*List of topmost directories containing TclX help files."
+  "List of topmost directories containing TclX help files."
   :type '(repeat directory)
   :group 'tcl)
 
 (defcustom tcl-use-smart-word-finder t
-  "*If not nil, use smart way to find current word, for Tcl help feature."
+  "If not nil, use smart way to find current word, for Tcl help feature."
   :type 'boolean
   :group 'tcl)
 
 (defcustom tcl-application "wish"
-  "*Name of Tcl program to run in inferior Tcl mode."
+  "Name of Tcl program to run in inferior Tcl mode."
   :type 'string
   :group 'tcl)
 
 (defcustom tcl-command-switches nil
-  "*List of switches to supply to the `tcl-application' program."
+  "List of switches to supply to the `tcl-application' program."
   :type '(repeat string)
   :group 'tcl)
 
 (defcustom tcl-prompt-regexp "^\\(% \\|\\)"
-  "*If not nil, a regexp that will match the prompt in the inferior process.
+  "If not nil, a regexp that will match the prompt in the inferior process.
 If nil, the prompt is the name of the application with \">\" appended.
 
 The default is \"^\\(% \\|\\)\", which will match the default primary
@@ -198,7 +196,7 @@ and secondary prompts for tclsh and wish."
   :group 'tcl)
 
 (defcustom inferior-tcl-source-command "source %s\n"
-  "*Format-string for building a Tcl command to load a file.
+  "Format-string for building a Tcl command to load a file.
 This format string should use `%s' to substitute a file name
 and should result in a Tcl expression that will command the
 inferior Tcl to load that file.  The filename will be appropriately
@@ -268,7 +266,7 @@ quoted for Tcl."
   ;; Maybe someone has a better set?
   (let ((map (make-sparse-keymap)))
     ;; Will inherit from `comint-mode-map' thanks to define-derived-mode.
-    (define-key map "\t" 'comint-dynamic-complete)
+    (define-key map "\t" 'completion-at-point)
     (define-key map "\M-?" 'comint-dynamic-list-filename-completions)
     (define-key map "\177" 'backward-delete-char-untabify)
     (define-key map "\M-\C-x" 'tcl-eval-defun)
@@ -302,7 +300,7 @@ quoted for Tcl."
     ["Tcl help" tcl-help-on-word tcl-help-directory-list]))
 
 (defvar inferior-tcl-buffer nil
-  "*The current inferior-tcl process buffer.
+  "The current inferior-tcl process buffer.
 
 MULTIPLE PROCESS SUPPORT
 ===========================================================================
@@ -334,8 +332,8 @@ This process selection is performed by function `inferior-tcl-proc'.
 Whenever \\[inferior-tcl] fires up a new process, it resets
 `inferior-tcl-buffer' to be the new process's buffer.  If you only run
 one process, this does the right thing.  If you run multiple
-processes, you can change `inferior-tcl-buffer' to another process
-buffer with \\[set-variable].")
+processes, you might need to set `inferior-tcl-buffer' to
+whichever process buffer you want to use.")
 
 ;;
 ;; Hooks and other customization.
@@ -411,9 +409,10 @@ This variable is generally set from `tcl-proc-regexp',
 `tcl-typeword-list', and `tcl-keyword-list' by the function
 `tcl-set-font-lock-keywords'.")
 
-(defvar tcl-font-lock-syntactic-keywords
-  ;; Mark the few `#' that are not comment-markers.
-  '(("[^;[{ \t\n][ \t]*\\(#\\)" (1 ".")))
+(defconst tcl-syntax-propertize-function
+  (syntax-propertize-rules
+   ;; Mark the few `#' that are not comment-markers.
+   ("[^;[{ \t\n][ \t]*\\(#\\)" (1 ".")))
   "Syntactic keywords for `tcl-mode'.")
 
 ;; FIXME need some way to recognize variables because array refs look
@@ -544,8 +543,11 @@ Uses variables `tcl-proc-regexp' and `tcl-keyword-list'."
 ;; The mode itself.
 ;;
 
+(defvar outline-regexp)
+(defvar outline-level)
+
 ;;;###autoload
-(define-derived-mode tcl-mode nil "Tcl"
+(define-derived-mode tcl-mode prog-mode "Tcl"
   "Major mode for editing Tcl code.
 Expression and list commands understand all Tcl brackets.
 Tab indents for Tcl code.
@@ -571,10 +573,7 @@ documentation for details):
 
 Turning on Tcl mode runs `tcl-mode-hook'.  Read the documentation for
 `tcl-mode-hook' to see what kinds of interesting hook functions
-already exist.
-
-Commands:
-\\{tcl-mode-map}"
+already exist."
   (unless (and (boundp 'filladapt-mode) filladapt-mode)
     (set (make-local-variable 'paragraph-ignore-fill-prefix) t))
 
@@ -593,9 +592,9 @@ Commands:
   (set (make-local-variable 'outline-level) 'tcl-outline-level)
 
   (set (make-local-variable 'font-lock-defaults)
-       '(tcl-font-lock-keywords nil nil nil beginning-of-defun
-        (font-lock-syntactic-keywords . tcl-font-lock-syntactic-keywords)
-        (parse-sexp-lookup-properties . t)))
+       '(tcl-font-lock-keywords nil nil nil beginning-of-defun))
+  (set (make-local-variable 'syntax-propertize-function)
+       tcl-syntax-propertize-function)
 
   (set (make-local-variable 'imenu-generic-expression)
        tcl-imenu-generic-expression)
@@ -663,7 +662,7 @@ Commands:
 
 \f
 
-(defun tcl-indent-command (&optional arg)
+(defun tcl-indent-command (&optional _arg)
   "Indent current line as Tcl code, or in some cases insert a tab character.
 If `tcl-tab-always-indent' is t (the default), always indent current line.
 If `tcl-tab-always-indent' is nil and point is not in the indentation
@@ -864,7 +863,7 @@ Returns nil if line starts inside a string, t if in a comment."
                       expr-p)
                   (progn
                     ;; Line is continuation line, or the sexp opener
-                    ;; is not a curly brace, or we are are looking at
+                    ;; is not a curly brace, or we are looking at
                     ;; an `expr' expression (which must be split
                     ;; specially).  So indentation is column of first
                     ;; good spot after sexp opener (with some added
@@ -1029,7 +1028,8 @@ Returns nil if line starts inside a string, t if in a comment."
     (with-current-buffer (process-buffer proc)
       ;; Delete prompt if requested.
       (when (marker-buffer inferior-tcl-delete-prompt-marker)
-        (delete-region (process-mark proc) inferior-tcl-delete-prompt-marker)
+       (let ((inhibit-read-only t))
+         (delete-region (process-mark proc) inferior-tcl-delete-prompt-marker))
         (set-marker inferior-tcl-delete-prompt-marker nil))))
   (comint-output-filter proc string))
 
@@ -1063,7 +1063,7 @@ With argument, positions cursor at end of buffer."
 (defun inferior-tcl-proc ()
   "Return current inferior Tcl process.
 See variable `inferior-tcl-buffer'."
-  (let ((proc (get-buffer-process (if (eq major-mode 'inferior-tcl-mode)
+  (let ((proc (get-buffer-process (if (derived-mode-p 'inferior-tcl-mode)
                                      (current-buffer)
                                    inferior-tcl-buffer))))
     (or proc
@@ -1199,8 +1199,7 @@ as input to future invocations.  FLAG is nil if not in comment,
 t otherwise.  If in comment, leaves point at beginning of comment."
   (let ((bol (save-excursion
               (goto-char end)
-              (beginning-of-line)
-              (point)))
+              (line-beginning-position)))
        real-comment
        last-cstart)
     (while (and (not last-cstart) (< (point) end))
@@ -1287,7 +1286,7 @@ to update the alist.")
 If FLAG is nil, just uses `current-word'.
 Otherwise scans backward for most likely Tcl command word."
   (if (and flag
-          (memq major-mode '(tcl-mode inferior-tcl-mode)))
+          (derived-mode-p 'tcl-mode 'inferior-tcl-mode))
       (condition-case nil
          (save-excursion
            ;; Look backward for first word actually in alist.
@@ -1363,7 +1362,7 @@ Prefix argument means switch to the Tcl buffer afterwards."
     ;; filename.
     (car (comint-get-source "Load Tcl file: "
                            (or (and
-                                (eq major-mode 'tcl-mode)
+                                (derived-mode-p 'tcl-mode)
                                 (buffer-file-name))
                                tcl-previous-dir/file)
                            '(tcl-mode) t))
@@ -1383,12 +1382,12 @@ Prefix argument means switch to the Tcl buffer afterwards."
    (list
     (car (comint-get-source "Restart with Tcl file: "
                            (or (and
-                                (eq major-mode 'tcl-mode)
+                                (derived-mode-p 'tcl-mode)
                                 (buffer-file-name))
                                tcl-previous-dir/file)
                            '(tcl-mode) t))
     current-prefix-arg))
-  (let* ((buf (if (eq major-mode 'inferior-tcl-mode)
+  (let* ((buf (if (derived-mode-p 'inferior-tcl-mode)
                  (current-buffer)
                inferior-tcl-buffer))
         (proc (and buf (get-process buf))))
@@ -1510,7 +1509,7 @@ The first line is assumed to look like \"#!.../program ...\"."
 ;; loading the XEmacs menu emulation code.
 ;;
 
-(defun tcl-popup-menu (e)
+(defun tcl-popup-menu (_e)
   (interactive "@e")
   (popup-menu tcl-mode-menu))
 
@@ -1548,5 +1547,4 @@ The first line is assumed to look like \"#!.../program ...\"."
 
 (provide 'tcl)
 
-;; arch-tag: 8a032554-c3ef-422e-b84c-acec0522179d
 ;;; tcl.el ends here