# HG changeset patch # User Rajesh Vaidheeswarran # Date 998340968 0 # Node ID ceec599316a4c11b9e38dab4bb00f9f6321b0f39 # Parent ef5cc490984d56a7ba4d41004b980a362dc89be0 whitespace 3.1 diff -r ef5cc490984d -r ceec599316a4 lisp/ChangeLog --- a/lisp/ChangeLog Mon Aug 20 18:46:16 2001 +0000 +++ b/lisp/ChangeLog Mon Aug 20 20:56:08 2001 +0000 @@ -1,3 +1,25 @@ +2001-08-20 Rajesh Vaidheeswarran + + * whitespace.el (whitespace-abort-on-error): Add custom variable + to whitespace to abort a write-file if whitespace is detected in + file. + + * whitespace.el (whitespace-write-file-hook): Hook to be called + when writing a file. If `whitespace-abort-on-error' is set, the + write will abort on detecting whitespaces. If + `whitespace-auto-cleanup' is set, the file will be cleaned + automatically prior to writing. + + * whitespace.el (whitespace-buffer-search): Let's not insert bogus + whitespaces in the error output! + + * whitespace.el (whitespace-check-indent-whitespace): defaults to + `indent-tabs-mode', since the latter notes user preferences on + TABs anyway. + + * whitespace.el (whitespace-version): 3.1. All of the above issues + were raised by Fran,Ag(Bois Pinard, which led to the fixes described. + 2001-08-20 Gerd Moellmann * textmodes/texnfo-upd.el (texinfo-every-node-update): Remove @@ -33,8 +55,8 @@ 2001-08-16 Miles Bader * simple.el (line-move): Undo previous change. - - * comint.el (comint-send-input): Add `inhibit-line-move-field-capture' + + * comint.el (comint-send-input): Add `inhibit-line-move-field-capture' property to input-terminating `boundary' overlays to avoid line-move wierdness. @@ -79,11 +101,11 @@ (toplevel): Set it as `common-lisp-indent-function' for `defmethod'. - * ediff-mult.el (ediff-get-meta-info): Fix the condition + * ediff-mult.el (ediff-get-meta-info): Fix the condition of a while-loop. * Makefile.in (DONTCOMPILE): Remove sc.el. - + * Makefile.in (finder_setwins): Renamed from nonobsolete_setwins. Don't include term/. @@ -158,7 +180,7 @@ * subr.el (add-minor-mode): Use mode-line-minor-mode-keymap for the minor mode name. - * emacs-lisp/easy-mmode.el (define-minor-mode): Use + * emacs-lisp/easy-mmode.el (define-minor-mode): Use mode-line-minor-mode-keymap for the minor mode name. * calendar/calendar.el (calendar-mode-line-format): Use @@ -206,13 +228,13 @@ * textmodes/paragraphs.el (forward-sentence): Avoid building a regexp from sentence-end. From Kenichi Handa . - * progmodes/executable.el (executable-set-magic): If + * progmodes/executable.el (executable-set-magic): If executable-find returns a quoted file name, unquote it before inserting it. * image.el (image-type-regexps): For JPEG files, use a regexp derived from the JFIF spec. - + * image.el (image-type-regexps): Use `\`' instead of `^' in most regular expressions. diff -r ef5cc490984d -r ceec599316a4 lisp/whitespace.el --- a/lisp/whitespace.el Mon Aug 20 18:46:16 2001 +0000 +++ b/lisp/whitespace.el Mon Aug 20 20:56:08 2001 +0000 @@ -5,7 +5,7 @@ ;; Author: Rajesh Vaidheeswarran ;; Keywords: convenience -;; $Id: whitespace.el,v 1.16 2001/07/16 12:22:59 pj Exp $ +;; $Id: whitespace.el,v 1.17 2001/08/20 10:05:03 gerd Exp $ ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify @@ -39,7 +39,7 @@ ;;; Code: -(defvar whitespace-version "3.0" "Version of the whitespace library.") +(defvar whitespace-version "3.1" "Version of the whitespace library.") (defvar whitespace-all-buffer-files nil "An associated list of buffers and files checked for whitespace cleanliness. @@ -136,7 +136,7 @@ :type 'regexp :group 'whitespace) -(defcustom whitespace-check-indent-whitespace t +(defcustom whitespace-check-indent-whitespace indent-tabs-mode "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'" @@ -165,6 +165,13 @@ :type 'string :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." + :type 'boolean + :group 'whitespace) + (defcustom whitespace-auto-cleanup nil "Cleanup a buffer automatically on finding it whitespace unclean." :type 'boolean @@ -561,7 +568,7 @@ (save-excursion (goto-char (point-min)) (while (re-search-forward regexp nil t) - (setq whitespace-retval (format "%s %s " whitespace-retval + (setq whitespace-retval (format "%s %s" whitespace-retval (match-beginning 0)))) (if (equal "" whitespace-retval) nil @@ -714,11 +721,27 @@ (if arg (progn (add-hook 'find-file-hooks 'whitespace-buffer) + (add-hook 'local-write-file-hooks 'whitespace-write-file-hook) (add-hook 'kill-buffer-hook 'whitespace-buffer)) (remove-hook 'find-file-hooks 'whitespace-buffer) + (remove-hook 'local-write-file-hooks 'whitespace-write-file-hook) (remove-hook 'kill-buffer-hook 'whitespace-buffer))) ;;;###autoload +(defun whitespace-write-file-hook () + "The local-write-file-hook to be called on the buffer when +whitespace check is enabled." + (interactive) + (let ((werr nil)) + (if whitespace-auto-cleanup + (whitespace-cleanup) + (setq werr (whitespace-buffer))) + (if (and whitespace-abort-on-error werr) + (error (concat "Abort write due to whitespaces in " + buffer-file-name)))) + nil) + +;;;###autoload (defun whitespace-describe () "A summary of whitespaces and what this library can do about them. @@ -776,6 +799,7 @@ (defun whitespace-unload-hook () (remove-hook 'find-file-hooks 'whitespace-buffer) + (remove-hook 'local-write-file-hooks 'whitespace-write-file-hook) (remove-hook 'kill-buffer-hook 'whitespace-buffer)) (provide 'whitespace)