bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23339: 24.5; align-region assumes that match does not contain newlin


From: Lars Ingebrigtsen
Subject: bug#23339: 24.5; align-region assumes that match does not contain newline
Date: Wed, 02 Dec 2020 13:19:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Josh <josh+gnu@nispio.net> writes:

> The align-region function assumes that a matching regexp does not
> contain a newline.  This causes unexpected behavior in cases where the
> first "column" being aligned contains only whitespace.  The following
> script exhibits the unexpected behavior:
>
> emacs -Q --eval '(progn
>  (switch-to-buffer "*test*")
>  (text-mode)
>  (setq indent-tabs-mode nil)
>  (insert "lorem ipsum, dolor sit amet,\n ,,\n")
>  (let ((table (make-syntax-table (syntax-table))))
>    ;; (modify-syntax-entry ?\n ">" table) ; <= UNCOMMENT THIS LINE TO FIX
>    (with-syntax-table table
>    (align-regexp (point-min) (point-max) "\\(\\s-*\\)," 1 1 t))))'
>
> Uncommenting the seventh line and running again will show the expected
> behavior.  The fix works around the problem by using a syntax map in
> which the newline character does not belong to the whitespace syntax
> class, thus preventing \s-* from matching the newline.

(This bug report unfortunately got no response at the time.)

You don't specify what the result is you're seeing, and what you expect
to see, so I'm not sure whether this is fixed or not.  When I try your
recipe in Emacs 26.1-28, I get:

PNG image

Which I think is correct behaviour?  

Are you still seeing buggy behaviour here in more recent Emacs versions?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]