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

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

[elpa] externals/boxy-headings d54f3e1 2/7: Generalized REL property


From: ELPA Syncer
Subject: [elpa] externals/boxy-headings d54f3e1 2/7: Generalized REL property
Date: Fri, 15 Oct 2021 10:57:19 -0400 (EDT)

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

    Generalized REL property
    
    Using regex to match multiple forms of REL. For example 'in-front' 'in
    front of' and 'in front' will all be standardized as 'in front of'.
---
 README.org       | 25 +++++++++++++++++--------
 boxy-headings.el | 51 ++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 55 insertions(+), 21 deletions(-)

diff --git a/README.org b/README.org
index ad9bcc5..488d328 100644
--- a/README.org
+++ b/README.org
@@ -5,8 +5,13 @@ View org files as a boxy diagram.
 =package-install RET boxy-headings RET=
 
 * Usage
+  :PROPERTIES:
+  :REL: right
+  :END:
 ** =boxy-headings=
-
+   :PROPERTIES:
+   :REL:      in-front
+   :END:
    To view all headings in an org-mode file as a boxy diagram, use
    the interactive function =boxy-headings=
 
@@ -17,27 +22,31 @@ View org files as a boxy diagram.
 
    To modify the relationship between a headline and its parent, add
    the property REL to the child headline. Valid values are:
-   - on top of
-   - in front of
+   - on-top
+   - in-front
    - behind
    - above
    - below
-   - to the right of
-   - to the left of
+   - right
+   - left
 
    The tooltip for each headline shows the values that would be
    displayed if the org file was in org columns view.
 
    [[file:demo/headings.gif]]
 * License
+  :PROPERTIES:
+  :REL:      below
+  :END:
   GPLv3
 * Development
-
+  :PROPERTIES:
+  :REL:      below
+  :END:
 ** Setup
-
    Install [[https://github.com/doublep/eldev#installation][eldev]]
 
-** Commands:
+** Commands
 *** =eldev lint=
     Lint the =boxy-headings.el= file
 *** =eldev compile=
diff --git a/boxy-headings.el b/boxy-headings.el
index cb30d1f..501a7af 100644
--- a/boxy-headings.el
+++ b/boxy-headings.el
@@ -29,13 +29,13 @@
 ;; a heading and its parent can be set by using a REL property on the
 ;; child heading.  Valid values for REL are:
 ;;
-;;   - on top of
-;;   - in front of
+;;   - on-top
+;;   - in-front
 ;;   - behind
 ;;   - above
 ;;   - below
-;;   - to the right of
-;;   - to the left of
+;;   - right
+;;   - left
 ;;
 ;;   The tooltip in `boxy-headings' shows the values for each row
 ;;   in `org-columns' and can be customized the same way as org
@@ -54,7 +54,7 @@
 ;;;; Options
 
 (defgroup boxy-headings nil
-  "Customization options for boxy-headings"
+  "Customization options for boxy-headings."
   :group 'applications)
 
 (defcustom boxy-headings-margin-x 2
@@ -223,13 +223,11 @@ diagram."
     (with-current-buffer (marker-buffer (car markers))
       (let* ((partitioned (seq-group-by
                            (lambda (h)
-                             (let ((child-rel (or (org-entry-get
-                                                   (org-element-property 
:begin h)
-                                                   "REL")
-                                                  "in")))
-                               (if (member child-rel 
boxy-children-relationships)
-                                   'children
-                                 'siblings)))
+                             (if (member (boxy-headings--get-rel
+                                          (org-element-property :begin h))
+                                         boxy-children-relationships)
+                                 'children
+                               'siblings))
                            (cddr heading)))
              (children (alist-get 'children partitioned))
              (siblings (alist-get 'siblings partitioned))
@@ -240,7 +238,7 @@ diagram."
                                         (lambda (column)
                                           (length (cadr (car column))))
                                         columns)))
-             (rel (save-excursion (goto-char pos) (or (org-entry-get nil 
"REL") "in")))
+             (rel (boxy-headings--get-rel pos))
              (level (if (member rel boxy-children-relationships)
                         (+ 1 parent-level)
                       parent-level))
@@ -302,6 +300,33 @@ diagram."
      headings)
     world))
 
+(defun boxy-headings--get-rel (&optional pos)
+  "Get the boxy relationship from an org heading at POS.
+
+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"))))
+
 (provide 'boxy-headings)
 
 ;;; boxy-headings.el ends here



reply via email to

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