# How to to get \[\[Title of the target note\]\] working with inline autocomplete in Org-roam

**URL:** <https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782>\
**Category:** Tips\
**Created:** [September 23, 2020, 7:57pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782 "2020-09-23T19:57:47Z")\
**Posts on this page:** 9\
**Page:** 3

<div class="post-metadata">

**Author:** ![Jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jason](https://org-roam.discourse.group/u/Jason)\
**Post date:** [January 5, 2022, 2:06pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/41 "2022-01-05T14:06:05Z")

</div>

Hi all. I’m having trouble having any sort of completion working at all.

As far as I understood, I should be able to at least use `M-x completion-at-point` to manually trigger a completion, but this is not working for me. So the `C-M-i` keybinding does nothing for me.

I also tried calling that function inside double brackets `[[someth|]]`, and it does not work either.

`Company` itself does give me completions for normal words.

Below is my relevant `company` config:

```auto
  (use-package company
    :ensure t
    :init
    (add-hook 'after-init-hook 'global-company-mode)
    :config
    (add-to-list 'company-frontends 'company-tng-frontend)
    (add-to-list 'company-backends 'company-capf) ; for org-roam completion
    (setq company-dabbrev-downcase nil)
    (setq company-dabbrev-ignore-case nil)
    (setq company-idle-delay 1)
    (setq company-auto-commit nil)
    (setq company-minimum-prefix-length 2)
  )

```

And my roam config:

```auto
(use-package org-roam
    :ensure t
    :custom
    (org-roam-directory "~/Notebooks/org/roam")
    :config
    (org-roam-db-autosync-mode)
    (setq org-roam-completion-everywhere t)
    ;(setq org-roam-completion-system 'ivy)
    ;(setq org-roam-link-title-format "@%s")
    (define-key org-roam-mode-map [mouse-1] #'org-roam-buffer-visit-thing)
    (org-roam-setup)
    :bind (("C-c n l" . org-roam-buffer-toggle)
            ("C-c n f" . org-roam-node-find)
            ("C-c n g" . org-roam-graph)
            ("C-c n i" . org-roam-node-insert)
            :map org-mode-map
            ("C-M-i" . completion-at-point)
))

```

I only recently upgraded to v2. Is there anything specific related to the v1-v2 changes?  
Please help!

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [January 5, 2022, 2:15pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/42 "2022-01-05T14:15:35Z")

</div>

> [@nobiot](#):
>
> I suggest you start by looking at the value of the following variables when you are visiting a file in the Org-roam directory:
> 
> - company-backends
> - org-roam-completion-functions
> 
> Also… is Company mode actually turned on when you visit a file in Org-roam directory? I don’t see how this happens from your config above only.

I suggest check these…

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [January 5, 2022, 2:20pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/43 "2022-01-05T14:20:50Z")

</div>

My guess is company-dabbrev is called before Org-roam is, and Company does not call capf for Org-roam. If this is the case, I don’t know if Company can support two backends run consecutively (I don’t even know if that produces one big list in a pop-up or two separate ones). My guess, in this case, would be you would need to turn off company-dabbrev.

Or use Corfu for one, and Company for the other.

---

<div class="post-metadata">

**Author:** ![Jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jason](https://org-roam.discourse.group/u/Jason)\
**Post date:** [January 5, 2022, 2:32pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/44 "2022-01-05T14:32:47Z")

</div>

Thanks for the info.

The `company-backends` value is:

```auto
(company-bbdb company-semantic company-cmake company-capf company-clang company-files
	      (company-dabbrev-code company-gtags company-etags company-keywords)
	      company-oddmuse company-dabbrev)

```

That of `org-roam-completion-functions` is:

```auto
(org-roam-complete-link-at-point org-roam-complete-everywhere)

```

I can confirm that `company-mode` is on.

I also tried setting only one backend for company, by `(setq company-backends '(company-capf))`. But still gets nothing.

---

<div class="post-metadata">

**Author:** ![Jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jason](https://org-roam.discourse.group/u/Jason)\
**Post date:** [January 5, 2022, 2:39pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/45 "2022-01-05T14:39:21Z")

</div>

Hang on!  
I think I get the problem. I wasn’t editing a file in side the roam directory. I thought it would also work if I link into the roam directory.

Now both `org-roam-complete-link-at-point` and `org-roam-complete-everywhere` work as expected.

Sorry for the noise.

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [January 5, 2022, 3:35pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/46 "2022-01-05T15:35:47Z")

</div>

How does company work when dabbrev and capf are both set like in your org-roam files?

---

<div class="post-metadata">

**Author:** ![Jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jason](https://org-roam.discourse.group/u/Jason)\
**Post date:** [January 6, 2022, 12:39pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/47 "2022-01-06T12:39:09Z")

</div>

According to the docstring of `company-backends`:

> Only one backend is used at a time. The choice depends on the order of  
> the items in this list, and on the values they return in response to the  
> ‘prefix’ command (see below). But a backend can also be a “grouped”  
> one (see below).

So I guess it is because the order.

I said last night that it didn’t work for me because I wasn’t editing a file inside the roam folder. It turns out it wasn’t quite right. I noticed that I have to open a roam file using the `C-c n f` (`org-roam-node-find`) function for the completions to work. If I open the very same file, for instance, from the command line (`emacs ./org/roam/somefile.org`), or using emacs `find-file`, no roam completions work.

Any idea why?

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [January 6, 2022, 1:58pm UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/48 "2022-01-06T13:58:57Z")

</div>

I think `:bind` in `use-package` deferrs loading of Org-roam (see this part in the Use-package [README](https://github.com/jwiegley/use-package#key-binding)).

> defers loading of `ace-jump-mode` until you actually use it

So when you launch Emacs “from the command line (`emacs ./org/roam/somefile.org`)”, `org-roam` has not been loaded yet. Try it yourself again. You would still see some commands in M-x because you would have `autoloaded` them, but you should see a limited number of these compared to when you have loaded the library.

In the case of `find-file`, the behaviour should also depend on whether or `org-roam` has already been loaded or not. My guess is that when you tested `find-file`, it was probably right after you launched Emacs, thus `org-roam` had not been loaded.

In general, once `org-roam` has been loaded, there should be no differecet between `find-file` and `org-roam-node-find` for the behaviour of Company.

---

<div class="post-metadata">

**Author:** ![Jason](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@Jason](https://org-roam.discourse.group/u/Jason)\
**Post date:** [January 7, 2022, 12:27am UTC](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782/49 "2022-01-07T00:27:00Z")

</div>

Indeed! Thanks for helping.

[Previous page](https://org-roam.discourse.group/t/how-to-to-get-title-of-the-target-note-working-with-inline-autocomplete-in-org-roam/782.md?page=2)
