[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master c66aaa6: Recomplexify ‘delete-trailing-whitesp
From: |
Sam Steingold |
Subject: |
Re: [Emacs-diffs] master c66aaa6: Recomplexify ‘delete-trailing-whitespace’ by treating \n as whitespace again |
Date: |
Fri, 14 Apr 2017 16:53:28 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (darwin) |
Hi
This patch causes delete-trailing-whitespace to hang when some
trailing whitespace is non-modifiable.
Thanks.
> * Noam Postavsky <address@hidden> [2017-03-14 22:31:58 -0400]:
>
> branch: master
> commit c66aaa61639e72a70a4f2c4bc73645048caebe53
> Author: Noam Postavsky <address@hidden>
> Commit: Noam Postavsky <address@hidden>
>
> Recomplexify ‘delete-trailing-whitespace’ by treating \n as whitespace
> again
>
> Mostly reverts "Simplify ‘delete-trailing-whitespace’ by not treating
> \n as whitespace" from 2016-07-04. Setting \n to non-whitespace
> causes the regex engine to backtrack a lot when searching for
> "\\s-+$" (Bug#26079).
>
> * lisp/simple.el (delete-trailing-whitespace): Don't change newline
> syntax, search for "\\s-$" and then skip backward over trailing
> whitespace.
> ---
> lisp/simple.el | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/lisp/simple.el b/lisp/simple.el
> index f110c6f..369fbf7 100644
> --- a/lisp/simple.el
> +++ b/lisp/simple.el
> @@ -633,10 +633,9 @@ buffer if the variable `delete-trailing-lines' is
> non-nil."
> (with-syntax-table (make-syntax-table (syntax-table))
> ;; Don't delete formfeeds, even if they are considered whitespace.
> (modify-syntax-entry ?\f "_")
> - ;; Treating \n as non-whitespace makes things easier.
> - (modify-syntax-entry ?\n "_")
> - (while (re-search-forward "\\s-+$" end-marker t)
> - (let ((b (match-beginning 0)) (e (match-end 0)))
> + (while (re-search-forward "\\s-$" end-marker t)
> + (skip-syntax-backward "-" (line-beginning-position))
> + (let ((b (point)) (e (match-end 0)))
> (when (region-modifiable-p b e)
> (delete-region b e)))))
> (if end
--
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
http://steingoldpsychology.com http://www.childpsy.net http://www.dhimmitude.org
http://camera.org http://americancensorship.org http://think-israel.org
The biggest childhood mistake is thinking that being an adult is fun.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Emacs-diffs] master c66aaa6: Recomplexify ‘delete-trailing-whitespace’ by treating \n as whitespace again,
Sam Steingold <=