From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nikolaj Schumacher Newsgroups: gmane.emacs.help Subject: Re: whitespace-cleanup + untabify? Date: Sat, 14 Jun 2008 18:49:43 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1213462225 14081 80.91.229.12 (14 Jun 2008 16:50:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 14 Jun 2008 16:50:25 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Kevin Rodgers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jun 14 18:51:08 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K7Yy3-0001FG-13 for geh-help-gnu-emacs@m.gmane.org; Sat, 14 Jun 2008 18:51:07 +0200 Original-Received: from localhost ([127.0.0.1]:33382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7YxE-0000mT-If for geh-help-gnu-emacs@m.gmane.org; Sat, 14 Jun 2008 12:50:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K7Yws-0000kT-0I for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:49:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K7Ywl-0000h6-Vz for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:49:49 -0400 Original-Received: from [199.232.76.173] (port=44132 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7Ywl-0000h0-EB for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:49:47 -0400 Original-Received: from fmmailgate02.web.de ([217.72.192.227]:49232) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K7Ywk-0001Ec-7b for help-gnu-emacs@gnu.org; Sat, 14 Jun 2008 12:49:46 -0400 Original-Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate02.web.de (Postfix) with ESMTP id 5C898E1A2249; Sat, 14 Jun 2008 18:49:44 +0200 (CEST) Original-Received: from [77.189.10.154] (helo=thursday) by smtp06.web.de with asmtp (WEB.DE 4.109 #226) id 1K7Ywi-0003wu-00; Sat, 14 Jun 2008 18:49:44 +0200 In-Reply-To: (Kevin Rodgers's message of "Sat\, 14 Jun 2008 06\:37\:07 -0600") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (darwin) X-Sender: n_schumacher@web.de X-Provags-ID: V01U2FsdGVkX180sTYu0Iswt3AwJXXaU0keKzxctvPX+Jnbe6B1 8HA44zs406CfFasehfvwU15uaGYlGujswehKvRW1T3fA5gwHr5 WaZ8MABb7KpkHDIoZqEA== X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:54839 Archived-At: Kevin Rodgers wrote: > It's not documented, but because whitespace-global-mode is defined > via define-minor-mode there should be whitespace-global-mode-hook. > So perhaps something like this will work: > > (add-hook 'whitespace-global-mode-hook > (lambda () > (when whitespace-global-mode > (untabify (point-min) (point-max))))) That won't work. It will probably only untabify the .emacs file. It should instead add an `untabify' variant to 'find-file-hook, 'write-file-functions and 'kill-buffer-hook. Of course that would ignore the setting of `whitespace-auto-cleanup', and would stay active after the mode has been disabled. I think the cleanest way would be a parallel mode: (defun untabify-buffer () (untabify (point-min) (point-max)) nil ;; for write-file-functions ) (define-minor-mode untabify-global-mode :global t :group 'whitespace (if untabify-global-mode (progn (add-hook 'find-file-hook 'untabify-buffer) (add-hook 'write-file-functions 'untabify-buffer nil t) (add-hook 'kill-buffer-hook 'untabify-buffer)) (remove-hook 'find-file-hook 'untabify-buffer) (remove-hook 'write-file-functions 'untabify-buffer t) (remove-hook 'kill-buffer-hook 'untabify-buffer))) (Not tested.) regards, Nikolaj Schumacher