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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23339 in the body.
You can then email your comments to 23339 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23339; Package emacs. (Fri, 22 Apr 2016 06:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to josh+gnu <at> nispio.net:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 22 Apr 2016 06:21:02 GMT) Full text and rfc822 format available.

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

From: Josh <josh+gnu <at> nispio.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; align-region assumes that match does not contain newline
Date: Thu, 21 Apr 2016 23:20:19 -0700
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.


In GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
 of 2015-04-10 on builder10-9.porkrind.org
Windowing system distributor `Apple', version 10.3.1348
Configured using:
 `configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp''

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Text

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils align time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
cocoa ns multi-tty emacs)

Memory information:
((conses 16 72780 5795)
 (symbols 48 17281 0)
 (miscs 40 39 123)
 (strings 32 10041 4622)
 (string-bytes 1 277927)
 (vectors 16 9051)
 (vector-slots 8 373020 18497)
 (floats 8 53 150)
 (intervals 56 167 0)
 (buffers 960 12))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23339; Package emacs. (Wed, 02 Dec 2020 12:20:02 GMT) Full text and rfc822 format available.

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

Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 02 Dec 2020 12:21:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23339; Package emacs. (Tue, 19 Jan 2021 07:33:02 GMT) Full text and rfc822 format available.

Message #13 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: Tue, 19 Jan 2021 08:32:24 +0100
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

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

More information was requested, but no response was given within a
month, so I'm closing this bug report.  If the problem still exists,
please respond to this email and we'll reopen the bug report.

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




bug closed, send any further explanations to 23339 <at> debbugs.gnu.org and josh+gnu <at> nispio.net Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 19 Jan 2021 07:33:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 16 Feb 2021 12:24:06 GMT) Full text and rfc822 format available.

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.