Commit dd5a5ee0 authored by Stefan Monnier's avatar Stefan Monnier
Browse files

* lisp/whitespace.el (whitespace-trailing-regexp): Don't rely on the

internal encoding (e.g. tibetan zero is not whitespace).
(global-whitespace-mode): Prefer save-current-buffer.
(whitespace-trailing-regexp): Remove useless save-match-data.
(whitespace-empty-at-bob-regexp): Minor simplification.
parent c2f51e23
2011-05-04 Stefan Monnier <monnier@iro.umontreal.ca>
* whitespace.el (whitespace-trailing-regexp): Don't rely on the
internal encoding (e.g. tibetan zero is not whitespace).
(global-whitespace-mode): Prefer save-current-buffer.
(whitespace-trailing-regexp): Remove useless save-match-data.
(whitespace-empty-at-bob-regexp): Minor simplification.
2011-05-03 Chong Yidong <cyd@stupidchicken.com> 2011-05-03 Chong Yidong <cyd@stupidchicken.com>
* emacs-lisp/autoload.el (generated-autoload-file): Doc fix (Bug#7989). * emacs-lisp/autoload.el (generated-autoload-file): Doc fix (Bug#7989).
......
...@@ -800,13 +800,12 @@ Used when `whitespace-style' includes `tabs'." ...@@ -800,13 +800,12 @@ Used when `whitespace-style' includes `tabs'."
(defcustom whitespace-trailing-regexp (defcustom whitespace-trailing-regexp
"\\(\\(\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)$" "\\([\t \u00A0]+\\)$"
"Specify trailing characters regexp. "Specify trailing characters regexp.
If you're using `mule' package, there may be other characters besides: If you're using `mule' package, there may be other characters besides:
\" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \ \" \" \"\\t\" \"\\u00A0\"
\"\\xF20\"
that should be considered blank. that should be considered blank.
...@@ -1133,7 +1132,7 @@ See also `whitespace-style', `whitespace-newline' and ...@@ -1133,7 +1132,7 @@ See also `whitespace-style', `whitespace-newline' and
(noninteractive ; running a batch job (noninteractive ; running a batch job
(setq global-whitespace-mode nil)) (setq global-whitespace-mode nil))
(global-whitespace-mode ; global-whitespace-mode on (global-whitespace-mode ; global-whitespace-mode on
(save-excursion (save-current-buffer
(add-hook 'find-file-hook 'whitespace-turn-on-if-enabled) (add-hook 'find-file-hook 'whitespace-turn-on-if-enabled)
(add-hook 'after-change-major-mode-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 (dolist (buffer (buffer-list)) ; adjust all local mode
...@@ -1141,7 +1140,7 @@ See also `whitespace-style', `whitespace-newline' and ...@@ -1141,7 +1140,7 @@ See also `whitespace-style', `whitespace-newline' and
(unless whitespace-mode (unless whitespace-mode
(whitespace-turn-on-if-enabled))))) (whitespace-turn-on-if-enabled)))))
(t ; global-whitespace-mode off (t ; global-whitespace-mode off
(save-excursion (save-current-buffer
(remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled) (remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled)
(remove-hook 'after-change-major-mode-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 (dolist (buffer (buffer-list)) ; adjust all local mode
...@@ -1526,7 +1525,7 @@ documentation." ...@@ -1526,7 +1525,7 @@ documentation."
;; whole buffer ;; whole buffer
(t (t
(save-excursion (save-excursion
(save-match-data (save-match-data ;FIXME: Why?
;; PROBLEM 1: empty lines at bob ;; PROBLEM 1: empty lines at bob
;; PROBLEM 2: empty lines at eob ;; PROBLEM 2: empty lines at eob
;; ACTION: remove all empty lines at bob and/or eob ;; ACTION: remove all empty lines at bob and/or eob
...@@ -1598,7 +1597,7 @@ documentation." ...@@ -1598,7 +1597,7 @@ documentation."
overwrite-mode ; enforce no overwrite overwrite-mode ; enforce no overwrite
tmp) tmp)
(save-excursion (save-excursion
(save-match-data (save-match-data ;FIXME: Why?
;; PROBLEM 1: 8 or more SPACEs at bol ;; PROBLEM 1: 8 or more SPACEs at bol
(cond (cond
;; ACTION: replace 8 or more SPACEs at bol by TABs, if ;; ACTION: replace 8 or more SPACEs at bol by TABs, if
...@@ -1870,7 +1869,7 @@ cleaning up these problems." ...@@ -1870,7 +1869,7 @@ cleaning up these problems."
(interactive "r") (interactive "r")
(setq force (or current-prefix-arg force)) (setq force (or current-prefix-arg force))
(save-excursion (save-excursion
(save-match-data (save-match-data ;FIXME: Why?
(let* ((has-bogus nil) (let* ((has-bogus nil)
(rstart (min start end)) (rstart (min start end))
(rend (max start end)) (rend (max start end))
...@@ -2412,9 +2411,8 @@ resultant list will be returned." ...@@ -2412,9 +2411,8 @@ resultant list will be returned."
"Match trailing spaces which do not contain the point at end of line." "Match trailing spaces which do not contain the point at end of line."
(let ((status t)) (let ((status t))
(while (if (re-search-forward whitespace-trailing-regexp limit t) (while (if (re-search-forward whitespace-trailing-regexp limit t)
(save-match-data (= whitespace-point (match-end 1)) ;; Loop if point at eol.
(= whitespace-point (match-end 1))) ;; loop if point at eol (setq status nil))) ;; End of buffer.
(setq status nil))) ;; end of buffer
status)) status))
...@@ -2428,9 +2426,7 @@ beginning of buffer." ...@@ -2428,9 +2426,7 @@ beginning of buffer."
((= b 1) ((= b 1)
(setq r (and (/= whitespace-point 1) (setq r (and (/= whitespace-point 1)
(looking-at whitespace-empty-at-bob-regexp))) (looking-at whitespace-empty-at-bob-regexp)))
(if r (set-marker whitespace-bob-marker (if r (match-end 1) b)))
(set-marker whitespace-bob-marker (match-end 1))
(set-marker whitespace-bob-marker b)))
;; inside bob empty region ;; inside bob empty region
((<= limit whitespace-bob-marker) ((<= limit whitespace-bob-marker)
(setq r (looking-at whitespace-empty-at-bob-regexp)) (setq r (looking-at whitespace-empty-at-bob-regexp))
...@@ -2441,9 +2437,7 @@ beginning of buffer." ...@@ -2441,9 +2437,7 @@ beginning of buffer."
;; intersection with end of bob empty region ;; intersection with end of bob empty region
((<= b whitespace-bob-marker) ((<= b whitespace-bob-marker)
(setq r (looking-at whitespace-empty-at-bob-regexp)) (setq r (looking-at whitespace-empty-at-bob-regexp))
(if r (set-marker whitespace-bob-marker (if r (match-end 1) b)))
(set-marker whitespace-bob-marker (match-end 1))
(set-marker whitespace-bob-marker b)))
;; it is not inside bob empty region ;; it is not inside bob empty region
(t (t
(setq r nil))) (setq r nil)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment