GNU bug report logs - #30139
25.3; Passing callback to align-region raises an error when using `justify` rule

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Michał Kondraciuk <k.michal@HIDDEN>; Keywords: patch; dated Tue, 16 Jan 2018 20:33:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) patch. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 30139 <at> debbugs.gnu.org:


Received: (at 30139) by debbugs.gnu.org; 19 Jan 2018 17:04:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 19 12:04:26 2018
Received: from localhost ([127.0.0.1]:35180 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1eca5a-00077F-0w
	for submit <at> debbugs.gnu.org; Fri, 19 Jan 2018 12:04:26 -0500
Received: from sender-pp-092.zoho.com ([135.84.80.237]:25403)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <k.michal@HIDDEN>) id 1eca5X-000774-Cb
 for 30139 <at> debbugs.gnu.org; Fri, 19 Jan 2018 12:04:25 -0500
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; 
 h=subject:from:to:references:message-id:date:user-agent:mime-version:in-reply-to:content-type;
 b=LyeCUb8QQYARWatT2ELbCPV2xS06do+y9FmsIORNMNzi0XFAOTNuw/uMcPJZWTkTI8tqsZrCgDad
 //sxCZPAZfBzF4kT96RMqvKgyZ2D85/cAAKAXsx1fPSGX5oLFd+W  
Received: from [192.168.43.88] (user-46-112-8-1.play-internet.pl [46.112.8.1])
 by mx.zohomail.com with SMTPS id 1516381452330890.5268619031701;
 Fri, 19 Jan 2018 09:04:12 -0800 (PST)
Subject: Re: bug#30139: 25.3; Passing callback to align-region raises an error
 when using `justify` rule
From: =?UTF-8?Q?Micha=c5=82_Kondraciuk?= <k.michal@HIDDEN>
To: 30139 <at> debbugs.gnu.org
References: <f232e32e-5e02-f426-39e3-56a686ed2def@HIDDEN>
Message-ID: <a8bf5ae3-08c0-52b6-e880-8fe4c3b6482e@HIDDEN>
Date: Fri, 19 Jan 2018 18:04:08 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.5.0
MIME-Version: 1.0
In-Reply-To: <f232e32e-5e02-f426-39e3-56a686ed2def@HIDDEN>
Content-Type: multipart/mixed; boundary="------------3ED6F3CFA8DC977F294388C0"
Content-Language: en-US
X-Zoho-Virus-Status: 1
X-ZohoMailClient: External
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 30139
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

This is a multi-part message in MIME format.
--------------3ED6F3CFA8DC977F294388C0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

I looked at source of `align-areas` in lisp/align.el and it looks like 
the changes made to `areas` on line 1196 are ignored in funcall on line 
1218.
Attached patch contains my proposed change.

--------------3ED6F3CFA8DC977F294388C0
Content-Type: text/x-patch;
 name="align.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="align.patch"

diff --git a/lisp/align.el b/lisp/align.el
index 941fa3a..10f3fcb 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -1215,10 +1215,16 @@ align-areas
 	      (gocol col) cur)
 	  (when area
 	    (if func
-		(funcall func
-			 (marker-position (car area))
-			 (marker-position (cdr area))
-			 change)
+                (if (and justify
+                         (consp (cdr area)))
+                    (funcall func
+                             (marker-position (car area))
+                             (marker-position (cadr area))
+                             change)
+                  (funcall func
+                             (marker-position (car area))
+                             (marker-position (cdr area))
+                             change))
 	      (if (not (and justify
 			    (consp (cdr area))))
 		  (goto-char (cdr area))

--------------3ED6F3CFA8DC977F294388C0--





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#30139; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Jan 2018 20:32:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 16 15:32:47 2018
Received: from localhost ([127.0.0.1]:59109 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ebXuY-00078w-LZ
	for submit <at> debbugs.gnu.org; Tue, 16 Jan 2018 15:32:47 -0500
Received: from eggs.gnu.org ([208.118.235.92]:45327)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <k.michal@HIDDEN>) id 1ebXmW-0006w3-5F
 for submit <at> debbugs.gnu.org; Tue, 16 Jan 2018 15:24:28 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <k.michal@HIDDEN>) id 1ebXmP-000739-E7
 for submit <at> debbugs.gnu.org; Tue, 16 Jan 2018 15:24:23 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:37227)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <k.michal@HIDDEN>) id 1ebXmP-000730-Ag
 for submit <at> debbugs.gnu.org; Tue, 16 Jan 2018 15:24:21 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36289)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <k.michal@HIDDEN>) id 1ebXmN-0002W9-OY
 for bug-gnu-emacs@HIDDEN; Tue, 16 Jan 2018 15:24:21 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <k.michal@HIDDEN>) id 1ebXmI-00070D-M8
 for bug-gnu-emacs@HIDDEN; Tue, 16 Jan 2018 15:24:19 -0500
Received: from sender-pp-092.zoho.com ([135.84.80.237]:25448)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <k.michal@HIDDEN>) id 1ebXmI-0006xw-El
 for bug-gnu-emacs@HIDDEN; Tue, 16 Jan 2018 15:24:14 -0500
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; 
 h=to:subject:from:message-id:date:user-agent:mime-version:content-type; 
 b=tehbgmLq76aNBIGC0ZZC8Y2qD4COVuBccr35rHKmFEARZkL6sM9xZhasli5TQXIBiXsS8I/jyu4X
 fO7uRXjALnszimLsoRStUlfTRgDJ7KcH48FdBy36MHGwhTPrJa/A  
Received: from [192.168.43.88] (user-46-112-8-1.play-internet.pl [46.112.8.1])
 by mx.zohomail.com with SMTPS id 1516134227288892.7711855119537;
 Tue, 16 Jan 2018 12:23:47 -0800 (PST)
To: bug-gnu-emacs@HIDDEN
Subject: 25.3; Passing callback to align-region raises an error when using
 `justify` rule
From: =?UTF-8?Q?Micha=c5=82_Kondraciuk?= <k.michal@HIDDEN>
Message-ID: <f232e32e-5e02-f426-39e3-56a686ed2def@HIDDEN>
Date: Tue, 16 Jan 2018 21:23:43 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.5.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Content-Language: en-US
X-ZohoMailClient: External
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 16 Jan 2018 15:32:45 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.0 (----)

1) Start emacs with `emacs --no-init-file`

2) Type into buffer named `*test*`:

    1234   23347   35466
       155555      267       31
    1444444 2444 32777


3) Type into `*scratch*` buffer:

   (let ((rule
          (list (list nil (cons 'regexp "\\(\\s-*[0-9]+\\)")
                      (cons 'group 1)
                      (cons 'justify t)
                      (cons 'spacing 1)
                      (cons 'repeat t)))))
     (with-current-buffer "*test*"
       (align-region (point-min) (point-max) 'entire rule nil
                     (lambda (&rest r) t))))

4) Evaluate scratch buffer


Expected behavior: Form above evaluates to nil.

Actual behavior - error is caught:
   Debugger entered--Lisp error: (wrong-type-argument markerp (#<marker 
at 53 in *test*> . #<marker (moves after insertion) at 60 in *test*>))
     marker-position((#<marker at 53 in *test*> . #<marker (moves after 
insertion) at 60 in *test*>))
     align-areas(((#<marker (moves after insertion) at 51 in *test*> 
#<marker at 53 in *test*> . #<marker (moves after insertion) at 60 in 
*test*>) (#<marker (moves after insertion) at 22 in *test*> #<marker at 
27 in *test*> . #<marker (moves after insertion) at 33 in *test*>) 
(#<marker (moves after insertion) at 1 in *test*> #<marker at 2 in 
*test*> . #<marker (moves after insertion) at 6 in *test*>)) (1 . t) 
(nil (regexp . "\\(\\s-*[0-9]+\\)") (group . 1) (justify . t) (spacing . 
1) (repeat . t)) (lambda (&rest r) t))
     align-region(1 71 entire ((nil (regexp . "\\(\\s-*[0-9]+\\)") 
(group . 1) (justify . t) (spacing . 1) (repeat . t))) nil (lambda 
(&rest r) t))
     (save-current-buffer (set-buffer "*test*") (align-region 
(point-min) (point-max) (quote entire) rule nil (function (lambda (&rest 
r) t))))
     (let ((rule (list (list nil (cons (quote regexp) 
"\\(\\s-*[0-9]+\\)") (cons (quote group) 1) (cons (quote justify) t) 
(cons (quote spacing) 1) (cons (quote repeat) t))))) 
(save-current-buffer (set-buffer "*test*") (align-region (point-min) 
(point-max) (quote entire) rule nil (function (lambda (&rest r) t)))))
     eval((let ((rule (list (list nil (cons (quote regexp) 
"\\(\\s-*[0-9]+\\)") (cons (quote group) 1) (cons (quote justify) t) 
(cons (quote spacing) 1) (cons (quote repeat) t))))) 
(save-current-buffer (set-buffer "*test*") (align-region (point-min) 
(point-max) (quote entire) rule nil (function (lambda (&rest r) t))))) nil)
     elisp--eval-last-sexp(nil)
     eval-last-sexp(nil)
     funcall-interactively(eval-last-sexp nil)
     call-interactively(eval-last-sexp nil nil)
     command-execute(eval-last-sexp)

This error doesn't happen if I don't use 'justify rule.


In GNU Emacs 25.3.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
  of 2017-09-12 built on lcy01-32
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:    Linux Mint 18.2 Sonya

Configured using:
  'configure --build=x86_64-linux-gnu --prefix=/usr
  '--includedir=${prefix}/include' '--mandir=${prefix}/share/man'
  '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var
  --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu'
  '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode
  --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib
  --program-suffix=25 --with-modules --with-x=yes --with-x-toolkit=gtk3
  'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
  -Werror=format-security' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
  'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES

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

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-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:
Checking 60 files in /usr/share/emacs/25.3/lisp/obsolete...
Checking for load-path shadows...done
Mark set [3 times]
Quit
Undo! [4 times]
C-x 4 k is undefined
C-x n C-g is undefined
Quit
Type "q" in help window to restore its previous buffer, C-M-v to scroll 
help.
switch-to-prev-buffer is not on any key
switch-to-next-buffer is not on any key

Load-path shadows:
/usr/share/emacs/site-lisp/dictionaries-common/flyspell hides 
/usr/share/emacs/25.3/lisp/textmodes/flyspell
/usr/share/emacs/site-lisp/dictionaries-common/ispell hides 
/usr/share/emacs/25.3/lisp/textmodes/ispell

Features:
(thingatpt kmacro two-column iso-transl pp shadow sort mail-extr
emacsbug message dired format-spec rfc822 mml mml-sec password-cache epg
epg-config gnus-util 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 help-mode easymenu cl-loaddefs
pcase cl-lib debug align time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded 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
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 102095 11612)
  (symbols 48 20091 1)
  (miscs 40 140 304)
  (strings 32 15967 3594)
  (string-bytes 1 461217)
  (vectors 16 13069)
  (vector-slots 8 442283 10883)
  (floats 8 180 200)
  (intervals 56 1866 2)
  (buffers 976 24)
  (heap 1024 37952 2989))






Acknowledgement sent to Michał Kondraciuk <k.michal@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#30139; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 23 Jan 2018 01:45:02 UTC

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