summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/doc/jao-org-focus.el47
1 files changed, 34 insertions, 13 deletions
diff --git a/lib/doc/jao-org-focus.el b/lib/doc/jao-org-focus.el
index a135ff5..2383cfc 100644
--- a/lib/doc/jao-org-focus.el
+++ b/lib/doc/jao-org-focus.el
@@ -24,20 +24,40 @@
(defvar-local jao-org-focus--parent nil)
(defvar-local jao-org-focus--section nil)
+(defvar jao-org-focus-siblings '("escaleta.org" . "novela.org"))
+
+(defun jao-org-focus--header-title ()
+ (when-let* ((elem (org-element-at-point))
+ (header (if (eq 'headline (org-element-type elem))
+ elem
+ (org-previous-visible-heading 1)
+ (org-element-at-point))))
+ (org-element-property :title header)))
+
+(defun jao-org-focus--is-outline ()
+ (string= (car jao-org-focus-siblings)
+ (file-name-nondirectory (or (buffer-file-name) ""))))
+
+(defun jao-org-focus-jump-to-sibling ()
+ (interactive)
+ (when-let* ((title (save-excursion (jao-org-focus--header-title)))
+ (file (if (jao-org-focus--is-outline)
+ (cdr jao-org-focus-siblings)
+ (car jao-org-focus-siblings)))
+ (link (format "[[./%s::*%s]]" file title)))
+ (org-link-open-from-string link)))
+
;;; focus on subtree
(defun jao-org-focus ()
"Pop creatingly to an indirect buffer focused on the encloing subtree.
When invoked on an indirect buffer, pops back to its base."
(interactive)
+ (when (jao-org-focus--is-outline)
+ (jao-org-focus-jump-to-sibling))
(if-let* ((b (get-buffer (or jao-org-focus--parent ""))))
(pop-to-buffer b)
- (when-let* ((elem (org-element-at-point))
- (header (if (eq 'headline (org-element-type elem))
- elem
- (org-previous-visible-heading 1)
- (org-element-at-point)))
- (title (org-element-property :title header))
+ (when-let* ((title (jao-org-focus--header-title))
(parent (buffer-name))
(bname (format "%s [%s]" title parent)))
(if-let* ((b (get-buffer bname)))
@@ -119,17 +139,18 @@ With arg, offer to switch to all children, regardless of their parent."
(defvar jao-org-focus-consult-buffer-source
`(:name "Focus buffers"
- :category jao-org-focus-buffers
- :action switch-to-buffer
- :hidden t
- :narrow ,(cons ?o "focus")
- :history jao-org-focus--focused-history
- :items ,(lambda () (mapcar 'buffer-name (jao-org-focus-list t)))))
+ :category jao-org-focus-buffers
+ :action switch-to-buffer
+ :hidden t
+ :narrow ,(cons ?o "focus")
+ :history jao-org-focus--focused-history
+ :items ,(lambda () (mapcar 'buffer-name (jao-org-focus-list t)))))
(define-minor-mode org-focus-mode
"A mode where keeping track of focused children is on by default."
:lighter " ◎"
- :keymap '(("\C-cl" . jao-org-focus-switch)
+ :keymap '(("\C-ce" . jao-org-focus-jump-to-sibling)
+ ("\C-cl" . jao-org-focus-switch)
("\C-cR" . jao-org-focus-redisplay)
("\C-co" . jao-org-focus)
("\C-cw" . count-words)