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

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

Re: whitespace-cleanup + untabify?


From: Juanma Barranquero
Subject: Re: whitespace-cleanup + untabify?
Date: Sat, 14 Jun 2008 14:02:17 +0200

On Sat, Jun 14, 2008 at 12:56, address@hidden <address@hidden> wrote:

> I haven't found any
> option that connects untabify and whitespace-cleanup. I'm using:

That really depends on how do you want to do the untabify.

For example, you can defadvice `whitespace-cleanup' like so

(defadvice whitespace-cleanup (after whitespace-untabify activate compile)
  (save-restriction
    (widen)
    (untabify (point-min) (point-max))))

so when you do M-x whitespace cleanup, it first cleans up and then
untabifies. Take into account that untabify removes tabs anywhere in
the line; if you prefer only to untabify at the beginning of line, you
could use this instead:

(defadvice whitespace-cleanup (after whitespace-untabify activate compile)
  (save-restriction
    (widen)
    (let ((tabify-regexp "^\t* [ \t]+"))
      (untabify (point-min) (point-max)))))

Both examples untabify the whole buffer (that's what the
`save-restriction' and `widen' calls are for), so if you in fact only
want to untabify the region, it's even simpler:

(defadvice whitespace-cleanup (after whitespace-untabify activate compile)
  (untabify (point-min) (point-max)))

Does this help?

  Juanma




reply via email to

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