]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/ascii-art-to-unicode/ascii-art-to-unicode.el
[aa2u int] Compute vertical/horizontal components separately.
[gnu-emacs-elpa] / packages / ascii-art-to-unicode / ascii-art-to-unicode.el
index 9aaa7ef8f9061061d1f7d8e3126117e681594567..3ebe951c65a6210f92cf1beb32e9eb342d56fc31 100644 (file)
@@ -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))