jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.42k stars 260 forks source link

Error (use-package): helm-bibtex/:config: Wrong number of arguments: (3 . 4), 2 #949

Closed hongyi-zhao closed 1 year ago

hongyi-zhao commented 3 years ago

On Ubuntu 20.04.2 LTS, I use the following use-package configuration for helm-bibtex:

;https://lucidmanager.org/productivity/emacs-bibtex-mode/
(setq bib-files-directory (directory-files-recursively
                             (concat (getenv "HOME") "/texmf/bibtex/bib/local") "^[A-Za-z].+.bib$")
      ;pdf-files-directory (concat (getenv "HOME") "/pdf")
      ;bib-notes-directory (concat (getenv "HOME") "/notes")
      )

(use-package helm-bibtex
  :demand t
  :config
  (require 'helm-config)
  (setq bibtex-completion-bibliography bib-files-directory
        ;bibtex-completion-library-path pdf-files-directory
        ;bibtex-completion-notes-path bib-notes-directory
        bibtex-completion-pdf-field "File"
        ;https://github.com/tmalsburg/helm-bibtex#insert-latex-cite-commands
        bibtex-completion-cite-prompt-for-optional-arguments nil)
  :bind
  (("<menu>" . helm-command-prefix)
   :map helm-command-map
   ("b" . helm-bibtex)
   ("B" . helm-bibtex-with-local-bibliography)
   ("n" . helm-bibtex-with-notes)
   ("<menu>" . helm-resume))

   :config
   ;https://github.com/tmalsburg/helm-bibtex#application-used-for-opening-pdfs
   (defun bibtex-completion-open-pdf-external (keys &optional fallback-action)
     (let ((bibtex-completion-pdf-open-function
         (lambda (fpath) (start-process "evince" "*helm-bibtex-evince*" "/usr/bin/evince" fpath))))
      (bibtex-completion-open-pdf keys fallback-action)))

     (helm-bibtex-helmify-action bibtex-completion-open-pdf-external helm-bibtex-open-pdf-external)

    (helm-add-action-to-source
         'helm-bibtex
         '(("P" helm-bibtex-open-pdf-external "Open PDF file in external viewer (if present)")))  

    ;https://github.com/tmalsburg/helm-bibtex#browser-used-for-opening-urls-and-dois 
    (setq bibtex-completion-browser-function
      (lambda (url _) (start-process "firefox" "*firefox*" "firefox" url))) 

    ;https://github.com/tmalsburg/helm-bibtex#predefined-searches
    (defun helm-bibtex-my-publications (&optional arg)
      "Search BibTeX entries authored by “Jane Doe”.
        With a prefix ARG, the cache is invalidated and the bibliography reread."
      (interactive "P")
      (helm-bibtex arg nil "Jane Doe"))

    ;; Bind this search function to Ctrl-x p:
    (global-set-key (kbd "C-x p") 'helm-bibtex-my-publications))

The above configuration will trigger the following error, but if I remove the :demand t directive, the problem will disappear:

Error (use-package): helm-bibtex/:config: Wrong number of arguments: (3 . 4), 2 Disable showing Disable logging

See here for some relevant discussion. Any hints for this problem?

Regards, HY

skangas commented 1 year ago

I think you're calling something with 3 arguments instead of an expected 4. I would move the configuration out of the use-package declaration and evaluate the sexps one by one to see which one is at fault.

I don't see a bug in use-package here.