1

I am using helm-org-in-buffer-headings to search headings in the current buffer. I am using this script (provided by jagra here) to activate follow mode:

  (with-eval-after-load "helm-org"
    (cl-defmethod helm-setup-user-source ((source helm-org-headings-class))
      (set-slot-value source 'follow 1)))

So as I navigate through the helm source list, I see the corresponding headings in the main buffer. For example:

enter image description here

Instead of seeing the entire document, while I browse through the source list, I would like to narrow-to-subtree.

Any ideas?

Adam
  • 1,857
  • 11
  • 32
  • You could change `helm-org-goto-marker` to start with `widen` and end with `org-narrow-to-subtree`, but that would keep the buffer narrowed when you press RET or exit the minibuffer. – jagrg Feb 26 '19 at 00:23
  • Hi @jagrg That could work. How would you implement it? Can you post a code snippet? Thanks. – Adam Feb 26 '19 at 14:36

1 Answers1

1

You can change helm-org-goto-marker to start with widen and end with org-narrow-to-subtree, but that would keep the buffer narrowed when you press RET or exit the minibuffer.

(advice-add 'helm-org-goto-marker :before (lambda (_marker) (widen)))
(advice-add 'helm-org-goto-marker :after (lambda (_marker) (org-narrow-to-subtree)))

For a similar effect that does not require narrowing, I would suggest moving the headline to the top of the screen. You may want to show the subheadings as well:

(advice-add 'helm-org-goto-marker :after (lambda (_marker)
                                           (recenter-top-bottom 0)
                                           (outline-show-children)))
jagrg
  • 3,824
  • 4
  • 19