emacs-citar / citar

Emacs package to quickly find and act on bibliographic references, and edit org, markdown, and latex academic documents.
GNU General Public License v3.0
502 stars 54 forks source link

Function "citar-indicator-create" not found #771

Closed deb75 closed 1 year ago

deb75 commented 1 year ago

I followed the wiki's indicator page and integrated it into my configuration :

(use-package citar
  :custom
  (citar-indicator-files-icons
    (citar-indicator-create
     :symbol (all-the-icons-faicon
              "file-o"
              :face 'all-the-icons-green
              :v-adjust -0.1)
     :function #'citar-has-files
     :padding "  " ; need this because the default padding is too low for these icons
     :tag "has:files"))
   (citar-indicator-links-icons
    (citar-indicator-create
     :symbol (all-the-icons-octicon
              "link"
              :face 'all-the-icons-orange
              :v-adjust 0.01)
     :function #'citar-has-links
     :padding "  "
     :tag "has:links"))
   (citar-indicator-notes-icons
    (citar-indicator-create
     :symbol (all-the-icons-material
              "speaker_notes"
              :face 'all-the-icons-blue
              :v-adjust -0.3)
     :function #'citar-has-notes
     :padding "  "
     :tag "has:notes"))
   (citar-indicator-cited-icons
    (citar-indicator-create
     :symbol (all-the-icons-faicon
              "circle-o"
              :face 'all-the-icon-green)
     :function #'citar-is-cited
     :padding "  "
     :tag "is:cited"))
  (citar-library-paths (list ... ))
  (org-cite-global-bibliography (list  ...))
  (org-cite-insert-processor 'citar)
  (org-cite-follow-processor 'citar)
  (org-cite-activate-processor 'citar)
  (citar-bibliography org-cite-global-bibliography)
  (org-cite-csl-styles-dir (concat (expand-file-name user-emacs-directory) "csl"))
  (org-cite-export-processors
   '((latex biblatex)
     (pandoc basic)
     (md (csl "ieee.csl"))
     (t basic)))
  :config
  (add-to-list 'citar-file-open-functions (cons "pdf" #'org-pdftools-open))
  (setq citar-library-file-extensions (list "pdf" "jpg")
        citar-at-point-function 'embark-act
        citar-file-additional-files-separator "-"
        citar-notes-paths (list (concat local/org-ref-directory "/notes/"))
         citar-indicators (list citar-indicator-files-icons
                                citar-indicator-links-icons
                                citar-indicator-notes-icons
                                citar-indicator-cited-icons)
        )
  :hook
  ;; (LaTeX-mode . citar-capf-setup)
  (org-mode . citar-capf-setup)
  :bind
  (:map org-mode-map :package org ("C-c b" . #'org-cite-insert)))

When starting emacs, it complains the function "citar-indicatro-create" is not found. Indeed, I did not find a (defun citar-indicator-create ...) in the source.

I tried also to put the indicator lines outside of the (use-package ) section. It still complains.

However, this function (citar-indicator-create) is called in the source without any errors, I wonder then why it complains when I add the indicator customizations ?

I remember having had the same trouble for another package, the given function had to be called in a special way. Could you help me to make it work ?

Regards

bdarcus commented 1 year ago

It's defined by the cl-defstruct.

Do you get the error after loading citar?

Like if you require it manually first, does it still complain?

bdarcus commented 1 year ago

Also, see this Doom PR.

https://github.com/doomemacs/doomemacs/pull/7168

It may suggest slight tweaks to the use-package?

deb75 commented 1 year ago

Got it !

I remember having had the same issue with another package.

The point is that the definition of citar-indcator-create is not available outside of the package.

Then this :

(use-package ...)

(defvar ... (citar-indicator-create ...))

fails, because the function is not found, although being defined in the package.

To make it work, it is needed to put defvar statements within the use-package call :

(use-package ...
 :config
(defvar ... (citar-indicator-create ...))
)

and it works like this, much like in the doom link you provided.

Thanks

Regards

bdarcus commented 1 year ago

Makes sense.

I'm considering somehow making those indicators available, perhaps through an optional extension file.

See #770.

tabroughton commented 1 year ago

I too have just had this same issue. I also wonderred if these couldn't be a part of the package and activated in some way with something like (setq citar-use-default-indicators t) or something like that. Glad to find this issue which has solved my issue.

bdarcus commented 1 year ago

You mean for the icon-based ones?

The challenge is I don't want to require all-the-icons, so need to figure out a way to avoid that, but still make it easier.

EDIT

Maybe a short-term solution can be wrapping the example in with-eval-after-load, or showing it in a use-package context.

I also want to experiment with SVG icons, but was waiting on a fix to svg-lib.

bdarcus commented 1 year ago

Couple of updates on this:

  1. I added the citar-indicator to autoload
  2. The doom PR was merged today