aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/align.el
diff options
context:
space:
mode:
authorHelmut Eller2026-02-13 09:10:16 +0100
committerHelmut Eller2026-02-13 09:10:16 +0100
commit91c9e9883488d715a30877dfd7641ef4b3c62658 (patch)
treee2c4525147e443f86baf9d0144aeadec082d7564 /lisp/align.el
parent9a4a54af9192a6653164364c75721ee814ffb1e8 (diff)
parentf1fe4d46190263e164ccd1e066095d46a156297f (diff)
downloademacs-feature/igc.tar.gz
emacs-feature/igc.zip
Merge branch 'master' into feature/igcfeature/igc
Diffstat (limited to 'lisp/align.el')
-rw-r--r--lisp/align.el42
1 files changed, 32 insertions, 10 deletions
diff --git a/lisp/align.el b/lisp/align.el
index 1f1c8f58009..362d59f2231 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -1407,11 +1407,18 @@ aligner would have dealt with are."
1407 (align-region 1407 (align-region
1408 beg end 'entire 1408 beg end 'entire
1409 exclude-rules nil 1409 exclude-rules nil
1410 ;; Use markers for exclusion area bounds so
1411 ;; they remain accurate after subsequent
1412 ;; alignment sections modify the buffer.
1410 (lambda (b e mode) 1413 (lambda (b e mode)
1411 (or (and mode (listp mode)) 1414 (or (and mode (listp mode))
1415 (let ((bm (copy-marker b))
1416 (em (copy-marker e t)))
1417 (push bm markers)
1418 (push em markers)
1412 (setq exclude-areas 1419 (setq exclude-areas
1413 (cons (cons b e) 1420 (cons (cons bm em)
1414 exclude-areas))))) 1421 exclude-areas))))))
1415 (setq exclude-areas 1422 (setq exclude-areas
1416 (nreverse 1423 (nreverse
1417 (sort exclude-areas #'car-less-than-car)))) 1424 (sort exclude-areas #'car-less-than-car))))
@@ -1458,14 +1465,17 @@ aligner would have dealt with are."
1458 (setq same nil) 1465 (setq same nil)
1459 (align--set-marker eol (line-end-position))) 1466 (align--set-marker eol (line-end-position)))
1460 1467
1461 ;; remember the beginning position of this rule 1468 ;; Remember the beginning position of this rule
1462 ;; match, and save the match-data, since either 1469 ;; match as a marker so it remains accurate after
1463 ;; the `valid' form, or the code that searches for 1470 ;; `align-regions' modifies the buffer for a
1464 ;; section separation, might alter it 1471 ;; previous alignment section. Also save the
1465 (setq rule-beg (match-beginning first) 1472 ;; match-data, since either the `valid' form, or
1466 save-match-data (match-data)) 1473 ;; the code that searches for section separation,
1467 1474 ;; might alter it.
1468 (or rule-beg 1475 (align--set-marker rule-beg (match-beginning first) t)
1476 (setq save-match-data (match-data))
1477
1478 (or (marker-position rule-beg)
1469 (error "No match for subexpression %s" first)) 1479 (error "No match for subexpression %s" first))
1470 1480
1471 ;; unless the `valid' attribute is set, and tells 1481 ;; unless the `valid' attribute is set, and tells
@@ -1480,6 +1490,18 @@ aligner would have dealt with are."
1480 (when (and last-point 1490 (when (and last-point
1481 (align-new-section-p last-point rule-beg 1491 (align-new-section-p last-point rule-beg
1482 thissep)) 1492 thissep))
1493 ;; Convert saved match-data positions to
1494 ;; markers before `align-regions' modifies
1495 ;; the buffer, so the restored match-data
1496 ;; reflects the updated buffer state.
1497 (setq save-match-data
1498 (mapcar (lambda (pos)
1499 (if (integerp pos)
1500 (let ((m (copy-marker pos)))
1501 (push m markers)
1502 m)
1503 pos))
1504 save-match-data))
1483 (align-regions regions align-props rule func) 1505 (align-regions regions align-props rule func)
1484 (setq regions nil) 1506 (setq regions nil)
1485 (setq align-props nil)) 1507 (setq align-props nil))