aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2013-08-01 14:58:28 +0200
committerTassilo Horn2013-08-01 14:58:28 +0200
commit06d36e2b5f500764309c00fa96bbed59ee7fd750 (patch)
treeee2f5879ce4614313acb033089f77a3da3c622d0
parent51457e0080c982a1760dcf75a84dba923dc37f01 (diff)
downloademacs-06d36e2b5f500764309c00fa96bbed59ee7fd750.tar.gz
emacs-06d36e2b5f500764309c00fa96bbed59ee7fd750.zip
Refactor out setting `whitespace-indent-tabs-mode' and
`whitespace-tab-width' buffer-locally to own function, so that `whitespace-cleanup' and friends work appropriately without needing to enable `whitespace-mode'. * whitespace.el (whitespace-ensure-local-variables): New function. (whitespace-cleanup-region): Call it. (whitespace-turn-on): Call it.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/whitespace.el13
2 files changed, 14 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e80c34d3842..d6623caed08 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-08-01 Tassilo Horn <tsdh@gnu.org>
2
3 * whitespace.el (whitespace-ensure-local-variables): New function.
4 (whitespace-cleanup-region): Call it.
5 (whitespace-turn-on): Call it.
6
12013-08-01 Michael Albinus <michael.albinus@gmx.de> 72013-08-01 Michael Albinus <michael.albinus@gmx.de>
2 8
3 Complete file name handlers. 9 Complete file name handlers.
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 801cdc52047..b462cf0b811 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1471,6 +1471,12 @@ documentation."
1471 ;; PROBLEM 6: 8 or more SPACEs after TAB 1471 ;; PROBLEM 6: 8 or more SPACEs after TAB
1472 (whitespace-cleanup-region (point-min) (point-max))))) 1472 (whitespace-cleanup-region (point-min) (point-max)))))
1473 1473
1474(defun whitespace-ensure-local-variables ()
1475 "Set `whitespace-indent-tabs-mode' and `whitespace-tab-width' locally."
1476 (set (make-local-variable 'whitespace-indent-tabs-mode)
1477 indent-tabs-mode)
1478 (set (make-local-variable 'whitespace-tab-width)
1479 tab-width))
1474 1480
1475;;;###autoload 1481;;;###autoload
1476(defun whitespace-cleanup-region (start end) 1482(defun whitespace-cleanup-region (start end)
@@ -1517,6 +1523,7 @@ documentation."
1517 ;; read-only buffer 1523 ;; read-only buffer
1518 (whitespace-warn-read-only "cleanup region") 1524 (whitespace-warn-read-only "cleanup region")
1519 ;; non-read-only buffer 1525 ;; non-read-only buffer
1526 (whitespace-ensure-local-variables)
1520 (let ((rstart (min start end)) 1527 (let ((rstart (min start end))
1521 (rend (copy-marker (max start end))) 1528 (rend (copy-marker (max start end)))
1522 (indent-tabs-mode whitespace-indent-tabs-mode) 1529 (indent-tabs-mode whitespace-indent-tabs-mode)
@@ -2095,7 +2102,6 @@ resultant list will be returned."
2095(defvar whitespace-display-table-was-local nil 2102(defvar whitespace-display-table-was-local nil
2096 "Used to remember whether a buffer initially had a local display table.") 2103 "Used to remember whether a buffer initially had a local display table.")
2097 2104
2098
2099(defun whitespace-turn-on () 2105(defun whitespace-turn-on ()
2100 "Turn on whitespace visualization." 2106 "Turn on whitespace visualization."
2101 ;; prepare local hooks 2107 ;; prepare local hooks
@@ -2108,10 +2114,7 @@ resultant list will be returned."
2108 (if (listp whitespace-style) 2114 (if (listp whitespace-style)
2109 whitespace-style 2115 whitespace-style
2110 (list whitespace-style))) 2116 (list whitespace-style)))
2111 (set (make-local-variable 'whitespace-indent-tabs-mode) 2117 (whitespace-ensure-local-variables)
2112 indent-tabs-mode)
2113 (set (make-local-variable 'whitespace-tab-width)
2114 tab-width)
2115 ;; turn on whitespace 2118 ;; turn on whitespace
2116 (when whitespace-active-style 2119 (when whitespace-active-style
2117 (whitespace-color-on) 2120 (whitespace-color-on)