'multiple instances of emacs overwrite recentf-list
I have quite usual recentf config.
(use-package recentf
:config
(setq
recentf-save-file "~/.cache/emacs/recentf"
recentf-max-saved-items 100000
recentf-max-menu-items 5000
)
(recentf-mode 1)
The problem is that I run multiple emacs instances. Unfortunately, it overwrites recentf file when the instances are closed.
instance 1 loads recentf version 1
instance 2 loads recentf version 1
... some times passed instance 1 and instance 2 do some work ...
instance 1 get closed and saves recentf version 3
instance 2 get closed and saves recentf version 4
Problem is that when instance 2 closes it does not read recentf of version 3. As a result files added by version 3 are lost. You can imagine it gets worst with more than one instance. How can I make recentf work correctly with multiple instaces.
Solution 1:[1]
In case anybody still encounters this issue:
Try the sync-recentf package. I have not used it but it looks like what you want.
Every Emacs instance maintains the variable recentf-list which is populated by calling recentf-load-list. Opening files will then append the new filepath to this variable but not to the file. Calling recentf-save-list will then cause this variable to be written to the recentf-file you specified. Note that this writing out is not appending to the file but rather replacing its content.
Simply calling recentf-load-list before saving is not an option either because this will override the unique files from the recentf-list.
The aforementioned package works around this limitation by creating a dummy file on top of recentf-list effectively seperating this variable into 'old and new'. When calling recentf-save-list a new recentf-list is created by the following steps:
- Save the new filepaths
- Override
recentf-listwith the values fromrecentf-file - Append saved filepaths to
recentf-list - Override
recentf-filewith the values from `recentf-list
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | k0kytos |
