;;; whitespace.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2000-2011 Free Software Foundation, Inc.
;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
;; Keywords: data, wp
-;; Version: 13.2
+;; Version: 13.2.1
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
;; This file is part of GNU Emacs.
;; Acknowledgements
;; ----------------
;;
+;; Thanks to felix (EmacsWiki) for keeping highlight when switching between
+;; major modes on a file.
+;;
;; Thanks to David Reitter <david.reitter@gmail.com> for suggesting a
;; `whitespace-newline' initialization with low contrast relative to
;; the background color.
(defcustom whitespace-trailing-regexp
- "\\(\\(\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)$"
+ "\\([\t \u00A0]+\\)$"
"Specify trailing characters regexp.
If you're using `mule' package, there may be other characters besides:
- \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
-\"\\xF20\"
+ \" \" \"\\t\" \"\\u00A0\"
that should be considered blank.
(noninteractive ; running a batch job
(setq global-whitespace-mode nil))
(global-whitespace-mode ; global-whitespace-mode on
- (save-excursion
+ (save-current-buffer
(add-hook 'find-file-hook 'whitespace-turn-on-if-enabled)
+ (add-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled)
(dolist (buffer (buffer-list)) ; adjust all local mode
(set-buffer buffer)
(unless whitespace-mode
(whitespace-turn-on-if-enabled)))))
(t ; global-whitespace-mode off
- (save-excursion
+ (save-current-buffer
(remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled)
+ (remove-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled)
(dolist (buffer (buffer-list)) ; adjust all local mode
(set-buffer buffer)
(unless whitespace-mode
;; whole buffer
(t
(save-excursion
- (save-match-data
+ (save-match-data ;FIXME: Why?
;; PROBLEM 1: empty lines at bob
;; PROBLEM 2: empty lines at eob
;; ACTION: remove all empty lines at bob and/or eob
overwrite-mode ; enforce no overwrite
tmp)
(save-excursion
- (save-match-data
+ (save-match-data ;FIXME: Why?
;; PROBLEM 1: 8 or more SPACEs at bol
(cond
;; ACTION: replace 8 or more SPACEs at bol by TABs, if
(interactive "r")
(setq force (or current-prefix-arg force))
(save-excursion
- (save-match-data
+ (save-match-data ;FIXME: Why?
(let* ((has-bogus nil)
(rstart (min start end))
(rend (max start end))
"Scroll help window, if it exists.
If UP is non-nil, scroll up; otherwise, scroll down."
- (condition-case data-help
+ (condition-case nil
(let ((buffer (get-buffer whitespace-help-buffer-name)))
(if buffer
(with-selected-window (get-buffer-window buffer)
"Match trailing spaces which do not contain the point at end of line."
(let ((status t))
(while (if (re-search-forward whitespace-trailing-regexp limit t)
- (save-match-data
- (= whitespace-point (match-end 1))) ;; loop if point at eol
- (setq status nil))) ;; end of buffer
+ (= whitespace-point (match-end 1)) ;; Loop if point at eol.
+ (setq status nil))) ;; End of buffer.
status))
((= b 1)
(setq r (and (/= whitespace-point 1)
(looking-at whitespace-empty-at-bob-regexp)))
- (if r
- (set-marker whitespace-bob-marker (match-end 1))
- (set-marker whitespace-bob-marker b)))
+ (set-marker whitespace-bob-marker (if r (match-end 1) b)))
;; inside bob empty region
((<= limit whitespace-bob-marker)
(setq r (looking-at whitespace-empty-at-bob-regexp))
;; intersection with end of bob empty region
((<= b whitespace-bob-marker)
(setq r (looking-at whitespace-empty-at-bob-regexp))
- (if r
- (set-marker whitespace-bob-marker (match-end 1))
- (set-marker whitespace-bob-marker b)))
+ (set-marker whitespace-bob-marker (if r (match-end 1) b)))
;; it is not inside bob empty region
(t
(setq r nil)))
r))
-(defun whitespace-buffer-changed (beg end)
+(defun whitespace-buffer-changed (_beg _end)
"Set `whitespace-buffer-changed' variable to t."
(setq whitespace-buffer-changed t))
(run-hooks 'whitespace-load-hook)
-;; arch-tag: 1b1e2500-dbd4-4a26-8f7a-5a5edfd3c97e
;;; whitespace.el ends here