doomemacs/core/core-os-linux.el
2016-10-02 23:34:54 +02:00

46 lines
1.2 KiB
EmacsLisp

;;; core-os-linux.el --- Debian-specific settings
(defun doom-open-with (command &rest args)
"Open PATH in APP-NAME, using xdg-open."
(interactive)
(unless args
(setq args (f-full (s-replace "'" "\\'"
(or path (if (eq major-mode 'dired-mode)
(dired-get-file-for-visit)
(buffer-file-name)))))))
(let ((command (apply 'format command
(mapcar (lambda (a) (shell-quote-argument a))
args))))
(message "Running: %s" command)
(shell-command command)))
;;
;; OS-specific functions
;;
(defun os-open-in-browser ()
"Open the current file in the browser."
(interactive)
(browse-url buffer-file-name))
(defun os-open-in-default-program ()
"Open the current file (or selected file in dired) with xdg-open."
(interactive)
(doom-open-with "xdg-open '%s'"))
;;
;; Plugins
;;
(use-package openwith
:config
(openwith-mode t)
(setq openwith-associations
'(("\\.\\(pdf\\|jpe?g\\|gif\\|docx?\\|pptx?\\|xlsx?\\|zip\\|tar\\(\\.gz\\)?\\|rar\\)$"
"xdg-open" (file)))))
(provide 'core-os-linux)
;;; core-os-linux.el ends here