Subject: bug#30139: 25.3; Passing callback to align-region raises an error when using `justify` rule

From: Michał Kondraciuk <[email-masked]>
Date: Tue, 16 Jan 2018 21:23:43 +0100

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))