Whenever I click on a mp3 or mp4 org-mode link, I'd like my files to open in their associated app after running some relevant applescripts I have. I also have some scripts that I'd like to run after opening those files too.
I already have scripts to change behavior of org-mode links of certain file types but I don't know what command actually opens files in each file type's default app. I've already got a package for running applescripts in Emacs from MELPA too, so the only part I'm missing is the command to open an org-link file in its associated app. What is it exactly?
(require 'org) (defun my-find-file-fn (file) "If the filename extension of FILE ends in `.txt' or `.el' or `.png', then use `find-file-other-frame'; otherwise, use `find-file-other-window'. The three file extensions txt/el/png are hard-coded into the let-bound variable `regex'." (let* ( ;; regexp-matchp-fn from: https://github.com/kentaro/auto-save-buffers-enhanced ;; regexp-matchp-fn modified by @sds: http://stackoverflow.com/a/20343715/2112489 (regexp-matchp-fn (lambda (regexps string) (and string (catch 'matched (let ((inhibit-changing-match-data t)) (dolist (regexp regexps) (when (string-match regexp string) (throw 'matched t)))))))) (ext (file-name-extension file)) (regex '("txt" "el" "png")) (regex2 '("mp3" "mp4"))) (if (funcall regexp-matchp-fn regex ext) (find-file-other-frame file) (if (funcall regexp-matchp-fn regex2 ext) (progn (apples-run-file "/path/to/my-applescript-to-run-before-opening-mp3-and-mp4-files.scpt") (open-file-in-default-app);;this part is missing! (apples-run-file "/path/to/my-applescript-to-run-after-opening-mp3-and-mp4-files.scpt")) (find-file-other-window file))))) (setq org-link-frame-setup '( (vm . vm-visit-folder-other-frame) (vm-imap . vm-visit-imap-folder-other-frame) (gnus . org-gnus-no-new-news) (file . my-find-file-fn) (wl . wl-other-frame)))