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[[...]]
linkorg-insert-link
works interactively in non-.org file buffers
So:
- Does the debug output indicate that passing the result of
mapcar
toorg-link-fontify-links-to-this-file()
returnsnil
? - Is there a value in my
org-stored-links
that is faulty? (How can I prevent this from happening?)
car
of each entry oforg-stored-links
must be a string (the link target). That follows from the firstmapcar
inorg-link-fontify-links-to-this-file
. Therefore the last two entries of yourorg-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 inorg-stored-links
. Since these are the last two items and the links are stored withpush
it must happen at the beginning of your session. You can giveorg-store-link
an:after
-advice and checkorg-stored-links
. – Tobias Jun 17 '19 at 10:39org-stored-links
in functionorg-protocol-store-link
. So you should also put an:after
-advice on that function with a check that signals auser-error
if there is thrash onorg-stored-links
. If you activate debug-on-error you also get a backtrace. – Tobias Jun 17 '19 at 10:45