(defvar whitespace-active-style nil
"Used to save locally `whitespace-style' value.")
-(defvar whitespace-indent-tabs-mode indent-tabs-mode
- "Used to save locally `indent-tabs-mode' value.")
-
-(defvar whitespace-tab-width tab-width
- "Used to save locally `tab-width' value.")
-
(defvar whitespace-point (point)
"Used to save locally current point value.
Used by function `whitespace-trailing-regexp' (which see).")
;; PROBLEM 6: `tab-width' 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)
;; 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)
- (tab-width whitespace-tab-width)
overwrite-mode ; enforce no overwrite
tmp)
(save-excursion
;; by SPACEs.
((memq 'space-after-tab whitespace-style)
(whitespace-replace-action
- (if whitespace-indent-tabs-mode 'tabify 'untabify)
+ (if indent-tabs-mode 'tabify 'untabify)
rstart rend (whitespace-space-after-tab-regexp) 1))
;; ACTION: replace `tab-width' or more SPACEs by TABs.
((memq 'space-after-tab::tab whitespace-style)
;; by SPACEs.
((memq 'space-before-tab whitespace-style)
(whitespace-replace-action
- (if whitespace-indent-tabs-mode 'tabify 'untabify)
+ (if indent-tabs-mode 'tabify 'untabify)
rstart rend whitespace-space-before-tab-regexp
- (if whitespace-indent-tabs-mode 0 2)))
+ (if indent-tabs-mode 0 2)))
;; ACTION: replace SPACEs before TAB by TABs.
((memq 'space-before-tab::tab whitespace-style)
(whitespace-replace-action
(defun whitespace-regexp (regexp &optional kind)
- "Return REGEXP depending on `whitespace-indent-tabs-mode'."
+ "Return REGEXP depending on `indent-tabs-mode'."
(format
(cond
((or (eq kind 'tab)
- whitespace-indent-tabs-mode)
+ indent-tabs-mode)
(car regexp))
((or (eq kind 'space)
- (not whitespace-indent-tabs-mode))
+ (not indent-tabs-mode))
(cdr regexp)))
- whitespace-tab-width))
+ tab-width))
(defun whitespace-indentation-regexp (&optional kind)
- "Return the indentation regexp depending on `whitespace-indent-tabs-mode'."
+ "Return the indentation regexp depending on `indent-tabs-mode'."
(whitespace-regexp whitespace-indentation-regexp kind))
(defun whitespace-space-after-tab-regexp (&optional kind)
- "Return the space-after-tab regexp depending on `whitespace-indent-tabs-mode'."
+ "Return the space-after-tab regexp depending on `indent-tabs-mode'."
(whitespace-regexp whitespace-space-after-tab-regexp kind))
whitespace-report-list)))
(when (pcase report-if-bogus (`nil t) (`never nil) (_ has-bogus))
(whitespace-kill-buffer whitespace-report-buffer-name)
- ;; `whitespace-indent-tabs-mode' is local to current buffer
- ;; `whitespace-tab-width' is local to current buffer
- (let ((ws-indent-tabs-mode whitespace-indent-tabs-mode)
- (ws-tab-width whitespace-tab-width))
+ ;; `indent-tabs-mode' may be local to current buffer
+ ;; `tab-width' may be local to current buffer
+ (let ((ws-indent-tabs-mode indent-tabs-mode)
+ (ws-tab-width tab-width))
(with-current-buffer (get-buffer-create
whitespace-report-buffer-name)
(erase-buffer)
(if (listp whitespace-style)
whitespace-style
(list whitespace-style)))
- (whitespace-ensure-local-variables)
;; turn on whitespace
(when whitespace-active-style
(whitespace-color-on)
`((,(let ((line-column (or whitespace-line-column fill-column)))
(format
"^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$"
- whitespace-tab-width
- (1- whitespace-tab-width)
- (/ line-column whitespace-tab-width)
- (let ((rem (% line-column whitespace-tab-width)))
+ tab-width
+ (1- tab-width)
+ (/ line-column tab-width)
+ (let ((rem (% line-column tab-width)))
(if (zerop rem)
""
(format ".\\{%d\\}" rem)))))
,(cond
((memq 'space-before-tab whitespace-active-style)
;; Show SPACEs before TAB (indent-tabs-mode).
- (if whitespace-indent-tabs-mode 1 2))
+ (if indent-tabs-mode 1 2))
((memq 'space-before-tab::tab whitespace-active-style)
1)
((memq 'space-before-tab::space whitespace-active-style)