0

It usually happens after a couple of days of use that C-c C-l / org-insert-link inside .org files does not allow me to insert new links anymore.

What I want to do is interactively insert link description and URL. I usually don't work with stored links via C-c l. This time, though, I tried to store a link and see if it fixes the problem. It doesn't. The debug output:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-match("^file:\\(.+\\)::" nil)
  #f(compiled-function (l) #<bytecode 0x411d16ed>)((nil ""))
  mapcar(#f(compiled-function (l) #<bytecode 0x411d16ed>) (("file:~/Pending/org/gtd/privat.org::*Brackweder Baugenossenschaft" "Brackweder Baugenossenschaft") (#("file:/tmp/test.txt::Hello" 20 25 (fontified t)) nil) ("file:~/Pending/org/gtd/privat.org::*Foci" "Foci") (#("file:~/Pending/org/gtd/dev.org::as" 32 34 (wrap-prefix #("        " 0 7 (face org-indent) 7 8 (face org-indent)) line-prefix #("        " 0 7 (face org-indent)) fontified t)) "transition to CalendarView framework") ("file:~/Pending/org/gtd/dev.org::*add app icon" "add app icon") (nil "") (nil "")))
  org-link-fontify-links-to-this-file()
  org-insert-link(nil)
  funcall-interactively(org-insert-link nil)
  call-interactively(org-insert-link nil nil)
  command-execute(org-insert-link)

The value of org-stored-links:

(("file:~/Pending/org/gtd/privat.org::*Brackweder Baugenossenschaft" "Brackweder Baugenossenschaft")
 (#("file:/tmp/test.txt::Hello" 20 25
    (fontified t))
   nil)
 ("file:~/Pending/org/gtd/privat.org::*Foci" "Foci")
 (#("file:~/Pending/org/gtd/dev.org::as" 32 34
    (wrap-prefix
     #("        " 0 7
       (face org-indent)
       7 8
       (face org-indent))
     line-prefix
     #("        " 0 7
       (face org-indent))
     fontified t))
   "transition to CalendarView framework")
 ("file:~/Pending/org/gtd/dev.org::*add app icon" "add app icon")
 (nil #1="")
 (nil #1#))
  • org-insert-link works when the insertion point is inside an existing [[...]] link
  • org-insert-link works interactively in non-.org file buffers

So:

  1. Does the debug output indicate that passing the result of mapcar to org-link-fontify-links-to-this-file() returns nil?
  2. Is there a value in my org-stored-links that is faulty? (How can I prevent this from happening?)
  • 1
    The car of each entry of org-stored-links must be a string (the link target). That follows from the first mapcar in org-link-fontify-links-to-this-file. Therefore the last two entries of your org-stored-links are invalid. Configuration: Emacs 26.1 with org-mode 9.1.13. Pitingly your tracing is too late. It is important to detect when the invalid entries are stored in org-stored-links. Since these are the last two items and the links are stored with push it must happen at the beginning of your session. You can give org-store-link an :after-advice and check org-stored-links. – Tobias Jun 17 at 10:39
  • 1
    Note that org also pushes links on org-stored-links in function org-protocol-store-link. So you should also put an :after-advice on that function with a check that signals a user-error if there is thrash on org-stored-links. If you activate debug-on-error you also get a backtrace. – Tobias Jun 17 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.