forked from SystemCrafters/crafted-emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrafted-osx-config.el
57 lines (43 loc) · 1.71 KB
/
crafted-osx-config.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
;;; crafted-osx-config.el --- osx specific config -*- lexical-binding: t -*-
;; Copyright (C) 2022
;; SPDX-License-Identifier: MIT
;; Author: System Crafters Community
;;; Commentary:
;; Make OSX feel more at home
;;; Code:
;;; Titlebar
(defun crafted-osx-transparent-titlebar ()
"Set the titlebar to be transparent."
(when (featurep 'ns)
(interactive)
(customize-set-variable 'frame-resize-pixelwise t)
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))))
;;; Special keys
(when (eq system-type 'darwin)
(customize-set-variable 'mac-right-option-modifier nil)
(customize-set-variable 'mac-command-modifier 'super)
(when (featurep 'ns)
(customize-set-variable 'ns-function-modifier 'hyper)))
;;; Keybinds
(keymap-global-set "s-W" #'delete-frame) ; ⌘-W = Close window
(keymap-global-set "s-}" #'tab-bar-switch-to-next-tab) ; ⌘-} = Next tab
(keymap-global-set "s-{" #'tab-bar-switch-to-prev-tab) ; ⌘-{ = Previous tab
(keymap-global-set "s-t" #'tab-bar-new-tab) ;⌘-t = New tab
(keymap-global-set "s-w" #'tab-bar-close-tab) ; ⌘-w = Close tab
(unless (version< emacs-version "28")
(keymap-global-set "s-Z" 'undo-redo)) ; ⌘-Z = Redo
;;; Better compatibility with osx based window managers
(when (featurep 'ns)
(defun ns-raise-emacs ()
"Raise Emacs."
(ns-do-applescript "tell application \"Emacs\" to activate"))
(defun ns-raise-emacs-with-frame (frame)
"Raise Emacs and select the provided frame."
(with-selected-frame frame
(when (display-graphic-p)
(ns-raise-emacs))))
(add-hook 'after-make-frame-functions 'ns-raise-emacs-with-frame)
(when (display-graphic-p)
(ns-raise-emacs)))
(provide 'crafted-osx-config)
;;; crafted-osx-config.el ends here