unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to toggle to buffer previously selected ?
@ 2008-02-07 10:45 Francis Moreau
  2008-02-07 10:52 ` Bastien Guerry
  2008-02-07 10:53 ` Tassilo Horn
  0 siblings, 2 replies; 11+ messages in thread
From: Francis Moreau @ 2008-02-07 10:45 UTC (permalink / raw)
  To: gnu-emacs-help

Hello all,

I know 'C-x o' to select the next selected buffer but I'd like
to toggle between 2 buffers even if more than 2 buffers are
displayed.

Thanks for your hints.
-- 
Francis




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

* Re: How to toggle to buffer previously selected ?
  2008-02-07 10:45 How to toggle to buffer previously selected ? Francis Moreau
@ 2008-02-07 10:52 ` Bastien Guerry
  2008-02-07 10:53 ` Tassilo Horn
  1 sibling, 0 replies; 11+ messages in thread
From: Bastien Guerry @ 2008-02-07 10:52 UTC (permalink / raw)
  To: help-gnu-emacs

"Francis Moreau" <francis.moro@gmail.com> writes:

> I know 'C-x o' to select the next selected buffer but I'd like
> to toggle between 2 buffers even if more than 2 buffers are
> displayed.

`C-x b' (which is bound to `switch-to-buffer')

Maybe you will like iswitchb:

(require 'iswitchb)

where `C-x b' is bound to `iswitchb-buffer', and offers a more
convenient prompt.

-- 
Bastien




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

* Re: How to toggle to buffer previously selected ?
  2008-02-07 10:45 How to toggle to buffer previously selected ? Francis Moreau
  2008-02-07 10:52 ` Bastien Guerry
@ 2008-02-07 10:53 ` Tassilo Horn
  2008-02-07 15:46   ` Francis Moreau
  1 sibling, 1 reply; 11+ messages in thread
From: Tassilo Horn @ 2008-02-07 10:53 UTC (permalink / raw)
  To: help-gnu-emacs

"Francis Moreau" <francis.moro@gmail.com> writes:

Hi Francis,

> I know 'C-x o' to select the next selected buffer but I'd like to
> toggle between 2 buffers even if more than 2 buffers are displayed.

I use this:

(defun th-other-buffer ()
  (interactive)
  (switch-to-buffer (other-buffer)))

(global-set-key (kbd "C-?") 'th-other-buffer)

Bye,
Tassilo





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

* Re: How to toggle to buffer previously selected ?
  2008-02-07 10:53 ` Tassilo Horn
@ 2008-02-07 15:46   ` Francis Moreau
  2008-02-07 15:58     ` Lennart Borgman (gmail)
                       ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Francis Moreau @ 2008-02-07 15:46 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: help-gnu-emacs

On Feb 7, 2008 11:53 AM, Tassilo Horn <tassilo@member.fsf.org> wrote:
> "Francis Moreau" <francis.moro@gmail.com> writes:
>
> Hi Francis,
>
> > I know 'C-x o' to select the next selected buffer but I'd like to
> > toggle between 2 buffers even if more than 2 buffers are displayed.
>
> I use this:
>
> (defun th-other-buffer ()
>   (interactive)
>   (switch-to-buffer (other-buffer)))
>
> (global-set-key (kbd "C-?") 'th-other-buffer)
>

This is not what I want to do. Sorry I wasn't clear enough in my previous email.

OK, let's say I have the following setup in my emacs:

+-------+--------+
|           |           |
|   1      |   2      |
|           |           |
+-------+--------+
|           |           |
|   3      |   4      |
|           |           |
+-------+--------+

Currently buffer "2" is selected.

I now select buffer "3". I did some typing in that buffer now I want
to get back quickly to buffer "2". I don't want to do "\C-x\C-o" but
I'd like for example just to do "\C-TAB".

So I can go back and forth between these 2 buffers just by typing "\C-TAB"

Thanks
-- 
Francis




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

* Re: How to toggle to buffer previously selected ?
  2008-02-07 15:46   ` Francis Moreau
@ 2008-02-07 15:58     ` Lennart Borgman (gmail)
  2008-02-07 16:18     ` Thierry Volpiatto
  2008-02-07 18:57     ` Tassilo Horn
  2 siblings, 0 replies; 11+ messages in thread
From: Lennart Borgman (gmail) @ 2008-02-07 15:58 UTC (permalink / raw)
  To: Francis Moreau; +Cc: Tassilo Horn, help-gnu-emacs

Francis Moreau wrote:
> On Feb 7, 2008 11:53 AM, Tassilo Horn <tassilo@member.fsf.org> wrote:
>> "Francis Moreau" <francis.moro@gmail.com> writes:
>>
>> Hi Francis,
>>
>>> I know 'C-x o' to select the next selected buffer but I'd like to
>>> toggle between 2 buffers even if more than 2 buffers are displayed.
>> I use this:
>>
>> (defun th-other-buffer ()
>>   (interactive)
>>   (switch-to-buffer (other-buffer)))
>>
>> (global-set-key (kbd "C-?") 'th-other-buffer)
>>
> 
> This is not what I want to do. Sorry I wasn't clear enough in my previous email.
> 
> OK, let's say I have the following setup in my emacs:
> 
> +-------+--------+
> |           |           |
> |   1      |   2      |
> |           |           |
> +-------+--------+
> |           |           |
> |   3      |   4      |
> |           |           |
> +-------+--------+
> 
> Currently buffer "2" is selected.
> 
> I now select buffer "3". I did some typing in that buffer now I want
> to get back quickly to buffer "2". I don't want to do "\C-x\C-o" but
> I'd like for example just to do "\C-TAB".
> 
> So I can go back and forth between these 2 buffers just by typing "\C-TAB"
> 
> Thanks

windmove




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

* Re: How to toggle to buffer previously selected ?
  2008-02-07 15:46   ` Francis Moreau
  2008-02-07 15:58     ` Lennart Borgman (gmail)
@ 2008-02-07 16:18     ` Thierry Volpiatto
  2008-02-07 18:57     ` Tassilo Horn
  2 siblings, 0 replies; 11+ messages in thread
From: Thierry Volpiatto @ 2008-02-07 16:18 UTC (permalink / raw)
  To: Francis Moreau; +Cc: Tassilo Horn, help-gnu-emacs

"Francis Moreau" <francis.moro@gmail.com> writes:

> On Feb 7, 2008 11:53 AM, Tassilo Horn <tassilo@member.fsf.org> wrote:
>> "Francis Moreau" <francis.moro@gmail.com> writes:
>>
>> Hi Francis,
>>
>> > I know 'C-x o' to select the next selected buffer but I'd like to
>> > toggle between 2 buffers even if more than 2 buffers are displayed.
>>
>> I use this:
>>
>> (defun th-other-buffer ()
>>   (interactive)
>>   (switch-to-buffer (other-buffer)))
>>
>> (global-set-key (kbd "C-?") 'th-other-buffer)
>>
>
> This is not what I want to do. Sorry I wasn't clear enough in my previous email.
>
> OK, let's say I have the following setup in my emacs:
>
> +-------+--------+
> |           |           |
> |   1      |   2      |
> |           |           |
> +-------+--------+
> |           |           |
> |   3      |   4      |
> |           |           |
> +-------+--------+
>
> Currently buffer "2" is selected.
>
> I now select buffer "3". I did some typing in that buffer now I want
> to get back quickly to buffer "2". I don't want to do "\C-x\C-o" but
> I'd like for example just to do "\C-TAB".
>
> So I can go back and forth between these 2 buffers just by typing "\C-TAB"
>
> Thanks

;; C-x o inversé de n windows(optional)
(defun other-window-backward (&optional n)
  "retourne sur n window(s) precedent(s)"
  (interactive "p")
  (other-window (- (or n 1))))
(global-set-key (kbd "<C-tab>") 'other-window-backward)

To go back 1 window C-tab 
2 windows C-u 2 C-tab ...etc...
-- 
A + Thierry
Pub key: http://pgp.mit.edu




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

* Re: How to toggle to buffer previously selected ?
  2008-02-07 15:46   ` Francis Moreau
  2008-02-07 15:58     ` Lennart Borgman (gmail)
  2008-02-07 16:18     ` Thierry Volpiatto
@ 2008-02-07 18:57     ` Tassilo Horn
  2008-02-08 11:11       ` Francis Moreau
       [not found]       ` <mailman.7148.1202469108.18990.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 11+ messages in thread
From: Tassilo Horn @ 2008-02-07 18:57 UTC (permalink / raw)
  To: Francis Moreau; +Cc: help-gnu-emacs

"Francis Moreau" <francis.moro@gmail.com> writes:

Hi Francis,

> OK, let's say I have the following setup in my emacs:
>
> +-------+--------+
> |       |        |
> |   1   |   2    |
> |       |        |
> +-------+--------+
> |       |        |
> |   3   |   4    |
> |       |        |
> +-------+--------+
>
> Currently buffer "2" is selected.
>
> I now select buffer "3". I did some typing in that buffer now I want
> to get back quickly to buffer "2". I don't want to do "\C-x\C-o" but
> I'd like for example just to do "\C-TAB".

Ah, ok, you mean windows, not buffers.  For that task I like
window-number.el.

  http://www.emacswiki.org/cgi-bin/wiki/window-number.el

It displays the each window's number in its mode-line and you can jump
to window X using M-X (for X in 1..0).

Bye,
Tassilo




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

* Re: How to toggle to buffer previously selected ?
  2008-02-07 18:57     ` Tassilo Horn
@ 2008-02-08 11:11       ` Francis Moreau
       [not found]       ` <mailman.7148.1202469108.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 11+ messages in thread
From: Francis Moreau @ 2008-02-08 11:11 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: help-gnu-emacs

On Feb 7, 2008 7:57 PM, Tassilo Horn <tassilo@member.fsf.org> wrote:
> "Francis Moreau" <francis.moro@gmail.com> writes:
>
> Hi Francis,
>
> > OK, let's say I have the following setup in my emacs:
> >
> > +-------+--------+
> > |       |        |
> > |   1   |   2    |
> > |       |        |
> > +-------+--------+
> > |       |        |
> > |   3   |   4    |
> > |       |        |
> > +-------+--------+
> >
> > Currently buffer "2" is selected.
> >
> > I now select buffer "3". I did some typing in that buffer now I want
> > to get back quickly to buffer "2". I don't want to do "\C-x\C-o" but
> > I'd like for example just to do "\C-TAB".
>
> Ah, ok, you mean windows, not buffers.  For that task I like
> window-number.el.

yes windows, not buffers, sorry

>
>   http://www.emacswiki.org/cgi-bin/wiki/window-number.el
>
> It displays the each window's number in its mode-line and you can jump
> to window X using M-X (for X in 1..0).
>

Hmm it doesn't do exactly what I described: you need to specify a window
number.

It's weird that we can't do this almost trivial windows back and forth
selection.

-- 
Francis




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

* Re: How to toggle to buffer previously selected ?
       [not found]       ` <mailman.7148.1202469108.18990.help-gnu-emacs@gnu.org>
@ 2008-02-08 14:27         ` Joel J. Adamson
  2008-02-08 19:08           ` Martin Marcher
  0 siblings, 1 reply; 11+ messages in thread
From: Joel J. Adamson @ 2008-02-08 14:27 UTC (permalink / raw)
  To: help-gnu-emacs

"Francis Moreau" <francis.moro@gmail.com> writes:

> On Feb 7, 2008 7:57 PM, Tassilo Horn <tassilo@member.fsf.org> wrote:
>> "Francis Moreau" <francis.moro@gmail.com> writes:
>>
> Hmm it doesn't do exactly what I described: you need to specify a window
> number.

Most often I just enter "M-%%<(- number-of-windows 1> C-x o", however
this is pretty much the same as window-number (which I'm very happy to
find out about).

Another thing I do pretty often is just re-split the windows.  For
example


--------------------
|         |        |
|         |        |
|         |        |
|    1    |   2    |
|         |        |
|         |        |
|         |        |
--------------------

C-x 1 in window 2
--------------------
|                  |
|                  |
|                  |
|    2             |
|                  |
|                  |
|                  |
--------------------

C-x 3 C-x o C-x b #<buffer 1>

--------------------
|         |        |
|         |        |
|         |        |
|    2    |   1    |
|         |        |
|         |        |
|         |        |
--------------------


Window configurations are not sacred and manipulating them is easy.  I
could make this into "exchange-windows" but it's easy enough as it is
(the above takes about 1 second on a slow day).

> It's weird that we can't do this almost trivial windows back and forth
> selection.

Usually I've found that these trivial things are difficult or have not
been implemented because it's better to do something else.  However,
Emacs is all about freedom, so do it!

Joel
--
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109


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

* Re: How to toggle to buffer previously selected ?
  2008-02-08 14:27         ` Joel J. Adamson
@ 2008-02-08 19:08           ` Martin Marcher
  0 siblings, 0 replies; 11+ messages in thread
From: Martin Marcher @ 2008-02-08 19:08 UTC (permalink / raw)
  To: help-gnu-emacs

On 2/8/08, Joel J. Adamson <jadamson@partners.org> wrote:
> Window configurations are not sacred and manipulating them is easy.  I
> could make this into "exchange-windows" but it's easy enough as it is
> (the above takes about 1 second on a slow day).

nice I just added the following:

;; Window moving
(global-set-key (kbd "C-<up>") 'windmove-up)
(global-set-key (kbd "C-<down>") 'windmove-down)
(global-set-key (kbd "C-<left>") 'windmove-left)
(global-set-key (kbd "C-<right>") 'windmove-right)

;; Yes I switched from vim :)
(global-set-key (kbd "C-c k") 'windmove-up)
(global-set-key (kbd "C-c j") 'windmove-down)
(global-set-key (kbd "C-c h") 'windmove-left)
(global-set-key (kbd "C-c l") 'windmove-right)


-- 
http://noneisyours.marcher.name
https://twitter.com/MartinMarcher
http://www.xing.com/profile/Martin_Marcher
http://www.linkedin.com/in/martinmarcher

You are not free to read this message,
by doing so, you have violated my licence
and are required to urinate publicly. Thank you.




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

* Re: How to toggle to buffer previously selected ?
       [not found] <mailman.7093.1202381161.18990.help-gnu-emacs@gnu.org>
@ 2008-02-15 13:32 ` Sam Peterson
  0 siblings, 0 replies; 11+ messages in thread
From: Sam Peterson @ 2008-02-15 13:32 UTC (permalink / raw)
  To: help-gnu-emacs

"Francis Moreau" <francis.moro@gmail.com> on Thu, 7 Feb 2008 11:45:49
+0100 didst step forth and proclaim thus:

> Hello all,
>
> I know 'C-x o' to select the next selected buffer but I'd like
> to toggle between 2 buffers even if more than 2 buffers are
> displayed.
>
> Thanks for your hints.
> -- 
> Francis

I think this *almost* does what you want.  I think you may have
trouble getting it to always swap between the last window you want,
but experimenting with the code will likely prove fruitful.

(defun go-back-window ()
  (interactive)
  (if (boundp 'last-window)
      (progn
	(let ((mywindow last-window))
	  (setq last-window (selected-window))
	  (select-window mywindow)))
    (setq last-window (selected-window))
    (select-window (next-window))))
(global-set-key "\C-cb" 'go-back-window)

-- 
Sam Peterson
peabodyenator@gmail.com
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown


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

end of thread, other threads:[~2008-02-15 13:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-07 10:45 How to toggle to buffer previously selected ? Francis Moreau
2008-02-07 10:52 ` Bastien Guerry
2008-02-07 10:53 ` Tassilo Horn
2008-02-07 15:46   ` Francis Moreau
2008-02-07 15:58     ` Lennart Borgman (gmail)
2008-02-07 16:18     ` Thierry Volpiatto
2008-02-07 18:57     ` Tassilo Horn
2008-02-08 11:11       ` Francis Moreau
     [not found]       ` <mailman.7148.1202469108.18990.help-gnu-emacs@gnu.org>
2008-02-08 14:27         ` Joel J. Adamson
2008-02-08 19:08           ` Martin Marcher
     [not found] <mailman.7093.1202381161.18990.help-gnu-emacs@gnu.org>
2008-02-15 13:32 ` Sam Peterson

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