From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Reuben Thomas Newsgroups: gmane.emacs.bugs Subject: bug#6651: Better fix Date: Mon, 26 Jul 2010 19:16:51 +0100 Message-ID: References: <87oce7lgnz.fsf@mord.config> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1280169466 3877 80.91.229.12 (26 Jul 2010 18:37:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 26 Jul 2010 18:37:46 +0000 (UTC) To: 6651 <6651@debbugs.gnu.org> Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 26 20:37:44 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSYZ-0008EU-Qs for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Jul 2010 20:37:44 +0200 Original-Received: from localhost ([127.0.0.1]:50733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdSYZ-0001VZ-9k for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Jul 2010 14:37:43 -0400 Original-Received: from [140.186.70.92] (port=33208 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdSYT-0001VU-BV for bug-gnu-emacs@gnu.org; Mon, 26 Jul 2010 14:37:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdSYS-0008AS-9O for bug-gnu-emacs@gnu.org; Mon, 26 Jul 2010 14:37:37 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36457) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSYS-0008AL-39 for bug-gnu-emacs@gnu.org; Mon, 26 Jul 2010 14:37:36 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1OdSEY-0005SR-4K; Mon, 26 Jul 2010 14:17:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87oce7lgnz.fsf@mord.config> Resent-From: Reuben Thomas Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 26 Jul 2010 18:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6651 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6651-submit@debbugs.gnu.org id=B6651.128016821220970 (code B ref 6651); Mon, 26 Jul 2010 18:17:01 +0000 Original-Received: (at 6651) by debbugs.gnu.org; 26 Jul 2010 18:16:52 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdSEN-0005SB-Vg for submit@debbugs.gnu.org; Mon, 26 Jul 2010 14:16:52 -0400 Original-Received: from exprod7og103.obsmtp.com ([64.18.2.159]) by debbugs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OdSEL-0005S6-FE for 6651@debbugs.gnu.org; Mon, 26 Jul 2010 14:16:50 -0400 Original-Received: from source ([209.85.214.171]) by exprod7ob103.postini.com ([64.18.6.12]) with SMTP ID DSNKTE3RFrTpk4i5tjmwyh1fkM5BEiEds/9C@postini.com; Mon, 26 Jul 2010 11:17:00 PDT Original-Received: by iwn41 with SMTP id 41so2767016iwn.30 for <6651@debbugs.gnu.org>; Mon, 26 Jul 2010 11:16:52 -0700 (PDT) Original-Received: by 10.231.29.33 with SMTP id o33mr8539012ibc.164.1280168211871; Mon, 26 Jul 2010 11:16:51 -0700 (PDT) Original-Received: by 10.231.196.144 with HTTP; Mon, 26 Jul 2010 11:16:51 -0700 (PDT) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 26 Jul 2010 14:17:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:38956 Archived-At: I recently found that my previous suggested workaround for using whitespace-mode's autocorrection without display is flawed, as it doesn't deal with local variables. This means that for example one's settings for tabs vs spaces can be ignored. Here's a fuller solution, which has two advantages: first, the local variables now work, and secondly, the workaround of explicitly setting write-file-functions is no longer needed. Instead, this version of the workaround disables whitespace-mode display altogether, by simply redefining whitespace-mode-{on,off}. It could therefore form the basis of a refactoring that allows display mode to be separated from correction mode. Code follows (for .emacs or equivalent): (require 'whitespace) ;; Versions of whitespace functions that don't turn visualisation on (defun whitespace-turn-on () "Turn on whitespace correction." ;; prepare local hooks (add-hook 'write-file-functions 'whitespace-write-file-hook nil t) ;; create whitespace local buffer environment (set (make-local-variable 'whitespace-font-lock-mode) nil) (set (make-local-variable 'whitespace-font-lock) nil) (set (make-local-variable 'whitespace-font-lock-keywords) nil) (set (make-local-variable 'whitespace-display-table) nil) (set (make-local-variable 'whitespace-display-table-was-local) nil) (set (make-local-variable 'whitespace-active-style) (if (listp whitespace-style) whitespace-style (list whitespace-style))) (set (make-local-variable 'whitespace-indent-tabs-mode) indent-tabs-mode) (set (make-local-variable 'whitespace-tab-width) tab-width)) (defun whitespace-turn-off () "Turn off whitespace correction." (remove-hook 'write-file-functions 'whitespace-write-file-hook t)) -- http://rrt.sc3d.org