[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Swap windows in a frame
From: |
Emanuel Berg |
Subject: |
Re: Swap windows in a frame |
Date: |
Mon, 10 Jan 2022 14:51:23 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Pankaj Jangid wrote:
>>> I have two windows in a frame. Is there a command to swap
>>> their location?
>>
>> I use buffer-up-swap (and buffer-{down,right,left}-swap) from the
>> windcycle[1] package.
>>
>> [1]: https://github.com/troydm/emacs-stuff/blob/master/windcycle.el
>
> Nice readymade package. Thanks for sharing.
(defun swap-windows ()
(interactive)
(let ((buffer (current-buffer)))
(other-window 1)
(switch-to-buffer-other-window (current-buffer))
(other-window 1)
(switch-to-buffer buffer) ))
I think that works by itself but if not the whole source is ...
;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;; http://user.it.uu.se/~embe8573/emacs-init/window-incal.el
;;; https://dataswamp.org/~incal/emacs-init/window-incal.el
;; same window for new things
(setq display-buffer-alist '((".*" display-buffer-same-window)))
(defun beginning-of-line-at-top ()
"Position point at `beginning-of-line'.
Then put that line at the top of the window."
(beginning-of-line)
(recenter 0) )
(defun doodle-buffer ()
(interactive)
(let ((doodle-buffer "~/ooa/doodle.el"))
(if (one-window-p)
(progn
(split-window-below)
(other-window 1)
(find-file doodle-buffer) )
(find-file doodle-buffer) )))
;; the two-window solution
(defun other-window-or-split ()
(interactive)
(when (one-window-p)
(split-window-below) )
(other-window 1) )
(defun swap-windows ()
(interactive)
(let ((buffer (current-buffer)))
(other-window 1)
(switch-to-buffer-other-window (current-buffer))
(other-window 1)
(switch-to-buffer buffer) ))
;; window size shorthands
(defun window-increase-size (lines)
(interactive "p")
(window-resize nil lines) ) ; the current WINDOW
(defun window-decrease-size (lines)
(interactive "p")
(window-resize nil (* -1 lines) ))
(provide 'window-incal)
--
underground experts united
https://dataswamp.org/~incal