diff --git a/README.md b/README.md index 0428d2c..892da10 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,14 @@ There's a fairly rough screencast showing the kind of things you can do with thi ## Typical Setup +By default `frames-only-mode` doesn't modify any keybindings. To replace common +window-using keybindings with their frame equivalents add +`(frames-only-mode-remap-common-window-)` to your config. + In combination with `frames-only-mode` I recommend: * Running emacs as [server-client](http://wikemacs.org/wiki/Emacs_server). * Binding a window manager hotkey to open new emacs frames (see below). -* Rebinding any window splitting keys that you use to call `make-frame` instead. Bind this shell command to a hotkey to automatically open a useful buffer in @@ -87,11 +90,12 @@ Alternatively the `*Completions*` buffer can be disabled entirely by setting * Fix some customize group weirdness * Fix sometimes leaving additional frames open after quitting magit * Regexp support in kill-frame-when-buffer-killed-buffer-list +* Add frames-only-mode-remap-common-window-split-keybindings ## Other links This mode originated in -[a blog post](http://techtrickery.com/tearing-out-the-emacs-window-manager.html) +[a blog post](http://techtrickery.net/tearing-out-the-emacs-window-manager.html) which has some additional details. diff --git a/frames-only-mode.el b/frames-only-mode.el index ec663fe..4c2eabc 100644 --- a/frames-only-mode.el +++ b/frames-only-mode.el @@ -252,9 +252,28 @@ magit status buffer." (defvar frames-only-mode-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-]") #'frames-only-mode-abort-recursive-edit) + ;; Additional keys rebinding common window commands are added/removed by TODO map) "Keymap for ‘frames-only-mode’.") +;;;###autoload +(defun frames-only-mode-remap-common-window-split-keybindings () + "Make frames-only-mode remap common window splitting keybinds. + +Only modifies `frames-only-mode-mode-map', no effect when the mode is +disabled. + +If you have much customisation of your keybinds then you should +probably do this manually instead. +" + (interactive) + (define-key frames-only-mode-mode-map [remap split-window-below] #'make-frame-command) + (define-key frames-only-mode-mode-map [remap split-window-right] #'make-frame-command) + ;; C-x 4 is other-window functions, C-x 5 is other frame. remap doesn't work + ;; for this case. + (define-key frames-only-mode-mode-map (kbd "C-x 4") #'ctl-x-5-prefix) + ) + ;;;###autoload (define-minor-mode frames-only-mode "Use frames instead of emacs windows." diff --git a/test/frames-only-mode-test.el b/test/frames-only-mode-test.el index 72862f3..ca9b80e 100644 --- a/test/frames-only-mode-test.el +++ b/test/frames-only-mode-test.el @@ -115,3 +115,18 @@ Expr should be false, true, false respectively." (should (frames-only-should-kill-frame-for-buffer "foo")) (should (frames-only-should-kill-frame-for-buffer "foolish")) (should-not (frames-only-should-kill-frame-for-buffer "bar")))) + + +(ert-deftest test-window-keybinding-overrides () + ;; By default we don't do any rebinding + (with-frames-only-mode + (should (equal (key-binding (kbd "C-x 2")) #'split-window-below)) + (should (equal (key-binding (kbd "C-x 4 b")) #'switch-to-buffer-other-window)) + ) + + (frames-only-mode-remap-common-window-split-keybindings) + (with-frames-only-mode + (should (equal (key-binding (kbd "C-x 2")) #'make-frame-command)) + (should (equal (key-binding (kbd "C-x 4 b")) #'switch-to-buffer-other-frame)) + ) + )