doomemacs/core/core-os.el
Henrik Lissner c7254e7bdc
Major optimization refactor, across the board
+ enable lexical-scope everywhere (lexical-binding = t): ~5-10% faster
  startup; ~5-20% general boost
+ reduce consing, function calls & garbage collection by preferring
  cl-loop & dolist over lambda closures (for mapc[ar], add-hook, and
  various cl-lib filter/map/reduce functions) -- where possible
+ prefer functions with dedicated opcodes, like assq (see byte-defop's
  in bytecomp.el for more)
+ prefer pcase & cond (faster) over cl-case
+ general refactor for code readability
+ ensure naming & style conventions are adhered to
+ appease byte-compiler by marking unused variables with underscore
+ defer minor mode activation to after-init, emacs-startup or
  window-setup hooks; a customization opportunity for users + ensures
  custom functionality won't interfere with startup.
2017-06-09 00:47:45 +02:00

58 lines
2.5 KiB
EmacsLisp

;;; core-os.el -*- lexical-binding: t; -*-
(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)
(after! evil
;; 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
(advice-add #'evil-visual-update-x-selection :override #'ignore))
(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)
;; A known problem with GUI Emacs on MacOS: it runs in an isolated
;; environment, so envvars will be wrong. That includes the PATH
;; Emacs picks up. `exec-path-from-shell' fixes this. This is slow
;; and benefits greatly from compilation.
(setq exec-path
(or (eval-when-compile
(when (require 'exec-path-from-shell nil t)
(setq exec-path-from-shell-check-startup-files nil
exec-path-from-shell-arguments (delete "-i" exec-path-from-shell-arguments))
(nconc exec-path-from-shell-variables '("GOPATH" "GOROOT" "PYTHONPATH"))
(exec-path-from-shell-initialize)
(persistent-soft-store 'exec-path exec-path "emacs")
exec-path))
exec-path)))
(t
(when (require 'osx-clipboard nil t)
(osx-clipboard-mode +1)))))
(IS-LINUX
;; native tooltips are ugly!
(setq x-gtk-use-system-tooltips nil)
))
(provide 'core-os)
;;; core-os.el ends here