l3kn / org-fc

Spaced Repetition System for Emacs org-mode
https://www.leonrische.me/fc/index.html
GNU General Public License v3.0
258 stars 31 forks source link

Error when starting review: before first heading #110

Open cashpw opened 1 year ago

cashpw commented 1 year ago

I encountered this bug today after updating Emacs. The root cause is the changes to org-up-heading-safe as of version 9.7-pre. These changes broke an assumption in org-fc-narrow and caused the pointer to move up to the top of the file, rather than stop at the top-level heading. I fixed the bug by modifying the (while (org-up-heading-safe)) line in org-fc-narrow to stop when it's at the top-level heading.

(defun org-fc-narrow ()
  "Narrow the outline tree.
Only parent headings of the current heading remain visible."
  (interactive)
  (let* ((tags (org-get-tags nil 'local)))
    ;; Find the first heading with a :narrow: tag or the top level
    ;; ancestor of the current heading and narrow to its region
    (save-excursion
      (while (not (equal (org-up-heading-safe)
                         1)))
      (org-narrow-to-subtree)
      (outline-hide-subtree))
    ;; Show only the ancestors of the current card
    (org-show-set-visibility org-fc-narrow-visibility)
    (if (member "noheading" tags) (org-fc-hide-heading))))
l3kn commented 1 year ago

Good find, I've run into this but couldn't figure out the cause.