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

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

[elpa] 01/03: [aa2u int] Compute vertical/horizontal components separate


From: Thien-Thi Nguyen
Subject: [elpa] 01/03: [aa2u int] Compute vertical/horizontal components separately.
Date: Fri, 09 May 2014 16:06:00 +0000

ttn pushed a commit to branch master
in repository elpa.

commit 0ead2529a64be782cabda3322abfc1711eb0c8ce
Author: Thien-Thi Nguyen <address@hidden>
Date:   Fri May 9 17:42:09 2014 +0200

    [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/ascii-art-to-unicode.el   |   41 ++++++++-----------
 1 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/packages/ascii-art-to-unicode/ascii-art-to-unicode.el 
b/packages/ascii-art-to-unicode/ascii-art-to-unicode.el
index 9aaa7ef..3ebe951 100644
--- a/packages/ascii-art-to-unicode/ascii-art-to-unicode.el
+++ b/packages/ascii-art-to-unicode/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]