• slightly OT: TCL code indent in emacs 27.2

    From Ralf Fassel@21:1/5 to All on Mon Nov 14 18:42:20 2022
    Any emacs users here who have hit this before?
    If so, how did you solve it?

    emacs 27.2 on Linux/Opensuse 15.4 and tcl.el like this:

    ;;; tcl.el --- Tcl code editing commands for Emacs
    ;; Copyright (C) 1994, 1998-2021 Free Software Foundation, Inc.

    In tcl-mode, the following code leads to incorrect indentation after the 'method' line:

    # --- cut here/1 ---
    proc xxx {} {
    yyy {
    method zzz
    }
    # previous line should indent like this, but stays at beginning of line
    # --- cut here/1 ---


    If I go on the line after "method zzz" and press TAB ('tcl-indent-command'), the line stays at the beginning of the line and does not indent like the previous 'method' line. If I change the 'method zzz' line to
    e.g. 'xmethod zzz, the next line indents correctly.

    If I change the code to

    # --- cut here/2 ---
    proc xxx {} {
    yyy { method zzz }
    # correct indent now
    # --- cut here/2 ---

    (which is the same as TCL is concerned), the indent works correctly.

    This has something to do with 'tcl-calculate-indent', which in turn in
    some way uses 'tcl-proc-regexp' (containing amongst others the 'method' keyword), but I can't figure out the convoluted details of all the
    functions called.

    Maybe someone here can offer some insight or even a solution?

    TNX
    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joerg Mertens@21:1/5 to Ralf Fassel on Mon Nov 14 21:21:39 2022
    Ralf Fassel <[email protected]> writes:

    emacs 27.2 on Linux/Opensuse 15.4 and tcl.el like this:

    ;;; tcl.el --- Tcl code editing commands for Emacs
    ;; Copyright (C) 1994, 1998-2021 Free Software Foundation, Inc.

    In tcl-mode, the following code leads to incorrect indentation after the 'method' line:

    # --- cut here/1 ---
    proc xxx {} {
    yyy {
    method zzz
    }
    # previous line should indent like this, but stays at beginning of line
    # --- cut here/1 ---

    Works correctly in Emacs 28.2. tcl.el is from 2022 in this version. I
    had 27.something until a few weeks ago and I don't remember this
    problem having occured here. I don't use Tcl that often, though.

    Maybe try running emacs -Q to eliminate the possibility it has something
    to do with your configuration.

    Joerg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Mon Nov 21 12:26:19 2022
    * Joerg Mertens <[email protected]>
    | Ralf Fassel <[email protected]> writes:

    | > emacs 27.2 on Linux/Opensuse 15.4 and tcl.el like this:
    | >
    | > ;;; tcl.el --- Tcl code editing commands for Emacs
    | > ;; Copyright (C) 1994, 1998-2021 Free Software Foundation, Inc.
    | >
    | > In tcl-mode, the following code leads to incorrect indentation after the
    | > 'method' line:
    | >
    | > # --- cut here/1 ---
    | > proc xxx {} {
    | > yyy {
    | > method zzz
    | > }
    | > # previous line should indent like this, but stays at beginning of line | > # --- cut here/1 ---

    | Works correctly in Emacs 28.2. tcl.el is from 2022 in this version.

    So there is hope... :-)

    | Maybe try running emacs -Q to eliminate the possibility it has
    | something to do with your configuration.

    First thing I tried: emacs -q --no-site-file

    TNX
    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ricardo kozmate.net@21:1/5 to All on Mon Nov 21 12:01:07 2022
    Em 14/11/22 17:42, Ralf Fassel escreveu:
    In tcl-mode, the following code leads to incorrect indentation after the 'method' line:

    # --- cut here/1 ---
    proc xxx {} {
    yyy {
    method zzz
    }
    # previous line should indent like this, but stays at beginning of line # --- cut here/1 ---

    Same here, also with emacs 27.2 (over Linux OpenSuse Leap 15.4)

    Emacs is a great help but it has a quirk here and there, namely with indentation, though I can't remember any by heart right now.

    Usually I just play along. Given that I only make short stuff and by
    myself, thus not needing to conform to any given style, that is OK.
    Although I'd rather be strict as to style choice.

    As to your example I note that yyy is not a keyword. Starting with a
    known keyword might work as expected:

    proc xxx {} {
    list xxx {
    yyy
    zzz
    }
    }

    and...


    proc xxx {} {
    set L [list xxx {
    yyy
    zzz
    }]
    }

    or not...

    proc xxx {} {
    set L [list xxx {
    yyy
    zzz
    }
    ]
    }


    Wow! :o

    Not important to me right now, so I'll probably wait for the
    distribution's update (early summer usually) to also update emacs

    --
    {ricardo from kozmate.net}

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ralf Fassel@21:1/5 to All on Mon Nov 21 14:33:53 2022
    * "Ricardo kozmate.net" <[email protected]>
    | Em 14/11/22 17:42, Ralf Fassel escreveu:
    | > In tcl-mode, the following code leads to incorrect indentation after the
    | > 'method' line:
    | > # --- cut here/1 ---
    | > proc xxx {} {
    | > yyy {
    | > method zzz
    | > }
    | > # previous line should indent like this, but stays at beginning of line
    | > # --- cut here/1 ---

    | Same here, also with emacs 27.2 (over Linux OpenSuse Leap 15.4)

    As Joerg Mertens mentioned in the other message, this seems to be fixed
    in 28.2. I just downloaded the 28.2 tarball, extracted tcl.el and indeed,
    this also works in 27.2. Since I don't want to mess with local copies
    of system files, I just wait for the next release, too.

    For those interested, I solved my 'problem' like this:

    (add-hook 'tcl-mode-hook
    (lambda ()
    ;; bug in 27.2 indenting, just remove the whole proc recognition thingy
    (if (equal emacs-version "27.2")
    (progn
    (setq tcl-proc-list nil)
    (tcl-set-proc-regexp)
    (tcl-set-font-lock-keywords)))))

    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ricardo kozmate.net@21:1/5 to All on Mon Nov 21 19:59:15 2022
    Em 21/11/22 13:33, Ralf Fassel escreveu:
    Since I don't want to mess with local copies
    of system files, I just wait for the next release, too.

    Precisely.

    For those interested, I solved my 'problem' like this:

    Thanks. I might try soon-ish.

    --
    {ricardo from kozmate.net}

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)