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

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 24 Jun 2019 22:10:46 +0200

"John Wiegley" <[email-masked]> writes:

>>>>>> "MK" == MichaB Kondraciuk <[email-masked]> writes:
>
> MK> is there any news on the status of this bug? Should I just send the patch to
> MK> emacs-devel?
>
> Hi MichaB,
>
> I would suggest the following code:
>
>     (funcall func
>              (marker-position (car area))
>              (marker-position (if (and justify
>                                        (consp (cdr area)))
>                                   (cadr area)
>                                 (cdr area)))
>              change)
>
> I can't really tell you at this point if this is the correct change, but if it
> solves the bug, it surely is an improvement.

I am guessing that you meant the following change:

diff --git a/lisp/align.el b/lisp/align.el
index 443237b451..cd72d52df4 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -1216,9 +1216,12 @@ align-areas
 	  (when area
 	    (if func
 		(funcall func
-			 (marker-position (car area))
-			 (marker-position (cdr area))
-			 change)
+                         (marker-position (car area))
+                         (marker-position (if (and justify
+                                                   (consp (cdr area)))
+                                              (cadr area)
+                                            (cdr area)))
+                         change)
 	      (if (not (and justify
 			    (consp (cdr area))))
 		  (goto-char (cdr area))

And with it in place, I don't get any errors.

But nothing happens in the *test* buffer at all, so that's a bit
underwhelming...

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