Kungsgeten / org-brain

Org-mode wiki + concept-mapping
MIT License
1.72k stars 102 forks source link

Wander2: new wander variant, copying also current entries title into clipboard? #300

Closed michaelsjackson closed 4 years ago

michaelsjackson commented 4 years ago

How can I get the current entries name during wander? UPDATE: This seems to get the current entry title: org-brain-entry-at-pt Second how to copy this entry title into clipboard each time during wandering?

This can be useful, if you would have a tts (text to speech engine) in the background, listening to the clipboard changes, then it would permanently speak out those titles, kind of giving random food for your brain training.

Can org-brain-visualize-follow-hook be useful here? We need something like org-brain-visualize-wander-hook I guess.

Or do we have already some mechanism built in, where we only need to set the right values, e.g. for copying into clipboard the entry title? Thanks in advance.

Kungsgeten commented 4 years ago

I think your best bet is to add a function to org-brain-after-visualize-hook. I think the following would work:

(defun mjack/wander-title-to-clipboard ()
  (when (member org-brain-wander-timer timer-list)
    (kill-new (org-brain-title org-brain--vis-entry))))
michaelsjackson commented 4 years ago

Thanks a lot Erik, works perfectly as well!

michaelsjackson commented 4 years ago

Maybe its worth giving this use case scenario in the main page as well, because I find it very useful in practice, especially together with obvz. Otherwise such a useful case is more or less hidden on the closed issues.

michaelsjackson commented 4 years ago

Wander stopped should stop this mechanism again. Now, even if I stop wandering, the permanent copying to clipboard seems to continue, as the tts engine continues repeating. :) Is there any relevant hook for that? after-wander-stopped-hook or so.

Kungsgeten commented 4 years ago

It is hard to know what should be included in the README. I think corner cases like this may make it more daunting for new users to read the documentation. Maybe it could be included in a wiki or similar (the documentation should probably be rewritten, but that project doesn't seem very fun).

When you stop wandering the org-brain-wander-timer should stop, and hence it is no longer a member of timer-list, so the above function shouldn't trigger (even though it is still run in the hook). If you want to add/remove the hook when wandering starts/stops your best bet would probably be to add an advice to the org-brain-visualize-wander function or org-brain-stop-wandering. I don't use advices much myself though so I don't think I could help you.

michaelsjackson commented 4 years ago

Ok, thanks, I will test a bit more, maybe it was a wrong usage on my side, who knows. For now I can close this issue again, reopening is easy anyway.

Now after using again, it did not repeat. Strange, so all is perfect now.