diff options
| author | Stefan Monnier | 2011-05-03 22:02:09 -0300 |
|---|---|---|
| committer | Stefan Monnier | 2011-05-03 22:02:09 -0300 |
| commit | dd5a5ee08cb51d0b0be8f92b8d57aa326d7a7295 (patch) | |
| tree | 40ad8670918cd0ac6bd70c0123a6726fa2bd595e | |
| parent | c2f51e23ab57da738bf3d7e1411a28dcfd9da75c (diff) | |
| download | emacs-dd5a5ee08cb51d0b0be8f92b8d57aa326d7a7295.tar.gz emacs-dd5a5ee08cb51d0b0be8f92b8d57aa326d7a7295.zip | |
* 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.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/whitespace.el | 28 |
2 files changed, 19 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2c1ab1c7f6f..664d59ab41d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-05-04 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * whitespace.el (whitespace-trailing-regexp): Don't rely on the | ||
| 4 | internal encoding (e.g. tibetan zero is not whitespace). | ||
| 5 | (global-whitespace-mode): Prefer save-current-buffer. | ||
| 6 | (whitespace-trailing-regexp): Remove useless save-match-data. | ||
| 7 | (whitespace-empty-at-bob-regexp): Minor simplification. | ||
| 8 | |||
| 1 | 2011-05-03 Chong Yidong <cyd@stupidchicken.com> | 9 | 2011-05-03 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 10 | ||
| 3 | * emacs-lisp/autoload.el (generated-autoload-file): Doc fix (Bug#7989). | 11 | * emacs-lisp/autoload.el (generated-autoload-file): Doc fix (Bug#7989). |
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index f5788eb1ee2..89f078a5063 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el | |||
| @@ -800,13 +800,12 @@ Used when `whitespace-style' includes `tabs'." | |||
| 800 | 800 | ||
| 801 | 801 | ||
| 802 | (defcustom whitespace-trailing-regexp | 802 | (defcustom whitespace-trailing-regexp |
| 803 | "\\(\\(\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)$" | 803 | "\\([\t \u00A0]+\\)$" |
| 804 | "Specify trailing characters regexp. | 804 | "Specify trailing characters regexp. |
| 805 | 805 | ||
| 806 | If you're using `mule' package, there may be other characters besides: | 806 | If you're using `mule' package, there may be other characters besides: |
| 807 | 807 | ||
| 808 | \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \ | 808 | \" \" \"\\t\" \"\\u00A0\" |
| 809 | \"\\xF20\" | ||
| 810 | 809 | ||
| 811 | that should be considered blank. | 810 | that should be considered blank. |
| 812 | 811 | ||
| @@ -1133,7 +1132,7 @@ See also `whitespace-style', `whitespace-newline' and | |||
| 1133 | (noninteractive ; running a batch job | 1132 | (noninteractive ; running a batch job |
| 1134 | (setq global-whitespace-mode nil)) | 1133 | (setq global-whitespace-mode nil)) |
| 1135 | (global-whitespace-mode ; global-whitespace-mode on | 1134 | (global-whitespace-mode ; global-whitespace-mode on |
| 1136 | (save-excursion | 1135 | (save-current-buffer |
| 1137 | (add-hook 'find-file-hook 'whitespace-turn-on-if-enabled) | 1136 | (add-hook 'find-file-hook 'whitespace-turn-on-if-enabled) |
| 1138 | (add-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled) | 1137 | (add-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled) |
| 1139 | (dolist (buffer (buffer-list)) ; adjust all local mode | 1138 | (dolist (buffer (buffer-list)) ; adjust all local mode |
| @@ -1141,7 +1140,7 @@ See also `whitespace-style', `whitespace-newline' and | |||
| 1141 | (unless whitespace-mode | 1140 | (unless whitespace-mode |
| 1142 | (whitespace-turn-on-if-enabled))))) | 1141 | (whitespace-turn-on-if-enabled))))) |
| 1143 | (t ; global-whitespace-mode off | 1142 | (t ; global-whitespace-mode off |
| 1144 | (save-excursion | 1143 | (save-current-buffer |
| 1145 | (remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled) | 1144 | (remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled) |
| 1146 | (remove-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled) | 1145 | (remove-hook 'after-change-major-mode-hook 'whitespace-turn-on-if-enabled) |
| 1147 | (dolist (buffer (buffer-list)) ; adjust all local mode | 1146 | (dolist (buffer (buffer-list)) ; adjust all local mode |
| @@ -1526,7 +1525,7 @@ documentation." | |||
| 1526 | ;; whole buffer | 1525 | ;; whole buffer |
| 1527 | (t | 1526 | (t |
| 1528 | (save-excursion | 1527 | (save-excursion |
| 1529 | (save-match-data | 1528 | (save-match-data ;FIXME: Why? |
| 1530 | ;; PROBLEM 1: empty lines at bob | 1529 | ;; PROBLEM 1: empty lines at bob |
| 1531 | ;; PROBLEM 2: empty lines at eob | 1530 | ;; PROBLEM 2: empty lines at eob |
| 1532 | ;; ACTION: remove all empty lines at bob and/or eob | 1531 | ;; ACTION: remove all empty lines at bob and/or eob |
| @@ -1598,7 +1597,7 @@ documentation." | |||
| 1598 | overwrite-mode ; enforce no overwrite | 1597 | overwrite-mode ; enforce no overwrite |
| 1599 | tmp) | 1598 | tmp) |
| 1600 | (save-excursion | 1599 | (save-excursion |
| 1601 | (save-match-data | 1600 | (save-match-data ;FIXME: Why? |
| 1602 | ;; PROBLEM 1: 8 or more SPACEs at bol | 1601 | ;; PROBLEM 1: 8 or more SPACEs at bol |
| 1603 | (cond | 1602 | (cond |
| 1604 | ;; ACTION: replace 8 or more SPACEs at bol by TABs, if | 1603 | ;; ACTION: replace 8 or more SPACEs at bol by TABs, if |
| @@ -1870,7 +1869,7 @@ cleaning up these problems." | |||
| 1870 | (interactive "r") | 1869 | (interactive "r") |
| 1871 | (setq force (or current-prefix-arg force)) | 1870 | (setq force (or current-prefix-arg force)) |
| 1872 | (save-excursion | 1871 | (save-excursion |
| 1873 | (save-match-data | 1872 | (save-match-data ;FIXME: Why? |
| 1874 | (let* ((has-bogus nil) | 1873 | (let* ((has-bogus nil) |
| 1875 | (rstart (min start end)) | 1874 | (rstart (min start end)) |
| 1876 | (rend (max start end)) | 1875 | (rend (max start end)) |
| @@ -2412,9 +2411,8 @@ resultant list will be returned." | |||
| 2412 | "Match trailing spaces which do not contain the point at end of line." | 2411 | "Match trailing spaces which do not contain the point at end of line." |
| 2413 | (let ((status t)) | 2412 | (let ((status t)) |
| 2414 | (while (if (re-search-forward whitespace-trailing-regexp limit t) | 2413 | (while (if (re-search-forward whitespace-trailing-regexp limit t) |
| 2415 | (save-match-data | 2414 | (= whitespace-point (match-end 1)) ;; Loop if point at eol. |
| 2416 | (= whitespace-point (match-end 1))) ;; loop if point at eol | 2415 | (setq status nil))) ;; End of buffer. |
| 2417 | (setq status nil))) ;; end of buffer | ||
| 2418 | status)) | 2416 | status)) |
| 2419 | 2417 | ||
| 2420 | 2418 | ||
| @@ -2428,9 +2426,7 @@ beginning of buffer." | |||
| 2428 | ((= b 1) | 2426 | ((= b 1) |
| 2429 | (setq r (and (/= whitespace-point 1) | 2427 | (setq r (and (/= whitespace-point 1) |
| 2430 | (looking-at whitespace-empty-at-bob-regexp))) | 2428 | (looking-at whitespace-empty-at-bob-regexp))) |
| 2431 | (if r | 2429 | (set-marker whitespace-bob-marker (if r (match-end 1) b))) |
| 2432 | (set-marker whitespace-bob-marker (match-end 1)) | ||
| 2433 | (set-marker whitespace-bob-marker b))) | ||
| 2434 | ;; inside bob empty region | 2430 | ;; inside bob empty region |
| 2435 | ((<= limit whitespace-bob-marker) | 2431 | ((<= limit whitespace-bob-marker) |
| 2436 | (setq r (looking-at whitespace-empty-at-bob-regexp)) | 2432 | (setq r (looking-at whitespace-empty-at-bob-regexp)) |
| @@ -2441,9 +2437,7 @@ beginning of buffer." | |||
| 2441 | ;; intersection with end of bob empty region | 2437 | ;; intersection with end of bob empty region |
| 2442 | ((<= b whitespace-bob-marker) | 2438 | ((<= b whitespace-bob-marker) |
| 2443 | (setq r (looking-at whitespace-empty-at-bob-regexp)) | 2439 | (setq r (looking-at whitespace-empty-at-bob-regexp)) |
| 2444 | (if r | 2440 | (set-marker whitespace-bob-marker (if r (match-end 1) b))) |
| 2445 | (set-marker whitespace-bob-marker (match-end 1)) | ||
| 2446 | (set-marker whitespace-bob-marker b))) | ||
| 2447 | ;; it is not inside bob empty region | 2441 | ;; it is not inside bob empty region |
| 2448 | (t | 2442 | (t |
| 2449 | (setq r nil))) | 2443 | (setq r nil))) |