Skip to content

Instantly share code, notes, and snippets.

@kuanyui
Last active January 25, 2024 05:33
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuanyui/65a408d393871048771c to your computer and use it in GitHub Desktop.
Save kuanyui/65a408d393871048771c to your computer and use it in GitHub Desktop.
resize-frame.el --- A minor mode to resize frames easily.
;;; resize-frame.el --- A minor mode to resize frames easily. -*- lexical-binding: t; -*-
;; Copyright (C) 2014 kuanyui
;; Author: kuanyui <azazabc123@gmail.com>
;; Keywords: frames, tools, convenience
;; License: WTFPL 1.0
;;; Commentary:
;; Press "ESC `" and use arrow-keys to adjust frames. press any key to done.
;;; Code:
(defvar resize-frame-map
(let ((map (make-keymap)))
(define-key map (kbd "<up>") 'enlarge-window)
(define-key map (kbd "<down>") 'shrink-window)
(define-key map (kbd "<right>") 'enlarge-window-horizontally)
(define-key map (kbd "<left>") 'shrink-window-horizontally)
(set-char-table-range (nth 1 map) t 'resize-frame-done)
(define-key map (kbd "C-p") 'enlarge-window)
(define-key map (kbd "C-n") 'shrink-window)
(define-key map (kbd "C-f") 'enlarge-window-horizontally)
(define-key map (kbd "C-b") 'shrink-window-horizontally)
map))
(define-minor-mode resize-frame
"A simple minor mode to resize-frame.
C-c C-c to apply."
;; The initial value.
:init-value nil
;; The indicator for the mode line.
:lighter " ResizeFrame"
;; The minor mode bindings.
:keymap resize-frame-map
:global t
(if (<= (length (window-list)) 1)
(progn (setq resize-frame nil)
(message "Only root frame exists, abort."))
(message "Use arrow-keys to adjust frames.")))
(defun resize-frame-done ()
(interactive)
(setq resize-frame nil)
(message "Done."))
(global-set-key (kbd "ESC `") 'resize-frame)
(provide 'resize-frame)
;;; resize-frame.el ends here
@nocaoper
Copy link

Thank you for the much useful script 👍

@JasonSKK
Copy link

Thanks! This is very handy.

@mirbehroznoor
Copy link

Thanks, now I can at least open and kill buffers without the fear of ruining the window layout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment