1

Suppose I edit an org-file, say /foo/bar/file.org and I want to insert links to multiple files living in another path, say /another/path/to/files/.

A stupid way to do this would be to call helm-find-files, navigate from /foo/bar/ to /another/path/to/file and insert the link to the first file via C-c @ (and enter the link name/description). Then I repeat the complete procedure for all other files.

Slightly more efficient would it be to use helm-resume with universal argument (e.g. C-u C-c h b) and then resume find files. Then there is no need to navigate from one path to the other each time.

I also tried to mark multiple files (via Alt-SPACE) and then press C-c @, but that doesn't work.

So is there a significantly more efficient way to do the same job?

1

Since current helm-find-files command does not support to insert multiple candidates as org links, a rough improvement can be made as follows:

(defun helm-files-insert-as-org-link (candidate)
  (let* ((marked-files (helm-marked-candidates :with-wildcard t)))
    (dolist (file marked-files)
      (let ((target (expand-file-name (helm-substitute-in-filename file))))
        (insert (format "[[file:%s] " file))))))

Use Ctrl-SPACE to mark multiple candidates, and insert them.

| improve this answer | |
  • See my post: I already tried this, but C-c @ doesn't work with this. – student Sep 6 at 7:18
  • Okay, you are right. It does not work. I will try to figure out a solution. One question: Would you like to insert all files as links in the folder or just part of them? That will make the solution different. – Leu_Grady Sep 6 at 8:07
  • Just a part of them which I may have to select manually (sometimes there might be a pattern in the filenames I want, so selecting it via a regexp would be elegant, but this would be another question). – student Sep 6 at 19:50
  • 1
    @student see the edits – Leu_Grady Sep 7 at 11:06

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.