branch: externals/boxy-headings commit be3dac154343f2a0bdcbdc1f8d355ff9eb729a1f Merge: 832aa9b 5c40f1a Author: Tyler Grinn <ty...@tygr.info> Commit: Tyler Grinn <ty...@tygr.info>
Merge branch 'next' into 'main' v2.1.0 Bug fixes * Added org 9.3 dependency for emacs 26. Improvements * Generalized `REL` property using regex to match, for example, all of "in front" "in front of" and "in-front". * Added max visibility option Fixes #2 See merge request tygrdev/boxy-headings!4 --- .gitignore | 1 + Eldev | 4 ++++ README.org | 25 ++++++++++++++------- boxy-headings.el | 68 +++++++++++++++++++++++++++++++++++++++++++------------- deps/boxy | 2 +- 5 files changed, 75 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index d921429..0c2cb57 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ # Added automatically by ‘eldev init’. /.eldev /Eldev-local +*-autoloads.el \ No newline at end of file diff --git a/Eldev b/Eldev index 2e16aa9..4a89d75 100644 --- a/Eldev +++ b/Eldev @@ -1,9 +1,13 @@ ; -*- mode: emacs-lisp; lexical-binding: t -*- +(eldev-use-package-archive 'gnu) + (setq eldev-standard-excludes '(".*" "/dist/" "/deps/")) (eldev-use-local-dependency "deps/boxy" 'packaged) +(eldev-use-plugin 'autoloads) + (eldev-defcommand boxy_headings-md5 (&rest _) "Create md5 checksum of .tar and .el files in dist folder." 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 c2a2f3a..5c2adbe 100644 --- a/boxy-headings.el +++ b/boxy-headings.el @@ -3,9 +3,9 @@ ;; Copyright (C) 2021 Free Software Foundation, Inc. ;; Author: Tyler Grinn <tylergr...@gmail.com> -;; Version: 2.0.0 +;; Version: 2.1.0 ;; File: boxy-headings.el -;; Package-Requires: ((emacs "26.1") (boxy "1.0")) +;; Package-Requires: ((emacs "26.1") (boxy "1.0") (org "9.3")) ;; Keywords: tools ;; URL: https://gitlab.com/tygrdev/boxy-headings @@ -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 @@ -85,6 +85,10 @@ "Default level to display boxes." :type 'number) +(defcustom boxy-headings-max-visibility 2 + "Maximum visibility to show when cycling global visibility." + :type 'number) + (defcustom boxy-headings-tooltips t "Show tooltips in a boxy diagram." :type 'boolean) @@ -120,13 +124,27 @@ (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 &key (display-buffer-fn 'display-buffer-pop-up-window) (visibility boxy-headings-default-visibility) - (max-visibility 2) + (max-visibility boxy-headings-max-visibility) select header (default-margin-x boxy-headings-margin-x) @@ -223,13 +241,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 +256,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 +318,26 @@ 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 ((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) ;;; boxy-headings.el ends here diff --git a/deps/boxy b/deps/boxy index a38c568..888e78c 160000 --- a/deps/boxy +++ b/deps/boxy @@ -1 +1 @@ -Subproject commit a38c568b0b88a730834c199f57443e606f5cf2c7 +Subproject commit 888e78ce58c5f217c84345b02a5aafd4c9a871b5