[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: whitespace issues
From: |
Rusi |
Subject: |
Re: whitespace issues |
Date: |
Tue, 30 Jun 2015 19:50:02 -0700 (PDT) |
User-agent: |
G2/1.0 |
On Wednesday, July 1, 2015 at 4:57:21 AM UTC+5:30, Emanuel Berg wrote:
> Rusi writes:
>
> > 1. Is it possible to have some sort of save-hook so
> > that all leading (indentation) whitespace is cleaned
> > up to space alone and tabs are removed?
>
> Do this and indentation will be in whitespaces only:
>
> (setq-default indent-tabs-mode nil)
>
> Only in Makefiles you still get tabs - otherwise they
> (the Makefiles) won't work.
>
> But to answer your question, yes, you can use
> `before-save-hook' and `untabify'.
>
> If you want to add exceptions, it could look like
> this:
>
> (defun untab-all ()
> (unless (member major-mode '(makefile-gmake-mode
> makefile-mode) ) ; exceptions
> (untabify (point-min) (point-max)))
> nil) ; tell 'did not write buffer to disk'
>
> But I think it is better to have the file as you edit
> it be as close to the finished form as possible, and
> not have it post-processed like that.
Ok thanks Emanuel, Jorge
Putting your two together I have
--------------------
(add-hook 'before-save-hook
'untab-python
)
(defun untab-python ()
(when (member major-mode '(python-mode))
(untabify (point-min) (point-max)))
nil)
----------------------
1. dunno about the save-excursion
2. member rather than equal/eq so that other modes can be added as desired
- Re: whitespace issues, (continued)
- Re: whitespace issues, Jorge A. Alfaro-Murillo, 2015/06/30
- Re: whitespace issues, Óscar Fuentes, 2015/06/30
- Re: whitespace issues, Ian Zimmerman, 2015/06/30
- Message not available
- Re: whitespace issues, Dan Espen, 2015/06/30
- Re: whitespace issues, Emanuel Berg, 2015/06/30
- Message not available
- Message not available
- Re: whitespace issues,
Rusi <=