* An org-follow-mode following org/org-roam links
@ 2024-10-21 14:56 Sébastien Lerique
2024-10-26 17:59 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Sébastien Lerique @ 2024-10-21 14:56 UTC (permalink / raw)
To: emacs-orgmode
Hello all,
First of all thanks to everybody for org (file, agenda, and much more),
such an amazing tool!
I'm trying to add a minor "org-follow-mode" somewhere between
"org-agenda-follow-mode" and "org-roam-ui-follow-mode"
<https://github.com/org-roam/> (request also posted on
<https://org-roam.discourse.group/t/advice-for-an-org-follow-mode-following-org-org-roam-links/3631>).
My intuition so far was to start from a copy of "org-agenda-follow-mode"
(and subcommands), adapting it to an org file being the main window.
--8<---------------cut here---------------start------------->8---
(defvar org-follow-mode nil)
(defvar org-pre-follow-window-conf nil)
(defun org-marked-tree-to-indirect-buffer (arg)
;; TODO needed?
;; (interactive "P")
;; (org-agenda-check-no-diary)
(let* ((marker
;;(or
(org-get-at-bol 'org-marker)
;; (org-agenda-error)
;; )
)
(buffer (marker-buffer marker))
(pos (marker-position marker)))
(with-current-buffer buffer
(save-excursion
(goto-char pos)
(org-tree-to-indirect-buffer arg))))
;; TODO needed?
;; (setq org-agenda-last-indirect-buffer org-last-indirect-buffer)
)
(defcustom org-follow-indirect nil
"Non-nil means `org-follow-mode' displays only the current item's
tree, in an indirect buffer."
:group 'org
:version "29.4"
:type 'boolean)
(defun org-do-context-action ()
"Show outline path and, maybe, follow mode window."
(let ((m (org-get-at-bol 'org-marker)))
(when (and (markerp m) (marker-buffer m))
(and org-follow-mode
(if org-follow-indirect
(let ((org-indirect-buffer-display 'other-window))
;; TODO or org-marked-tree-to-indirect-buffer from above
(org-tree-to-indirect-buffer nil))
;; TODO needed?
;; (org-agenda-show)
;; TODO
;; (and org-agenda-show-outline-path
;; (org-with-point-at m (org-display-outline-path org-agenda-show-outline-path)))
)))))
(defun org-follow-mode ()
"Toggle follow mode in a buffer."
(interactive)
(unless org-follow-mode
(setq org-pre-follow-window-conf
(current-window-configuration)))
(setq org-follow-mode (not org-follow-mode))
(unless org-follow-mode
(set-window-configuration org-pre-follow-window-conf))
;; TODO needed?
;; (org-set-mode-name)
(org-do-context-action)
(message "Follow mode is %s"
(if org-follow-mode "on" "off")))
--8<---------------cut here---------------end--------------->8---
Now this obviously doesn't work, primarily because I have no
`org-marker` defined as no agenda line is selected.
I then went over the "org-roam-ui-follow-mode" code, little of which I
could use for this as most of the follow-mode looks simpler, directly
using the network instead of having to manage windows.
Would anyone have some advice to set this up? How to replace the use of
`marker` and read the current org position instead?
Thanks again for reading, and best to y'all
--
Sébastien Lerique
https://slvh.fr/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: An org-follow-mode following org/org-roam links
2024-10-21 14:56 An org-follow-mode following org/org-roam links Sébastien Lerique
@ 2024-10-26 17:59 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2024-10-26 17:59 UTC (permalink / raw)
To: Sébastien Lerique; +Cc: emacs-orgmode
Sébastien Lerique <sl@eauchat.org> writes:
> ...
> Now this obviously doesn't work, primarily because I have no
> `org-marker` defined as no agenda line is selected.
>
> I then went over the "org-roam-ui-follow-mode" code, little of which I
> could use for this as most of the follow-mode looks simpler, directly
> using the network instead of having to manage windows.
>
> Would anyone have some advice to set this up? How to replace the use of
> `marker` and read the current org position instead?
You can do something like (save-excursion (org-back-to-heading t) (point-marker))
This will move point back to the beginning of current heading, return
marker corresponding to that point, and move back.
Hope it helps.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-26 17:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 14:56 An org-follow-mode following org/org-roam links Sébastien Lerique
2024-10-26 17:59 ` Ihor Radchenko
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).