diff options
| author | Amy Grinn <grinn.amy@gmail.com> | 2021-10-15 14:29:37 +0000 |
|---|---|---|
| committer | Amy Grinn <grinn.amy@gmail.com> | 2021-10-15 14:29:37 +0000 |
| commit | 8957f85ab941fe35701880853e90e6125809c896 (patch) | |
| tree | 1a0a8eac6edaf95f84d8aabe6e8fae8f246ed4f6 | |
| parent | 4db9b662ffd4fd7a745853337e83ff5c0cb87e39 (diff) | |
| parent | b37450d4753eaa7cfa9f228cc9555adebe4e6298 (diff) | |
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
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | Eldev | 4 | ||||
| -rw-r--r-- | README.org | 25 | ||||
| -rw-r--r-- | boxy-headings.el | 68 | ||||
| m--------- | deps/boxy | 0 |
5 files changed, 74 insertions, 24 deletions
@@ -4,3 +4,4 @@ # Added automatically by ‘eldev init’. /.eldev /Eldev-local +*-autoloads.el
\ No newline at end of file @@ -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." @@ -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 <tylergrinn@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 -Subproject a38c568b0b88a730834c199f57443e606f5cf2c +Subproject 888e78ce58c5f217c84345b02a5aafd4c9a871b |
