* Infinite loop in whitespace-buffer-trailing-cleanup
@ 2005-07-03 12:13 Romain Francoise
2005-07-03 13:00 ` Romain Francoise
0 siblings, 1 reply; 4+ messages in thread
From: Romain Francoise @ 2005-07-03 12:13 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 826 bytes --]
There is a bug in `whitespace-buffer-trailing-cleanup' when trying to
remove trailing whitespace in a non-writable file with
`kill-read-only-ok' set to t.
Steps to reproduce this bug:
1. Create a file with only whitespace, e.g. echo -e "\n\n\n\n" >/tmp/foo
2. Make it non-writable: chmod a-w /tmp/foo
3. Open /tmp/foo in Emacs
4. M-x set-variable RET kill-read-only-ok RET t RET
5. M-: (require 'whitespace) RET
6. M-: (whitespace-buffer-trailing-cleanup) RET
7. Wait, don't interrupt.
In Emacs 21.4, this results in a segmentation fault after a few
seconds. In Emacs from CVS, it results in the following backtrace:
Debugger entered--Lisp error: (error "Lisp nesting exceeds `max-lisp-eval-depth'")
x-set-cut-buffer("\n" t)
x-select-text("\n" t)
kill-new("\n")
copy-region-as-kill(3 4)
byte-code("Ä\b \"ÂÅ\x12\vÂ\x11
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Infinite loop in whitespace-buffer-trailing-cleanup
2005-07-03 12:13 Infinite loop in whitespace-buffer-trailing-cleanup Romain Francoise
@ 2005-07-03 13:00 ` Romain Francoise
2005-07-04 14:51 ` Richard M. Stallman
0 siblings, 1 reply; 4+ messages in thread
From: Romain Francoise @ 2005-07-03 13:00 UTC (permalink / raw)
Whoops, sorry, control characters in my previous message truncated the
backtrace. Here's the full version:
Debugger entered--Lisp error: (error "Lisp nesting exceeds `max-lisp-eval-depth'")
x-set-cut-buffer("\n" t)
x-select-text("\n" t)
kill-new("\n")
copy-region-as-kill(3 4)
byte-code("..." [beg end this-command kill-read-only-ok copy-region-as-kill kill-region message "Read only text copied to kill ring" nil barf-if-buffer-read-only signal text-read-only] 3)
kill-region(3 4)
kill-line()
whitespace-buffer-trailing-cleanup()
[... this line repeated 300 times ...]
whitespace-buffer-trailing-cleanup()
eval((whitespace-buffer-trailing-cleanup))
eval-expression((whitespace-buffer-trailing-cleanup) nil)
call-interactively(eval-expression)
(This is Debian bug #273123.)
--
Romain Francoise <romain@orebokech.com> | All you've been is a piece of
it's a miracle -- http://orebokech.com/ | blood wrapped in skin.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Infinite loop in whitespace-buffer-trailing-cleanup
2005-07-03 13:00 ` Romain Francoise
@ 2005-07-04 14:51 ` Richard M. Stallman
2005-07-05 18:22 ` Romain Francoise
0 siblings, 1 reply; 4+ messages in thread
From: Richard M. Stallman @ 2005-07-04 14:51 UTC (permalink / raw)
Cc: emacs-devel
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."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-07-05 18:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-03 12:13 Infinite loop in whitespace-buffer-trailing-cleanup Romain Francoise
2005-07-03 13:00 ` Romain Francoise
2005-07-04 14:51 ` Richard M. Stallman
2005-07-05 18:22 ` Romain Francoise
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.