From 65da0e0a9e2272ce7fa55ba31a96a1803d149ee1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 2 Oct 2016 23:29:51 +0200 Subject: [PATCH] Add Linux config (mainly for Arch) --- core/core-os-linux.el | 45 ++++++++++++++++++++++++++++++++++++------- core/core-os.el | 17 ++++++++-------- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/core/core-os-linux.el b/core/core-os-linux.el index 9c67c94e2..d249e1032 100644 --- a/core/core-os-linux.el +++ b/core/core-os-linux.el @@ -1,14 +1,45 @@ ;;; core-os-linux.el --- Debian-specific settings -;; Treat clipboard input as UTF-8 string first; compound text next, etc. -(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) - -(defun doom-open-with (&optional app-name path) +(defun doom-open-with (command &rest args) + "Open PATH in APP-NAME, using xdg-open." (interactive) - (error "Not yet implemented")) + (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))) -(defun def-docset! (&rest _) - (message "No docset function defined!")) + +;; +;; 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 diff --git a/core/core-os.el b/core/core-os.el index 1f217702a..4748c2eae 100644 --- a/core/core-os.el +++ b/core/core-os.el @@ -4,20 +4,21 @@ (defconst IS-LINUX (eq system-type 'gnu/linux)) (defconst IS-WINDOWS (eq system-type 'windows-nt)) -;; Use a shared clipboard -(setq x-select-enable-clipboard t - select-enable-clipboard t) +(setq + ;; Use a shared clipboard + x-select-enable-clipboard t + select-enable-clipboard t + ;; Treat clipboard input as UTF-8 string first; compound text next, etc. + x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)) ;; Stubs, these should be defined in all OS modules (noop! doom-open-with (&optional app-name path)) -(noop! os-switch-to-term) -(noop! os-switch-to-term-and-cd) +(noop! os-open-in-browser) (noop! os-open-in-default-program) (noop! os-reveal) (noop! os-reveal-project) -(noop! os-open-in-browser) -(noop! os-upload) -(noop! os-upload-folder) +(noop! os-switch-to-term) +(noop! os-switch-to-term-and-cd) (cond (IS-MAC (require 'core-os-osx)) (IS-LINUX (require 'core-os-linux))