doomemacs/modules/tools/macos/autoload.el

46 lines
1.9 KiB
EmacsLisp
Raw Normal View History

;;; tools/macos/autoload.el -*- lexical-binding: t; -*-
2017-02-19 18:54:42 -05:00
;;;###autoload
(defun +macos-open-with (&optional app-name path)
"Send PATH to APP-NAME on OSX."
(interactive)
2017-02-25 02:11:24 -05:00
(let* ((path (expand-file-name
(replace-regexp-in-string
"'" "\\'"
(or path (if (eq major-mode 'dired-mode)
(dired-get-file-for-visit)
(buffer-file-name)))
nil t)))
2017-02-19 18:54:42 -05:00
(command (format "open %s"
(if app-name
(format "-a %s '%s'" (shell-quote-argument app-name) path)
(format "'%s'" path)))))
(message "Running: %s" command)
(shell-command command)))
(defmacro +macos!open-with (id &optional app dir)
2017-02-19 18:54:42 -05:00
`(defun ,(intern (format "+macos/%s" id)) ()
(interactive)
(+macos-open-with ,app ,dir)))
2017-05-10 05:27:28 +02:00
;;;###autoload (autoload '+macos/open-in-default-program "tools/macos/autoload" nil t)
(+macos!open-with open-in-default-program)
2017-02-19 18:54:42 -05:00
2017-05-10 05:27:28 +02:00
;;;###autoload (autoload '+macos/reveal-in-finder "tools/macos/autoload" nil t)
(+macos!open-with reveal-in-finder "Finder" default-directory)
2017-02-19 18:54:42 -05:00
2017-05-10 05:27:28 +02:00
;;;###autoload (autoload '+macos/reveal-project-in-finder "tools/macos/autoload" nil t)
(+macos!open-with reveal-project-in-finder "Finder" (doom-project-root))
2017-02-19 18:54:42 -05:00
2017-05-10 05:27:28 +02:00
;;;###autoload (autoload '+macos/send-to-transmit "tools/macos/autoload" nil t)
(+macos!open-with send-to-transmit "Transmit")
2017-02-19 18:54:42 -05:00
2017-05-10 05:27:28 +02:00
;;;###autoload (autoload '+macos/send-cwd-to-transmit "tools/macos/autoload" nil t)
(+macos!open-with send-cwd-to-transmit "Transmit" default-directory)
2017-02-19 18:54:42 -05:00
2017-05-10 05:27:28 +02:00
;;;###autoload (autoload '+macos/send-to-launchbar "tools/macos/autoload" nil t)
(+macos!open-with send-to-launchbar "LaunchBar")
2017-02-19 18:54:42 -05:00
2017-05-10 05:27:28 +02:00
;;;###autoload (autoload '+macos/send-project-to-launchbar "tools/macos/autoload" nil t)
(+macos!open-with send-project-to-launchbar "LaunchBar" (doom-project-root))