Inspired by John Kitchin's presentation of org-links features in Org-mode 9, I tried to implement a simple functionality for "file" links. Since I am working on several machines, I wanted the link face to show if file exists on disk. So in org-link-set-parameters
func for "file" I've put this simple code:
:face '(lambda (path) (if (file-exists-p path)
'(:foreground "green")
'(:foreground "red")))
It works just fine unless file has Polish characters in its name ("ąęćłóśżź"). Especially after editing the link description with org-insert-link
with cursor on the link it's face becomes red (as non existent file), and the path becomes for example like this (assuming the file name is "żółć.org"):
[[file:%C5%BC%C3%B3%C5%82%C4%87.org]]
I was changing the value of file-name-coding-system
variable but without any impact for described behaviour.
When I change value of the :follow
key to '(lambda (path) (message "%s" (file-exists-p path)))
it returns "t". I assume then that it has something to do with filtering file name by different emacs functions but I can't find which would be responsible for wrong behaviour of the ":face" parameter.
I'd appreciate any help to fix that.
org-link-escape
on the filename, so you should runorg-link-unescape
to get back the original.url-encode-url
instead oforg-link-escape
). You should consider transforming your comment into an answer.file-name-coding-system
. If you do so in spite of the warning you can get problems with names of files created and saved with Emacs.url-encode-url
andorg-link-escape
are identical except when they're not :-)