branch: elpa/hl-block-mode
commit 1abef340d8802a0f309c3baa6f259a9fafd7e19e
Author: Campbell Barton <[email protected]>
Commit: Campbell Barton <[email protected]>

    Style: use when-let* for cleaner code
    
    Replace (let ((x ...)) (when x ...)) pattern with when-let*
    in three functions for more concise and idiomatic code.
    
    Note: when-let is deprecated; when-let* is the current form.
---
 hl-block-mode.el | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/hl-block-mode.el b/hl-block-mode.el
index 237cbdf9738..221be9bd0d4 100644
--- a/hl-block-mode.el
+++ b/hl-block-mode.el
@@ -101,15 +101,14 @@ Useful for languages that use S-expressions to avoid 
overly nested highlighting.
   "A version of `syntax-ppss' to match curly braces.
 PT is typically the `(point)'."
   (declare (important-return-value t))
-  (let ((beg
-         (ignore-errors
-           (nth 1 (syntax-ppss pt)))))
-    (when beg
-      (cond
-       ((memq (char-after beg) hl-block-bracket)
-        beg)
-       (t
-        (hl-block--syntax-prev-bracket (1- beg)))))))
+  (when-let* ((beg
+               (ignore-errors
+                 (nth 1 (syntax-ppss pt)))))
+    (cond
+     ((memq (char-after beg) hl-block-bracket)
+      beg)
+     (t
+      (hl-block--syntax-prev-bracket (1- beg))))))
 
 
 (defun hl-block--find-range (pt)
@@ -134,18 +133,16 @@ PT is typically the `(point)'."
 (defun hl-block--find-all-ranges (pt)
   "Return ranges starting from PT, outer-most to inner-most."
   (declare (important-return-value t))
-  (let ((range (hl-block--find-range pt)))
-    (when range
-      ;; When the previous range is nil, this simply terminates the list.
-      (cons range (hl-block--find-all-ranges (car range))))))
+  (when-let* ((range (hl-block--find-range pt)))
+    ;; When the previous range is nil, this simply terminates the list.
+    (cons range (hl-block--find-all-ranges (car range)))))
 
 
 (defun hl-block--find-single-range (pt)
   "Return ranges starting from PT, only a single level."
   (declare (important-return-value t))
-  (let ((range (hl-block--find-range pt)))
-    (when range
-      (list range))))
+  (when-let* ((range (hl-block--find-range pt)))
+    (list range)))
 
 
 (defun hl-block--syntax-skip-to-multi-line ()

Reply via email to