# ORB: helm-bibtex -\> \`open notes\` won't create new note

**URL:** <https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690>\
**Category:** Troubleshooting\
**Created:** [August 30, 2020, 5:45pm UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690 "2020-08-30T17:45:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hermann.westerholt](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/hermann.westerholt/32/373_2.png) [@hermann.westerholt](https://org-roam.discourse.group/u/hermann.westerholt)\
**Post date:** [August 30, 2020, 5:45pm UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/1 "2020-08-30T17:45:25Z")

</div>

Hi guys,

while transitioning from `org-ref` to `org-roam-bibtex` I’ve encountered a problem. My issue is somewhat related to this one - [`open notes` in `org-roam-bibtex` does not work](https://org-roam.discourse.group/t/open-notes-in-org-roam-bibtex-does-not-work/294) - yet slightly different.

In his excellent video tutorial on the usage of ORB, @zaeph can be seen running `M-x helm-bibtex`, selecting a note and then running `Edit notes`. In theory (and in the video), this will either open the associated org-roam file or create a new one.

The problem I have is that `Edit notes` jumps to/adds a headline in my `org-ref-bibliography-notes` file instead (that used to be my old workflow). My understanding is that ORB is supposed to overwrite pre-existing configurations but I must have made a mistake in my setup.

As a spacemacs user (I haven’t mustered the courage yet to switch to doom emacs), please see my private layer file below.

Thanks in advance for your help!

```auto
(defconst org-roam-packages
  '(
    (org-roam :location
              (recipe :fetcher github :repo "jethrokuan/org-roam"))
    (company-org-roam :toggle (configuration-layer/package-used-p 'company))
    org-roam-bibtex))

(defun org-roam/init-org-roam ()
  (use-package org-roam
    :hook
    (after-init . org-roam-mode)
    ;; :custom
    ;; (org-roam-directory "~/org/roam/")
    :init
    (progn
      (spacemacs/declare-prefix "aR" "org-roam")
      (spacemacs/set-leader-keys
        "aRl" 'org-roam
        "aRt" 'org-roam-dailies-today
        "aRf" 'org-roam-find-file
        "aRg" 'org-roam-graph)

      (spacemacs/declare-prefix-for-mode 'org-mode "mr" "org-roam")
      (spacemacs/set-leader-keys-for-major-mode 'org-mode
        "rl" 'org-roam
        "rt" 'org-roam-dailies-today
        "rb" 'org-roam-switch-to-buffer
        "rf" 'org-roam-find-file
        "ri" 'org-roam-insert
        "rg" 'org-roam-graph))))

(defun org-roam/init-company-org-roam ()
  (use-package company-org-roam
    :defer t
    :init (spacemacs|add-company-backends
            :backends company-org-roam
            :modes org-roam-mode org-mode)))

(defun org-roam/init-org-roam-bibtex ()
  (use-package org-roam-bibtex
    :after org-roam
    :hook (org-roam-mode . org-roam-bibtex-mode)
    :bind (:map org-mode-map
                (("C-c n a" . orb-note-actions)))))

```

---

<div class="post-metadata">

**Author:** ![mshevchuk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mshevchuk](https://org-roam.discourse.group/u/mshevchuk)\
**Post date:** [August 30, 2020, 7:00pm UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/2 "2020-08-30T19:00:30Z")

</div>

Hi Hermann,

this could be some loading issues. How do you load `org-ref`?

Could you also check whether `org-roam-bibtex-mode` is active? If not, could you run `org-roam-bibtex-mode` and check whether the Helm problem persists?

---

<div class="post-metadata">

**Author:** ![hermann.westerholt](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/hermann.westerholt/32/373_2.png) [@hermann.westerholt](https://org-roam.discourse.group/u/hermann.westerholt)\
**Post date:** [August 30, 2020, 10:15pm UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/3 "2020-08-30T22:15:21Z")

</div>

Thank you so much, running `org-roam-bibtex-mode` fixed it of course and pointed me in the right direction … for some reason, I thought that the layer itself would be enough but I had to add

```auto
(require 'org-roam-bibtex)
(add-hook 'after-init-hook #'org-roam-bibtex-mode)
(define-key org-roam-bibtex-mode-map (kbd "C-c n a") #'orb-note-actions)

```

to my `.spacemacs`.

All of this is actually very well [documented here](https://github.com/org-roam/org-roam-bibtex#without-use-package) but since lines 2 and 3 of the snippet above look very similar to the `:hook` and `:bind` part in `init-org-roam-bibtex`, I thought that the entire snippet had to be redundant.

I see and understand now that `(require 'org-roam-bibtex)` is needed to activate `org-roam-bibtex` mode, but I would have expected the layer to take care of hooks and keybindings. Well, I guess I’ll just have to learn more about Elisp in general and spacemacs in particular. Again, thank you!

---

<div class="post-metadata">

**Author:** ![mshevchuk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mshevchuk](https://org-roam.discourse.group/u/mshevchuk)\
**Post date:** [August 31, 2020, 6:52am UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/4 "2020-08-31T06:52:33Z")

</div>

@hermann.westerholt You are absolutely right, the layer, as described in the README, _should_ be enough. The fact that it does not work might indicate interference in your config. That’s why my question how you load `org-ref`, possibly also `org` and `helm-bibtex`.

---

<div class="post-metadata">

**Author:** ![hermann.westerholt](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/hermann.westerholt/32/373_2.png) [@hermann.westerholt](https://org-roam.discourse.group/u/hermann.westerholt)\
**Post date:** [August 31, 2020, 9:02am UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/5 "2020-08-31T09:02:57Z")

</div>

Ah, snap! Once again, thank you for pointing me in the right direction. It all makes sense now! If only I had remembered this part at the very top of the [`org-layer` for spacemacs documentation](https://www.spacemacs.org/layers/+emacs/org/README.html#important-note):

> Since version 0.104, spacemacs uses the `org` version from the org ELPA repository instead of the one shipped with emacs. Then, any `org` related code should not be loaded before `dotspacemacs/user-config` , otherwise both versions will be loaded and will conflict.
> 
> Because of autoloading, calling to `org` functions will trigger the loading up of the `org` shipped with emacs which will induce conflicts. One way to avoid conflict is to wrap your `org` config code in a `with-eval-after-load` block like this:

```Lisp
(with-eval-after-load 'org
  ;; here goes your Org config :)
  ;; ....
  )

```

I nuked my config file a while ago and completely forgot about this crucial detail … the layer now works as expected and I have gotten rid of the additional clutter in my `.spacemacs` file. Essence of my story: RTFM

Thank you!

---

<div class="post-metadata">

**Author:** ![mshevchuk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mshevchuk](https://org-roam.discourse.group/u/mshevchuk)\
**Post date:** [August 31, 2020, 11:55am UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/6 "2020-08-31T11:55:05Z")

</div>

I’m glad you’ve figured it out. Don’t worry about your story here, it will help others 🙂

---

<div class="post-metadata">

**Author:** ![albigujn](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@albigujn](https://org-roam.discourse.group/u/albigujn)\
**Post date:** [September 11, 2020, 6:28pm UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/7 "2020-09-11T18:28:58Z")

</div>

I’m a bit confused about what types of org configuration options are supposed to be wrapped. Is it literally everything in `dotspacemacs/user-config` related to org? What about stuff like all the org-roam-bibtex configuration?

Here are some examples from my `dotspacemacs/user-config`:

```auto
  (add-hook 'org-mode-hook 'spacemacs/toggle-truncate-lines-off)
  (add-hook 'org-mode-hook 'hl-todo-mode)
  (customize-set-variable 'org-blank-before-new-entry ;; disables org's magic decision making around new lines
                          '((heading . nil)
                            (plain-list-item . nil)))

  (use-package org
    :config
    (setq org-startup-indented t)
    (setq org-startup-with-latex-preview t)
    )
  ;; org-mode latex fragment configuration
  (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.2))
  (setq org-preview-latex-default-process 'dvisvgm) ;; dvisvgm instead of dvipng for high resolution latex fragments
  (add-hook 'org-mode-hook 'org-fragtog-mode) ;; automatically toggle fragments
  (setq org-highlight-latex-and-related '(latex)) ;; need the parens around latex for some reason

  (add-hook 'org-mode-hook 'smartparens-mode)

  ;; org-roam-bibtex
  ;; note that init code is directly in private Spacemacs layer
  (add-hook 'org-mode-hook 'org-roam-bibtex-mode)
  (setq reftex-default-bibliography '("~/Dropbox/org/bibtex/ref.bib"))

  ;; see org-ref for use of these variables
  (setq org-ref-bibliography-notes "~/Dropbox/org/bibtex/org-ref-notes.org"
        org-ref-notes-directory "~/Dropbox/org/bibtex/helm-bibtex-notes"
        org-ref-default-bibliography '("~/Dropbox/org/bibtex/ref.bib")
        org-ref-pdf-directory "~/Dropbox/org/bibtex/pdf/")
  ;; helm-bibtex variables
  (setq bibtex-completion-bibliography "~/Dropbox/org/bibtex/ref.bib"
        bibtex-completion-library-path "~/Dropbox/org/bibtex/pdf"
        bibtex-completion-notes-path "~/Dropbox/org/bibtex/helm-bibtex-notes")

```

A couple specific questions:

1. I’ve been loading org-roam-bibtex (and other modes) with `(add-hook 'org-mode-hook 'org-roam-bibtex-mode)` and it usually seems ok but sometimes seems buggy on Emacs startup. How is it supposed to be done?
2. How much of that config should be wrapped inside `with-eval-after-load 'org`?

---

<div class="post-metadata">

**Author:** ![mshevchuk](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mshevchuk](https://org-roam.discourse.group/u/mshevchuk)\
**Post date:** [September 11, 2020, 9:09pm UTC](https://org-roam.discourse.group/t/orb-helm-bibtex-open-notes-wont-create-new-note/690/8 "2020-09-11T21:09:11Z")

</div>

Although I’ve been using Spacemacs for quite a while, I’m not using it anymore, so my answer will lack certainty in Spacemacs specifics.

This is a common sense advice:

1. You can safely put any simple `setq`'s almost anywhere. Simple means your `setq` does not call any functions or uses any variables, just `(setq my-var "my-value")`. Otherwise, it’s better to put them into `with-eval-after-load`. Spacemacs recommends to wrap all Org config into `with-eval-after-load`. Note however, that some packages, Org including as far as I remember, may require some of their settings set before the package is loaded, unless they are set through Customize.

2. You _should better_ wrap `add-to-list` and `add-hook` into `with-eval-after-load`. This will ensure that the list and hook variables you are setting are initialized, or you’ll catch some `undefined variable` errors. It’s almost always safe to use `with-eval-after-load` with any kind of configuration stuff, unless things must be set/done _before_ loading the package.

3. You should probably not use `use-package` in your `dotspacemacs/user-config` function. You should not use `use-package` twice. Org layer has already done this for you once (I assume you are using Org layer). Actually, I think this is the offending piece that makes your Emacs buggy upon startup. Another problem with this `use-package` statement of yours is that it does not have any “deferring” statememts such as `:hook`, `:after`, `:commands`, or simply `:defer t`. Refer to `use-package`'s docs for a clarification. But again, you do not need it here, you don’t need it at all. Spacemacs has taken care of it.

4. Org Roam and ORB examples above in the topic refer to creating a private Spacemacs layer, which you put in `$SPACEMACSDIR/layers` or `$SPACEMACSDIR/private/layers` or something like that. Consult Spacemacs docs on how to create layers. Items 1–3 also apply to Org roam and ORB. But since you are creating a private layer, you can put _all_ of their configuration in the layer inside the respective `use-package` statements. This is good for decluttering your `dotspacemacs/user-config`.
