tmalsburg/helm-bibtex

What's the mode hook defined in `helm-bibtex` to conditionally activate it when AUCTeX's `LaTeX-mode` is called?

hongyi-zhao opened this issue · 4 comments

I'm using the following configuration for helm-bibtex:

(use-package helm
  :demand t
  :config (require 'helm-autoloads))
(use-package helm-bibtex
  :demand t
  :init
  (setq
   ;;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)
   )
  )

The above configuration will always enable the above packages during the starting process of Emacs, but I want to conditionally activate helm-bibtex when AUCTeX's LaTeX-mode is called and enabled.

For this purpose, it seems that the mode hook based method should be used, but I don't know what's the appropriate hooks defined in helm-bibtex which can help me to achieve this goal.
Any tips will be appreciated.

Regards,
Zhao

Helm-bibtex doesn't have a global mode that can be activated/deactivated. It's generally available for use once it's loaded. Could you please explain why you'd want to activate it only in specific buffers? Helm-bibtex should not interfere with modes in other buffers, so I don't see what would be gained by deactivating it. And what would you like to happen when the user tries to use the helm-bibtex command in a buffer where helm-bibtex is not activated? Would you like to get an error message like Error: helm-bibtex not activated? If yes, why?

My simple idea is that this package should only be used when preparing documents with LaTeX. Therefore, I have filed this issue.

The purpose of this package is not just to support LaTeX authoring. I use it productively in many other scenarios. For instance, when a student asks me for the most important papers about topic X. To answer this, I start an e-mail, fire up helm-bibtex, select these papers, and then insert their references into the e-mail ("Insert reference" from action menu). Done.

If you don't want to use helm-bibtex outside LaTeX documents, the easiest solution is just to ignore it. No need to deactivate it, since it's not doing much anyway when you don't use it.

Thank you for sharing your ideas and examples of usage scenarios. As a result, the :demand t should be used when using it via use-package.