unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to avoid SPACE TAB in a file?
@ 2009-11-25 19:25 Ulrich Neumerkel
  2009-11-25 20:04 ` Colin S. Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Neumerkel @ 2009-11-25 19:25 UTC (permalink / raw)
  To: help-gnu-emacs

It occurs to me occasionally that I happen to write SPACE TAB in a buffer
saved into a file.  This is mostly when I edit files with different
tabbing conventions.

Is there are general clean minor-mode or other way to avoid writing
this combination in general?


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

* Re: How to avoid SPACE TAB in a file?
  2009-11-25 19:25 How to avoid SPACE TAB in a file? Ulrich Neumerkel
@ 2009-11-25 20:04 ` Colin S. Miller
  2009-11-25 21:21   ` Drew Adams
  2009-11-25 23:11   ` Ulrich Neumerkel
  0 siblings, 2 replies; 6+ messages in thread
From: Colin S. Miller @ 2009-11-25 20:04 UTC (permalink / raw)
  To: help-gnu-emacs

Ulrich Neumerkel wrote:
> It occurs to me occasionally that I happen to write SPACE TAB in a buffer
> saved into a file.  This is mostly when I edit files with different
> tabbing conventions.
> 
> Is there are general clean minor-mode or other way to avoid writing
> this combination in general?

Hi Ulrich,
If you want emacs to always insert spaces instead of tabs then you can put
(setq indent-tabs-mode nil)
in your .emacs.

This needs to be set for each buffer, so it should be put in a hook like
(add-hook 'c-mode-hook '(lambda ()
    (setq indent-tabs-mode nil)))


You'll need to replace 'c-mode-hook  with the correct hook for the
editing mode you use. Most of them are named after the mode's main
function.


HTH,
Colin S. Miller
-- 
Replace the obvious in my email address with the first three letters of the hostname to reply.


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

* RE: How to avoid SPACE TAB in a file?
  2009-11-25 20:04 ` Colin S. Miller
@ 2009-11-25 21:21   ` Drew Adams
  2009-11-25 23:11   ` Ulrich Neumerkel
  1 sibling, 0 replies; 6+ messages in thread
From: Drew Adams @ 2009-11-25 21:21 UTC (permalink / raw)
  To: 'Colin S. Miller', help-gnu-emacs

> If you want emacs to always insert spaces instead of tabs 
> then you can put (setq indent-tabs-mode nil) in your .emacs.
> This needs to be set for each buffer, so it should be put in 
> a hook like
> (add-hook 'c-mode-hook '(lambda () (setq indent-tabs-mode nil)))


(setq-default indent-tabs-mode t)





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

* Re: How to avoid SPACE TAB in a file?
  2009-11-25 20:04 ` Colin S. Miller
  2009-11-25 21:21   ` Drew Adams
@ 2009-11-25 23:11   ` Ulrich Neumerkel
  2009-11-26 14:46     ` Ulrich Neumerkel
  1 sibling, 1 reply; 6+ messages in thread
From: Ulrich Neumerkel @ 2009-11-25 23:11 UTC (permalink / raw)
  To: help-gnu-emacs

"Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> writes:
>Ulrich Neumerkel wrote:
>> It occurs to me occasionally that I happen to write SPACE TAB in a buffer
>> saved into a file.  This is mostly when I edit files with different
>> tabbing conventions.
>> 
>> Is there are general clean minor-mode or other way to avoid writing
>> this combination in general?
>
>Hi Ulrich,
>If you want emacs to always insert spaces instead of tabs then you can put
>(setq indent-tabs-mode nil)
>in your .emacs.
>
>This needs to be set for each buffer, so it should be put in a hook like
>(add-hook 'c-mode-hook '(lambda ()
>    (setq indent-tabs-mode nil)))
>
>You'll need to replace 'c-mode-hook  with the correct hook for the
>editing mode you use. Most of them are named after the mode's main
>function.

The files/tabbing conventions are not mine, I just edit (tiny) parts of
the files.  That's how those extra spaces actually appear.
I am considering rolling it on my own with after-save-hook.


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

* Re: How to avoid SPACE TAB in a file?
  2009-11-25 23:11   ` Ulrich Neumerkel
@ 2009-11-26 14:46     ` Ulrich Neumerkel
  2009-11-27 15:11       ` Drew Adams
  0 siblings, 1 reply; 6+ messages in thread
From: Ulrich Neumerkel @ 2009-11-26 14:46 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks again for your responses.  Currently I put in my .emacs.el

(defun no-space-tab ()
  (interactive)
  (let
      ((point (point)))
    (save-match-data
      (goto-char (point-min))
      (cond
       ((search-forward " \t" nil t)
	(backward-char 1)
	(error "SPACE found prior to TAB! Press Backspace"))
       (t (goto-char point))))))

(add-hook 'after-save-hook 'no-space-tab)



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

* RE: How to avoid SPACE TAB in a file?
  2009-11-26 14:46     ` Ulrich Neumerkel
@ 2009-11-27 15:11       ` Drew Adams
  0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2009-11-27 15:11 UTC (permalink / raw)
  To: 'Ulrich Neumerkel', help-gnu-emacs

> Thanks again for your responses.  Currently I put in my .emacs.el
> 
> (defun no-space-tab ()
>   (interactive)
>   (let
>       ((point (point)))
>     (save-match-data
>       (goto-char (point-min))
>       (cond
>        ((search-forward " \t" nil t)
> 	(backward-char 1)
> 	(error "SPACE found prior to TAB! Press Backspace"))
>        (t (goto-char point))))))
> 
> (add-hook 'after-save-hook 'no-space-tab)

`C-h f untabify'





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

end of thread, other threads:[~2009-11-27 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-25 19:25 How to avoid SPACE TAB in a file? Ulrich Neumerkel
2009-11-25 20:04 ` Colin S. Miller
2009-11-25 21:21   ` Drew Adams
2009-11-25 23:11   ` Ulrich Neumerkel
2009-11-26 14:46     ` Ulrich Neumerkel
2009-11-27 15:11       ` Drew Adams

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).