takaxp / org-tree-slide

A presentation tool for org-mode based on the visibility of outline trees
https://qiita.com/takaxp/items/8dfb5d34dfcd79f9fa5c
GNU General Public License v3.0
426 stars 61 forks source link

Presentation doesn't narrow focus correctly #53

Open Lownin opened 2 years ago

Lownin commented 2 years ago

The gif in the README over at https://github.com/takaxp/org-tree-slide shows the focus narrowing on subheadings, but currently all subheadings appear to be displayed on the parent slide. Similarly, the parent slide appears even after stepping to the sub-slides. Is there a way to activate the behavior from the gif where each slide, including subslides, are the only slides in view? Screen Shot 2022-07-14 at 5 04 40 PM

Using Doom on macOS via railwaycat/emacsmacport/emacs-mac

takaxp commented 2 years ago

(...I will post again...)

takaxp commented 2 years ago

Note: before applying a change described below, please resolve #54.

So, this is happen because of an advice for +org-present--hide-first-heading-maybe-a configured in ~/doom.d/modules/lang/org/contrib/present.el. Regarding updates on org-narrow-to-subtree at 68a44eadac00d07e2b45b10da60e0e3cd6300d6f and 004ac14a5bacf311e3d0f14a7cd8345a49980bef of org.el, the advice should be updated accordingly. I'm not sure the code below is correct in terms of omitting the first heading, but it will resolve the issue on not narrowing at this moment. Please try to replace the original code with the following.

(defadvice! +org-present--hide-first-heading-maybe-a (fn &rest args)
                "Omit the first heading if `+org-present-hide-first-heading' is non-nil."
                :around #'org-tree-slide--display-tree-with-narrow
                (letf!
                 (defun org-narrow-to-subtree (&optional element)
                   "Narrow buffer to the current subtree."
                   (interactive)
                   (save-excursion
                     (save-match-data
                       (org-with-limited-levels
                        (narrow-to-region
                         (progn
                           (when (org-before-first-heading-p)
                             (org-next-visible-heading 1))
                           (org-back-to-heading t)
                           (when +org-present-hide-first-heading
                             (forward-line 1))
                           (point))
                         (progn
                           (org-end-of-subtree t t)
                           (when (and (org-at-heading-p) (not (eobp)))
                             (backward-char 1))
                           (point)))))))
                 (apply fn args)))
Lownin commented 2 years ago

The code above works when applied in modules/lang/org/autoload/contrib-present.el

There is an unexpected behavior when using the org-tree-slide-presentation-profile that is indenting the slide header when the current heading is a subheading. It seems to match the indentation level of the subheading though it doesn't affect me in practice since I prefer the simple profile.