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?


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)
  • works perfectly!
    – dangom
    Jan 4 '21 at 21:17

Your Answer

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

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