2015-06-06 06:40:33 -04:00
|
|
|
;;; core-os-osx.el --- Mac-specific settings
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2016-05-19 03:12:13 -04:00
|
|
|
(global-set-key (kbd "M-q") 'kill-emacs)
|
|
|
|
|
2015-06-04 18:23:21 -04:00
|
|
|
;; Use a shared clipboard
|
|
|
|
(setq x-select-enable-clipboard t
|
2015-12-09 02:04:25 -05:00
|
|
|
select-enable-clipboard t
|
2015-08-22 23:42:42 -04:00
|
|
|
;; Prefixes: Command = M, Alt = A
|
|
|
|
mac-command-modifier 'meta
|
|
|
|
mac-option-modifier 'alt
|
2015-11-09 15:52:55 -05:00
|
|
|
;; sane trackpad/mouse scroll settings
|
2015-11-10 18:10:32 -05:00
|
|
|
mac-redisplay-dont-reset-vscroll t
|
2015-11-09 15:52:55 -05:00
|
|
|
mac-mouse-wheel-smooth-scroll nil
|
2016-03-06 00:44:22 -05:00
|
|
|
mouse-wheel-scroll-amount '(5 ((shift) . 2)) ; one line at a time
|
|
|
|
mouse-wheel-progressive-speed nil ; don't accelerate scrolling
|
2015-06-04 18:23:21 -04:00
|
|
|
;; Curse Lion and its sudden but inevitable fullscreen mode!
|
2016-05-21 23:12:50 -04:00
|
|
|
;; NOTE Meaningless to railwaycat's emacs-mac build
|
2015-06-04 18:23:21 -04:00
|
|
|
ns-use-native-fullscreen nil
|
|
|
|
;; Don't open files from the workspace in a new frame
|
2015-11-09 15:52:55 -05:00
|
|
|
ns-pop-up-frames nil)
|
2015-06-04 18:23:21 -04:00
|
|
|
|
|
|
|
;; fix emacs PATH on OSX (GUI only)
|
2015-06-24 15:36:05 +02:00
|
|
|
(when window-system
|
2015-06-04 18:23:21 -04:00
|
|
|
(setenv "SHELL" "/usr/local/bin/zsh")
|
2015-11-23 15:22:13 -05:00
|
|
|
;; `exec-path-from-shell' is slow, so bring out the cache
|
|
|
|
(setq exec-path
|
2016-05-23 17:12:41 -04:00
|
|
|
(eval-when-compile
|
|
|
|
(require 'exec-path-from-shell)
|
|
|
|
(exec-path-from-shell-initialize)
|
|
|
|
exec-path)))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2015-12-11 22:44:03 -05:00
|
|
|
;; Enable mouse support in terminal
|
|
|
|
(unless window-system
|
|
|
|
(require 'mouse)
|
|
|
|
(xterm-mouse-mode t)
|
2016-01-30 21:16:10 -05:00
|
|
|
(global-set-key [mouse-4] (λ! (scroll-down 4)))
|
|
|
|
(global-set-key [mouse-5] (λ! (scroll-up 4)))
|
|
|
|
|
2015-12-11 22:44:03 -05:00
|
|
|
(defun track-mouse (e))
|
|
|
|
(setq mouse-sel-mode t))
|
|
|
|
|
2016-03-06 00:44:22 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; OSX-related plugins + hacks
|
|
|
|
;;
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2016-05-23 17:05:29 -04:00
|
|
|
(use-package applescript-mode
|
|
|
|
:mode "\\.applescript$"
|
2016-05-26 18:43:22 -04:00
|
|
|
:config (def-docset! applescript-mode "applescript"))
|
2016-05-21 23:12:50 -04:00
|
|
|
|
|
|
|
(def-project-type! lb6 "lb6"
|
|
|
|
:match "\\.lb\\(action\\|ext\\)/.+$"
|
|
|
|
:build (lambda ()
|
|
|
|
(awhen (f-traverse-upwards (lambda (f) (f-ext? f "lbaction")))
|
|
|
|
(shell-command (format "open '%s'" it)))))
|
|
|
|
|
2015-11-13 03:40:32 -05:00
|
|
|
(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
|
2016-04-26 02:00:19 -04:00
|
|
|
(when (or (featurep 'mac) (featurep 'ns))
|
|
|
|
(advice-add 'evil-visual-update-x-selection :override 'ignore)))
|
2015-06-04 18:23:21 -04:00
|
|
|
|
2016-03-06 00:44:22 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
;; OS-integration
|
|
|
|
;;
|
2015-11-17 02:07:24 -05:00
|
|
|
|
2016-05-20 22:37:30 -04:00
|
|
|
(defun doom-open-with (&optional app-name path)
|
2015-06-15 09:05:52 +02:00
|
|
|
"Send PATH to APP-NAME on OSX."
|
2015-06-04 18:23:21 -04:00
|
|
|
(interactive)
|
2015-11-13 03:51:02 -05:00
|
|
|
(let* ((path (f-full (s-replace "'" "\\'"
|
|
|
|
(or path (if (eq major-mode 'dired-mode)
|
|
|
|
(dired-get-file-for-visit)
|
|
|
|
(buffer-file-name))))))
|
|
|
|
(command (format "open %s"
|
|
|
|
(if app-name
|
2015-11-25 17:23:22 -05:00
|
|
|
(format "-a %s '%s'" (shell-quote-argument app-name) path)
|
2015-11-13 03:51:02 -05:00
|
|
|
(format "'%s'" path)))))
|
2015-06-04 18:23:21 -04:00
|
|
|
(message "Running: %s" command)
|
|
|
|
(shell-command command)))
|
|
|
|
|
2016-05-20 09:19:56 -04:00
|
|
|
(defmacro def-open-with! (id &optional app dir)
|
2015-12-09 02:05:00 -05:00
|
|
|
`(defun ,(intern (format "os-%s" id)) ()
|
|
|
|
(interactive)
|
2016-05-20 22:37:30 -04:00
|
|
|
(doom-open-with ,app ,dir)))
|
2015-12-09 02:05:00 -05:00
|
|
|
|
2016-05-20 09:19:56 -04:00
|
|
|
(def-open-with! open-in-default-program)
|
|
|
|
(def-open-with! open-in-browser "Google Chrome")
|
|
|
|
(def-open-with! reveal "Finder" default-directory)
|
2016-05-20 22:37:30 -04:00
|
|
|
(def-open-with! reveal-project "Finder" (doom/project-root))
|
2016-05-20 09:19:56 -04:00
|
|
|
(def-open-with! upload "Transmit")
|
|
|
|
(def-open-with! upload-folder "Transmit" default-directory)
|
|
|
|
(def-open-with! send-to-launchbar "LaunchBar")
|
2016-05-20 22:37:30 -04:00
|
|
|
(def-open-with! send-project-to-launchbar "LaunchBar" (doom/project-root))
|
2015-12-09 02:05:00 -05:00
|
|
|
|
|
|
|
(defun os-switch-to-term ()
|
2015-09-30 13:49:37 -04:00
|
|
|
(interactive)
|
2015-11-17 02:07:24 -05:00
|
|
|
(do-applescript "tell application \"iTerm\" to activate"))
|
2015-09-30 13:49:37 -04:00
|
|
|
|
2015-12-09 02:05:00 -05:00
|
|
|
(defun os-switch-to-term-and-cd ()
|
2015-09-30 13:49:37 -04:00
|
|
|
(interactive)
|
2016-05-20 22:37:30 -04:00
|
|
|
(doom:send-to-tmux (format "cd %s" (shell-quote-argument default-directory)))
|
|
|
|
(doom-switch-to-iterm))
|
2015-09-30 13:49:37 -04:00
|
|
|
|
2016-03-01 01:59:36 -05:00
|
|
|
;; Open with external programs
|
2016-03-06 00:44:22 -05:00
|
|
|
(use-package openwith
|
|
|
|
:config
|
|
|
|
(openwith-mode t)
|
|
|
|
(setq openwith-associations
|
|
|
|
'(("\\.\\(pdf\\|jpe?g\\|gif\\|docx?\\|pptx?\\|xlsx?\\|zip\\|tar\\(\\.gz\\)?\\|rar\\)$"
|
|
|
|
"open" (file)))))
|
2015-11-19 05:49:05 -05:00
|
|
|
|
2015-06-06 06:40:33 -04:00
|
|
|
(provide 'core-os-osx)
|
|
|
|
;;; core-os-osx.el ends here
|