help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

indentation - always a pita


From: Harry Putnam
Subject: indentation - always a pita
Date: Tue, 24 Jun 2003 15:28:43 -0700
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux)

Maybe its just because I only have 3 brain cells to rub together. But
it always seems like a massive undertaking to do anything about
indentation in some of the scripting or language modes.

In the instant case its Shell-script (bash)
Pressing Ctrl-Alt \ to format the entire buffer.

Gives me something like:

if [ ];then
    if [ ];then
        case $opt in
            t) cmd
                if  [ ];then 
                    cmd
                fi
                ;;
            h) cmd
                if [ ];then
                    case $otheropt in
                        a) cmd
                            if [ ];then
                                cmd
                            fi
                            ;;
                        b) cmd
                            ::
                    esac
                fi
        esac
        if [];then
            cmd
        fi
    fi
fi

Admittedly a bit contrived but this seems a little extreme to me.  Now
to do something about this, I dimmly recall starting to before and
quickly discovering its quite complicated.

I'd like something closer to what cperl does.  Also I'd like there to
be NO TABS whatever.  Using tabs in code is guaranteed to cause a
problem sooner or later, when one is forced to edit with something
besides emacs.

So what is the simplist route to getting something like
if [ ];then
  if [ ];then
    if [];then
      cmd
    fi
  fi
fi

Two spaces per clause and 2 spaces for actions inside clause.
No tabs at all.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]