GNU bug report logs - #23339
24.5; align-region assumes that match does not contain newline

Previous Next

Package: emacs;

Reported by: josh+gnu <at> nispio.net

Date: Fri, 22 Apr 2016 06:21:02 UTC

Severity: normal

Tags: moreinfo

Found in version 24.5

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 23339 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Josh <josh+gnu <at> nispio.net>
Cc: 23339 <at> debbugs.gnu.org
Subject: Re: bug#23339: 24.5; align-region assumes that match does not
 contain newline
Date: Wed, 02 Dec 2020 13:19:47 +0100
[Message part 1 (text/plain, inline)]
Josh <josh+gnu <at> 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:

[Message part 2 (image/png, inline)]
[Message part 3 (text/plain, inline)]
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

This bug report was last modified 4 years and 128 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.