yuchen-lea / org-media-note

Taking interactive notes when watching videos or listening to audios in org-mode.
GNU General Public License v3.0
243 stars 35 forks source link

void-function org-media-note-setup-org-ref when not requiring org-media-note-org-ref #29

Closed promisedlandt closed 3 years ago

promisedlandt commented 3 years ago

Hello Yuchen,

I get the error (void-function org-media-note-setup-org-ref) when I enter an org file. Installed org-media-note by cloning to directory, adding it to load path, and adding the following to my init.el:

(setq org-media-note-use-org-ref t)
(require 'org-media-note)
(add-hook 'org-mode-hook (lambda () (org-media-note-mode)))

If I add (require 'org-media-note-org-ref) it works. Is it a bug and you can fix it? Otherwise, if it's expected behaviour, I am happy open a pull request and add it to the readme if you like.

Stack trace:

Debugger entered--Lisp error: (void-function org-media-note-setup-org-ref)
  (org-media-note-setup-org-ref)
  (progn (org-media-note-setup-org-ref))
  (if org-media-note-use-org-ref (progn (org-media-note-setup-org-ref)))
  (progn (advice-add 'org-insert-item :before-until #'org-insert-item--media-note-item) (if org-media-note-use-org-ref (progn (org-media-note-setup-org-ref))))
  (if org-media-note-mode (progn (advice-add 'org-insert-item :before-until #'org-insert-item--media-note-item) (if org-media-note-use-org-ref (progn (org-media-note-setup-org-ref)))) (advice-remove 'org-insert-item #'org-insert-item--media-note-item))
  (let ((last-message (current-message))) (progn (set-default 'org-media-note-mode (cond ((eq arg 'toggle) (not (default-value 'org-media-note-mode))) ((and (numberp arg) (< arg 1)) nil) (t t)))) (if (boundp 'global-minor-modes) (progn (setq global-minor-modes (delq 'org-media-note-mode global-minor-modes)) (if (default-value 'org-media-note-mode) (progn (setq global-minor-modes (cons 'org-media-note-mode global-minor-modes)))))) (if org-media-note-mode (progn (advice-add 'org-insert-item :before-until #'org-insert-item--media-note-item) (if org-media-note-use-org-ref (progn (org-media-note-setup-org-ref)))) (advice-remove 'org-insert-item #'org-insert-item--media-note-item)) (run-hooks 'org-media-note-mode-hook (if (default-value 'org-media-note-mode) 'org-media-note-mode-on-hook 'org-media-note-mode-off-hook)) (if (called-interactively-p 'any) (progn (customize-mark-as-set 'org-media-note-mode) (if (and (current-message) (not (equal last-message (current-message)))) nil (let ((local "")) (message "Org-Media-Note mode %sabled%s" (if (default-value ...) "en" "dis") local))))))
  org-media-note-mode()
  (lambda nil (org-media-note-mode))()
  run-hooks(change-major-mode-after-body-hook text-mode-hook outline-mode-hook org-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook text-mode-hook outline-mode-hook org-mode-hook))
  run-mode-hooks(org-mode-hook)
  org-mode()
  set-auto-mode-0(org-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(t t)

I am using org-media-note git version fa5c2e759f90069dcf7d19076f47b537e00b9d15

yuchen-lea commented 3 years ago

Thanks for the detailed report! Of course, it's not the expected behaviour.

Since I use magic comment for org-media-note-setup-org-ref, the autoloaded function should be called correctly without requiring org-media-note-org-ref, as long as you config your autoload mechanism. https://github.com/yuchen-lea/org-media-note/blob/fa5c2e759f90069dcf7d19076f47b537e00b9d15/org-media-note-org-ref.el#L145

I think the reason may be installing this package manually, without using package.el or straight. In this way, no xxx-autoloads.el is generated, thus org-media-note-setup-org-ref cannot be found.

To sum up, if you install manually, you have to require org-media-note-org-ref. If you use some package manager, like straight, autoload will do that automatically for you.