Rewrite core libraries (WIP)

This commit is contained in:
Henrik Lissner 2017-01-16 23:15:48 -05:00
parent 83c852e11f
commit 50ea98319f
68 changed files with 1892 additions and 5345 deletions

View file

@ -1,28 +1,59 @@
;;; core-os.el
;;; core-os.el --- consistent behavior across OSes
(defconst IS-MAC (eq system-type 'darwin))
(defconst IS-LINUX (eq system-type 'gnu/linux))
(defconst IS-WINDOWS (eq system-type 'windows-nt))
(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))
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING)
;; Use a shared clipboard
select-enable-clipboard t
select-enable-primary t)
;; Stubs, these should be defined in all OS modules
(noop! doom-open-with (&optional app-name path))
(noop! os-open-in-browser)
(noop! os-open-in-default-program)
(noop! os-reveal)
(noop! os-reveal-project)
(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))
(IS-WINDOWS (require 'core-os-win32)))
;;;
;; OS-specific configs
(cond (IS-MAC
;; Prefixes: Command = M, Alt = A
(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)
;; On OSX, in GUI Emacs, `exec-path' isn't populated properly (it should
;; match $PATH in my shell). `exe-path-from-shell' fixes this.
(package! exec-path-from-shell)
(when (display-graphic-p)
(setenv "SHELL" "/usr/local/bin/zsh")
;; `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
(require 'exec-path-from-shell)
(exec-path-from-shell-initialize)
exec-path)
"emacs"))))
(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
(setq x-super-keysym 'meta
x-meta-keysym 'alt)))
(provide 'core-os)
;;; core-os.el ends here