emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ascii-art-to-unicode 1de2351 09/42: [aa2u int] Compute


From: Stefan Monnier
Subject: [elpa] externals/ascii-art-to-unicode 1de2351 09/42: [aa2u int] Compute vertical/horizontal components separately.
Date: Sun, 29 Nov 2020 18:57:04 -0500 (EST)

branch: externals/ascii-art-to-unicode
commit 1de235157efa9190ce2fe7116fae168dd160de42
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [aa2u int] Compute vertical/horizontal components separately.
    
    * packages/ascii-art-to-unicode/ascii-art-to-unicode.el
    (aa2u-replacement ok): Recognize ‘UP’, ‘DOWN’, ‘LEFT’, ‘RIGHT’
    instead of ‘n’, ‘s’, ‘w’, ‘e’.
    (aa2u-replacement two-p): New internal func.
    (aa2u-replacement just): Likewise.
    (aa2u-replacement): Don't glom everything for one ‘pcase’;
    instead, construct args to ‘aa2u-ucs-bd-uniform-name’
    by computing vertical and horizontal components separately.
---
 ascii-art-to-unicode.el | 41 +++++++++++++++++------------------------
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/ascii-art-to-unicode.el b/ascii-art-to-unicode.el
index 9aaa7ef..3ebe951 100644
--- a/ascii-art-to-unicode.el
+++ b/ascii-art-to-unicode.el
@@ -137,8 +137,8 @@ Their values are STRINGIFIER and COMPONENTS, respectively."
                     (eq ?+ (char-after pos))
                     ;; Require properly directional neighborliness.
                     (memq (case name
-                            ((n s) 'VERTICAL)
-                            ((w e) 'HORIZONTAL))
+                            ((UP DOWN)    'VERTICAL)
+                            ((LEFT RIGHT) 'HORIZONTAL))
                           (get-text-property pos 'aa2u-components)))
                name))
          (v (name dir) (let ((bol (line-beginning-position dir))
@@ -151,28 +151,21 @@ Their values are STRINGIFIER and COMPONENTS, 
respectively."
                          (unless (or (> bol pos)
                                      (<= eol pos))
                            (ok name pos))))
-         (light (&rest components) (apply 'aa2u-1c
-                                          'aa2u-ucs-bd-uniform-name
-                                          'LIGHT components)))
-      (let* ((n (v 'n 0))
-             (s (v 's 2))
-             (w (h 'w -1))
-             (e (h 'e  1)))
-        (pcase (delq nil (list n s w e))
-          (`(n s w e) (light 'VERTICAL 'HORIZONTAL))
-          (`(s e)     (light 'DOWN 'RIGHT))
-          (`(s w)     (light 'DOWN 'LEFT))
-          (`(n e)     (light 'UP 'RIGHT))
-          (`(n w)     (light 'UP 'LEFT))
-          (`(n s e)   (light 'VERTICAL 'RIGHT))
-          (`(n s w)   (light 'VERTICAL 'LEFT))
-          (`(n w e)   (light 'UP 'HORIZONTAL))
-          (`(s w e)   (light 'DOWN 'HORIZONTAL))
-          (`(n)       (light 'UP))
-          (`(s)       (light 'DOWN))
-          (`(w)       (light 'LEFT))
-          (`(e)       (light 'RIGHT))
-          (_          nil))))))
+         (two-p (ls) (= 2 (length ls)))
+         (just (&rest args) (delq nil args)))
+      (apply 'aa2u-1c
+             'aa2u-ucs-bd-uniform-name
+             'LIGHT
+             (just (pcase (just (v 'UP   0)
+                                (v 'DOWN 2))
+                     ((pred two-p) 'VERTICAL)
+                     (`(,vc)        vc)
+                     (_             nil))
+                   (pcase (just (h 'LEFT  -1)
+                                (h 'RIGHT  1))
+                     ((pred two-p) 'HORIZONTAL)
+                     (`(,hc)        hc)
+                     (_             nil)))))))
 
 (defun aa2u-phase-2 ()
   (goto-char (point-min))



reply via email to

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