l3kn / org-fc

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

Error when attempting to review cards: "org-fc-index: Symbol’s function definition is void: org-fc-awk-index" #67

Open MattHood opened 3 years ago

MattHood commented 3 years ago

Thanks for your work on org-fc - I'm very keen to get started with it! I'm just having an issue getting set up: when I attempt to review cards, the following error appears in the mini buffer:

org-fc-index: Symbol’s function definition is void: org-fc-awk-index

This occurs even when running M-x org-fc-demo - the demo.org file opens, but the above error appears and nothing else happens.

My system: OS: macOS Big Sur 11.5.2 Emacs: Mituharu's Emacs-mac, emacs version 27.2. Also replicated on emacs-plus, with emacs version 28. Relevant emacs config:

(straight-use-package 'hydra)
(straight-use-package
 '(org-fc
   :type git :repo "https://git.sr.ht/~l3kn/org-fc"
   :files (:defaults "awk" "demo.org")
   :custom (org-fc-directories '("~/Org/"))
   :config
   (require 'org-fc-hydra)))

Dependencies installed via

> brew install gawk findutils

Any help would be greatly appreciated.

Matt.

l3kn commented 3 years ago

Can you do a C-h f (describe-function) and check if any of the org-fc-awk-... functions show up?

MattHood commented 3 years ago

Thank you for your quick response :)

For org-fc-awk-index:

org-fc-awk-index is a compiled Lisp function in ‘org-fc-awk.el’.

(org-fc-awk-index PATHS &optional FILTER)

Find cards in PATHS matching an optional FILTER predicate.
FILTER can be either nil or a function taking a single card as
  its input.

Another, org-fc-awk-combine-tags:

org-fc-awk-combine-tags is a compiled Lisp function in
‘org-fc-awk.el’.

(org-fc-awk-combine-tags ITAGS LTAGS)

Simulate org tag inheritance on ITAGS and LTAGS.
ITAGS and LTAGS are strings ‘":tag1:tag2:"’

Is there any other output that might be helpful?

MattHood commented 3 years ago

I've made some progress. By evaluating (require 'org-fc-awk) in a scratch buffer, I was able to begin the review process in org-fc-demo without error.

However, upon arriving at a review of the "Compact Double Card" heading, the review session ceased, with the error: No such flashcard type: double. I found then that many of the (require ...) statements can be found in org-fc.el, so I evaluated (require 'org-fc). Following this, I was able to successfully review.

I then tried modifying the :config part of my straight-use-package declaration to include (require 'org-fc) to fix the issue on startup, but this didn't work; I still need to manually evaluate (require 'org-fc).

chuxubank commented 2 years ago

@MattHood I just meet this problem when I want to defer load the org-fc package (with only :defer t).

I find that when I use :after org in use-package's config, the problem is solved. So maybe you should require this package after org is loaded.

As a reference, you can check my config file.

MattHood commented 2 years ago

Thanks for your suggestion @chuxubank - unfortunately it didn't change anything, there must just be something weird about my setup.

I hope it works for someone else who may stumble upon this thread in the future.

doolio commented 1 year ago

I too experienced this error. The suggestion by @chuxubank removes the error. However, @l3kn C-h f does not find any org-fc-awk-* functions for me.

My org-fc config is as follows:

(use-package org-fc
  :straight (:type git :repo "https://git.sr.ht/~l3kn/org-fc"
                   :files (:defaults "awk" "demo.org"))
  :after org
  :bind ("H-f" . org-fc-hydra/body)
  :config
  (require 'org-fc-hydra))

I can confirm that straight creates symlinks in the ~/.emacs.d/straight/build/org-fc directory to all the .el files in the ~/.emacs.d/straight/repos/org-fc directory as well as the .awk files in the awk sub-directory. There is also no autoloads for org-fc-awk from what I can tell in the org-fc-autoloads.el file.

Since org-fc-core.el contains the function org-fc-index which calls out to org-fc-awk.el and specifically org-fc-awk-index via org-fc-index-function is it a case where we need to add (require 'org-fc-awk) to the recommended use-package form as we currently do for org-fc-hydra?

Edit: I think the :after org line is necessary as if I'm not mistaken you don't (require 'org) anywhere, no?

l3kn commented 1 year ago

Interesting, maybe I can't replicate the error because in my config org-mode is loaded before any of the code for org-fc. In that case, adding (require 'org) inside org-fc seems like a better solution than a :after org in the use-package definition.

org-fc-hydra is required separately because it's considered an optional feature, unlike org-fc-awk without which org-fc would be unusable.

I'll try to move some code around in my emacs config to replicate this, then try the (require 'org) fix.