summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2024-02-11 16:39:29 +0000
committerGrégoire Duchêne <gduchene@awhk.org>2024-02-11 16:39:29 +0000
commit86dfb4e4f281b299fc7139d730e665de0e54d133 (patch)
tree15bac24ead62f7fa0db98f43603363d235e47d9e
parentd13df53ace537f0cb2afafa787bfde06e15f1020 (diff)
emacs: Replace my/focus-frame with my/resize-frame
my/resize-frame will provide more options to resize the frame as desired. Also, make that function available only on macOS, since Linux has capable tiling window managers.
-rw-r--r--dotfiles-darwin/emacs/functions.el24
-rw-r--r--dotfiles-darwin/emacs/init.el5
-rw-r--r--emacs/functions.el8
-rw-r--r--emacs/init.el1
4 files changed, 29 insertions, 9 deletions
diff --git a/dotfiles-darwin/emacs/functions.el b/dotfiles-darwin/emacs/functions.el
new file mode 100644
index 0000000..2339e3e
--- /dev/null
+++ b/dotfiles-darwin/emacs/functions.el
@@ -0,0 +1,24 @@
+;; -*- lexical-binding: t -*-
+
+(defun my/modify-frame-parameters (parameters &optional frame)
+ (when (frame-parameter frame 'fullscreen)
+ (toggle-frame-maximized))
+ (modify-frame-parameters frame (append parameters
+ '((height . 1.0) (top . 1.0)
+ (left . 0.0) (user-position t)))))
+
+(defun my/resize-frame (&optional frame)
+ "Interactively resize FRAME."
+ (interactive)
+ (let ((echo-keystrokes nil))
+ (set-transient-map
+ (let ((map (make-sparse-keymap)))
+ (dolist (elem `(("j" . ((width . ,(/ 2.0 3))))
+ ("k" . ((left . 1.0) (width . ,(/ 2.0 3))))
+ ("l" . ((left . 0.5) (width . 0.5)))))
+ (keymap-set map (car elem) (lambda ()
+ (interactive)
+ (my/modify-frame-parameters (cdr elem)))))
+ map)
+ t nil
+ "Use %k to resize the frame")))
diff --git a/dotfiles-darwin/emacs/init.el b/dotfiles-darwin/emacs/init.el
index a8c0ab2..a34ffe4 100644
--- a/dotfiles-darwin/emacs/init.el
+++ b/dotfiles-darwin/emacs/init.el
@@ -15,3 +15,8 @@
(when my/night-theme (load-theme my/night-theme :no-confirm :no-enable))
(run-at-time nil (* 15 60) #'my/maybe-switch-theme my/day-theme
my/night-theme #'my/macos-dark-p)))
+
+
+;; “Window” Management
+
+(keymap-global-set "C-c l" #'my/resize-frame)
diff --git a/emacs/functions.el b/emacs/functions.el
index 3e879cc..85b45ac 100644
--- a/emacs/functions.el
+++ b/emacs/functions.el
@@ -62,14 +62,6 @@ enabled."
(dolist (mode '(menu-bar-mode scroll-bar-mode tool-bar-mode))
(when (and (fboundp mode) (symbol-value mode)) (funcall mode -1))))
-(defun my/focus-frame (&optional frame)
- "Focus FRAME."
- (interactive)
- (delete-other-windows)
- (modify-frame-parameters frame '((height . 1.0) (width . 0.5)
- (left . 0.5) (top . 1.0)
- (user-position . t))))
-
;; Misc. Stuff
diff --git a/emacs/init.el b/emacs/init.el
index d270371..97baec0 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -98,7 +98,6 @@
(keymap-global-set "C-TAB" #'other-window)
(keymap-global-set "C-M-TAB" #'other-frame)
-(keymap-global-set "C-c l" #'my/focus-frame)
(keymap-global-set "C-c f" #'toggle-frame-maximized)
(windmove-default-keybindings 'super)