doomemacs/core/core-os-linux.el

49 lines
1.3 KiB
EmacsLisp
Raw Normal View History

2015-06-06 18:40:33 +08:00
;;; core-os-linux.el --- Debian-specific settings
(setq x-super-keysym 'alt
x-meta-keysym 'meta)
2016-10-03 05:29:51 +08:00
(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)))
2016-10-03 05:29:51 +08:00
;;
;; OS-specific functions
;;
(defun os-open-in-browser ()
"Open the current file in the browser."
2015-06-06 18:40:33 +08:00
(interactive)
2016-10-03 05:29:51 +08:00
(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
;;
2015-06-06 18:40:33 +08:00
2016-10-03 05:29:51 +08:00
(use-package openwith
:config
(openwith-mode t)
(setq openwith-associations
'(("\\.\\(pdf\\|jpe?g\\|gif\\|docx?\\|pptx?\\|xlsx?\\|zip\\|tar\\(\\.gz\\)?\\|rar\\)$"
"xdg-open" (file)))))
2016-02-21 04:30:30 +08:00
2015-06-06 18:40:33 +08:00
(provide 'core-os-linux)
;;; core-os-linux.el ends here