alphapapa / org-now

Conveniently show current Org tasks in a sidebar window
60 stars 3 forks source link

Error when running org-now-refile-to-previous-location on level 1 headers #10

Open max6166 opened 9 months ago

max6166 commented 9 months ago

I get an error when I run org-now-refile-to-previous-location on a level 1 header. Level 2 and upward work correctly.

Steps to recreate below.

  1. Create org-file and add a level 1 header:

    * Test 1
  2. Run org-now-refile-to-now on the level 1 header. The org-now buffer is updated to:

    * Now
    ** Test 1
    :PROPERTIES:
    :refiled_from: ("/Users/xxx/org/productivity/temp.org" "Test 1")
    :END:
  3. Run org-now-refile-to-previous-location on the same header in the org-now buffer. The following error occurs: org-find-olp: Heading not found on level 1: Test 1

It also adds an :ID to the entry as follows:

* Now
** Test 1
:PROPERTIES:
:refiled_from: ("/Users/xxx/org/productivity/temp.org" "Test 1")
:ID:       8ABAD3A7-0D3B-4545-A6D7-6E6D9466E7D7
:END:

Below is the output when debug-on-error is enabled:

Debugger entered--Lisp error: (error "Heading not found on level 1: Test 1")
  signal(error ("Heading not found on level 1: Test 1"))
  error("Heading not found on level %d: %s" 1 "Test 1")
  org-find-olp(("/Users/xxx/org/productivity/temp.org" "Test 1"))
  org-now-refile-to-previous-location()
  funcall-interactively(org-now-refile-to-previous-location)
  #<subr call-interactively>(org-now-refile-to-previous-location nil nil)
  apply(#<subr call-interactively> (org-now-refile-to-previous-location nil nil))
  call-interactively(org-now-refile-to-previous-location nil nil)
  command-execute(org-now-refile-to-previous-location)
alphapapa commented 9 months ago

Haha, yes, that's an obvious bug in hindsight. I guess I've never used level 1 headings that way before. I don't know how soon I'll get to fixing this, but thanks for reporting.

I should probably also abbreviate the filename when writing to the property.