Skip to content

Commit

Permalink
[feature] add a restore function to org-brain-visualize-mode (#345)
Browse files Browse the repository at this point in the history
* [feature] add a restore function to org-brain-visualize-mode

Like how user calls "Info" mode, if there is no `org-brain-visualize'
buffer exists, then everything is the same as before. If there
is *org-brain* buffer exists, switch to *org-brain*.

This feature is helpful for users who need constantly switch between
the Org-brain and the working documents.

The `quit' message can be further improved by using a better-quitting
strategy. However, the function right now can achieve this feature. It
is unclear what side effects will bring to the current packages.
Careful review should be taken.

* [mis] indentation

* [clean up]

* [clean up]

* [internal] change function name

* [internal] simplify checking exisence of *org-brain* buffer

* [internal] using `when` instead of `if` since there is no else clause

* [internal] no need for `progn`

* [feature] add `org-brain-visualize-dwim' for easy access
  • Loading branch information
randomwangran authored Jan 8, 2021
1 parent 2f36f30 commit f7939ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,15 @@ among entries.

* Usage

You can create new entries by =M-x org-brain-visualize= and then typing the name
of a non-existing entry. You could also use =M-x org-brain-add-entry= if you do
not want to visualize the new entry. Also commands which add children, parents
and friends, or links to entries, can create new entries in the same way. Se
/General information/ below.
You can create new entries by =M-x org-brain-visualize= and then
typing the name of a non-existing entry. You can go back to the
=*org-brain*= buffer by =M-x org-brain-visualize-dwim=. It will switch
to the =*org-brain*= buffer. If there's no such buffer, or if already
there, run =org-brain-visualize=. You could also use =M-x
org-brain-add-entry= if you do not want to visualize the new entry.
Also commands which add children, parents and friends, or links to
entries, can create new entries in the same way. Se /General
information/ below.

If you find that =org-brain= is missing entries, or list entries which doesn't
exist, try using =M-x org-brain-update-id-locations=, which syncs the
Expand Down
13 changes: 13 additions & 0 deletions org-brain.el
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,19 @@ Unless WANDER is t, `org-brain-stop-wandering' will be run."
(pop-to-buffer "*org-brain*")
(pop-to-buffer-same-window "*org-brain*")))))

;;;###autoload
(defun org-brain-visualize-dwim ()
"Switch to the *org-brain* buffer.
If there's no such buffer, or if already there, run `org-brain-visualize'."
(interactive)
(if (and (not (org-brain-maybe-switch-brain))
(not (eq major-mode 'org-brain-visualize-mode))
(get-buffer "*org-brain*"))
(if org-brain-open-same-window
(pop-to-buffer "*org-brain*")
(pop-to-buffer-same-window "*org-brain*"))
(call-interactively #'org-brain-visualize)))

;;;###autoload
(defun org-brain-visualize-entry-at-pt ()
"Use `org-brain-visualize' on the `org-brain-entry-at-pt'.
Expand Down

0 comments on commit f7939ef

Please sign in to comment.