I have *test*
buffer with following contents:
1234 23347 35466
155555 267 31
1444444 2444 32777
Now I'm trying to understand how passing a callback to align-region
works, so I wrote this script:
(let* ((group -1)
(regexp
"\\(\\s-*[0-9]+\\)")
(spacing 5)
(repeat t)
(rule
(list (list nil (cons 'regexp regexp)
(cons 'group (abs group))
(if (< group 0)
(cons 'justify t)
(cons 'bogus nil))
(if (>= spacing 0)
(cons 'spacing spacing)
(cons 'column (abs spacing)))
(cons 'repeat repeat)))))
(with-current-buffer "*test*"
(align-region (point-min) (point-max) 'entire rule nil
(lambda (&rest r) t))))
I copied that rule from definition of align-regexp
.
When I evaluate my code I get en error:
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*>)) (5 . t) (nil (regexp . "\\(\\s-*[0-9]+\\)") (group . 1) (justify . t) (spacing . 5) (repeat . t)) (lambda (&rest r) t))
align-region(1 72 entire ((nil (regexp . "\\(\\s-*[0-9]+\\)") (group . 1) (justify . t) (spacing . 5) (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* ((group -1) (regexp "\\(\\s-*[0-9]+\\)") (spacing 5) (repeat t) (rule (list (list nil (cons (quote regexp) regexp) (cons (quote group) (abs group)) (if (< group 0) (cons (quote justify) t) (cons (quote bogus) nil)) (if (>= spacing 0) (cons (quote spacing) spacing) (cons (quote column) (abs spacing))) (cons (quote repeat) repeat))))) (save-current-buffer (set-buffer "*test*") (align-region (point-min) (point-max) (quote entire) rule nil (function (lambda (&rest r) t)))))
eval((let* ((group -1) (regexp "\\(\\s-*[0-9]+\\)") (spacing 5) (repeat t) (rule (list (list nil (cons (quote regexp) regexp) (cons (quote group) (abs group)) (if (< group 0) (cons (quote justify) t) (cons (quote bogus) nil)) (if (>= spacing 0) (cons (quote spacing) spacing) (cons (quote column) (abs spacing))) (cons (quote repeat) repeat))))) (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(t)
eval-last-sexp(t)
eval-print-last-sexp(nil)
funcall-interactively(eval-print-last-sexp nil)
call-interactively(eval-print-last-sexp nil nil)
command-execute(eval-print-last-sexp)
The script evaluates cleanly if I change group
to 1 in line 1 (so I don't use 'justify
rule).
Am I missing something obvious? I tested this on emacs-25.3 and 26-0.90 and the results are the same.