help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting the last used window


From: Francis Moreau
Subject: Re: Selecting the last used window
Date: Wed, 08 Dec 2010 15:34:50 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

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

> I'd like to select the last used window. So doing this several times
> select only 2 windows, the 2 most recent used windows.
>
> Does anybody if such command exist ?

Ok, just in case someone is interested, I hacked window-number.el (since
I'm using this package) in order to map M-0 to select the window
previously selected.

WARNING: I don't speak elisp, so the modications are probably ugly and
incorrect. So any advices are welcome.


diff --git a/window-number.el b/window-number.el
index 491458d..cae3567 100644
--- a/window-number.el
+++ b/window-number.el
@@ -80,14 +80,20 @@ minibuffer (even if not active) last."
              (not (eq walk-windows-current walk-windows-start))))
     (reverse (cons (car list) (cdr list)))))
 
+(setq prev-win (selected-window))
+
 (defun window-number-select (number)
   "Selects the nth window."
   (interactive "P")
   (if (integerp number)
-      (let ((window (nth (1- number) (window-number-list))))
-        (if (and window (or (not (window-minibuffer-p window))
+      (let ((window prev-win))
+       (if (< number 10)
+           (setq window (nth (1- number) (window-number-list))))
+       (if (and window (or (not (window-minibuffer-p window))
                             (minibuffer-window-active-p window)))
-            (select-window window)
+           (progn
+             (setq prev-win (selected-window))
+             (select-window window))
           (error "No such window.")))))
 
 (defun window-number ()


-- 
Francis


reply via email to

[Prev in Thread] Current Thread [Next in Thread]