[logaling-commit] logaling/logalimacs [master] Collect the loga-compute-length function

Back to archive index

null+****@clear***** null+****@clear*****
Wed Jun 27 10:12:54 JST 2012


yuta yamada	2012-06-27 10:12:54 +0900 (Wed, 27 Jun 2012)

  New Revision: 3636e8a2d050f766a2c01b48386c4a4ec70c1387
  https://github.com/logaling/logalimacs/commit/3636e8a2d050f766a2c01b48386c4a4ec70c1387

  Log:
    Collect the loga-compute-length function

  Modified files:
    logalimacs.el

  Modified: logalimacs.el (+17 -14)
===================================================================
--- logalimacs.el    2012-06-27 10:03:15 +0900 (a419ea9)
+++ logalimacs.el    2012-06-27 10:12:54 +0900 (c80b044)
@@ -294,16 +294,23 @@
       (loga-format-to-string converted-list))))
 
 (defun loga-extract-keywords-from (all-data)
-  (loop with keywords and source and target and note
-        for pair across all-data do
-        (loop for (key . value) in pair do
-              (case key
-                ('source (setq source value))
-                ('target (setq target value))
-                ('note   (setq note   value))))
-        (push `(,source ,target ,note) keywords)
+  (loop with keywords
+        for pair across all-data
+        collect (loga-trim-and-compute-length pair) into keywords
         finally return keywords))
 
+(defun loga-trim-and-compute-length (translation-group)
+  (loop with source and target and note
+        with source-length and target-length
+        for (key . value) in translation-group do
+        (case key
+          ('source (setq source value
+                         source-length (loga-compute-length source)))
+          ('target (setq target value
+                         target-length (loga-compute-length target)))
+          ('note   (setq note value)))
+        finally return `(,source ,target ,note ,source-length ,target-length)))
+
 (defun loga-format-to-string (converted-list)
   (let* ((striped-list (loop for (word) in converted-list
                              collect word)))
@@ -312,9 +319,7 @@
 (defun loga-format (words)
   (loop with formated-words = '()
         with size = loga-current-max-length
-        for (source target note) in words
-        for source-length = (loga-compute-length source)
-        for target-length = (loga-compute-length target)
+        for (source target note source-length target-length) in words
         if (and (loga-less-than-window-half-p source-length target-length)
                 (> loga-width-limit-source source-length))
         do (push (loga-append-margin source target note size) formated-words)
@@ -323,9 +328,7 @@
 (defun loga-compute-max-length (words)
   (loop with max-source-length = 0
         with max-target-length = 0
-        for (source target) in words
-        for source-length = (loga-compute-length source)
-        for target-length = (loga-compute-length target)
+        for (source target note source-length target-length) in words
         if (loga-clear-condition-p max-source-length max-target-length
                                    source-length target-length)
         do (setq max-source-length (max max-source-length source-length)
-------------- next part --------------
An HTML attachment was scrubbed...
다운로드 



More information about the logaling-commit mailing list
Back to archive index