chore: migrate conditional bindings for Emacs 31

This commit is contained in:
Kinneyzhang 2026-08-26 00:09:08 +08:00
parent db071d7768
commit 88b23b5f80
2 changed files with 9 additions and 9 deletions

View File

@ -163,7 +163,7 @@
(defun ecss-schema-set-property (schemas id)
"Return a defensive copy of property ID from SCHEMAS, or nil."
(ecss--schema-set-check schemas)
(when-let ((schema (gethash id (ecss--schema-set-table schemas))))
(when-let* ((schema (gethash id (ecss--schema-set-table schemas))))
(ecss--copy-property-schema schema)))
(defun ecss-schema-set-property-ids (schemas)
@ -254,7 +254,7 @@
"Expand one PROPERTY VALUE declaration using SCHEMAS."
(ecss--validate-declaration-property schemas property)
(let ((schema (ecss--schema-for schemas property)))
(if-let ((expander (and schema
(if-let* ((expander (and schema
(ecss-property-schema-shorthand schema))))
(pcase-let* ((`(,raw . ,important) (ecss--unwrap-important value))
(expanded
@ -320,7 +320,7 @@ the same expanded longhand, including explicit nil declarations."
(defun ecss--set-origin-layers (stylesheet origin layers)
"Set STYLESHEET ORIGIN order to LAYERS."
(if-let ((cell (assq origin (ecss--stylesheet-layers stylesheet))))
(if-let* ((cell (assq origin (ecss--stylesheet-layers stylesheet))))
(setcdr cell layers)
(setf (ecss--stylesheet-layers stylesheet)
(append (ecss--stylesheet-layers stylesheet)
@ -417,7 +417,7 @@ optional selector limiting the rule to a matching subject or ancestor."
(defun ecss--rule-match-facts (rule subject adapter)
"Return RULE match facts for SUBJECT through ADAPTER, or nil."
(when-let ((specificity
(when-let* ((specificity
(ecss--selector-matched-specificity
(ecss-rule-selector rule) subject adapter)))
(let ((distance (ecss--scope-distance
@ -440,7 +440,7 @@ SPECIFICITY, DISTANCE, and DECLARATION-ORDER are the match precedence facts."
(defun ecss--rule-candidates (rule subject adapter)
"Return candidates from matching RULE for SUBJECT through ADAPTER."
(when-let ((facts (ecss--rule-match-facts rule subject adapter)))
(when-let* ((facts (ecss--rule-match-facts rule subject adapter)))
(cl-loop for (property value) on (ecss-rule-declarations rule) by #'cddr
for declaration-order from 0
collect (ecss--candidate-from-rule

View File

@ -118,7 +118,7 @@ an alist. PARENT and CHILDREN establish its initial tree position."
(setf (ecss-subject-parent old-child) nil)))
(setf (ecss-subject-children subject) (copy-sequence children))
(dolist (child children)
(when-let ((old-parent (ecss-subject-parent child)))
(when-let* ((old-parent (ecss-subject-parent child)))
(unless (eq old-parent subject)
(setf (ecss-subject-children old-parent)
(delq child (ecss-subject-children old-parent)))))
@ -509,7 +509,7 @@ ancestors, children, or siblings return nil. Invalid selectors signal
(defun ecss--subject-previous-siblings (subject adapter)
"Return SUBJECT's preceding siblings through ADAPTER."
(when-let ((parent (ecss--subject-parent subject adapter)))
(when-let* ((parent (ecss--subject-parent subject adapter)))
(let ((siblings (ecss--subject-children parent adapter)) result)
(while (and siblings (not (eq (car siblings) subject)))
(push (pop siblings) result))
@ -580,7 +580,7 @@ Compare without case when INSENSITIVE is non-nil."
(defun ecss--subject-following-siblings (subject adapter)
"Return siblings following SUBJECT through ADAPTER."
(when-let ((parent (ecss--subject-parent subject adapter)))
(when-let* ((parent (ecss--subject-parent subject adapter)))
(let ((siblings (ecss--subject-children parent adapter)))
(while (and siblings (not (eq (pop siblings) subject))))
siblings)))
@ -626,7 +626,7 @@ Compare without case when INSENSITIVE is non-nil."
(:has (ecss--selector-match-has (cdr selector) subject adapter))
(:descendant (ecss--selector-match-descendant selector subject adapter))
(:child (and (ecss-selector-match-p (nth 2 selector) subject adapter)
(when-let ((parent (ecss--subject-parent subject adapter)))
(when-let* ((parent (ecss--subject-parent subject adapter)))
(ecss-selector-match-p (nth 1 selector) parent adapter))))
(:adjacent (ecss--selector-match-adjacent selector subject adapter))
(:sibling (ecss--selector-match-sibling selector subject adapter))))