diff options
| author | Richard M. Stallman | 1999-09-10 02:42:59 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-09-10 02:42:59 +0000 |
| commit | 24b72a45b79fdeec02e68ceb19efc21c741317f6 (patch) | |
| tree | 779be66e6d18f0977b487bafa06b8f91165f83b7 | |
| parent | 774b98f30d8d21ddd939e0afa1b2417c96ac3c6d (diff) | |
| download | emacs-24b72a45b79fdeec02e68ceb19efc21c741317f6.tar.gz emacs-24b72a45b79fdeec02e68ceb19efc21c741317f6.zip | |
Finish making it fit Emacs conventions. Add autoloads.
| -rw-r--r-- | lisp/whitespace.el | 233 |
1 files changed, 146 insertions, 87 deletions
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 8b67cfd7dbb..4d417983e4d 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el | |||
| @@ -30,6 +30,11 @@ | |||
| 30 | 30 | ||
| 31 | ;; `whitespace-buffer' - To check the current buffer for whitespace problems. | 31 | ;; `whitespace-buffer' - To check the current buffer for whitespace problems. |
| 32 | ;; `whitespace-cleanup' - To cleanup all whitespaces in the current buffer. | 32 | ;; `whitespace-cleanup' - To cleanup all whitespaces in the current buffer. |
| 33 | ;; `whitespace-region' - To check between point and mark for whitespace | ||
| 34 | ;; problems. | ||
| 35 | ;; `whitespace-cleanup-region' - To cleanup all whitespaces between point | ||
| 36 | ;; and mark in the current buffer. | ||
| 37 | ;; `whitespace-describe' - A simple introduction to the library. | ||
| 33 | 38 | ||
| 34 | ;;; Code: | 39 | ;;; Code: |
| 35 | 40 | ||
| @@ -37,73 +42,72 @@ | |||
| 37 | (add-hook 'find-file-hooks 'whitespace-buffer) | 42 | (add-hook 'find-file-hooks 'whitespace-buffer) |
| 38 | (add-hook 'kill-buffer-hook 'whitespace-buffer) | 43 | (add-hook 'kill-buffer-hook 'whitespace-buffer) |
| 39 | 44 | ||
| 40 | (defvar whitespace-version "1.9" "Version of the whitespace library.") | 45 | (defvar whitespace-version "2.3" "Version of the whitespace library.") |
| 41 | (defvar whitespace-indent-regexp (concat "^\\( *\\) " " ") | 46 | ;; Find out what type of Emacs we are running in. |
| 42 | "Any 8 or more spaces that can be replaced with a TAB") | ||
| 43 | (defvar whitespace-spacetab-regexp " \t" "A TAB followed by a space") | ||
| 44 | (defvar whitespace-ateol-regexp "[ \t]$" "A TAB or a space at the EOL") | ||
| 45 | (defvar whitespace-errbuf "*Whitespace Errors*" | ||
| 46 | "The buffer where the errors will appear") | ||
| 47 | |||
| 48 | ;; Find out what type of emacs we are running in. | ||
| 49 | (defvar whitespace-running-emacs (if (string-match "XEmacs\\|Lucid" | 47 | (defvar whitespace-running-emacs (if (string-match "XEmacs\\|Lucid" |
| 50 | emacs-version) nil t) | 48 | emacs-version) nil t) |
| 51 | "If the current Emacs is not XEmacs, then, this is t.") | 49 | "If this is Emacs, not XEmacs, this is t.") |
| 52 | |||
| 53 | ;; For users of Emacs 19.x, defgroup and defcustom are not defined. | ||
| 54 | 50 | ||
| 55 | (if (< (string-to-int emacs-version) 20) | 51 | (if whitespace-running-emacs (require 'timer)) |
| 56 | (progn | ||
| 57 | (defmacro defgroup (sym memb doc &rest args) | ||
| 58 | t) | ||
| 59 | (defmacro defcustom (sym val doc &rest args) | ||
| 60 | `(defvar ,sym ,val ,doc)))) | ||
| 61 | 52 | ||
| 62 | (defgroup whitespace nil | 53 | (defvar whitespace-all-buffer-files nil |
| 63 | "Check for five different types of whitespaces in source code. | 54 | "An associated list of buffers and files checked for whitespace cleanliness. |
| 64 | 55 | ||
| 65 | 1. Leading space \(empty lines at the top of a file\). | 56 | This is to enable periodic checking of whitespace cleanliness in the files |
| 66 | 2. Trailing space \(empty lines at the end of a file\). | 57 | visited by the buffers.") |
| 67 | 3. Indentation space \(8 or more spaces at beginning of line, that should be | ||
| 68 | replaced with TABS\). | ||
| 69 | 4. Spaces followed by a TAB. \(Almost always, we never want that\). | ||
| 70 | 5. Spaces or TABS at the end of a line. | ||
| 71 | 58 | ||
| 72 | Whitespace errors are reported in a buffer, and on the modeline. | 59 | (defvar whitespace-rescan-timer nil |
| 60 | "Timer object used to rescan the files in buffers that have been modified.") | ||
| 73 | 61 | ||
| 74 | Modeline will show a W:<x> to denote a particular type of whitespace, where | 62 | ;; For users of Emacs 19.x, defgroup and defcustom are not defined. |
| 75 | `x' can be one \(or more\) of: | ||
| 76 | 63 | ||
| 77 | e - End-of-Line whitespace. | 64 | (eval-when-compile |
| 78 | i - Indentation whitespace. | 65 | (if (< (string-to-int emacs-version) 20) |
| 79 | l - Leading whitespace. | 66 | (progn |
| 80 | s - Space followed by Tab. | 67 | (defmacro defgroup (sym memb doc &rest args) |
| 81 | t - Trailing whitespace. | 68 | "Null macro for defgroup in all versions of Emacs < 20.x" |
| 69 | t) | ||
| 70 | (defmacro defcustom (sym val doc &rest args) | ||
| 71 | "Macro to alias defcustom to defvar in all versions of Emacs < 20.x" | ||
| 72 | `(defvar ,sym ,val ,doc))))) | ||
| 82 | 73 | ||
| 83 | " | 74 | (defgroup whitespace nil |
| 75 | "Check for and fix five different types of whitespaces in source code." | ||
| 84 | ;; Since XEmacs doesn't have a 'convenience group, use the next best group | 76 | ;; Since XEmacs doesn't have a 'convenience group, use the next best group |
| 85 | ;; which is 'editing? | 77 | ;; which is 'editing? |
| 86 | :group (if whitespace-running-emacs 'convenience 'editing)) | 78 | :group (if whitespace-running-emacs 'convenience 'editing)) |
| 87 | 79 | ||
| 88 | (defcustom whitespace-auto-cleanup nil | 80 | (defcustom whitespace-spacetab-regexp " \t" |
| 89 | "Setting this will cleanup a buffer automatically on finding it whitespace | 81 | "Regexp to match a TAB followed by a space." |
| 90 | unclean. | 82 | :type 'string |
| 83 | :group 'whitespace) | ||
| 91 | 84 | ||
| 92 | Use the emacs `customize' command to set this. | 85 | (defcustom whitespace-indent-regexp (concat "^\\(\t*\\) " " ") |
| 93 | " | 86 | "Regexp to match (any TABS followed by) 8/more whitespaces at start of line." |
| 87 | :type 'string | ||
| 88 | :group 'whitespace) | ||
| 89 | |||
| 90 | (defcustom whitespace-ateol-regexp "[ \t]$" | ||
| 91 | "Regexp to match a TAB or a space at the EOL." | ||
| 92 | :type 'string | ||
| 93 | :group 'whitespace) | ||
| 94 | |||
| 95 | (defcustom whitespace-errbuf "*Whitespace Errors*" | ||
| 96 | "The buffer where whitespace related messages will be logged." | ||
| 97 | :type 'string | ||
| 98 | :group 'whitespace) | ||
| 99 | |||
| 100 | (defcustom whitespace-auto-cleanup nil | ||
| 101 | "Cleanup a buffer automatically on finding it whitespace unclean." | ||
| 94 | :type 'boolean | 102 | :type 'boolean |
| 95 | :group 'whitespace) | 103 | :group 'whitespace) |
| 96 | 104 | ||
| 97 | (defcustom whitespace-silent nil | 105 | (defcustom whitespace-silent nil |
| 98 | "Setting this to t will cause the whitespace error buffer not to pop | 106 | "All whitespace errors will be shown only in the modeline when t. |
| 99 | up. All whitespace errors will be shown only in the modeline. | ||
| 100 | 107 | ||
| 101 | Note that setting this may cause all whitespaces introduced in a file to go | 108 | Note that setting this may cause all whitespaces introduced in a file to go |
| 102 | unnoticed when the buffer is killed, unless the user visits the `*Whitespace | 109 | unnoticed when the buffer is killed, unless the user visits the `*Whitespace |
| 103 | Errors*' buffer before opening \(or closing\) another file. | 110 | Errors*' buffer before opening (or closing) another file." |
| 104 | |||
| 105 | Use the emacs `customize' command to set this. | ||
| 106 | " | ||
| 107 | :type 'boolean | 111 | :type 'boolean |
| 108 | :group 'whitespace) | 112 | :group 'whitespace) |
| 109 | 113 | ||
| @@ -121,37 +125,27 @@ Use the emacs `customize' command to set this. | |||
| 121 | simula-mode tcl-mode tex-mode | 125 | simula-mode tcl-mode tex-mode |
| 122 | texinfo-mode vrml-mode xml-mode) | 126 | texinfo-mode vrml-mode xml-mode) |
| 123 | 127 | ||
| 124 | "Modes that we check whitespace in. These are mostly programming and | 128 | "Major Modes in which we turn on whitespace checking. |
| 125 | documentation modes. But you may add other modes that you want whitespaces | ||
| 126 | checked in by adding something like the following to your `.emacs': | ||
| 127 | |||
| 128 | \(setq whitespace-modes \(cons 'my-mode \(cons 'my-other-mode | ||
| 129 | whitespace-modes\)\) | ||
| 130 | |||
| 131 | Or, alternately, you can use the Emacs `customize' command to set this. | ||
| 132 | " | ||
| 133 | :group 'whitespace) | ||
| 134 | 129 | ||
| 135 | (if whitespace-running-emacs (require 'timer)) | 130 | These are mostly programming and documentation modes. But you may add other |
| 131 | modes that you want whitespaces checked in by adding something like the | ||
| 132 | following to your `.emacs': | ||
| 136 | 133 | ||
| 137 | (defvar whitespace-all-buffer-files nil | 134 | \(setq whitespace-modes (cons 'my-mode (cons 'my-other-mode |
| 138 | "An associated list of all buffers | 135 | whitespace-modes))\) |
| 139 | and theirs files checked for whitespace cleanliness. This is to enable | ||
| 140 | periodic checking of whitespace cleanliness in the files visited by the | ||
| 141 | buffers.") | ||
| 142 | 136 | ||
| 143 | (defvar whitespace-rescan-timer nil | 137 | Or, alternately, you can use the Emacs `customize' command to set this." |
| 144 | "Timer object that will be set to | 138 | :group 'whitespace) |
| 145 | rescan the files in Emacs buffers that have been modified.") | ||
| 146 | 139 | ||
| 147 | (defcustom whitespace-rescan-timer-time 60 | 140 | (defcustom whitespace-rescan-timer-time 60 |
| 148 | "seconds after which | 141 | "Period in seconds to rescan modified buffers for whitespace creep. |
| 149 | `whitespace-rescan-files-in-buffers' will check for modified files in Emacs | 142 | |
| 150 | buffers." | 143 | This is the period after which the timer will fire causing |
| 144 | `whitespace-rescan-files-in-buffers' to check for whitespace creep in | ||
| 145 | modified buffers." | ||
| 151 | :type 'integer | 146 | :type 'integer |
| 152 | :group 'whitespace) | 147 | :group 'whitespace) |
| 153 | 148 | ||
| 154 | |||
| 155 | ;; Tell Emacs about this new kind of minor mode | 149 | ;; Tell Emacs about this new kind of minor mode |
| 156 | (make-variable-buffer-local 'whitespace-mode) | 150 | (make-variable-buffer-local 'whitespace-mode) |
| 157 | (put 'whitespace-mode 'permanent-local nil) | 151 | (put 'whitespace-mode 'permanent-local nil) |
| @@ -166,12 +160,14 @@ buffers." | |||
| 166 | minor-mode-alist))) | 160 | minor-mode-alist))) |
| 167 | 161 | ||
| 168 | (defun whitespace-check-whitespace-mode (&optional arg) | 162 | (defun whitespace-check-whitespace-mode (&optional arg) |
| 163 | "Test and set the whitespace-mode in qualifying buffers." | ||
| 169 | (if (null whitespace-mode) | 164 | (if (null whitespace-mode) |
| 170 | (setq whitespace-mode | 165 | (setq whitespace-mode |
| 171 | (if (or arg (member major-mode whitespace-modes)) | 166 | (if (or arg (member major-mode whitespace-modes)) |
| 172 | t | 167 | t |
| 173 | nil)))) | 168 | nil)))) |
| 174 | 169 | ||
| 170 | ;;;###autoload | ||
| 175 | (defun whitespace-buffer (&optional quiet) | 171 | (defun whitespace-buffer (&optional quiet) |
| 176 | "Find five different types of white spaces in buffer: | 172 | "Find five different types of white spaces in buffer: |
| 177 | 173 | ||
| @@ -184,8 +180,7 @@ buffers." | |||
| 184 | Check for whitespace only if this buffer really contains a non-empty file | 180 | Check for whitespace only if this buffer really contains a non-empty file |
| 185 | and: | 181 | and: |
| 186 | 1. the major mode is one of the whitespace-modes, or | 182 | 1. the major mode is one of the whitespace-modes, or |
| 187 | 2. `whitespace-buffer' was explicitly called with a prefix argument. | 183 | 2. `whitespace-buffer' was explicitly called with a prefix argument." |
| 188 | " | ||
| 189 | (interactive) | 184 | (interactive) |
| 190 | (whitespace-check-whitespace-mode current-prefix-arg) | 185 | (whitespace-check-whitespace-mode current-prefix-arg) |
| 191 | (if (and buffer-file-name (> (buffer-size) 0) whitespace-mode) | 186 | (if (and buffer-file-name (> (buffer-size) 0) whitespace-mode) |
| @@ -249,7 +244,7 @@ and: | |||
| 249 | (if whitespace-errmsg | 244 | (if whitespace-errmsg |
| 250 | (progn | 245 | (progn |
| 251 | (insert whitespace-errmsg) | 246 | (insert whitespace-errmsg) |
| 252 | (if (not (and quiet whitespace-silent)) | 247 | (if (not (or quiet whitespace-silent)) |
| 253 | (display-buffer whitespace-errbuf t)) | 248 | (display-buffer whitespace-errbuf t)) |
| 254 | (if (not quiet) | 249 | (if (not quiet) |
| 255 | (message "Whitespaces: [%s] in %s" | 250 | (message "Whitespaces: [%s] in %s" |
| @@ -258,17 +253,21 @@ and: | |||
| 258 | (if (not quiet) | 253 | (if (not quiet) |
| 259 | (message "%s clean" whitespace-filename))))))))) | 254 | (message "%s clean" whitespace-filename))))))))) |
| 260 | 255 | ||
| 256 | ;;;###autoload | ||
| 261 | (defun whitespace-region (s e) | 257 | (defun whitespace-region (s e) |
| 262 | "To check a region specified by point and mark for whitespace errors." | 258 | "Check a region specified by point and mark for whitespace errors." |
| 263 | (interactive "r") | 259 | (interactive "r") |
| 264 | (save-excursion | 260 | (save-excursion |
| 265 | (save-restriction | 261 | (save-restriction |
| 266 | (narrow-to-region s e) | 262 | (narrow-to-region s e) |
| 267 | (whitespace-buffer)))) | 263 | (whitespace-buffer)))) |
| 268 | 264 | ||
| 265 | ;;;###autoload | ||
| 269 | (defun whitespace-cleanup () | 266 | (defun whitespace-cleanup () |
| 270 | "To cleanup the five different kinds of whitespace problems that | 267 | "Cleanup the five different kinds of whitespace problems. |
| 271 | are defined in \\[whitespace-buffer]" | 268 | |
| 269 | Use \\[describe-function] whitespace-describe to read a summary of the | ||
| 270 | whitespace problems." | ||
| 272 | (interactive) | 271 | (interactive) |
| 273 | ;; If this buffer really contains a file, then run, else quit. | 272 | ;; If this buffer really contains a file, then run, else quit. |
| 274 | (whitespace-check-whitespace-mode current-prefix-arg) | 273 | (whitespace-check-whitespace-mode current-prefix-arg) |
| @@ -314,8 +313,9 @@ are defined in \\[whitespace-buffer]" | |||
| 314 | (whitespace-force-mode-line-update))) | 313 | (whitespace-force-mode-line-update))) |
| 315 | (setq tab-width whitespace-tabwith-saved)))) | 314 | (setq tab-width whitespace-tabwith-saved)))) |
| 316 | 315 | ||
| 316 | ;;;###autoload | ||
| 317 | (defun whitespace-cleanup-region (s e) | 317 | (defun whitespace-cleanup-region (s e) |
| 318 | "To do a whitespace cleanup on a region specified by point and mark." | 318 | "Whitespace cleanup on a region specified by point and mark." |
| 319 | (interactive "r") | 319 | (interactive "r") |
| 320 | (save-excursion | 320 | (save-excursion |
| 321 | (save-restriction | 321 | (save-restriction |
| @@ -338,7 +338,7 @@ are defined in \\[whitespace-buffer]" | |||
| 338 | nil)))) | 338 | nil)))) |
| 339 | 339 | ||
| 340 | (defun whitespace-buffer-leading-cleanup () | 340 | (defun whitespace-buffer-leading-cleanup () |
| 341 | "To remove any empty lines at the top of the file." | 341 | "Remove any empty lines at the top of the file." |
| 342 | (save-excursion | 342 | (save-excursion |
| 343 | (let ((pmin nil) | 343 | (let ((pmin nil) |
| 344 | (pmax nil)) | 344 | (pmax nil)) |
| @@ -418,9 +418,7 @@ are defined in \\[whitespace-buffer]" | |||
| 418 | (replace-match newregexp)))) | 418 | (replace-match newregexp)))) |
| 419 | 419 | ||
| 420 | (defun whitespace-indent-cleanup () | 420 | (defun whitespace-indent-cleanup () |
| 421 | "Search for any 8 or more whitespaces at the beginning of a line and | 421 | "Search for 8/more spaces at the start of a line and replace it with tabs." |
| 422 | replace it with tabs." | ||
| 423 | (interactive) | ||
| 424 | (save-excursion | 422 | (save-excursion |
| 425 | (goto-char (point-min)) | 423 | (goto-char (point-min)) |
| 426 | (while (re-search-forward whitespace-indent-regexp nil t) | 424 | (while (re-search-forward whitespace-indent-regexp nil t) |
| @@ -431,17 +429,26 @@ replace it with tabs." | |||
| 431 | 429 | ||
| 432 | ;; Force mode line updation for different Emacs versions | 430 | ;; Force mode line updation for different Emacs versions |
| 433 | (defun whitespace-force-mode-line-update () | 431 | (defun whitespace-force-mode-line-update () |
| 434 | "To Force the mode line update for different flavors of Emacs." | 432 | "Force the mode line update for different flavors of Emacs." |
| 435 | (if whitespace-running-emacs | 433 | (if whitespace-running-emacs |
| 436 | (force-mode-line-update) ; Emacs | 434 | (force-mode-line-update) ; Emacs |
| 437 | (redraw-modeline))) ; XEmacs | 435 | (redraw-modeline))) ; XEmacs |
| 438 | 436 | ||
| 439 | (defun whitespace-check-buffer-list (buf-name buf-file) | 437 | (defun whitespace-check-buffer-list (buf-name buf-file) |
| 438 | "Add a buffer and its file to the whitespace monitor list. | ||
| 439 | |||
| 440 | The buffer named BUF-NAME and its associated file BUF-FILE are now monitored | ||
| 441 | periodically for whitespace." | ||
| 440 | (if (and whitespace-mode (not (member (list buf-file buf-name) | 442 | (if (and whitespace-mode (not (member (list buf-file buf-name) |
| 441 | whitespace-all-buffer-files))) | 443 | whitespace-all-buffer-files))) |
| 442 | (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name)))) | 444 | (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name)))) |
| 443 | 445 | ||
| 444 | (defun whitespace-tickle-timer () | 446 | (defun whitespace-tickle-timer () |
| 447 | "Tickle timer to periodically to scan qualifying files for whitespace creep. | ||
| 448 | |||
| 449 | If timer is not set, then set it to scan the files in | ||
| 450 | `whitespace-all-buffer-files' periodically (defined by | ||
| 451 | `whitespace-rescan-timer-time') for whitespace creep." | ||
| 445 | (if (not whitespace-rescan-timer) | 452 | (if (not whitespace-rescan-timer) |
| 446 | (setq whitespace-rescan-timer | 453 | (setq whitespace-rescan-timer |
| 447 | (if whitespace-running-emacs | 454 | (if whitespace-running-emacs |
| @@ -452,10 +459,9 @@ replace it with tabs." | |||
| 452 | whitespace-rescan-timer-time))))) | 459 | whitespace-rescan-timer-time))))) |
| 453 | 460 | ||
| 454 | (defun whitespace-rescan-files-in-buffers (&optional arg) | 461 | (defun whitespace-rescan-files-in-buffers (&optional arg) |
| 455 | "Check to see if all the files that are whitespace clean are | 462 | "Check monitored files for whitespace creep since last scan." |
| 456 | actually clean still, if in buffers, or need rescaning." | ||
| 457 | (let ((whitespace-all-my-files whitespace-all-buffer-files) | 463 | (let ((whitespace-all-my-files whitespace-all-buffer-files) |
| 458 | buffile bufname thiselt buf) | 464 | buffile bufname thiselt buf) |
| 459 | (if (not whitespace-all-my-files) | 465 | (if (not whitespace-all-my-files) |
| 460 | (progn | 466 | (progn |
| 461 | (if whitespace-running-emacs | 467 | (if whitespace-running-emacs |
| @@ -488,7 +494,7 @@ actually clean still, if in buffers, or need rescaning." | |||
| 488 | (whitespace-refresh-rescan-list buffile bufname)))))) | 494 | (whitespace-refresh-rescan-list buffile bufname)))))) |
| 489 | 495 | ||
| 490 | (defun whitespace-refresh-rescan-list (buffile bufname) | 496 | (defun whitespace-refresh-rescan-list (buffile bufname) |
| 491 | "Refresh the list of files to be rescaned." | 497 | "Refresh the list of files to be rescaned for whitespace creep." |
| 492 | (if whitespace-all-buffer-files | 498 | (if whitespace-all-buffer-files |
| 493 | (progn | 499 | (progn |
| 494 | (setq whitespace-all-buffer-files | 500 | (setq whitespace-all-buffer-files |
| @@ -501,6 +507,59 @@ actually clean still, if in buffers, or need rescaning." | |||
| 501 | (if whitespace-rescan-timer | 507 | (if whitespace-rescan-timer |
| 502 | (setq whitespace-rescan-timer nil))))) | 508 | (setq whitespace-rescan-timer nil))))) |
| 503 | 509 | ||
| 510 | ;;;###autoload | ||
| 511 | (defun whitespace-describe () | ||
| 512 | "A summary of whitespaces and what this library can do about them. | ||
| 513 | |||
| 514 | The whitespace library is intended to find and help fix five different types | ||
| 515 | of whitespace problems that commonly exist in source code. | ||
| 516 | |||
| 517 | 1. Leading space (empty lines at the top of a file). | ||
| 518 | 2. Trailing space (empty lines at the end of a file). | ||
| 519 | 3. Indentation space (8 or more spaces at beginning of line, that should be | ||
| 520 | replaced with TABS). | ||
| 521 | 4. Spaces followed by a TAB. (Almost always, we never want that). | ||
| 522 | 5. Spaces or TABS at the end of a line. | ||
| 523 | |||
| 524 | Whitespace errors are reported in a buffer, and on the modeline. | ||
| 525 | |||
| 526 | Modeline will show a W:<x> to denote a particular type of whitespace, where | ||
| 527 | `x' can be one (or more) of: | ||
| 528 | |||
| 529 | e - End-of-Line whitespace. | ||
| 530 | i - Indentation whitespace. | ||
| 531 | l - Leading whitespace. | ||
| 532 | s - Space followed by Tab. | ||
| 533 | t - Trailing whitespace. | ||
| 534 | |||
| 535 | (since (3) is the most controversial one, here is the rationale: Most | ||
| 536 | terminal drivers and printer drivers have TAB configured or even | ||
| 537 | hardcoded to be 8 spaces. (Some of them allow configuration, but almost | ||
| 538 | always they default to 8.) | ||
| 539 | |||
| 540 | Changing tab-width to other than 8 and editing will cause your code to | ||
| 541 | look different from within Emacs, and say, if you cat it or more it, or | ||
| 542 | even print it. | ||
| 543 | |||
| 544 | Almost all the popular programming modes let you define an offset (like | ||
| 545 | c-basic-offset or perl-indent-level) to configure the offset, so you | ||
| 546 | should never have to set your tab-width to be other than 8 in all these | ||
| 547 | modes. In fact, with an indent level of say, 4, 2 TABS will cause Emacs | ||
| 548 | to replace your 8 spaces with one \t (try it). If vi users in your | ||
| 549 | office complain, tell them to use vim, which distinguishes between | ||
| 550 | tabstop and shiftwidth (vi equivalent of our offsets), and also ask them | ||
| 551 | to set smarttab.) | ||
| 552 | |||
| 553 | All the above have caused (and will cause) unwanted codeline integration and | ||
| 554 | merge problems. | ||
| 555 | |||
| 556 | whitespace.el will complain if it detects whitespaces on opening a file, and | ||
| 557 | warn you on closing a file also. (if in case you had inserted any | ||
| 558 | whitespaces during the process of your editing.)" | ||
| 559 | (interactive) | ||
| 560 | (message "Use C-h f whitespace-describe to read about whitespace.el v%s." | ||
| 561 | whitespace-version)) | ||
| 562 | |||
| 504 | (provide 'whitespace) | 563 | (provide 'whitespace) |
| 505 | 564 | ||
| 506 | ;;; whitespace.el ends here | 565 | ;;; whitespace.el ends here |