unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* death to tabs
@ 2003-04-04 20:23 John Russell
  2003-04-04 20:30 ` greg jednaszewski
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: John Russell @ 2003-04-04 20:23 UTC (permalink / raw)



Ok, seriously, I don't ever want to see another tab as long as I
live.  I want _every__ tab I ever wrote converted to spaces right
now and I never want to have a tab show up when I hit the TAB key
again.  All spaces all the time.  

I found 
  (setq indent-tabs-mode nil)

for future tab annihilation but how can I convert a doc with tabs in
it to just spaces.  Thanks for the help.

John

PS sorry for the brusque tone.  Its just one of those last straw things.

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

* Re: death to tabs
  2003-04-04 20:23 John Russell
@ 2003-04-04 20:30 ` greg jednaszewski
  2003-04-04 21:15 ` Bijan Soleymani
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: greg jednaszewski @ 2003-04-04 20:30 UTC (permalink / raw)


John Russell <jorussel@cisco.com> wrote:
> for future tab annihilation but how can I convert a doc with tabs in
> it to just spaces.  Thanks for the help.

M-x untabify

will convert all tabs in a region to spaces.

-- 
Greg Jednaszewski   | "Man, it must be great bein' you, lookin'
greg@attenuated.org |  at me!"  -J.B.

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

* RE: death to tabs
@ 2003-04-04 20:48 Sebastien Routier
  0 siblings, 0 replies; 18+ messages in thread
From: Sebastien Routier @ 2003-04-04 20:48 UTC (permalink / raw)


No need to apologies about your tone!! It is understandable. I was just
talking about this to a colleague how was about to blow a fuse!!

For all of you who have to deal with ignorant-tab-lovers/notepad-users here
is what I use:

(defun my-untabify-buffer ()
  "Run Untabify against the current buffer."
  (interactive)
  (untabify (point-min) (point-max))
  (message "Untabify Complete"))
;;
(define-key global-map [f9] 'my-untabify-buffer)


I almost hooked it to find-file but thought that that might be going a
little too far!!!

bye.
/Sebast


:
####[ Linux One Stanza Tip (LOST) ]###########################

Sub : Knowing kernel version on running box (#1)     LOST #267

To know the kernel version  currently  running on a box, use
uname. 'uname -a' will give a print out of  ALL details like
hardware type, release, processor etc. man uname for details

####<prashanthninan@yahoo.com>################################
:



> -----Original Message-----
> From: John Russell [mailto:jorussel@cisco.com]
> Sent: Friday, April 04, 2003 3:23 PM
> To: help-gnu-emacs@gnu.org
> Subject: death to tabs 
> 
> 
> 
> Ok, seriously, I don't ever want to see another tab as long as I
> live.  I want _every__ tab I ever wrote converted to spaces right
> now and I never want to have a tab show up when I hit the TAB key
> again.  All spaces all the time.  
> 
> I found 
>   (setq indent-tabs-mode nil)
> 
> for future tab annihilation but how can I convert a doc with tabs in
> it to just spaces.  Thanks for the help.
> 
> John
> 
> PS sorry for the brusque tone.  Its just one of those last 
> straw things.
> _______________________________________________
> Help-gnu-emacs mailing list
> Help-gnu-emacs@gnu.org
> http://mail.gnu.org/mailman/listinfo/help-gnu-emacs
> 

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

* Re: death to tabs
  2003-04-04 20:23 John Russell
  2003-04-04 20:30 ` greg jednaszewski
@ 2003-04-04 21:15 ` Bijan Soleymani
  2003-04-04 21:37 ` Peter Lee
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Bijan Soleymani @ 2003-04-04 21:15 UTC (permalink / raw)


John Russell <jorussel@cisco.com> writes:

> Ok, seriously, I don't ever want to see another tab as long as I
> live.  I want _every__ tab I ever wrote converted to spaces right
> now and I never want to have a tab show up when I hit the TAB key
> again.  All spaces all the time.  
> 
> I found 
>   (setq indent-tabs-mode nil)
> 
> for future tab annihilation but how can I convert a doc with tabs in
> it to just spaces.  Thanks for the help.
> 
> John
> 
> PS sorry for the brusque tone.  Its just one of those last straw things.

M-x untabify convert all tabs in region to multiple spaces.

So select the entire document, and then run untabify.

Bijan

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

* Re: death to tabs
  2003-04-04 20:23 John Russell
  2003-04-04 20:30 ` greg jednaszewski
  2003-04-04 21:15 ` Bijan Soleymani
@ 2003-04-04 21:37 ` Peter Lee
  2003-04-04 23:11 ` Benjamin Rutt
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Peter Lee @ 2003-04-04 21:37 UTC (permalink / raw)


John Russell <jorussel@cisco.com> writes:

> Ok, seriously, I don't ever want to see another tab as long as I
> live.  I want _every__ tab I ever wrote converted to spaces right
> now and I never want to have a tab show up when I hit the TAB key
> again.  All spaces all the time.  
> 
> I found 
>   (setq indent-tabs-mode nil)
> 
> for future tab annihilation but how can I convert a doc with tabs in
> it to just spaces.  Thanks for the help.


C-x h
M-x untabify<RET>

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

* Re: death to tabs
  2003-04-04 20:23 John Russell
                   ` (2 preceding siblings ...)
  2003-04-04 21:37 ` Peter Lee
@ 2003-04-04 23:11 ` Benjamin Rutt
  2003-04-04 23:25   ` Bruce Korb
                     ` (3 more replies)
  2003-04-05  0:17 ` chris.danx
                   ` (2 subsequent siblings)
  6 siblings, 4 replies; 18+ messages in thread
From: Benjamin Rutt @ 2003-04-04 23:11 UTC (permalink / raw)


John Russell <jorussel@cisco.com> writes:

> Ok, seriously, I don't ever want to see another tab as long as I
> live.  I want _every__ tab I ever wrote converted to spaces right
> now and I never want to have a tab show up when I hit the TAB key
> again.  All spaces all the time.  
>
> I found 
>   (setq indent-tabs-mode nil)

I think to set this globally, you actually want 

    (setq-default indent-tabs-mode nil)

in your ~/.emacs, since indent-tabs-mode is one of those variables
which becomes buffer-local when set in any fashion.
-- 
Benjamin

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

* Re: death to tabs
  2003-04-04 23:11 ` Benjamin Rutt
@ 2003-04-04 23:25   ` Bruce Korb
  2003-04-05 13:50   ` Roy Smith
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 18+ messages in thread
From: Bruce Korb @ 2003-04-04 23:25 UTC (permalink / raw)
  Cc: help-gnu-emacs

John Russell <jorussel@cisco.com> writes:
> 
> > Ok, seriously, I don't ever want to see another tab as long as I
> > live.  I want _every__ tab I ever wrote converted to spaces right
> > now and I never want to have a tab show up when I hit the TAB key
> > again.  All spaces all the time.

I agree!  We'll never write another makefile, either.

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

* Re: death to tabs
  2003-04-04 20:23 John Russell
                   ` (3 preceding siblings ...)
  2003-04-04 23:11 ` Benjamin Rutt
@ 2003-04-05  0:17 ` chris.danx
  2003-04-05  1:15   ` Thomas A. Horsley
  2003-04-07 11:36   ` Colin Marquardt
  2003-04-05  0:59 ` Thomas A. Horsley
  2003-04-07  8:16 ` Stefan Kamphausen
  6 siblings, 2 replies; 18+ messages in thread
From: chris.danx @ 2003-04-05  0:17 UTC (permalink / raw)


John Russell wrote:
> Ok, seriously, I don't ever want to see another tab as long as I
> live.  I want _every__ tab I ever wrote converted to spaces right
> now and I never want to have a tab show up when I hit the TAB key
> again.  

Amen to that!  Working on files at home then at uni or vice versa screws 
up the tabs all the time! Our lecturers code drives me mad!  Some of 
their code is indented 2 spaces while others use non standard tab 
offsets with multiple tabs and when we add new code it goes all wonky 
because of tabs :(

What I'd like is for emacs to create new files without tabs and detect 
if a file uses tabs & guess the right offset to preserve others 
preference or retabify everything to make it neat (and have tabs only 
for makefiles).  Failing that I am prepared to damn them all and use 
Sebatien Routers code! :)


Anyone help with this?
Danx

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

* Re: death to tabs
  2003-04-04 20:23 John Russell
                   ` (4 preceding siblings ...)
  2003-04-05  0:17 ` chris.danx
@ 2003-04-05  0:59 ` Thomas A. Horsley
  2003-04-07  8:16 ` Stefan Kamphausen
  6 siblings, 0 replies; 18+ messages in thread
From: Thomas A. Horsley @ 2003-04-05  0:59 UTC (permalink / raw)


>I want _every__ tab I ever wrote converted to spaces right now and I never
>want to have a tab show up when I hit the TAB key again.

Me too, unfortunately I still need to use "make" (most versions of
which moronically require TAB chars at the start of actions, even though
if you accidentally put spaces there, it always complains about
an error in the file - if it can recognize spaces as errors, why
can't it just pretend they were tabs :-).

Anyway, I still nil out indent-tabs-mode, and just use quoted-insert to add
real TABs to Makefiles. By the way, you really want:

   (setq-default indent-tabs-mode nil)

otherwise you have to keep setting it again for every buffer.
--
>>==>> The *Best* political site <URL:http://www.vote-smart.org/> >>==+
      email: Tom.Horsley@worldnet.att.net icbm: Delray Beach, FL      |
<URL:http://home.att.net/~Tom.Horsley> Free Software and Politics <<==+

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

* Re: death to tabs
  2003-04-05  0:17 ` chris.danx
@ 2003-04-05  1:15   ` Thomas A. Horsley
  2003-04-05 13:56     ` Roy Smith
  2003-04-05 20:24     ` Kai Großjohann
  2003-04-07 11:36   ` Colin Marquardt
  1 sibling, 2 replies; 18+ messages in thread
From: Thomas A. Horsley @ 2003-04-05  1:15 UTC (permalink / raw)


>Amen to that!  Working on files at home then at uni or vice versa screws up
>the tabs all the time! Our lecturers code drives me mad!  Some of their code
>is indented 2 spaces while others use non standard tab offsets with multiple
>tabs and when we add new code it goes all wonky because of tabs :(

Aside from merely using M-x untabify, you can also M-x set-variable and
change the tab-width variable first. That way if you can deduce (perhaps by
deciding which tab-width results in the most readable display) the value the
moron who wrote the code was using for tab-width, you can then untabify
after setting tab-width.

Of course, the true villian in the whole TAB story is the unknown (to me,
anyway) Prince of Evil who designed the first editor which allowed you to
change the tab width to be something other than 8, thus removing text
formatting information from the file, and placing it only in the brain of
the author (where it is unlikely to be recoverable by those who follow
after).

(Or worse yet, in the brains of multiple authors over time, all of
whom used different default values for the chunk of code they were
working on).

Of course, worse than TABs in Makefiles, there is Python - the language that
actually gives meaning to whitespace, yet also allows TABs in input source
files, (if you think other languages are wonky with TABs in 'em...)
--
>>==>> The *Best* political site <URL:http://www.vote-smart.org/> >>==+
      email: Tom.Horsley@worldnet.att.net icbm: Delray Beach, FL      |
<URL:http://home.att.net/~Tom.Horsley> Free Software and Politics <<==+

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

* Re: death to tabs
  2003-04-04 23:11 ` Benjamin Rutt
  2003-04-04 23:25   ` Bruce Korb
@ 2003-04-05 13:50   ` Roy Smith
  2003-04-05 16:35     ` Benjamin Rutt
  2003-04-06  5:25   ` Luis O. Silva
       [not found]   ` <mailman.4167.1049606724.21513.help-gnu-emacs@gnu.org>
  3 siblings, 1 reply; 18+ messages in thread
From: Roy Smith @ 2003-04-05 13:50 UTC (permalink / raw)


Benjamin Rutt <rutt+news@cis.ohio-state.edu> wrote:

> John Russell <jorussel@cisco.com> writes:
> 
> > Ok, seriously, I don't ever want to see another tab as long as I
> > live.  I want _every__ tab I ever wrote converted to spaces right
> > now and I never want to have a tab show up when I hit the TAB key
> > again.  All spaces all the time.  
> >
> > I found 
> >   (setq indent-tabs-mode nil)
> 
> I think to set this globally, you actually want 
> 
>     (setq-default indent-tabs-mode nil)
> 
> in your ~/.emacs, since indent-tabs-mode is one of those variables
> which becomes buffer-local when set in any fashion.

I've had trouble getting the global default value to not be over-ridden 
locally in each buffer.  What I do now is set it in my C mode hook:

(add-hook 'c-mode-hook 'my-c-mode-hook t)
(add-hook 'c++-mode-hook 'my-c-mode-hook t)
(defun my-c-mode-hook ()
  (c-set-style "linux")
  (line-number-mode 1)
  (setq indent-tabs-mode nil)
  (setq c-basic-offset 4))

I'm not sure if this is the "right" way to do it, but it seems to do 
what I want, so I'm happy.

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

* Re: death to tabs
  2003-04-05  1:15   ` Thomas A. Horsley
@ 2003-04-05 13:56     ` Roy Smith
  2003-04-05 20:24     ` Kai Großjohann
  1 sibling, 0 replies; 18+ messages in thread
From: Roy Smith @ 2003-04-05 13:56 UTC (permalink / raw)


tom.horsley@att.net (Thomas A. Horsley) wrote:
> Of course, worse than TABs in Makefiles, there is Python - the language that
> actually gives meaning to whitespace, yet also allows TABs in input source
> files, (if you think other languages are wonky with TABs in 'em...)

Surely you've heard of

http://compsoc.dur.ac.uk/whitespace/

I'm waiting for somebody to announce that they've written an emacs mode 
for it :-)

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

* Re: death to tabs
  2003-04-05 13:50   ` Roy Smith
@ 2003-04-05 16:35     ` Benjamin Rutt
  0 siblings, 0 replies; 18+ messages in thread
From: Benjamin Rutt @ 2003-04-05 16:35 UTC (permalink / raw)


Roy Smith <roy@panix.com> writes:

> I've had trouble getting the global default value to not be over-ridden 
> locally in each buffer.  What I do now is set it in my C mode hook:
>
> (add-hook 'c-mode-hook 'my-c-mode-hook t)
> (add-hook 'c++-mode-hook 'my-c-mode-hook t)
> (defun my-c-mode-hook ()
>   (c-set-style "linux")
>   (line-number-mode 1)
>   (setq indent-tabs-mode nil)
>   (setq c-basic-offset 4))
>
> I'm not sure if this is the "right" way to do it, but it seems to do 
> what I want, so I'm happy.

Yes, I think both setting the global default and setting it as you
wish per-mode is the right way to approach this problem.  Each major
mode is free to override the default.  Having the default set to nil,
however, probably means that you'll have to use hooks like the above
less often.  Just watch out for Makefiles which require leading TABs,
as another poster mentioned.
-- 
Benjamin

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

* Re: death to tabs
  2003-04-05  1:15   ` Thomas A. Horsley
  2003-04-05 13:56     ` Roy Smith
@ 2003-04-05 20:24     ` Kai Großjohann
  1 sibling, 0 replies; 18+ messages in thread
From: Kai Großjohann @ 2003-04-05 20:24 UTC (permalink / raw)


tom.horsley@att.net (Thomas A. Horsley) writes:

> Of course, the true villian in the whole TAB story is the unknown (to me,
> anyway) Prince of Evil who designed the first editor which allowed you to
> change the tab width to be something other than 8, thus removing text
> formatting information from the file, and placing it only in the brain of
> the author (where it is unlikely to be recoverable by those who follow
> after).

Actually, if used right, tabs in source code can be useful.  You
know, some people prefer an indentation offset of 2, some prefer 4,
and still others prefer still other numbers.  If each indentation
level was indicated by a tab char, all those people could have their
preferred viewing experience without changing the file.  If you use
spaces, you impose your preference on the others.

There is a problem of alignment, though.  This needs to be done in a
smart way.  Here's my idea on it.  Look at this code:

if ( a == b ) {
    //-1
    if ( some_long_variable ==
         another_long_variable ) {
        //-2
        do_something();
        do_something_else();
    }
}

I use an offset of 4, as you can see.  The comments mark the
indentation levels.  So the second if statement should be preceded by
one tab.  The "another_long_variable" line should also start with one
tab, then it should have 5 spaces for alignment.  The do_something
lines should start with two tabs each.

If this was the case, then others could take the code and view it
with a different tab-width setting and everything would still look
right.  In particular, some_long_variable and another_long_variable
would still be aligned!

I would really like if this were to happen.  But it's not going to
happen anytime soon, I'm afraid.
-- 
A preposition is not a good thing to end a sentence with.

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

* Re: death to tabs
  2003-04-04 23:11 ` Benjamin Rutt
  2003-04-04 23:25   ` Bruce Korb
  2003-04-05 13:50   ` Roy Smith
@ 2003-04-06  5:25   ` Luis O. Silva
       [not found]   ` <mailman.4167.1049606724.21513.help-gnu-emacs@gnu.org>
  3 siblings, 0 replies; 18+ messages in thread
From: Luis O. Silva @ 2003-04-06  5:25 UTC (permalink / raw)
  Cc: help-gnu-emacs

Hi Benjamin,

On Fri, 04 Apr 2003 18:11:29 -0500, Benjamin Rutt writes:

   BR> I think to set this globally, you actually want

   BR>     (setq-default indent-tabs-mode nil)

   BR> in your ~/.emacs, since indent-tabs-mode is one of
   BR> those variables which becomes buffer-local when set in
   BR> any fashion.

Please be indulgent with my ignorance. I have set
`indent-tabs-mode' to nil through `custom-set-variables' and
the setting seems to be global. Should I infer from this that
`custom-set-variables' acts like `setq-default'?

Thanks in advance for enlightenment.
luis

-- 
Luis Octavio Silva P.
St. Petersburg State University.
66/3 Botanicheskaya St., Apt.119/2
Stary Peterhof
St. Petersburg, Russia.
+---------------------------------+
|     WE ARE NOT DOING ENOUGH!    |
| We haven't been able to prevent |
|    criminal governments from    |
|    killing people for profit    |
+---------------------------------+

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

* Re: death to tabs
       [not found]   ` <mailman.4167.1049606724.21513.help-gnu-emacs@gnu.org>
@ 2003-04-06 17:54     ` Benjamin Rutt
  0 siblings, 0 replies; 18+ messages in thread
From: Benjamin Rutt @ 2003-04-06 17:54 UTC (permalink / raw)


"Luis O. Silva" <silva@paloma.spbu.ru> writes:

> Please be indulgent with my ignorance. I have set
> `indent-tabs-mode' to nil through `custom-set-variables' and
> the setting seems to be global. Should I infer from this that
> `custom-set-variables' acts like `setq-default'?

I expect that custom does the right thing both for variables that are
automatically buffer-local and for those that are not, but I can't
answer that for sure.
-- 
Benjamin

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

* Re: death to tabs
  2003-04-04 20:23 John Russell
                   ` (5 preceding siblings ...)
  2003-04-05  0:59 ` Thomas A. Horsley
@ 2003-04-07  8:16 ` Stefan Kamphausen
  6 siblings, 0 replies; 18+ messages in thread
From: Stefan Kamphausen @ 2003-04-07  8:16 UTC (permalink / raw)


Hi John,

John Russell <jorussel@cisco.com> wrote in message news:<m3wuiaxb9d.fsf@debussy.cisco.com>...
> Ok, seriously, I don't ever want to see another tab as long as I
> live.  I want _every__ tab I ever wrote converted to spaces right
> now and I never want to have a tab show up when I hit the TAB key
> again.  All spaces all the time.  
> 
> I found 
>   (setq indent-tabs-mode nil)
> 
> for future tab annihilation but how can I convert a doc with tabs in
> it to just spaces.  Thanks for the help.

very old holy war that is...
You might be interested in reading
http://www.jwz.org/doc/tabs-vs-spaces.html

In contrast to the code mentioned there I'd use (make-local-hook
'write-contents-hook) instead of make-local-variable, use (when
(search-forward...)) instead of (if ..) and I chose to leave trailing
whitespaces in lines (to make them rectangle-selectable) so I removed
a few lines.

Best Regards
Stefan Kamphausen

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

* Re: death to tabs
  2003-04-05  0:17 ` chris.danx
  2003-04-05  1:15   ` Thomas A. Horsley
@ 2003-04-07 11:36   ` Colin Marquardt
  1 sibling, 0 replies; 18+ messages in thread
From: Colin Marquardt @ 2003-04-07 11:36 UTC (permalink / raw)


"chris.danx" <spamoff.danx@ntlworld.com> writes:

> What I'd like is for emacs to create new files without tabs and
> detect if a file uses tabs & guess the right offset to preserve
> others preference or retabify everything to make it neat (and have
> tabs only for makefiles).

See http://www.emacswiki.org/cgi-bin/wiki.pl?GuessOffset
for a start on this.

HTH,
  Colin

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

end of thread, other threads:[~2003-04-07 11:36 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-04 20:48 death to tabs Sebastien Routier
  -- strict thread matches above, loose matches on Subject: below --
2003-04-04 20:23 John Russell
2003-04-04 20:30 ` greg jednaszewski
2003-04-04 21:15 ` Bijan Soleymani
2003-04-04 21:37 ` Peter Lee
2003-04-04 23:11 ` Benjamin Rutt
2003-04-04 23:25   ` Bruce Korb
2003-04-05 13:50   ` Roy Smith
2003-04-05 16:35     ` Benjamin Rutt
2003-04-06  5:25   ` Luis O. Silva
     [not found]   ` <mailman.4167.1049606724.21513.help-gnu-emacs@gnu.org>
2003-04-06 17:54     ` Benjamin Rutt
2003-04-05  0:17 ` chris.danx
2003-04-05  1:15   ` Thomas A. Horsley
2003-04-05 13:56     ` Roy Smith
2003-04-05 20:24     ` Kai Großjohann
2003-04-07 11:36   ` Colin Marquardt
2003-04-05  0:59 ` Thomas A. Horsley
2003-04-07  8:16 ` Stefan Kamphausen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).