Note for Emacs users

Emacs users that want to use Joplin (desktop) “Edit in external editor” feature may run into the situation that, when the note is saved in Emacs, it is not updated in Joplin.
This will happen when you use the emacsclient program with a running emacs server, and Emacs is configured to create backup files (files with the same name as the original but with a ~ appended), which is enabled by default.
In this case, Emacs will rename the original file to the new name, and create a new file. Since Joplin is watching the original file for modifications, it will not detect the changes.
Only when Joplin is restarted it will pick up the modified contents.

A solution to this is to either permanently disable creating backup files (not advised) or to force backup files being made by copying their contents in a new file, while Emacs continues editing the original file.

The most elegant solution is to enforce this behaviour only when editing via the emacs server. You can do this by adding the following lines to your .emacs:

  (custom-set-variables
    '(server-switch-hook
      '((lambda nil
         (let (server-buf)
           (setq backup-by-copying t)
           ))))
  )

For more information, please see https://www.emacswiki.org/emacs/EmacsClient.

Disclaimer: You shouldn't edit individual Joplin files without Joplin.

But when you do, the following Emacs mode may be useful :slight_smile: .

It takes care of keeping the metadata intact and updates timestamps.

;;++ Joplin mode (on top of Markdown).
(autoload 'joplin-mode "joplin-mode"
   "Major mode for editing Joplin files" t)
; Note that joplin-mode will step down if it is not joplin data.
(add-to-list 'auto-mode-alist '("/[a-f0-9]\\{32\\}\\.md\\'" . joplin-mode))
;;--

joplin-mode.el (2.1 KB)

1 Like

if you dont disable creation of backup/autosave files one downside is that your joplin config dir will fill up with edit-xxx~ files, which you may/not want

you can customize the emacs init for joplin by eg adding a ~/.config/joplin/emacs/init.el file and adding -l ~/.config/joplin/emacs/init.el to your callout command

for example to disable backup/autosave you could add

(setq make-backup-files nil) ; stop creating backup~ files
(setq auto-save-default nil) ; stop creating #autosave# files

to the init file

Another option is to tell emacs to put all backups in a dedicated directory. In this example I created and use a dir called "emacsBackups" under $HOME (this is on linux.)

(setq backup-directory-alist '(("." . "~/emacsBackups")))