all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* indent-tab-mode
@ 2006-09-30 21:03 Gary Wessle
  2006-09-30 21:33 ` indent-tab-mode Tassilo Horn
  0 siblings, 1 reply; 7+ messages in thread
From: Gary Wessle @ 2006-09-30 21:03 UTC (permalink / raw)


hi
my indent-tab-mode is on but when I am writing in sh mode

#!/bin/sh
if [ ... ]
then

the "then" is not indented automatically. how can I fix this?

thanks

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indent-tab-mode
  2006-09-30 21:03 indent-tab-mode Gary Wessle
@ 2006-09-30 21:33 ` Tassilo Horn
  2006-10-01 19:25   ` indent-tab-mode Gary Wessle
  0 siblings, 1 reply; 7+ messages in thread
From: Tassilo Horn @ 2006-09-30 21:33 UTC (permalink / raw)


Gary Wessle <phddas@yahoo.com> writes:

Hi Gary,

> my indent-tab-mode is on but when I am writing in sh mode
>
> #!/bin/sh
> if [ ... ]
> then
>
> the "then" is not indented automatically. how can I fix this?

`indent-tab-mode' has nothing to do with how the indention of certain
programming language constructs looks like. If it's non-nil, indentation
uses tabs, if it's nil it uses spaces.

,----[ C-h v indent-tabs-mode RET ]
| indent-tabs-mode is a variable defined in `C source code'.
|
| [...]
| 
| Documentation:
| *Indentation can insert tabs if this is non-nil.
| Setting this variable automatically makes it local to the current buffer.
`----

I think it's quite common not to indent `then':

,----
| if [...]
| then
|     do-this
|     do-that
| done
`----

Another common style is:

,----
| if [...]; then
|     do-this
|     do-that
| done
`----

Bye,
Tassilo
-- 
My opinions may have changed, but not the fact that I am right.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indent-tab-mode
  2006-09-30 21:33 ` indent-tab-mode Tassilo Horn
@ 2006-10-01 19:25   ` Gary Wessle
  2006-10-01 19:55     ` indent-tab-mode Peter Dyballa
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Gary Wessle @ 2006-10-01 19:25 UTC (permalink / raw)


Tassilo Horn <heimdall@uni-koblenz.de> writes:

> Gary Wessle <phddas@yahoo.com> writes:
> 
> Hi Gary,
> 
> > my indent-tab-mode is on but when I am writing in sh mode
> >
> > #!/bin/sh
> > if [ ... ]
> > then
> >
> > the "then" is not indented automatically. how can I fix this?
> 
> `indent-tab-mode' has nothing to do with how the indention of certain
> programming language constructs looks like. If it's non-nil, indentation
> uses tabs, if it's nil it uses spaces.
> 
> ,----[ C-h v indent-tabs-mode RET ]
> | indent-tabs-mode is a variable defined in `C source code'.
> |
> | [...]
> | 
> | Documentation:
> | *Indentation can insert tabs if this is non-nil.
> | Setting this variable automatically makes it local to the current buffer.
> `----
> 
> I think it's quite common not to indent `then':
> 
> ,----
> | if [...]
> | then
> |     do-this
> |     do-that
> | done
> `----
> 
> Another common style is:
> 
> ,----
> | if [...]; then
> |     do-this
> |     do-that
> | done
> `----
> 
> Bye,
> Tassilo


then how can I indent-while-typing this code
#!/bin/sh
#
# if not vehicle name is given
# i.e. -z $1 is defined and it is NULL
#
# if no command line arg

if [ -z $1 ]
then
rental="*** Unknown vehicle ***"
elif [ -n $1 ]
then
# otherwise make first arg as rental
rental=$1
fi

case $rental in
"car") echo "For $rental Rs.20 per k/m";;
"van") echo "For $rental Rs.10 per k/m";;
"jeep") ehco "For $rental Rs.5 per k/m";;
"bicycle") echo "For $rental 20 paisa per k/m";;
*) echo "Sorry, I can not get a $rental for you";;
esac

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indent-tab-mode
  2006-10-01 19:25   ` indent-tab-mode Gary Wessle
@ 2006-10-01 19:55     ` Peter Dyballa
  2006-10-01 20:25     ` indent-tab-mode s. keeling
  2006-10-11 11:57     ` indent-tab-mode Sam Peterson
  2 siblings, 0 replies; 7+ messages in thread
From: Peter Dyballa @ 2006-10-01 19:55 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 01.10.2006 um 21:25 schrieb Gary Wessle:

> then how can I indent-while-typing this code

C-q TAB

Or: some spaces as indentation and in the next line(s) a TAB.

--
Greetings

   Pete     === -Q
              ==<__/% >>
_____________(_)____@_____________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indent-tab-mode
  2006-10-01 19:25   ` indent-tab-mode Gary Wessle
  2006-10-01 19:55     ` indent-tab-mode Peter Dyballa
@ 2006-10-01 20:25     ` s. keeling
  2006-10-02  0:37       ` indent-tab-mode Gary Wessle
  2006-10-11 11:57     ` indent-tab-mode Sam Peterson
  2 siblings, 1 reply; 7+ messages in thread
From: s. keeling @ 2006-10-01 20:25 UTC (permalink / raw)


Gary Wessle <phddas@yahoo.com>:
> 
>  then how can I indent-while-typing this code
>  #!/bin/sh
>  #
>  # if not vehicle name is given
>  # i.e. -z $1 is defined and it is NULL
>  #
>  # if no command line arg
> 
>  if [ -z $1 ]
>  then
>  rental="*** Unknown vehicle ***"
>  elif [ -n $1 ]
>  then
>  # otherwise make first arg as rental
>  rental=$1
>  fi
> 
>  case $rental in
>  "car") echo "For $rental Rs.20 per k/m";;
>  "van") echo "For $rental Rs.10 per k/m";;
>  "jeep") ehco "For $rental Rs.5 per k/m";;

Typo:......^^^^

>  "bicycle") echo "For $rental 20 paisa per k/m";;
>  *) echo "Sorry, I can not get a $rental for you";;
>  esac


-- 
Any technology distinguishable from magic is insufficiently advanced.
(*)    http://www.spots.ab.ca/~keeling          Linux Counter #80292
- -    http://www.faqs.org/rfcs/rfc1855.html    Please, don't Cc: me.
       Spammers! http://www.spots.ab.ca/~keeling/emails.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indent-tab-mode
  2006-10-01 20:25     ` indent-tab-mode s. keeling
@ 2006-10-02  0:37       ` Gary Wessle
  0 siblings, 0 replies; 7+ messages in thread
From: Gary Wessle @ 2006-10-02  0:37 UTC (permalink / raw)


"s. keeling" <keeling@spots.ab.ca> writes:

> Gary Wessle <phddas@yahoo.com>:
> > 
> >  then how can I indent-while-typing this code
> >  #!/bin/sh
> >  #
> >  # if not vehicle name is given
> >  # i.e. -z $1 is defined and it is NULL
> >  #
> >  # if no command line arg
> > 
> >  if [ -z $1 ]
> >  then
> >  rental="*** Unknown vehicle ***"
> >  elif [ -n $1 ]
> >  then
> >  # otherwise make first arg as rental
> >  rental=$1
> >  fi
> > 
> >  case $rental in
> >  "car") echo "For $rental Rs.20 per k/m";;
> >  "van") echo "For $rental Rs.10 per k/m";;
> >  "jeep") ehco "For $rental Rs.5 per k/m";;
> 
> Typo:......^^^^

the expected results:




#!/bin/sh
#
# if not vehicle name is given
# i.e. -z $1 is defined and it is NULL
#
# if no command line arg

if [ -z $1 ]			# first arg not given?
    then
    rental="*** Unknown vehicle ***"
elif [ -n $1 ]			# first arg given
    then
# otherwise make first arg as rental
    rental=$1
fi

case $rental in
"car") echo "For $rental Rs.20 per k/m";;
"van") echo "For $rental Rs.10 per k/m";;
"jeep") echo "For $rental Rs.5 per k/m";;
"bicycle") echo "For $rental 20 paisa per k/m";;
    *) echo "Sorry, I can not get a $rental for you";;
esac

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: indent-tab-mode
  2006-10-01 19:25   ` indent-tab-mode Gary Wessle
  2006-10-01 19:55     ` indent-tab-mode Peter Dyballa
  2006-10-01 20:25     ` indent-tab-mode s. keeling
@ 2006-10-11 11:57     ` Sam Peterson
  2 siblings, 0 replies; 7+ messages in thread
From: Sam Peterson @ 2006-10-11 11:57 UTC (permalink / raw)


Gary Wessle <phddas@yahoo.com> writes:

> then how can I indent-while-typing this code

Use C-j to carriage return or put the following in your .emacs:

(global-set-key "\C-m" 'newline-and-indent)
(global-set-key "\C-j" 'newline)

-- 
Sam Peterson
skpeterson AT nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-10-11 11:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-30 21:03 indent-tab-mode Gary Wessle
2006-09-30 21:33 ` indent-tab-mode Tassilo Horn
2006-10-01 19:25   ` indent-tab-mode Gary Wessle
2006-10-01 19:55     ` indent-tab-mode Peter Dyballa
2006-10-01 20:25     ` indent-tab-mode s. keeling
2006-10-02  0:37       ` indent-tab-mode Gary Wessle
2006-10-11 11:57     ` indent-tab-mode Sam Peterson

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.