help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: command-execute: Wrong type argument: commandp, helm-command-prefix


From: Hongyi Zhao
Subject: Re: command-execute: Wrong type argument: commandp, helm-command-prefix
Date: Fri, 5 May 2023 12:18:18 +0800

On Fri, May 5, 2023 at 10:59 AM Ruijie Yu <ruijie@netyu.xyz> wrote:
>
>
> Platon Pronko <platon7pronko@gmail.com> writes:
>
> > On 2023-05-05 08:34, Hongyi Zhao wrote:
>
> >>    :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))
> >> ```
> >> When I hit <menu> hey for the first time, the following error will be
> >> triggered:
> >> command-execute: Wrong type argument: commandp, helm-command-prefix
> >> If I hit this key once more, the problem doesn't appear. I'm very
> >> puzzled by this problem. Any tips will be appreciated.
> >> See
> >> https://github.com/tmalsburg/helm-bibtex/issues/429#issuecomment-1535010227
> >> for the related discussion.
> >> Regards,
> >> Zhao
>
> >   :bind
> >   (("<f8>" . helm-command-prefix)
> >    :map helm-command-map
> >    ("b" . helm-bibtex)
> >    ("B" . helm-bibtex-with-local-bibliography)
> >    ("n" . helm-bibtex-with-notes)
> >    ("<f8>" . helm-resume))
>
> When I macroexpand
>
>     (use-package helm-bibtex :bind ("<f8>" . helm-command-prefix))
>
> I get this:
>
> ```emacs-lisp
> (progn
>   (unless
>       (fboundp 'helm-command-prefix)
>     (autoload #'helm-command-prefix "helm-bibtex" nil t))
>   (bind-keys :package helm-bibtex
>              ("<f8>" . helm-command-prefix)))
> ```
>
> When I macroexpand
>
>     (use-package helm-bibtex :bind-keymap ("<f8>" . helm-command-prefix))
>
> I get this:
>
> ```emacs-lisp
> (bind-key "<f8>"
>   #'(lambda nil
>       (interactive)
>       (use-package-autoload-keymap 'helm-command-prefix 'helm-bibtex nil)))
> ```
>
> Looking at the docstring of `bind-keys', it seems to me that the fact
> that :bind happens to work sometimes is unintended, and we should prefer
> :bind-keymap instead.  Hongyi, try to move your keybind to
> `helm-command-prefix' into a :bind-keymap section and see if that helps.
>
> FTR, I wasn't able to reproduce the error with :bind "<f9>" either.  I
> don't have "<menu>" key set, so I can't test that.

Nice trick and it works. I've tried with several keys, such as,
<menu>, <f8>, etc., to set helm-command-prefix, and they all works
smoothly this way. The following is revised configuration according to
the above advice:

(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)))

  )

> --
> Best,
>
>
> RY

Regards,
Zhao

> [Please note that this mail might go to spam due to some
> misconfiguration in my mail server -- still investigating.]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]