[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org-real 5f5f352 117/160: Jump to location when enterin
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org-real 5f5f352 117/160: Jump to location when entering org real mode |
Date: |
Wed, 6 Oct 2021 16:58:28 -0400 (EDT) |
branch: externals/org-real
commit 5f5f352795e7676b5103d7f11bf93a40edd36c1a
Author: Tyler Grinn <tylergrinn@gmail.com>
Commit: Tyler Grinn <tylergrinn@gmail.com>
Jump to location when entering org real mode
With either org-real-world or org-real-headlines, the cursor will be
at the position of the box in the diagram matching where the cursor is
originally.
---
demo/garage.org | 30 ++++++++++++++---------------
org-real.el | 60 +++++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 63 insertions(+), 27 deletions(-)
diff --git a/demo/garage.org b/demo/garage.org
index ae95ec8..9cef143 100644
--- a/demo/garage.org
+++ b/demo/garage.org
@@ -1,17 +1,17 @@
* Items in the garage
- - [[real://garage/workbench?rel=in][workbench]]
- - [[real://garage/workbench?rel=in/paintbrush?rel=in front of][paintbrush]]
- - [[real://garage/workbench?rel=in/paintbrush?rel=in front of/wrench?rel=to
the left of][wrench]]
- - [[real://garage/workbench?rel=in/nails?rel=on top of/screwdriver?rel=on
top of][screwdriver]]
- - [[real://garage/workbench?rel=in/ratchet?rel=on top of][ratchet]]
- - [[real://garage/east wall?rel=in/rake?rel=on/hoe?rel=to the left
of/snowblower?rel=above/shovel?rel=above][shovel]]
- - [[real://garage/east wall?rel=in/rake?rel=on][rake]]
- - [[real://garage/workbench?rel=in/hammer?rel=on][hammer]]
- - [[real://garage/east wall?rel=in/rake?rel=on/hoe?rel=to the left of][hoe]]
- - [[real://garage/car?rel=in/air freshener?rel=in][air freshener]]
- - [[real://garage/workbench?rel=in/nails?rel=on top of][nails]]
- - [[real://garage/east wall?rel=in][East wall]]
- - [[real://garage/east wall?rel=in/rake?rel=on/hoe?rel=to the left
of/snowblower?rel=above][snowblower]]
- - [[real://garage/workbench?rel=in/hammer?rel=on/screws?rel=to the right
of][screws]]
+ - [[real://garage/workbench][workbench]]
+ - [[real://garage/workbench/paintbrush?rel=in front of][paintbrush]]
+ - [[real://garage/workbench/paintbrush?rel=in front of/wrench?rel=to the
left of][wrench]]
+ - [[real://garage/workbench/nails?rel=on top of/screwdriver?rel=on top
of][screwdriver]]
+ - [[real://garage/workbench/ratchet?rel=on top of][ratchet]]
+ - [[real://garage/east wall/rake?rel=on/hoe?rel=to the left
of/snowblower?rel=above/shovel?rel=above][shovel]]
+ - [[real://garage/east wall/rake?rel=on][rake]]
+ - [[real://garage/workbench/hammer?rel=on][hammer]]
+ - [[real://garage/east wall/rake?rel=on/hoe?rel=to the left of][hoe]]
+ - [[real://garage/car/air freshener][air freshener]]
+ - [[real://garage/workbench/nails?rel=on top of][nails]]
+ - [[real://garage/east wall][East wall]]
+ - [[real://garage/east wall/rake?rel=on/hoe?rel=to the left
of/snowblower?rel=above][snowblower]]
+ - [[real://garage/workbench/hammer?rel=on/screws?rel=to the right
of][screws]]
- [[real://garage/saw?rel=on][saw]]
- - [[real://garage/workbench?rel=in/paintbrush?rel=in front of/wrench?rel=to
the left of/pliers?rel=below][pliers]]
+ - [[real://garage/workbench/paintbrush?rel=in front of/wrench?rel=to the
left of/pliers?rel=below][pliers]]
diff --git a/org-real.el b/org-real.el
index 3f13785..aceb019 100644
--- a/org-real.el
+++ b/org-real.el
@@ -217,24 +217,60 @@
(defun org-real-world ()
"View all real links in the current buffer."
(interactive)
- (org-real--pp
- (org-real--merge
- (mapcar
- (lambda (containers)
- (org-real--make-instance 'org-real-box containers))
- (org-real--parse-buffer)))
- nil nil t))
+ (let ((link (cond
+ ((org-in-regexp org-link-bracket-re 1)
+ (match-string-no-properties 1))
+ ((org-in-regexp org-link-plain-re)
+ (org-unbracket-string "<" ">" (match-string 0)))))
+ (world (org-real--merge
+ (mapcar
+ (lambda (containers)
+ (org-real--make-instance 'org-real-box containers))
+ (org-real--parse-buffer)))))
+ (org-real--pp world nil nil t)
+ (if (and link (string= "real" (ignore-errors (url-type
(url-generic-parse-url link)))))
+ (let ((containers (reverse (org-real--parse-url link)))
+ match parent)
+ (while (and containers (not match))
+ (setq match (org-real--find-matching
+ (org-real-box :name (plist-get (pop containers)
:name))
+ world)))
+ (when match
+ (setq parent (with-slots (parent) match parent))
+ (while (not (org-real--is-visible parent))
+ (setq match parent)
+ (setq parent (with-slots (parent) match parent)))
+ (run-with-timer
+ 0 nil
+ (lambda ()
+ (let ((top (org-real--get-top match))
+ (left (org-real--get-left match)))
+ (forward-line (- (+ org-real--current-offset top 1
org-real-padding-y)
+ (line-number-at-pos)))
+ (move-to-column (+ left 1 org-real-padding-x))))))))))
(defun org-real-headlines ()
"View all org headlines as an org real diagram.
MAX-LEVEL is the maximum level to show headlines for."
(interactive)
- (org-real--pp
- (org-real--parse-headlines)
- nil
- 'display-buffer-same-window
- t 1 2))
+ (let ((path (seq-filter 'identity (append (list (org-entry-get nil "ITEM"))
(reverse (org-get-outline-path)))))
+ (world (save-excursion (org-real--parse-headlines)))
+ match)
+ (org-real--pp world nil 'display-buffer-same-window t 1 2)
+ (while (and path (not match))
+ (setq match (org-real--find-matching (org-real-box :name (pop path))
world)))
+ (when match
+ (while (not (org-real--is-visible match))
+ (setq match (with-slots (parent) match parent)))
+ (let ((top (org-real--get-top match))
+ (left (org-real--get-left match)))
+ (run-with-timer
+ 0 nil
+ (lambda ()
+ (forward-line (- (+ org-real--current-offset top 1
org-real-padding-y)
+ (line-number-at-pos)))
+ (move-to-column (+ left 1 org-real-padding-x))))))))
(defun org-real-apply ()
"Apply any change from the real link at point to the current buffer."
- [elpa] externals/org-real 72dd6bf 113/160: Added more customization vars, (continued)
- [elpa] externals/org-real 72dd6bf 113/160: Added more customization vars, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real bf8a26c 105/160: Navigate by relationship; color currenly selected box and rel-box, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real d9aab4e 103/160: Refactoring, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real b3d1c09 115/160: Redesigned tooltips, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real d23f9bf 112/160: If headline is a link, only display description, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real f883078 101/160: Merge branch 'next' into 'main', ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 9707641 130/160: Allow boxes to not have location markers, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real add82f3 124/160: Added smoke test; fixed behind preposition, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 6428a6d 125/160: Smooth lines, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real e38ae9b 131/160: Added help-echo slot for minibuffer messages, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 5f5f352 117/160: Jump to location when entering org real mode,
ELPA Syncer <=
- [elpa] externals/org-real ce817a1 139/160: Merge display-rel-box, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 75871b1 140/160: Color theme update, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 5541420 143/160: Use buffer name instead of buffer-file-name for org-real-headlines, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real cd43923 119/160: Use original relationship for tooltip if changed, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real f03777b 132/160: Fixed hiding of rel-box border, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 8d5af75 144/160: Linting, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real ab46371 160/160: Merge branch 'next' into 'main', ELPA Syncer, 2021/10/06
- [elpa] externals/org-real 20e80af 145/160: Bump version, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real babe4da 148/160: Add submodules during ci/cd pipeline, ELPA Syncer, 2021/10/06
- [elpa] externals/org-real a13ee17 155/160: Added elpaignore, ELPA Syncer, 2021/10/06