Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a customization option: org-brain-narrow-to-entry #360

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions org-brain.el
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ This `format' string is used in `org-brain-entry-name' for headline entries.
`format' gets two objects: the file and the headline."
:group 'org-brain
:type '(string))

(defcustom org-brain-visualize-text-hook nil
"Hook runs after inserting `org-brain-text' in `org-brain-visualize'.

Expand Down Expand Up @@ -424,6 +425,11 @@ Must be set before `org-brain' is loaded."
(const :tag "Default" default)
(function :tag "Custom function")))

(defcustom org-brain-narrow-to-entry nil
"On `org-brain-goto', whether to narrow the buffer to the specific entry or not."
:group 'org-brain
:type '(boolean))

;;;;; Faces and face helper functions

(defface org-brain-title
Expand Down Expand Up @@ -1629,12 +1635,17 @@ If VERBOSE is non-nil then display a message."
;;;###autoload
(defun org-brain-goto (&optional entry goto-file-func)
"Goto buffer and position of org-brain ENTRY.
If ENTRY isn't specified, ask for the ENTRY.
Unless GOTO-FILE-FUNC is nil, use `pop-to-buffer-same-window' for opening the entry."
If ENTRY isn't specified, ask for the ENTRY. Unless
GOTO-FILE-FUNC is nil, use `pop-to-buffer-same-window' for
opening the entry.

If `org-brain-narrow-to-entry' is t, narrow the focus to only
the org-brain-entry after visiting the buffer."
(interactive)
(org-brain-stop-wandering)
(unless entry (setq entry (org-brain-choose-entry "Goto entry: " 'all)))
(when (and org-brain-quit-after-goto (eq 'major-mode 'org-brain-visualize-mode))
(when (and org-brain-quit-after-goto
(eq 'major-mode 'org-brain-visualize-mode))
(org-brain-visualize-quit))
(let ((marker (org-brain-entry-marker entry)))
(apply (or goto-file-func #'pop-to-buffer-same-window)
Expand All @@ -1643,7 +1654,9 @@ Unless GOTO-FILE-FUNC is nil, use `pop-to-buffer-same-window' for opening the en
(goto-char (marker-position marker))
(when (org-at-heading-p)
(org-show-entry)
(org-show-subtree)))
(org-show-subtree)
(when org-brain-narrow-to-entry
(org-narrow-to-subtree))))
entry)

(define-obsolete-function-alias 'org-brain-open 'org-brain-goto "0.4")
Expand Down