obsidian.el icon indicating copy to clipboard operation
obsidian.el copied to clipboard

Multi-vault support

Open junyeong-huray opened this issue 1 year ago • 2 comments

Hello

Obsidian can open multiple vaults. But obsidian-mode can treat only one vault that is specified by obsidian-specify-path in the init.el.

I can make use of obsidian-* functions for multiple vaults after I run M-x obsidian-specify-path manually. But it would be convenient if it is done automatically. I mean that when I am editing some markdowns of vault A, M-x obsidian-* are applied to vault A. And if I am editing some markdowns of vault B, M-x obsidian-* are applied to vault B.

I'm not sure this is a feasible feature. But it would be great if I can opt in/out this feature as I want.

Thanks,

junyeong-huray avatar Jun 27 '23 09:06 junyeong-huray

In fact it might be possible. Let me think about it.

licht1stein avatar Jun 27 '23 09:06 licht1stein

Perhaps this could be a possible workaround:

Add a .dir-locals.el file to the vaults main directories like this one:

((nil . ((eval . (obsidian-specify-path "c:/whereveryourvaultis")))))

This will execute the obsidian-specify-path automatically when you open a file in the vault.

However, to be sure that you can have two different buffers that belongs to two differents vaults opened at the same time, you should also need to reapply the local variables each time you switch to an already opened buffer. This hook should just do the trick:

(add-hook 'buffer-list-update-hook 'hack-dir-local-variables-non-file-buffer)

Of course I'm just trying to find a work around, I know this is not the perfect solution...

mastro35 avatar Jul 13 '23 15:07 mastro35