From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Richard M. Stallman" Newsgroups: gmane.emacs.devel Subject: Re: Infinite loop in whitespace-buffer-trailing-cleanup Date: Mon, 04 Jul 2005 10:51:52 -0400 Message-ID: References: <87slyw6qa8.fsf@orebokech.com> <871x6g6o4l.fsf@orebokech.com> Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1120489713 18267 80.91.229.2 (4 Jul 2005 15:08:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 4 Jul 2005 15:08:33 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 04 17:08:32 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DpSY2-0006ec-Qz for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2005 17:07:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DpSZF-00046f-Pi for ged-emacs-devel@m.gmane.org; Mon, 04 Jul 2005 11:09:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DpSWR-0002vK-GH for emacs-devel@gnu.org; Mon, 04 Jul 2005 11:06:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DpSWI-0002qC-JP for emacs-devel@gnu.org; Mon, 04 Jul 2005 11:06:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DpSWG-0002le-QL for emacs-devel@gnu.org; Mon, 04 Jul 2005 11:06:00 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DpSQW-0003hb-EB for emacs-devel@gnu.org; Mon, 04 Jul 2005 11:00:04 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1DpSIa-0001Xf-MY; Mon, 04 Jul 2005 10:51:52 -0400 Original-To: Romain Francoise In-reply-to: <871x6g6o4l.fsf@orebokech.com> (message from Romain Francoise on Sun, 03 Jul 2005 15:00:10 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:40335 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:40335 Does this make it work? *** whitespace.el 10 Jun 2005 09:28:20 -0400 1.36 --- whitespace.el 04 Jul 2005 09:37:22 -0400 *************** *** 608,624 **** (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)))))) (defun whitespace-buffer-trailing () "Check to see if are is more than one empty line at the bottom." --- 608,616 ---- (defun whitespace-buffer-leading-cleanup () "Remove any empty lines at the top of the file." (save-excursion ! (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,672 **** (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)))))))) (defun whitespace-buffer-search (regexp) "Search for any given whitespace REGEXP." --- 639,649 ---- (defun whitespace-buffer-trailing-cleanup () "Delete all the empty lines at the bottom." (save-excursion ! (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."