org-media-note
org-media-note copied to clipboard
org-insert-link video: completion support
Hello, I just wanted to document a little customization in case someone finds it useful. Using org-media-note (without org-ref). When I was trying to insert a link via M-x org-insert-link I didn't get any completions in the minibuffer.
The function you have to change for it to work is org-link-set-parameters. I just defined a completion function really quickly copying and slightly modifying org-link-complete-file. So if you add this to your init file you will get completions working in the minibuffer:
(defun org-link-complete-video (&optional arg) "Create a video link using completion." (let ((file (concat (read-file-name "Video: ") "#0:00:0")) (pwd (file-name-as-directory (expand-file-name "."))) (pwd1 (file-name-as-directory (abbreviate-file-name (expand-file-name "."))))) (cond ((equal arg '(16)) (concat "video:" (abbreviate-file-name (expand-file-name file)))) ((string-match (concat "^" (regexp-quote pwd1) "\(.+\)") file) (concat "video:" (match-string 1 file))) ((string-match (concat "^" (regexp-quote pwd) "\(.+\)") (expand-file-name file)) (concat "video:" (match-string 1 (expand-file-name file)))) (t (concat "video:" file)))))
(org-link-set-parameters "video" :complete #'org-link-complete-video)