diff options
| author | Eli Zaretskii | 2006-11-04 10:34:56 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2006-11-04 10:34:56 +0000 |
| commit | 113fa448472fbbe5be5aee0cf5547cda29540060 (patch) | |
| tree | bed15b20a03798a1d38888bd94398feb66e98030 | |
| parent | e6043b9581253b9215c2a751d0e77c562f177350 (diff) | |
| download | emacs-113fa448472fbbe5be5aee0cf5547cda29540060.tar.gz emacs-113fa448472fbbe5be5aee0cf5547cda29540060.zip | |
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
the beginning of a line.
(whitespace-buffer): Use `remove-overlays' instead of
`whitespace-unhighlight-the-space' and `overlay-recenter' to speed up overlay
handling.
(whitespace-buffer-leading, whitespace-buffer-trailing): Make these functions
highlight the text removed by `whitespace-buffer-leading-cleanup' and
`whitespace-buffer-trailing-cleanup' respectively.
(whitespace-buffer-search): Use `with-local-quit'. Move `format' out of loop
to speed up scanning larger buffers.
(whitespace-unhighlight-the-space): Remove `remove-hook' since that function is
never added to a hook.
(whitespace-spacetab-regexp, whitespace-ateol-regexp)
(whitespace-buffer-leading-cleanup)
(whitespace-refresh-rescan-list): Fix docstrings.
| -rw-r--r-- | lisp/ChangeLog | 23 | ||||
| -rw-r--r-- | lisp/whitespace.el | 99 |
2 files changed, 59 insertions, 63 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a9d99e0e6bd..a026c80deb5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2006-11-04 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * whitespace.el (whitespace-indent-regexp): Make this match any | ||
| 4 | multiples of eight spaces near the beginning of a line. | ||
| 5 | (whitespace-buffer): Use `remove-overlays' instead of | ||
| 6 | `whitespace-unhighlight-the-space' and `overlay-recenter' to | ||
| 7 | speed up overlay handling. | ||
| 8 | (whitespace-buffer-leading, whitespace-buffer-trailing): Make | ||
| 9 | these functions highlight the text removed by | ||
| 10 | `whitespace-buffer-leading-cleanup' and | ||
| 11 | `whitespace-buffer-trailing-cleanup' respectively. | ||
| 12 | (whitespace-buffer-search): Use `with-local-quit'. Move | ||
| 13 | `format' out of loop to speed up scanning larger buffers. | ||
| 14 | (whitespace-unhighlight-the-space): Remove `remove-hook' since | ||
| 15 | that function is never added to a hook. | ||
| 16 | (whitespace-spacetab-regexp, whitespace-ateol-regexp) | ||
| 17 | (whitespace-buffer-leading-cleanup) | ||
| 18 | (whitespace-refresh-rescan-list): Fix docstrings. | ||
| 19 | |||
| 1 | 2006-11-03 Ken Manheimer <ken.manheimer@gmail.com> | 20 | 2006-11-03 Ken Manheimer <ken.manheimer@gmail.com> |
| 2 | 21 | ||
| 3 | * allout.el (allout-during-yank-processing): Cue for inhibiting | 22 | * allout.el (allout-during-yank-processing): Cue for inhibiting |
| @@ -237,7 +256,7 @@ | |||
| 237 | * midnight.el (midnight-buffer-display-time): Doc fix. | 256 | * midnight.el (midnight-buffer-display-time): Doc fix. |
| 238 | (clean-buffer-list-kill-never-buffer-names): Add "*server*". | 257 | (clean-buffer-list-kill-never-buffer-names): Add "*server*". |
| 239 | 258 | ||
| 240 | 2006-10-22 martin rudalics <rudalics@gmx.at> | 259 | 2006-10-22 Martin Rudalics <rudalics@gmx.at> |
| 241 | 260 | ||
| 242 | * textmodes/flyspell.el (flyspell-check-region-doublons): | 261 | * textmodes/flyspell.el (flyspell-check-region-doublons): |
| 243 | Fix last fix. | 262 | Fix last fix. |
| @@ -254,7 +273,7 @@ | |||
| 254 | event to unread-command-events as (t . EVENT) so it will be added | 273 | event to unread-command-events as (t . EVENT) so it will be added |
| 255 | to this-command-keys by read-key-sequence. | 274 | to this-command-keys by read-key-sequence. |
| 256 | 275 | ||
| 257 | 2006-10-22 martin rudalics <rudalics@gmx.at> | 276 | 2006-10-22 Martin Rudalics <rudalics@gmx.at> |
| 258 | 277 | ||
| 259 | * textmodes/flyspell.el (flyspell-word): Skip past all previous | 278 | * textmodes/flyspell.el (flyspell-word): Skip past all previous |
| 260 | whitespace when checking doublons. | 279 | whitespace when checking doublons. |
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index bb829278ef3..9c98b23cf28 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el | |||
| @@ -194,7 +194,7 @@ It can be overriden by setting a buffer local variable | |||
| 194 | :group 'whitespace) | 194 | :group 'whitespace) |
| 195 | 195 | ||
| 196 | (defcustom whitespace-spacetab-regexp "[ ]+\t" | 196 | (defcustom whitespace-spacetab-regexp "[ ]+\t" |
| 197 | "Regexp to match a space followed by a TAB." | 197 | "Regexp to match one or more spaces followed by a TAB." |
| 198 | :type 'regexp | 198 | :type 'regexp |
| 199 | :group 'whitespace) | 199 | :group 'whitespace) |
| 200 | 200 | ||
| @@ -205,8 +205,9 @@ It can be overriden by setting a buffer local variable | |||
| 205 | :type 'boolean | 205 | :type 'boolean |
| 206 | :group 'whitespace) | 206 | :group 'whitespace) |
| 207 | 207 | ||
| 208 | (defcustom whitespace-indent-regexp (concat "^\\(\t*\\) " " ") | 208 | (defcustom whitespace-indent-regexp "^\t*\\( \\)+" |
| 209 | "Regexp to match (any TABS followed by) 8/more whitespaces at start of line." | 209 | "Regexp to match multiples of eight spaces near line beginnings. |
| 210 | The default value ignores leading TABs." | ||
| 210 | :type 'regexp | 211 | :type 'regexp |
| 211 | :group 'whitespace) | 212 | :group 'whitespace) |
| 212 | 213 | ||
| @@ -217,9 +218,8 @@ It can be overriden by setting a buffer local variable | |||
| 217 | :type 'boolean | 218 | :type 'boolean |
| 218 | :group 'whitespace) | 219 | :group 'whitespace) |
| 219 | 220 | ||
| 220 | ;; (defcustom whitespace-ateol-regexp "[ \t]$" | ||
| 221 | (defcustom whitespace-ateol-regexp "[ \t]+$" | 221 | (defcustom whitespace-ateol-regexp "[ \t]+$" |
| 222 | "Regexp to match a TAB or a space at the EOL." | 222 | "Regexp to match one or more TABs or spaces at line ends." |
| 223 | :type 'regexp | 223 | :type 'regexp |
| 224 | :group 'whitespace) | 224 | :group 'whitespace) |
| 225 | 225 | ||
| @@ -425,7 +425,8 @@ and: | |||
| 425 | (progn | 425 | (progn |
| 426 | (whitespace-check-buffer-list (buffer-name) buffer-file-name) | 426 | (whitespace-check-buffer-list (buffer-name) buffer-file-name) |
| 427 | (whitespace-tickle-timer) | 427 | (whitespace-tickle-timer) |
| 428 | (whitespace-unhighlight-the-space) | 428 | (remove-overlays nil nil 'face 'whitespace-highlight) |
| 429 | (overlay-recenter (point-max)) | ||
| 429 | (if whitespace-auto-cleanup | 430 | (if whitespace-auto-cleanup |
| 430 | (if buffer-read-only | 431 | (if buffer-read-only |
| 431 | (if (not quiet) | 432 | (if (not quiet) |
| @@ -591,74 +592,53 @@ See `whitespace-buffer' docstring for a summary of the problems." | |||
| 591 | (whitespace-buffer t))) | 592 | (whitespace-buffer t))) |
| 592 | 593 | ||
| 593 | (defun whitespace-buffer-leading () | 594 | (defun whitespace-buffer-leading () |
| 594 | "Check to see if there are any empty lines at the top of the file." | 595 | "Return t if the current buffer has leading newline characters. |
| 596 | If highlighting is enabled, highlight these characters." | ||
| 595 | (save-excursion | 597 | (save-excursion |
| 596 | (let ((pmin nil) | 598 | (goto-char (point-min)) |
| 597 | (pmax nil)) | 599 | (skip-chars-forward "\n") |
| 598 | (goto-char (point-min)) | 600 | (unless (bobp) |
| 599 | (beginning-of-line) | 601 | (whitespace-highlight-the-space (point-min) (point)) |
| 600 | (setq pmin (point)) | 602 | t))) |
| 601 | (end-of-line) | ||
| 602 | (setq pmax (point)) | ||
| 603 | (if (equal pmin pmax) | ||
| 604 | (progn | ||
| 605 | (whitespace-highlight-the-space pmin (1+ pmax)) | ||
| 606 | t) | ||
| 607 | nil)))) | ||
| 608 | 603 | ||
| 609 | (defun whitespace-buffer-leading-cleanup () | 604 | (defun whitespace-buffer-leading-cleanup () |
| 610 | "Remove any empty lines at the top of the file." | 605 | "Remove any leading newline characters from current buffer." |
| 611 | (save-excursion | 606 | (save-excursion |
| 612 | (goto-char (point-min)) | 607 | (goto-char (point-min)) |
| 613 | (skip-chars-forward "\n") | 608 | (skip-chars-forward "\n") |
| 614 | (delete-region (point-min) (point)))) | 609 | (delete-region (point-min) (point)))) |
| 615 | 610 | ||
| 616 | (defun whitespace-buffer-trailing () | 611 | (defun whitespace-buffer-trailing () |
| 617 | "Check to see if are is more than one empty line at the bottom." | 612 | "Return t if the current buffer has extra trailing newline characters. |
| 613 | If highlighting is enabled, highlight these characters." | ||
| 618 | (save-excursion | 614 | (save-excursion |
| 619 | (let ((pmin nil) | 615 | (goto-char (point-max)) |
| 620 | (pmax nil)) | 616 | (skip-chars-backward "\n") |
| 621 | (goto-char (point-max)) | 617 | (forward-line) |
| 622 | (beginning-of-line) | 618 | (unless (eobp) |
| 623 | (setq pmin (point)) | 619 | (whitespace-highlight-the-space (point) (point-max)) |
| 624 | (end-of-line) | 620 | t))) |
| 625 | (setq pmax (point)) | ||
| 626 | (if (equal pmin pmax) | ||
| 627 | (progn | ||
| 628 | (goto-char (- (point) 1)) | ||
| 629 | (beginning-of-line) | ||
| 630 | (setq pmin (point)) | ||
| 631 | (end-of-line) | ||
| 632 | (setq pmax (point)) | ||
| 633 | (if (equal pmin pmax) | ||
| 634 | (progn | ||
| 635 | (whitespace-highlight-the-space (- pmin 1) pmax) | ||
| 636 | t) | ||
| 637 | nil)) | ||
| 638 | nil)))) | ||
| 639 | 621 | ||
| 640 | (defun whitespace-buffer-trailing-cleanup () | 622 | (defun whitespace-buffer-trailing-cleanup () |
| 641 | "Delete all the empty lines at the bottom." | 623 | "Remove extra trailing newline characters from current buffer." |
| 642 | (save-excursion | 624 | (save-excursion |
| 643 | (goto-char (point-max)) | 625 | (goto-char (point-max)) |
| 644 | (skip-chars-backward "\n") | 626 | (skip-chars-backward "\n") |
| 645 | (if (not (bolp)) | 627 | (unless (eobp) |
| 646 | (forward-char 1)) | 628 | (forward-line) |
| 647 | (delete-region (point) (point-max)))) | 629 | (delete-region (point) (point-max))))) |
| 648 | 630 | ||
| 649 | (defun whitespace-buffer-search (regexp) | 631 | (defun whitespace-buffer-search (regexp) |
| 650 | "Search for any given whitespace REGEXP." | 632 | "Search for any given whitespace REGEXP." |
| 651 | (let ((whitespace-retval "")) | 633 | (with-local-quit |
| 652 | (save-excursion | 634 | (let (whitespace-retval) |
| 653 | (goto-char (point-min)) | 635 | (save-excursion |
| 654 | (while (re-search-forward regexp nil t) | 636 | (goto-char (point-min)) |
| 655 | (progn | 637 | (while (re-search-forward regexp nil t) |
| 656 | (setq whitespace-retval (format "%s %s" whitespace-retval | 638 | (whitespace-highlight-the-space (match-beginning 0) (match-end 0)) |
| 657 | (match-beginning 0))) | 639 | (push (match-beginning 0) whitespace-retval))) |
| 658 | (whitespace-highlight-the-space (match-beginning 0) (match-end 0)))) | 640 | (when whitespace-retval |
| 659 | (if (equal "" whitespace-retval) | 641 | (format " %s" (nreverse whitespace-retval)))))) |
| 660 | nil | ||
| 661 | whitespace-retval)))) | ||
| 662 | 642 | ||
| 663 | (defun whitespace-buffer-cleanup (regexp newregexp) | 643 | (defun whitespace-buffer-cleanup (regexp newregexp) |
| 664 | "Search for any given whitespace REGEXP and replace it with the NEWREGEXP." | 644 | "Search for any given whitespace REGEXP and replace it with the NEWREGEXP." |
| @@ -713,17 +693,14 @@ Also with whitespaces whose testing has been turned off." | |||
| 713 | "Highlight the current line, unhighlighting a previously jumped to line." | 693 | "Highlight the current line, unhighlighting a previously jumped to line." |
| 714 | (if whitespace-display-spaces-in-color | 694 | (if whitespace-display-spaces-in-color |
| 715 | (let ((ol (whitespace-make-overlay b e))) | 695 | (let ((ol (whitespace-make-overlay b e))) |
| 716 | (push ol whitespace-highlighted-space) | ||
| 717 | (whitespace-overlay-put ol 'face 'whitespace-highlight)))) | 696 | (whitespace-overlay-put ol 'face 'whitespace-highlight)))) |
| 718 | ;; (add-hook 'pre-command-hook 'whitespace-unhighlight-the-space)) | ||
| 719 | 697 | ||
| 720 | (defun whitespace-unhighlight-the-space() | 698 | (defun whitespace-unhighlight-the-space() |
| 721 | "Unhighlight the currently highlight line." | 699 | "Unhighlight the currently highlight line." |
| 722 | (if (and whitespace-display-spaces-in-color whitespace-highlighted-space) | 700 | (if (and whitespace-display-spaces-in-color whitespace-highlighted-space) |
| 723 | (progn | 701 | (progn |
| 724 | (mapc 'whitespace-delete-overlay whitespace-highlighted-space) | 702 | (mapc 'whitespace-delete-overlay whitespace-highlighted-space) |
| 725 | (setq whitespace-highlighted-space nil)) | 703 | (setq whitespace-highlighted-space nil)))) |
| 726 | (remove-hook 'pre-command-hook 'whitespace-unhighlight-the-space))) | ||
| 727 | 704 | ||
| 728 | (defun whitespace-check-buffer-list (buf-name buf-file) | 705 | (defun whitespace-check-buffer-list (buf-name buf-file) |
| 729 | "Add a buffer and its file to the whitespace monitor list. | 706 | "Add a buffer and its file to the whitespace monitor list. |
| @@ -780,7 +757,7 @@ If timer is not set, then set it to scan the files in | |||
| 780 | (whitespace-refresh-rescan-list buffile bufname)))))) | 757 | (whitespace-refresh-rescan-list buffile bufname)))))) |
| 781 | 758 | ||
| 782 | (defun whitespace-refresh-rescan-list (buffile bufname) | 759 | (defun whitespace-refresh-rescan-list (buffile bufname) |
| 783 | "Refresh the list of files to be rescaned for whitespace creep." | 760 | "Refresh the list of files to be rescanned for whitespace creep." |
| 784 | (if whitespace-all-buffer-files | 761 | (if whitespace-all-buffer-files |
| 785 | (setq whitespace-all-buffer-files | 762 | (setq whitespace-all-buffer-files |
| 786 | (delete (list buffile bufname) whitespace-all-buffer-files)) | 763 | (delete (list buffile bufname) whitespace-all-buffer-files)) |