forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-gui-frames.el
93 lines (62 loc) · 2.61 KB
/
init-gui-frames.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
;;; init-gui-frames.el --- Behaviour specific to non-TTY frames -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; Stop C-z from minimizing windows under OS X
(defun sanityinc/maybe-suspend-frame ()
(interactive)
(unless (and *is-a-mac* window-system)
(suspend-frame)))
(global-set-key (kbd "C-z") 'sanityinc/maybe-suspend-frame)
;; Suppress GUI features
(setq use-file-dialog nil)
(setq use-dialog-box nil)
(setq inhibit-startup-screen t)
;; Window size and features
(setq-default
window-resize-pixelwise t
frame-resize-pixelwise t)
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when (fboundp 'set-scroll-bar-mode)
(set-scroll-bar-mode nil))
(menu-bar-mode -1)
(let ((no-border '(internal-border-width . 0)))
(add-to-list 'default-frame-alist no-border)
(add-to-list 'initial-frame-alist no-border))
(defun sanityinc/adjust-opacity (frame incr)
"Adjust the background opacity of FRAME by increment INCR."
(unless (display-graphic-p frame)
(error "Cannot adjust opacity of this frame"))
(let* ((oldalpha (or (frame-parameter frame 'alpha) 100))
;; The 'alpha frame param became a pair at some point in
;; emacs 24.x, e.g. (100 100)
(oldalpha (if (listp oldalpha) (car oldalpha) oldalpha))
(newalpha (+ incr oldalpha)))
(when (and (<= frame-alpha-lower-limit newalpha) (>= 100 newalpha))
(modify-frame-parameters frame (list (cons 'alpha newalpha))))))
(when (and *is-a-mac* (fboundp 'toggle-frame-fullscreen))
;; Command-Option-f to toggle fullscreen mode
;; Hint: Customize `ns-use-native-fullscreen'
(global-set-key (kbd "M-ƒ") 'toggle-frame-fullscreen))
;; TODO: use seethru package instead?
(global-set-key (kbd "M-C-8") (lambda () (interactive) (sanityinc/adjust-opacity nil -2)))
(global-set-key (kbd "M-C-9") (lambda () (interactive) (sanityinc/adjust-opacity nil 2)))
(global-set-key (kbd "M-C-7") (lambda () (interactive) (modify-frame-parameters nil `((alpha . 100)))))
(when *is-a-mac*
(when (maybe-require-package 'ns-auto-titlebar)
(ns-auto-titlebar-mode)))
(setq frame-title-format
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
;; Non-zero values for `line-spacing' can mess up ansi-term and co,
;; so we zero it explicitly in those cases.
(add-hook 'term-mode-hook
(lambda ()
(setq line-spacing 0)))
;; Change global font size easily
(require-package 'default-text-scale)
(add-hook 'after-init-hook 'default-text-scale-mode)
(require-package 'disable-mouse)
(provide 'init-gui-frames)
;;; init-gui-frames.el ends here