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?

  • 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 at 0:23
  • Hi @jagrg That could work. How would you implement it? Can you post a code snippet? Thanks. – Adam Feb 26 at 14:36
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)))
  • Perfect. Thanks @jagrg! – Adam Feb 27 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.