unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Swap windows in a frame
@ 2022-01-10  3:48 Pankaj Jangid
  2022-01-10  4:29 ` Samuel Banya
  2022-01-10  5:05 ` Yuri Khan
  0 siblings, 2 replies; 10+ messages in thread
From: Pankaj Jangid @ 2022-01-10  3:48 UTC (permalink / raw)
  To: help-gnu-emacs

I have two windows in a frame. Is there a command to swap their
location?

I have a wide configuration and windows are left and right. Left is
where I work mostly and is in front of eyes. Right is for reference and
for occasional use. Sometimes, due to some commands, the work window
goes to right. And I want swap its location with the other buffer
window. How can I do that?

Regards
Pankaj




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  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
  1 sibling, 1 reply; 10+ messages in thread
From: Samuel Banya @ 2022-01-10  4:29 UTC (permalink / raw)
  To: Emanuel Berg

Not sure if it helps, but take a look at my config, as you're going to probably have to make some custom Elisp function to do some good swapping.

Download my config and open it up in Org Mode, and find the section on window management, as I have a few swapping functions you might want to steal:

https://git.musimatic.xyz/dotfiles/tree/emacs/.emacs.d

More specifically, here's my config:
https://git.musimatic.xyz/dotfiles/tree/emacs/.emacs.d/configuration.org 

Sincerely,

Sam
On Sun, Jan 9, 2022, at 10:48 PM, Pankaj Jangid wrote:
> I have two windows in a frame. Is there a command to swap their
> location?
> 
> I have a wide configuration and windows are left and right. Left is
> where I work mostly and is in front of eyes. Right is for reference and
> for occasional use. Sometimes, due to some commands, the work window
> goes to right. And I want swap its location with the other buffer
> window. How can I do that?
> 
> Regards
> Pankaj
> 
> 
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  2022-01-10  3:48 Swap windows in a frame Pankaj Jangid
  2022-01-10  4:29 ` Samuel Banya
@ 2022-01-10  5:05 ` Yuri Khan
  2022-01-10  6:27   ` Pankaj Jangid
  1 sibling, 1 reply; 10+ messages in thread
From: Yuri Khan @ 2022-01-10  5:05 UTC (permalink / raw)
  To: Pankaj Jangid; +Cc: help-gnu-emacs

On Mon, 10 Jan 2022 at 10:56, Pankaj Jangid <pankaj@codeisgreat.org> 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



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  2022-01-10  4:29 ` Samuel Banya
@ 2022-01-10  5:10   ` Pankaj Jangid
  0 siblings, 0 replies; 10+ messages in thread
From: Pankaj Jangid @ 2022-01-10  5:10 UTC (permalink / raw)
  To: help-gnu-emacs

"Samuel Banya" <sbanya@fastmail.com> writes:

> Download my config and open it up in Org Mode, and find the section on
> window management, as I have a few swapping functions you might want
> to steal:
>
> https://git.musimatic.xyz/dotfiles/tree/emacs/.emacs.d
>
> More specifically, here's my config:
> https://git.musimatic.xyz/dotfiles/tree/emacs/.emacs.d/configuration.org
>

Thanks a lot for sharing this. This is definitely going to help.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Pankaj Jangid @ 2022-01-10  6:27 UTC (permalink / raw)
  To: help-gnu-emacs

Yuri Khan <yuri.v.khan@gmail.com> writes:

> On Mon, 10 Jan 2022 at 10:56, Pankaj Jangid <pankaj@codeisgreat.org> 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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  2022-01-10  6:27   ` Pankaj Jangid
@ 2022-01-10 13:51     ` Emanuel Berg via Users list for the GNU Emacs text editor
  2022-01-10 16:39       ` Pankaj Jangid
  0 siblings, 1 reply; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-01-10 13:51 UTC (permalink / raw)
  To: help-gnu-emacs

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




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  2022-01-10 13:51     ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2022-01-10 16:39       ` Pankaj Jangid
  2022-01-11 23:53         ` Ergus via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 10+ messages in thread
From: Pankaj Jangid @ 2022-01-10 16:39 UTC (permalink / raw)
  To: help-gnu-emacs

Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

>>>> I have two windows in a frame. Is there a command to swap
>>>> their location?

> (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) ))
>

Yes. Thanks for sharing this. Pasting it to my init :-) 




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  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
  0 siblings, 2 replies; 10+ messages in thread
From: Ergus via Users list for the GNU Emacs text editor @ 2022-01-11 23:53 UTC (permalink / raw)
  To: help-gnu-emacs, Pankaj Jangid

Hi

I see here many complicated answers and recommendation for external packages and nobody mentions winmove. 

winmove.el (that comes with emacs) already have the all the swap functions  
 ​windmove-swap-states-<left,right,up,down>. You only need to bind them or use the binding functions it also provide.



On January 10, 2022 5:39:03 PM GMT+01:00, Pankaj Jangid <pankaj@codeisgreat.org> wrote:
>Emanuel Berg via Users list for the GNU Emacs text editor
><help-gnu-emacs@gnu.org> writes:
>
>>>>> I have two windows in a frame. Is there a command to swap
>>>>> their location?
>
>> (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) ))
>>
>
>Yes. Thanks for sharing this. Pasting it to my init :-) 
>
>

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  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
  1 sibling, 0 replies; 10+ messages in thread
From: Pankaj Jangid @ 2022-01-12  4:54 UTC (permalink / raw)
  To: help-gnu-emacs

Ergus via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:

> winmove.el (that comes with emacs) already have the all the swap
> functions
>  ​windmove-swap-states-<left,right,up,down>. You only need to bind them
>  or use the binding functions it also provide.

Thanks for sharing this built-in. I was surprised when I couldn’t find
this basic thing in Emacs. It kind of shattered my belief. ;)

Cleaning up my config again. 




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Swap windows in a frame
  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
  1 sibling, 0 replies; 10+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2022-01-12 21:05 UTC (permalink / raw)
  To: help-gnu-emacs

Ergus via Users list for the GNU Emacs text editor wrote:

> I see here many complicated answers and recommendation for
> external packages and nobody mentions winmove.
>
> winmove.el (that comes with emacs) already have the all the
> swap functions ​windmove-swap-states-<left,right,up,down>.
> You only need to bind them or use the binding functions it
> also provide.

Elisp please ...

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-01-12 21:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).