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

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

[elpa] externals/boxy-headings 409fd73 4/7: Refactoring


From: ELPA Syncer
Subject: [elpa] externals/boxy-headings 409fd73 4/7: Refactoring
Date: Fri, 15 Oct 2021 10:57:19 -0400 (EDT)

branch: externals/boxy-headings
commit 409fd73b0cefe95ef54baa67c90935175b4a4174
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>

    Refactoring
---
 boxy-headings.el | 47 +++++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/boxy-headings.el b/boxy-headings.el
index 22992e4..6afcfd4 100644
--- a/boxy-headings.el
+++ b/boxy-headings.el
@@ -124,6 +124,20 @@
     (t (:background "gainsboro" :foreground "dim gray")))
   "Face for tooltips in a boxy diagram.")
 
+;;;; Variables
+
+(defvar boxy-headings-rel-alist
+  '(("on top of"       . ("on.+top"))
+    ("in front of"     . ("in.+front"))
+    ("behind"          . ("behind"))
+    ("below"           . ("below"))
+    ("to the left of"  . ("to the left of"))
+    ("to the right of" . ("to the right of")))
+  "Mapping from a boxy relationship to a list of regexes.
+
+Each regex will be tested against the REL property of each
+heading.")
+
 ;;;; Pretty printing
 
 (cl-defun boxy-headings-pp (box
@@ -310,26 +324,19 @@ diagram."
 POS can be nil to use the heading at point.
 
 The default relationship is 'in'."
-  (let ((rel (org-entry-get pos "REL")))
-    (cond
-     ((not rel)
-      "in")
-     ((string-match-p "on.+top" rel)
-      "on top of")
-     ((string-match-p "in.+front" rel)
-      "in front of")
-     ((string-match-p "behind" rel)
-      "behind")
-     ((string-match-p "above" rel)
-      "above")
-     ((string-match-p "below" rel)
-      "below")
-     ((string-match-p "left" rel)
-      "to the left of")
-     ((string-match-p "right" rel)
-      "to the right of")
-     (t
-      "in"))))
+  (let ((heading-rel (org-entry-get pos "REL")))
+    (if (not heading-rel)
+        "in"
+      (seq-find
+       (lambda (rel)
+         (seq-some
+          (lambda (pattern)
+            (message "Testing pattern %s" pattern)
+            (string-match-p pattern heading-rel))
+          (alist-get rel boxy-headings-rel-alist
+                     nil nil #'equal)))
+       boxy-relationships
+       "in"))))
 
 (provide 'boxy-headings)
 



reply via email to

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