0

When we call helm-find-files on an org link or path, helm is smart enough to autocomplete the path, making it easy for us to navigate from there. Unfortunately, if the link starts with [[file:./this/file/name.png]], then helm extended actions fail, because helm can't find a file that starts with "file:".

Does anyone know how I could advice helm-find-files to trim the "file:" part of a link?

1 Answer 1

1

Here's how you can advice helm to strip the file: part:

(advice-add 'helm-find-files-initial-input :filter-return
            (lambda (&optional input)
              (if (string-prefix-p "file:" input)
                  (replace-regexp-in-string "file:\\(.+\\)" "\\1" input)
                input)))
1
  • works perfectly!
    – Daniel
    Commented Jan 4, 2021 at 21:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.