Skip to content

Instantly share code, notes, and snippets.

@RTfXGaGeqSeItbMUgpFlekUs
Created July 25, 2010 06:53
Show Gist options
  • Save RTfXGaGeqSeItbMUgpFlekUs/489375 to your computer and use it in GitHub Desktop.
Save RTfXGaGeqSeItbMUgpFlekUs/489375 to your computer and use it in GitHub Desktop.
(defmacro smart-tabs-advice (function offset)
(defvaralias offset 'tab-width)
`(defadvice ,function (around smart-tabs activate)
(cond
(indent-tabs-mode
(save-excursion
(beginning-of-line)
(while (looking-at "\t*\\( +\\)\t+")
(replace-match "" nil nil nil 1)))
(setq tab-width tab-width)
(let ((tab-width fill-column)
(,offset fill-column))
ad-do-it))
(t
ad-do-it))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment