Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The problem related to (require 'helm-config) and (require 'helm-bibtex). #432

Closed
hongyi-zhao opened this issue May 15, 2023 · 9 comments
Closed

Comments

@hongyi-zhao
Copy link

In my case, the configuration for helm and helm-bibtex is as follows:

(use-package helm
  :bind (:map helm-command-map
          ("C-c h" . helm-execute-persistent-action)))

(use-package helm-bibtex
  :init
  (setq
   bibtex-completion-pdf-field "File"
   ;;https://github.com/tmalsburg/helm-bibtex#insert-latex-cite-commands
   bibtex-completion-cite-prompt-for-optional-arguments nil)

  :bind-keymap
  ("<menu>" . helm-command-prefix)
  :bind
  (
   :map helm-command-map
   ("b" . helm-bibtex)
   ("B" . helm-bibtex-with-local-bibliography)
   ("n" . helm-bibtex-with-notes)
   ("<menu>" . helm-resume)
   )

  :config
  (require 'helm-config)
  ;;https://github.com/tmalsburg/helm-bibtex#application-used-for-opening-pdfs
  ;;https://github.com/tmalsburg/helm-bibtex/issues/386
  (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)))

  )

With the above setting, I still observed the following result:

C-x b *scratch* RET then in scratch buffer eval (featurep 'helm-bibtex) by C-x C-e gives nil.

Then, I try to eval (require 'helm-bibtex) in scratch buffer and the following error will be triggered:

Debugger entered--Lisp error: (file-missing "Cannot open load file"
"No such file or directory" "helm-config")
  require(helm-config)
  (progn (require 'helm-config) (defalias
'bibtex-completion-open-pdf-external #'(lambda (keys &optional
fallback-action) (let ((bibtex-completion-pdf-open-function #'...))
(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)"))) (setq bibtex-completion-browser-function #'(lambda
(url _) (start-process "firefox" "*firefox*" "firefox" url))) t)
  (condition-case err (progn (require 'helm-config) (defalias
'bibtex-completion-open-pdf-external #'(lambda (keys &optional
fallback-action) (let ((bibtex-completion-pdf-open-function ...))
(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)"))) (setq bibtex-completion-browser-function #'(lambda
(url _) (start-process "firefox" "*firefox*" "firefox" url))) t)
((debug error) (funcall use-package--warning56 :config err)))
  (lambda nil (condition-case err (progn (require 'helm-config)
(defalias 'bibtex-completion-open-pdf-external #'(lambda (keys
&optional fallback-action) (let (...) (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)"))) (setq bibtex-completion-browser-function #'(lambda (url
_) (start-process "firefox" "*firefox*" "firefox" url))) t) ((debug
error) (funcall use-package--warning56 :config err))))()
  eval-after-load-helper("/home/werner/.emacs.d/straight/build/helm-bibtex/h...")
  run-hook-with-args(eval-after-load-helper
"/home/werner/.emacs.d/straight/build/helm-bibtex/h...")
  do-after-load-evaluation("/home/werner/.emacs.d/straight/build/helm-bibtex/h...")
  require(helm-bibtex)
  (progn (require 'helm-bibtex))
  eval((progn (require 'helm-bibtex)) t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

What do these problems mean, and do they indicate a corresponding bug in the helm-bibtex package?

See here and here for the related discussions.

Regards,
Zhao

@tmalsburg
Copy link
Owner

If I understand correctly, your Emacs fails to execute the command (require 'helm-config). If true, this suggests a faulty helm configuration. (And other users had similar problems in the past.) Please make sure helm is installed and configured exactly as recommended. I'm closing this now, but Feel free to reopen this issue if you come to the conclusion that the problem is in helm-bibtex, after all.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 15, 2023

According to the description here:

Note: In the past we had a file called “helm-config.el” that was needed for installation from source only (most people were requiring it with an installation from package which was unuseful) the file doesn’t exists anymore, therefore if you try to require it you will have an error.

It seems that (require 'helm-config) shouldn't be used currently.

@tmalsburg
Copy link
Owner

Ah, I see. The code doesn't use (require 'helm-config) anywhere but it was used in the documentation. I removed it. Thank you!

@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 16, 2023

I've removed the (require 'helm-config) from my init.el, but when I eval (require 'helm-bibtex) in scratch buffer still gives the following error:

Debugger entered--Lisp error: (wrong-number-of-arguments (3 . 4) 2)
  helm-add-action-to-source(helm-bibtex (("P"
helm-bibtex-open-pdf-external "Open PDF file in external viewer (if
present)")))
  (progn (defalias 'bibtex-completion-open-pdf-external #'(lambda
(keys &optional fallback-action) (let
((bibtex-completion-pdf-open-function #'...))
(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)"))) (setq bibtex-completion-browser-function #'(lambda
(url _) (start-process "firefox" "*firefox*" "firefox" url))) t)
  (condition-case err (progn (defalias
'bibtex-completion-open-pdf-external #'(lambda (keys &optional
fallback-action) (let ((bibtex-completion-pdf-open-function ...))
(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)"))) (setq bibtex-completion-browser-function #'(lambda
(url _) (start-process "firefox" "*firefox*" "firefox" url))) t)
((debug error) (funcall use-package--warning56 :config err)))
  (lambda nil (condition-case err (progn (defalias
'bibtex-completion-open-pdf-external #'(lambda (keys &optional
fallback-action) (let (...) (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)"))) (setq bibtex-completion-browser-function #'(lambda (url
_) (start-process "firefox" "*firefox*" "firefox" url))) t) ((debug
error) (funcall use-package--warning56 :config err))))()
  eval-after-load-helper("/home/werner/.emacs.d/straight/build/helm-bibtex/h...")
  run-hook-with-args(eval-after-load-helper
"/home/werner/.emacs.d/straight/build/helm-bibtex/h...")
  do-after-load-evaluation("/home/werner/.emacs.d/straight/build/helm-bibtex/h...")
  require(helm-bibtex)
  (progn (require 'helm-bibtex))
  eval((progn (require 'helm-bibtex)) t)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)
 

See https://lists.gnu.org/archive/html/help-gnu-emacs/2023-05/msg00148.html for the related discussions.

@hongyi-zhao hongyi-zhao changed the title eval (featurep 'helm-bibtex) gives nil. The problem related to (require 'helm-config) and (require 'helm-bibtex). May 16, 2023
@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 16, 2023

Finally, It solved the problem discussed here with the following simpler configuration:

;; https://github.com/emacs-helm/helm/wiki#if-installed-from-source
;; First issue the following command
/home/werner/.emacs.d/straight/repos/helm$ make
(use-package helm :config (require 'helm-autoloads))

(use-package helm-bibtex
  :init
  (setq
   bibtex-completion-pdf-field "File"
   ;;https://github.com/tmalsburg/helm-bibtex#insert-latex-cite-commands
   bibtex-completion-cite-prompt-for-optional-arguments nil)

  :bind-keymap
  ("<menu>" . helm-command-prefix)
  :bind
  (
   :map helm-command-map
   ("b" . helm-bibtex)
   ("B" . helm-bibtex-with-local-bibliography)
   ("n" . helm-bibtex-with-notes)
   ("<menu>" . helm-resume)
   )
  )

See the attached screenshot for the completion results, which include
bibtex-completion-cite-commands:

image

See #431 (comment) for the related discussion.

@tmalsburg
Copy link
Owner

Yes, it's sometimes really important in Emacs configurations to do things in the right order. Glad you could fix it.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented May 16, 2023

As you can see, I've already removed almost all the advanced or fine-tuned configurations of this package, which in turn fixed the related problems. So, I'm still confused on the out-of-box using of the configurations represented in README.org.

@tmalsburg
Copy link
Owner

It shouldn't be necessary to remove all advanced configurations. I think the last problem was simply that you tried to load helm-bibtex before helm was properly loaded. Not sure though. In cases like this, it's useful start with a simple configuration that works and to then add features step by step.

@hongyi-zhao
Copy link
Author

Anyway, the minimum configuration above is sufficient for my usage scenario, therefore, I will not add functions step by step, at least now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants