forked from SystemCrafters/crafted-emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crafted-osx.el
70 lines (54 loc) · 2.15 KB
/
crafted-osx.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
58
59
60
61
62
63
64
65
66
67
68
69
70
;;; crafted-osx.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:
(defgroup crafted-osx '()
"Osx specific configurations for Crafted Emacs."
:tag "Crafted Osx"
:group 'crafted)
;; Define configuration variables
(define-obsolete-variable-alias
'rational-osx-transparent-titlebar
'crafted-osx-transparent-titlebar
"1")
(defcustom crafted-osx-transparent-titlebar nil
"When set the osx title bar will become the same color as the emacs frame"
:group 'crafted-osx
:type 'boolean)
;; titlebar
(when crafted-osx-transparent-titlebar
(customize-set-variable frame-resize-pixelwise t)
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(add-to-list 'default-frame-alist '(selected-frame) 'name nil)
(add-to-list 'default-frame-alist '(ns-appearance . dark))) ;; assuming a dark theme is in use
;; Special keys
(when (featurep 'ns)
(customize-set-variable mac-right-option-modifier nil)
(customize-set-variable mac-command-modifier 'super)
(customize-set-variable ns-function-modifier 'hyper))
;; Keybinds
(global-set-key (kbd "s-W") 'delete-frame) ; ⌘-W = Close window
(global-set-key (kbd "s-}") 'tab-bar-switch-to-next-tab) ; ⌘-} = Next tab
(global-set-key (kbd "s-{") 'tab-bar-switch-to-prev-tab) ; ⌘-{ = Previous tab
(global-set-key (kbd "s-t") 'tab-bar-new-tab) ;⌘-t = New tab
(global-set-key (kbd "s-w") 'tab-bar-close-tab) ; ⌘-w = Close tab
(unless (< emacs-major-version 28)
(global-set-key (kbd "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)
;;; crafted-osx.el ends here