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

From: Lars Ingebrigtsen <[email-masked]>
Date: Sat, 28 Sep 2019 19:47:17 +0200

Rolf Ade <[email-masked]> writes:

> * lisp/progmodes/tcl.el (tcl-calculate-indent) Fall back to old
>   indentation method for tcl code at the start of the buffer before the
>   first word matching an element out of tcl-proc-list.
>
> Copyright-paperwork-exempt: yes
>
> diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el
> index 0fd3d6d1bf..db97230480 100644
> --- a/lisp/progmodes/tcl.el
> +++ b/lisp/progmodes/tcl.el
> @@ -817,7 +817,9 @@ tcl-calculate-indent
>            found-next-line)
>        (if parse-start
>           (goto-char parse-start)
> -       (beginning-of-defun))
> +       (if (not (beginning-of-defun))
> +            (let ((beginning-of-defun-function nil))
> +              (beginning-of-defun))))

Hm...  This does fix the indentation issue, but I wonder whether
tcl-beginning-of-defun-function should be fixed instead so that the
movement commands work better?

I don't use TCL, but the problem is that top-level (outside of
functions) that tcl-beginning-of-defun-function doesn't go to the start
of forms like:

if {$argc != 0} {
    puts stderr "usage: $argv0"
}

But what should beginning-of-defun do outside of functions?  It's not
documented in the doc string of that function...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no