X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/1399490e2bb58e1e7212d7a8469e1286ced9423a..a73fae1ffa16e60f5ddc3a5536d322edc10a8a83:/lisp/whitespace.el diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 801cdc5204..3208c578fe 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el @@ -1,6 +1,6 @@ ;;; whitespace.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE -;; Copyright (C) 2000-2013 Free Software Foundation, Inc. +;; Copyright (C) 2000-2014 Free Software Foundation, Inc. ;; Author: Vinicius Jose Latorre ;; Maintainer: Vinicius Jose Latorre @@ -344,7 +344,7 @@ ;; Thanks to Andreas Roehler for ;; indicating defface byte-compilation warnings. ;; -;; Thanks to TimOCallaghan (EmacsWiki) for the idea about highlight +;; Thanks to Tim O'Callaghan (EmacsWiki) for the idea about highlight ;; "long" lines. See EightyColumnRule (EmacsWiki). ;; ;; Thanks to Yanghui Bian for indicating a new @@ -1084,7 +1084,7 @@ See also `whitespace-style', `whitespace-newline' and (not (memq major-mode (cdr whitespace-global-modes))) (memq major-mode whitespace-global-modes))) (t nil)) - ;; ...we have a display (we're running a batch job) + ;; ...we have a display (not running a batch job) (not noninteractive) ;; ...the buffer is not internal (name starts with a space) (not (eq (aref (buffer-name) 0) ?\ )) @@ -1471,6 +1471,12 @@ documentation." ;; PROBLEM 6: 8 or more SPACEs after TAB (whitespace-cleanup-region (point-min) (point-max))))) +(defun whitespace-ensure-local-variables () + "Set `whitespace-indent-tabs-mode' and `whitespace-tab-width' locally." + (set (make-local-variable 'whitespace-indent-tabs-mode) + indent-tabs-mode) + (set (make-local-variable 'whitespace-tab-width) + tab-width)) ;;;###autoload (defun whitespace-cleanup-region (start end) @@ -1517,6 +1523,7 @@ documentation." ;; read-only buffer (whitespace-warn-read-only "cleanup region") ;; non-read-only buffer + (whitespace-ensure-local-variables) (let ((rstart (min start end)) (rend (copy-marker (max start end))) (indent-tabs-mode whitespace-indent-tabs-mode) @@ -2095,7 +2102,6 @@ resultant list will be returned." (defvar whitespace-display-table-was-local nil "Used to remember whether a buffer initially had a local display table.") - (defun whitespace-turn-on () "Turn on whitespace visualization." ;; prepare local hooks @@ -2108,10 +2114,7 @@ resultant list will be returned." (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) + (whitespace-ensure-local-variables) ;; turn on whitespace (when whitespace-active-style (whitespace-color-on)