Subject: Re: bug#23565: (24.5; tcl-end-of-defun and tcl-eval-defun doesn't work reliable)

From: Noam Postavsky <[email-masked]>
Date: Thu, 16 Jun 2016 23:55:00 -0400

tag 23565 + confirmed
quit

It has to do with the tcl-omit-ws-regexp which is used to set the
buffer local value of defun-prompt-regexp (why isn't it called
tcl-defun-prompt-regexp?). The current setting, along with commentary
is:

;; Here's another stab.  I think this one actually works.
;; We have to be careful that the open-brace following this regexp
;; is indeed the one corresponding to the function's body so
;; that end-of-defun works correctly.  Tricky cases are:
;;    proc foo { {arg1 def} arg2 } {
;; as well as
;;    proc foo { \n {arg1 def} \n arg2 } {
;; The current setting handles the first case properly but not the second.
;; It also fails if `proc' is not in column-0 (e.g. it's in a namespace).
(defconst tcl-omit-ws-regexp "^[^]\" \t\n#}][^\n\"#]+[ \t]+")

If I remove the " from the second character set, then the examples
given in this bug report work, but probably some others might break (I
don't know tcl well enough to come up with any).

;; this works for given examples
(defconst tcl-omit-ws-regexp "^[^]\" \t\n#}][^\n#]+[ \t]+")

A regexp based approach is probably always doomed to have some bad
cases, so perhaps the real fix is to define a
beginning-of-defun-function for tcl-mode.