Subject: bug#43324: Auto-indenting csh/tcsh shell scripts [emacs-28]

From: Kaushal Modi <[email-masked]>
Date: Mon, 6 Jun 2022 12:44:35 -0400

On Mon, Jun 6, 2022 at 12:20 PM Lars Ingebrigtsen <[email-masked]> wrote:
> Does this mean that indentation doesn't work for tcsh in
> shell-script-mode?  I had a brief look at a tcsh script and did some
> indentation, and it seemed to work OK for me.
>
> What are the bits that are missing?

Hi Lars,

Thank you for following up on this. tcsh script indentation is still
broken on the 28.1 release for me.

Here's a GIF recording (attached with this email) showing me opening a
tcsh script in emacs -Q and attempting to auto-indent the whole buffer
and also a region. Both mess up the whole indentation.

Example script:

=====
#!/bin/tcsh -f
# Time-stamp: <2015-05-22 10:30:53 kmodi>

# This script splits the pane depending on the current panes height and width
# The result is to not result in too narrow or too wide panes after split

set pane_height=`tmux display -p -F '#{pane_height}'`
set pane_width=`tmux display -p -F '#{pane_width}'`
# echo "Pane Height = $pane_height"
# echo "Pane Width  = $pane_width"

# for the small Dell monitor when the terminal is full screen
# Small Dell monitor resolution = 1600 x 1200
#  width in chars = 174, height in chars = 59
# Normalize the pane height and width (resolution/char)
set height_factor = `expr 1200 / 59`
set width_factor  = `expr 1600 / 174`
set pane_height_norm = `expr $pane_height \* $height_factor`
set pane_width_norm  = `expr $pane_width  \* $width_factor`
# echo "Pane Height factor = $height_factor"
# echo "Pane Width factor  = $width_factor"
# echo "Pane Height normalized = $pane_height_norm"
# echo "Pane Width  normalized = $pane_width_norm"

if ( $pane_width_norm > $pane_height_norm ) then
   tmux split-window -h "$*" # splits current pane vertically
else
   tmux split-window -v "$*" # splits current pane horizontally
endif
=====