all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Swap windows in a frame
Date: Mon, 10 Jan 2022 14:51:23 +0100	[thread overview]
Message-ID: <87pmozsnqc.fsf@zoho.eu> (raw)
In-Reply-To: 87o84kjebn.fsf@codeisgreat.org

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




  reply	other threads:[~2022-01-10 13:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10  3:48 Swap windows in a frame Pankaj Jangid
2022-01-10  4:29 ` Samuel Banya
2022-01-10  5:10   ` Pankaj Jangid
2022-01-10  5:05 ` Yuri Khan
2022-01-10  6:27   ` Pankaj Jangid
2022-01-10 13:51     ` Emanuel Berg via Users list for the GNU Emacs text editor [this message]
2022-01-10 16:39       ` Pankaj Jangid
2022-01-11 23:53         ` Ergus via Users list for the GNU Emacs text editor
2022-01-12  4:54           ` Pankaj Jangid
2022-01-12 21:05           ` Emanuel Berg via Users list for the GNU Emacs text editor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmozsnqc.fsf@zoho.eu \
    --to=help-gnu-emacs@gnu.org \
    --cc=moasenwood@zoho.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.