From 23fc3133c461d67d183db0414be8a5b5aabf29ed Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 29 Aug 2020 11:50:03 +0200 Subject: [PATCH] Try to fix a problem with org-roam and it's auto-rename feature The old title is sometimes not retrieved correctly and nil is passed instead. This leads to errors and links not being updated. --- init.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 83e3f97..0c10597 100644 --- a/init.el +++ b/init.el @@ -2687,7 +2687,23 @@ With given ARG, display files in `db/important-document-path’." :bind (:map org-roam-mode-map (("C-c n l" . org-roam) ("C-c n f" . org-roam-find-file) - ("C-c n g" . org-roam-graph-show)))) + ("C-c n g" . org-roam-graph-show))) + :config (progn + + ;; There seems to be a problem when capturing notes with the capture + ;; template. More precisely, `org-roam-current-title' does not get + ;; set correctly (is it my setup or a general bug?) This causes + ;; `org-roam--update-file-name-on-title-change' to get a nil + ;; argument, on which it barfs. Let's intercept this case and don't + ;; do anything. This effectively disables the auto-rename + ;; functionality when using org-capture to add notes. + + (defun db/org-roam--no-titlechange-if-title-is-nil (orig-fun &rest args) + (unless (cl-some #'null args) + (apply orig-fun args))) + + (advice-add 'org-roam--update-file-name-on-title-change + :around #'db/org-roam--no-titlechange-if-title-is-nil))) (use-package org-ref :defer t