emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master cf4778a1365 1/3: Simplify alist lookups in align-region


From: Stefan Kangas
Subject: master cf4778a1365 1/3: Simplify alist lookups in align-region
Date: Thu, 28 Sep 2023 15:45:30 -0400 (EDT)

branch: master
commit cf4778a1365a4524da3afe4395b6a90b02e763be
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    Simplify alist lookups in align-region
    
    * lisp/align.el (align-region): Simplify alist lookup caching.
---
 lisp/align.el | 50 ++++++++++++--------------------------------------
 1 file changed, 12 insertions(+), 38 deletions(-)

diff --git a/lisp/align.el b/lisp/align.el
index 4f7e97dfc6a..a286addb51f 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -1337,12 +1337,18 @@ aligner would have dealt with are."
                 (thissep (if rulesep (cdr rulesep) separate))
                 same (eol 0)
                 search-start
-                groups ;; group-c
-                spacing spacing-c
-                tab-stop tab-stop-c
-                repeat repeat-c
-                valid valid-c
-                first
+                 (groups (ensure-list (or (cdr (assq 'group rule)) 1)))
+                 (spacing (cdr (assq 'spacing rule)))
+                 (tab-stop (let ((rule-ts (assq 'tab-stop rule)))
+                              (cond (rule-ts
+                                     (cdr rule-ts))
+                                    ((symbolp align-to-tab-stop)
+                                     (symbol-value align-to-tab-stop))
+                                    (t
+                                     align-to-tab-stop))))
+                 (repeat (cdr (assq 'repeat rule)))
+                 (valid (assq 'valid rule))
+                 (first (car groups))
                 regions index
                 last-point
                 save-match-data
@@ -1459,44 +1465,12 @@ aligner would have dealt with are."
                     (if (and (bolp) (> (point) search-start))
                         (forward-char -1))
 
-                    ;; lookup the `group' attribute the first time
-                    ;; that we need it
-                    (unless nil ;; group-c
-                      (setq groups (or (cdr (assq 'group rule)) 1))
-                      (setq groups (ensure-list groups))
-                      (setq first (car groups)))
-
-                    (unless spacing-c
-                      (setq spacing (cdr (assq 'spacing rule))
-                            spacing-c t))
-
-                    (unless tab-stop-c
-                      (setq tab-stop
-                            (let ((rule-ts (assq 'tab-stop rule)))
-                              (cond (rule-ts
-                                     (cdr rule-ts))
-                                    ((symbolp align-to-tab-stop)
-                                     (symbol-value align-to-tab-stop))
-                                    (t
-                                     align-to-tab-stop)))
-                            tab-stop-c t))
-
                     ;; test whether we have found a match on the same
                     ;; line as a previous match
                     (when (> (point) eol)
                       (setq same nil)
                       (align--set-marker eol (line-end-position)))
 
-                    ;; lookup the `repeat' attribute the first time
-                    (or repeat-c
-                        (setq repeat (cdr (assq 'repeat rule))
-                              repeat-c t))
-
-                    ;; lookup the `valid' attribute the first time
-                    (or valid-c
-                        (setq valid (assq 'valid rule)
-                              valid-c t))
-
                     ;; remember the beginning position of this rule
                     ;; match, and save the match-data, since either
                     ;; the `valid' form, or the code that searches for



reply via email to

[Prev in Thread] Current Thread [Next in Thread]