Mercurial > emacs
diff lisp/whitespace.el @ 83353:532e0a9335a9
Merged in changes from CVS trunk. Plus added lisp/term tweaks.
Patches applied:
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--base-0
tag of miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-474
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-1
Add CVS metadata files.
* lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-2
Update from CVS.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-393
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Sun, 04 Sep 2005 03:48:17 +0000 |
parents | 6c13700d1c13 41bb365f41c4 |
children | b31326248cf6 |
line wrap: on
line diff
--- a/lisp/whitespace.el Thu Aug 25 12:03:34 2005 +0000 +++ b/lisp/whitespace.el Sun Sep 04 03:48:17 2005 +0000 @@ -1,6 +1,7 @@ ;;; whitespace.el --- warn about and clean bogus whitespaces in the file -;; Copyright (C) 1999, 2000, 2005 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2000, 2002, 2003, 2004, +;; 2005 Free Software Foundation, Inc. ;; Author: Rajesh Vaidheeswarran <rv@gnu.org> ;; Keywords: convenience @@ -109,32 +110,32 @@ (put 'whitespace-mode-line 'permanent-local nil) (defvar whitespace-check-buffer-leading nil - "Test leading whitespace for file in current buffer if t") + "Test leading whitespace for file in current buffer if t.") (make-variable-buffer-local 'whitespace-check-buffer-leading) (put 'whitespace-check-buffer-leading 'permanent-local nil) (defvar whitespace-check-buffer-trailing nil - "Test trailing whitespace for file in current buffer if t") + "Test trailing whitespace for file in current buffer if t.") (make-variable-buffer-local 'whitespace-check-buffer-trailing) (put 'whitespace-check-buffer-trailing 'permanent-local nil) (defvar whitespace-check-buffer-indent nil - "Test indentation whitespace for file in current buffer if t") + "Test indentation whitespace for file in current buffer if t.") (make-variable-buffer-local 'whitespace-check-buffer-indent) (put 'whitespace-check-buffer-indent 'permanent-local nil) (defvar whitespace-check-buffer-spacetab nil - "Test Space-followed-by-TABS whitespace for file in current buffer if t") + "Test Space-followed-by-TABS whitespace for file in current buffer if t.") (make-variable-buffer-local 'whitespace-check-buffer-spacetab) (put 'whitespace-check-buffer-spacetab 'permanent-local nil) (defvar whitespace-check-buffer-ateol nil - "Test end-of-line whitespace for file in current buffer if t") + "Test end-of-line whitespace for file in current buffer if t.") (make-variable-buffer-local 'whitespace-check-buffer-ateol) (put 'whitespace-check-buffer-ateol 'permanent-local nil) (defvar whitespace-highlighted-space nil - "The variable to store the extent to highlight") + "The variable to store the extent to highlight.") (make-variable-buffer-local 'whitespace-highlighted-space) (put 'whitespace-highlighted-space 'permanent-local nil) @@ -142,61 +143,53 @@ (eval-when-compile (if (not (fboundp 'defgroup)) (defmacro defgroup (sym memb doc &rest args) - "Null macro for defgroup in all versions of Emacs that don't define -defgroup" + "Null macro for `defgroup' in all versions of Emacs that don't define it." t)) (if (not (fboundp 'defcustom)) (defmacro defcustom (sym val doc &rest args) - "Macro to alias defcustom to defvar in all versions of Emacs that -don't define defcustom" + "Macro to alias `defcustom' to `defvar' in all versions of Emacs that +don't define it." `(defvar ,sym ,val ,doc)))) -(if (fboundp 'make-overlay) - (progn - (defalias 'whitespace-make-overlay 'make-overlay) - (defalias 'whitespace-overlay-put 'overlay-put) - (defalias 'whitespace-delete-overlay 'delete-overlay) - (defalias 'whitespace-overlay-start 'overlay-start) - (defalias 'whitespace-overlay-end 'overlay-end) - (defalias 'whitespace-mode-line-update 'force-mode-line-update)) - (defalias 'whitespace-make-overlay 'make-extent) - (defalias 'whitespace-overlay-put 'set-extent-property) - (defalias 'whitespace-delete-overlay 'delete-extent) - (defalias 'whitespace-overlay-start 'extent-start) - (defalias 'whitespace-overlay-end 'extent-end) - (defalias 'whitespace-mode-line-update 'redraw-modeline)) +(defalias 'whitespace-make-overlay + (if (featurep 'xemacs) 'make-extent 'make-overlay)) +(defalias 'whitespace-overlay-put + (if (featurep 'xemacs) 'set-extent-property 'overlay-put)) +(defalias 'whitespace-delete-overlay + (if (featurep 'xemacs) 'delete-extent 'delete-overlay)) +(defalias 'whitespace-overlay-start + (if (featurep 'xemacs) 'extent-start 'overlay-start)) +(defalias 'whitespace-overlay-end + (if (featurep 'xemacs) 'extent-end 'overlay-end)) +(defalias 'whitespace-mode-line-update + (if (featurep 'xemacs) 'redraw-modeline 'force-mode-line-update)) -(if (featurep 'xemacs) -(defgroup whitespace nil - "Check for and fix five different types of whitespaces in source code." - ;; Since XEmacs doesn't have a 'convenience group, use the next best group - ;; which is 'editing? - :link '(emacs-commentary-link "whitespace.el") - :group 'editing) (defgroup whitespace nil "Check for and fix five different types of whitespaces in source code." :version "21.1" :link '(emacs-commentary-link "whitespace.el") - :group 'convenience)) + ;; Since XEmacs doesn't have a 'convenience group, use the next best group + ;; which is 'editing? + :group (if (featurep 'xemacs) 'editing 'convenience)) (defcustom whitespace-check-leading-whitespace t - "Flag to check leading whitespace. This is the global for the system. + "Flag to check leading whitespace. This is the global for the system. It can be overriden by setting a buffer local variable -`whitespace-check-buffer-leading'" +`whitespace-check-buffer-leading'." :type 'boolean :group 'whitespace) (defcustom whitespace-check-trailing-whitespace t - "Flag to check trailing whitespace. This is the global for the system. + "Flag to check trailing whitespace. This is the global for the system. It can be overriden by setting a buffer local variable -`whitespace-check-buffer-trailing'" +`whitespace-check-buffer-trailing'." :type 'boolean :group 'whitespace) (defcustom whitespace-check-spacetab-whitespace t - "Flag to check space followed by a TAB. This is the global for the system. + "Flag to check space followed by a TAB. This is the global for the system. It can be overriden by setting a buffer local variable -`whitespace-check-buffer-spacetab'" +`whitespace-check-buffer-spacetab'." :type 'boolean :group 'whitespace) @@ -206,9 +199,9 @@ :group 'whitespace) (defcustom whitespace-check-indent-whitespace indent-tabs-mode - "Flag to check indentation whitespace. This is the global for the system. + "Flag to check indentation whitespace. This is the global for the system. It can be overriden by setting a buffer local variable -`whitespace-check-buffer-indent'" +`whitespace-check-buffer-indent'." :type 'boolean :group 'whitespace) @@ -218,9 +211,9 @@ :group 'whitespace) (defcustom whitespace-check-ateol-whitespace t - "Flag to check end-of-line whitespace. This is the global for the system. + "Flag to check end-of-line whitespace. This is the global for the system. It can be overriden by setting a buffer local variable -`whitespace-check-buffer-ateol'" +`whitespace-check-buffer-ateol'." :type 'boolean :group 'whitespace) @@ -242,9 +235,9 @@ :group 'whitespace) (defcustom whitespace-abort-on-error nil - "While writing a file, abort if the file is unclean. If -`whitespace-auto-cleanup' is set, that takes precedence over this -variable." + "While writing a file, abort if the file is unclean. +If `whitespace-auto-cleanup' is set, that takes precedence over +this variable." :type 'boolean :group 'whitespace) @@ -277,7 +270,7 @@ tcl-mode tex-mode texinfo-mode vrml-mode xml-mode) - "Major Modes in which we turn on whitespace checking. + "Major modes in which we turn on whitespace checking. These are mostly programming and documentation modes. But you may add other modes that you want whitespaces checked in by adding something like the @@ -608,17 +601,9 @@ (defun whitespace-buffer-leading-cleanup () "Remove any empty lines at the top of the file." (save-excursion - (let ((pmin nil) - (pmax nil)) - (goto-char (point-min)) - (beginning-of-line) - (setq pmin (point)) - (end-of-line) - (setq pmax (point)) - (if (equal pmin pmax) - (progn - (kill-line) - (whitespace-buffer-leading-cleanup)))))) + (goto-char (point-min)) + (skip-chars-forward "\n") + (delete-region (point-min) (point)))) (defun whitespace-buffer-trailing () "Check to see if are is more than one empty line at the bottom." @@ -647,26 +632,11 @@ (defun whitespace-buffer-trailing-cleanup () "Delete all the empty lines at the bottom." (save-excursion - (let ((pmin nil) - (pmax nil)) - (goto-char (point-max)) - (beginning-of-line) - (setq pmin (point)) - (end-of-line) - (setq pmax (point)) - (if (equal pmin pmax) - (progn - (goto-char (1- pmin)) - (beginning-of-line) - (setq pmin (point)) - (end-of-line) - (setq pmax (point)) - (if (equal pmin pmax) - (progn - (goto-char (1- (point-max))) - (beginning-of-line) - (kill-line) - (whitespace-buffer-trailing-cleanup)))))))) + (goto-char (point-max)) + (skip-chars-backward "\n") + (if (not (bolp)) + (forward-char 1)) + (delete-region (point) (point-max)))) (defun whitespace-buffer-search (regexp) "Search for any given whitespace REGEXP."