From 72577b823c83cea6ba90e39dd80f077f3a933515 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Feb 2017 07:02:03 -0500 Subject: [PATCH] Add core-os.el --- core/core-os.el | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ core/core.el | 4 +--- core/packages.el | 5 +++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 core/core-os.el diff --git a/core/core-os.el b/core/core-os.el new file mode 100644 index 000000000..6d2761c96 --- /dev/null +++ b/core/core-os.el @@ -0,0 +1,54 @@ +;;; core-os.el + +(defconst IS-MAC (eq system-type 'darwin)) +(defconst IS-LINUX (eq system-type 'gnu/linux)) + + ;; clipboard +(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING) + ;; Use a shared clipboard + select-enable-clipboard t + select-enable-primary t) + + +(cond (IS-MAC + (setq mac-command-modifier 'meta + mac-option-modifier 'alt + ;; sane trackpad/mouse scroll settings + mac-redisplay-dont-reset-vscroll t + mac-mouse-wheel-smooth-scroll nil + mouse-wheel-scroll-amount '(5 ((shift) . 2)) ; one line at a time + mouse-wheel-progressive-speed nil ; don't accelerate scrolling + ;; Curse Lion and its sudden but inevitable fullscreen mode! + ;; NOTE Meaningless to railwaycat's emacs-mac build + ns-use-native-fullscreen nil + ;; Don't open files from the workspace in a new frame + ns-pop-up-frames nil) + + (cond ((display-graphic-p) + ;; `exec-path-from-shell' is slow, so bring out the cache + (setq exec-path + (or (persistent-soft-fetch 'exec-path "emacs") + (persistent-soft-store + 'exec-path + (progn (when (require 'exec-path-from-shell nil t) + (exec-path-from-shell-initialize)) + exec-path) + "emacs")))) + (t + (when (require 'osx-clipboard nil t) + (osx-clipboard-mode +1)))) + + (@after evil + ;; On OSX, stop copying each visual state move to the clipboard: + ;; https://bitbucket.org/lyro/evil/issue/336/osx-visual-state-copies-the-region-on + ;; Most of this code grokked from: + ;; http://stackoverflow.com/questions/15873346/elisp-rename-macro + (when (or (featurep 'mac) (featurep 'ns)) + (advice-add 'evil-visual-update-x-selection :override 'ignore)))) + + (IS-LINUX + ;; nothing yet + )) + +(provide 'core-os) +;;; core-os.el ends here diff --git a/core/core.el b/core/core.el index 6761a3615..1031f054d 100644 --- a/core/core.el +++ b/core/core.el @@ -53,9 +53,6 @@ line or use --debug-init to enable this.") "Location of the autoloads.el, which is generated by `doom/reload-autoloads' and `doom-initialize-autoloads'.") -(defconst IS-MAC (eq system-type 'darwin)) -(defconst IS-LINUX (eq system-type 'gnu/linux)) - (defgroup doom nil "" :group 'emacs) @@ -139,6 +136,7 @@ enable multiple minor modes for the same regexp.") ;;; Let 'er rip (require 'core-lib) + (require 'core-os) ; consistent behavior across Oses (doom-initialize-autoloads) (unless noninteractive (@def-package anaphora diff --git a/core/packages.el b/core/packages.el index c4aec83cd..c797b0e4d 100644 --- a/core/packages.el +++ b/core/packages.el @@ -8,6 +8,11 @@ (@package ht) (@package smex) +;; core-os.el +(when IS-MAC + (@package exec-path-from-shell) + (@package osx-clipboard)) + ;; core-ui.el (@package highlight-indent-guides) (@package highlight-numbers)