emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ian Eure <ian@retrospec.tv>
To: emacs-orgmode@gnu.org
Subject: Bug: org-id-add-location fails when cloning a subtree [9.1.9 (release_9.1.9-65-g5e4542 @ /home/ieure/.emacs.d/straight/build/org/)]
Date: Wed, 15 Apr 2020 10:57:24 -0700	[thread overview]
Message-ID: <87a73caayj.fsf@phaktory> (raw)

If you have a subtree of entries with :ID: properties and call M-x 
`org-clone-subtree-with-time-shift' on it, an error occurs:

    Wrong type argument: stringp, nil

This is due to the interaction of 
`org-clone-subtree-with-time-shift' and `org-id-add-location'. 
When the former is called, it creates a temp buffer to operate on: 

Then calls `org-id-get-create': 

Which calls `org-id-get', which calls `buffer-file-name', which 
evals to nil, because no file backs the temp buffer.  That nil is 
then passed to `org-id-add-location': 

Which unconditionally calls `abbreviate-file-name': 

Which signals the error.

I’ve confirmed that this is still a problem in the 9.3.6, which is 
the latest release, as well as Git master.

A simplistic fix would be to swap the let and when lines in 

diff --git a/lisp/org-id.el b/lisp/org-id.el
index 1ff433bd8..945a9a1f6 100644
--- a/lisp/org-id.el
+++ b/lisp/org-id.el
@@ -572,8 +572,8 @@ When FILES is given, scan also these files."
 (defun org-id-add-location (id file)
   "Add the ID with location FILE to the database of ID 
   ;; Only if global tracking is on, and when the buffer has a 
-  (let ((afile (abbreviate-file-name file)))
-    (when (and org-id-track-globally id file)
+  (when (and org-id-track-globally id file)
+    (let ((afile (abbreviate-file-name file)))
       (unless org-id-locations (org-id-locations-load))
       (puthash id afile org-id-locations)
       (unless (member afile org-id-files)

However, this causes a more subtle bug, which is that the IDs of 
cloned subtrees won’t be tracked correctly.  Perhaps a solution to 
that is to use an indirect buffer of the source when cloning, 
instead of a temp buffer.

Emacs  : GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, X toolkit, 
Xaw3d scroll bars)
 of 2019-09-22, modified by Debian
Package: Org mode version 9.1.9 (release_9.1.9-65-g5e4542 @ 

             reply	other threads:[~2020-04-15 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 17:57 Ian Eure [this message]
2020-04-16  5:18 ` Subject: [PATCH] org-id: Allow file name to be overridden on ID creation Kyle Meyer
2020-04-21  0:52   ` Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a73caayj.fsf@phaktory \
    --to=ian@retrospec.tv \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).