Newsgroups: fj.editor.emacs
Path: galaxy.trc.rwcp.or.jp!jaist-news!cs.titech!wnoc-tyo-news!sh.wide!kogwy!ae-keio!ae-keio!yuuji
From: yuuji@ae.keio.ac.jp (HIROSE Yuuji)
Subject: Window manager for GNU Emacs. [Re: Q: j-shell]
In-Reply-To: toru@sy.ssl.fujitsu.co.jp's message of 31 Oct 93 06:38:42 GMT
Message-ID: <YUUJI.93Nov3015034@figaro.ae.keio.ac.jp>
Sender: news@ae.keio.ac.jp
Nntp-Posting-Host: figaro
Organization: okoma lab., keio univ., yokohama, japan.
References: <TORU.93Oct31153842@volvo.sy.ssl.fujitsu.co.jp>
Distribution: fj
Date: Tue, 2 Nov 1993 16:50:32 GMT
Lines: 661
Xref: galaxy.trc.rwcp.or.jp fj.editor.emacs:4087
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.editor.emacs&nb=4087&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.

$B7DXf5A=N$N9-@%$H?=$7$^$9!#(B

>>>>> $B%a%C%;!<%8(BID <TORU.93Oct31153842@volvo.sy.ssl.fujitsu.co.jp>$B$N(B,
>>>>> toru@sy.ssl.fujitsu.co.jp (Tooru.Okahara) $B$5$s$N5-;v$h$j(B:

$B2,86$5$s(B>   $B;d$b$3$NJU$N;H$$>!<j$,$$$^$$$A$@$C$?$N$G3HD%$5$;$k(B elisp $B$r(B
$B2,86$5$s(B> $B:n$C$F;H$C(B $B$F$$$^$9!#4JC1$K8@$&$H(B emacs $B$NCf$GJ#?t$N(B j-shell 
$B2,86$5$s(B> $B%P%C%U%!$r%;%l%/%H(B $B$7$d$9$/$7$?$b$N$G$9!#<+F0(B rlogin $B$N5!G=$J(B
$B2,86$5$s(B> $B$I$b$"$j$^$9!#(B

  $B@$$NCf;w$?$h$&$J$3$H$r9M$($k?M$,$$$k$b$N$G$9$M(B:-)$B!#(Bscreen $B%3%^%s%IIw$N(B
$B%&%#%s%I%&@ZBX$(5!G=$r(B((j-)shell $B$K8B$i$:(B)$BE,MQ$7$?$b$N$r:n$C$F;H$C$F$$$^(B
$B$9!#(BGNUS$B$r$"$2$F$$$k;~$K(Bmail$B$,Mh$?>l9g$K!"=V;~$K(B mh-e $B$N%&%#%s%I%&$K@ZBX(B
$B$($F(B inc $B$G$-$?$j$9$k$N$G2wE,$G$9!#(B

///  $B7DXf5A=NBg3XM}9)3X8&5f2J4IM}9)3X@l968e4|Gn;N2]DxBg6p8&5f<<(B  /
//  $B9-@%M:Fs(B  [yuuji@ae.keio.ac.jp,  yuuji@educ.cc.keio.ac.jp]  //
/  $B")(B223 $B?@F`@n8)2#IM;T9AKL6hF|5H(B3-14-1 045-563-1151:$BFb@~(B3678  ///


#!/bin/sh
# This is a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 11/02/1993 16:44 UTC by yuuji@figaro
# Source directory /tmp_mnt/net/pajero/chome/okoma/yuuji
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#  24731 -rw-r--r-- windows.el
#
# ============= windows.el ==============
if test -f 'windows.el' -a X"$1" != X"-c"; then
echo 'x - skipping windows.el (File already exists)'
else
echo 'x - extracting windows.el (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'windows.el' &&
;;; -*- Emacs-Lisp -*-
;;; Window manager for GNU Emacs.
;;; windows.el version 0.2
;;; (C) 1993 by HIROSE Yuuji [yuuji@ae.keio.ac.jp]
;;; Last modified Tue Oct 12 00:47:49 1993 on gloria
X
;;; Japanese Document:
;;;
;;;GNU Emacs $BMQJT=82hLL%^%M!<%8%c(B [windows]
;;;
;;;$B!Z$G$-$k;v![(B
;;;
;;;  GNU Emacs $B$G$O=D2#G$0U$N?t$@$1%&%#%s%I%&$rJ,3d$7$F:n6H$r$9$k;v(B
;;;$B$,$G$-$^$9!#%W%m%0%i%`$r3+H/$9$k;~$J$I$N%&%#%s%I%&J,3d$O8zN($KBg(B
;;;$B$-$/1F6A$9$k$N$G!"?M$K$h$C$F9%$_$NJ,3d7ABV$r;}$C$F$$$k;v$G$7$g$&!#(B
;;;$B$7$+$7$=$NESCf$G!"%a%$%k$d%K%e!<%9$rFI$`$H$=$NJ,3d7ABV$r2u$5$l$F(B
;;;$B$7$^$$$^$9!#@5$7$$<j=g$G%a%$%k%j!<%@%b!<%I$r=*$o$l$PNI$$$N$G$9$,!"(B
;;;$B$=$l$@$H$^$?%a%$%k$,Mh$?;~$K:F$S%a%$%k%j!<%@%b!<%I$r5/F0$7$J$1$l(B
;;;$B$P$J$j$^$;$s!#(B
;;;  windows.el $B$r%m!<%I$9$k$H!"9%$_$N%&%#%s%I%&J,3d7ABV$rJ#?t;}$A!"(B
;;;$B$=$l$i$r@ZBX$($J$,$i(B Emacs $B$r;H$&;v$,$G$-$^$9!#(B
;;;
;;;$B!Z=`Hw![(B
;;;
;;;  windows.el $B$r(B load-path $B$NDL$C$?%G%#%l%/%H%j$KF~$l$F$/$@$5$$!#(B
;;;$B$=$7$F0J2<$N9T$r(B .emacs $B$KF~$l$F$/$@$5$$!#(B
;;;
;;;   (autoload 'win-switch-to-window "windows" "Switch window." t)
;;;   (autoload 'win-show-window-list "windows" "List window." t)
;;;   (autoload 'win-last-window "windows" "Switch to lastwindow." t)
;;;   (define-key global-map "\C-cC-w1" 'win-switch-to-window)
;;;
;;;
;;;$B!Z%-!<Dj5A![(B
;;;
;;;  $B%G%U%)%k%H$N%W%j%U%#%/%9%-!<$O(B C-c C-w $B$G$9!#$3$l$G$OITET9g$J(B
;;;$B>l9g$O!X%-!<%+%9%?%^%$%:!Y$N9`$r;2>H$7$F$/$@$5$$!#I8=`>uBV$N%-!<(B
;;;$B%P%$%s%I$O0J2<$N$h$&$K$J$C$F$$$^$9!#(B
;;;
;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$a$K!V(BCreate, Duplicate, Preserve$B!W$H$$$&%W(B
;;;$B%m%s%W%H$,=P$^$9!#$3$l$i$N0UL#$O0J2<$N$h$&$K$J$C$F$$$^$9!#(B
;;;
;;;Create$B8=2hLL$r8=%P%C%U%!$KJ]B88e!"?75,%&%#%s%I(B
;;;$B%&$r@8@.(B
;;;Duplicate$B8=2hLL$r8=%P%C%U%!$KJ]B88e!"8=2hLL$HF1$8(B
;;;$B%&%#%s%I%&$r@8@.(B
;;;Preserve$B8=%P%C%U%!$O99?7$;$:!"8=2hLL$r?75,%&%#%s(B
;;;$B%I%&$H$7$FEPO?(B
;;;
;;;$B!Z%-!<%+%9%?%^%$%:![(B
;;;
;;;  $B%W%j%U%#%/%9%-!<$rNc$($P(B C-c w $B$KJQ99$9$k;~$O(B .emacs $B$K<!$N$h(B
;;;$B$&$J5-=R$r$$$l$^$9!#(B
;;;
;;;(setq win:switch-prefix "\C-cw")
;;;(define-key global-map win:switch-prefix nil)
;;;(define-key global-map "\C-cw1" 'win-switch-to-window)
;;;
;;;  $B%&%#%s%I%&$NA*Br$r(B1$B!A(B9$B$G$O$J$/$F!"(Ba$B!A(Bz$B$K$9$k$3$H$b$G$-$^$9!#(B
;;;
;;;(setq win:switch-prefix "\C-cw")
;;;(define-key global-map win:switch-prefix nil)
;;;(define-key global-map "\C-cwa" 'win-switch-to-window)
;;;(setq win:base-key ?`);; ` $B$O!VD>A0$N>uBV!W(B
;;;(setq win:max-configs 27);; `$B!A(Bz$B$O(B27$BJ8;z(B
;;;(setq win:quick-select nil);; C-c$B1Q;z(B $B$K3d$jEv$F$J$$(B
;;;
;;;$B$3$3$G(B ` $B$O%"%9%-!<%3!<%I$G(B a $B$N0l$DA0$K$"$k$3$H$KCm0U$7$F$/$@$5(B
;;;$B$$!#(BC-c C-w ` $B$OD>A0>uBVJ]B8MQ%P%C%U%!$H!"%+%l%s%H%&%#%s%I%&$NFb(B
;;;$BMF$N8r49$K3d$jEv$F$i$l$^$9!#(B
;;;
;;;$B!Z%P%0![(B
;;;
;;;  $B%&%#%s%I%&4D6-$G;HMQ$7$F$$$k>l9g$G!"(BEmacs $B$N%&%#%s%I%&$r%j%5%$(B
;;;$B%:$7$?>l9g!"%j%5%$%:$9$kA0$NJ,3d>uBV$OI|5"$G$-$^$;$s!#(B
;;;
;;;$B!Z$"$H$,$-![(B
;;;
;;;  $B;w$?$h$&$J$NB>$K$b$"$j$=$&!#(B
;;;
;;;$B!Z<h$j07$$![(B
;;;
;;;  $B$3$N%W%m%0%i%`$O!"%U%j!<%=%U%H%&%'%"$H$$$?$7$^$9!#$3$N%W%m%0%i(B
;;;$B%`$r;HMQ$7$F@8$8$?$$$+$J$k7k2L$KBP$7$F$b:n<T$O0l@Z$N@UG$$rIi$o$J(B
;;;$B$$$b$N$H$$$?$7$^$9$,!"%3%a%s%H$d%P%0%l%]!<%H$OBg$$$K4?7^$$$?$7$^(B
;;;$B$9!#$*5$7Z$K$4O"Mm2<$5$$!#O"Mm$O0J2<$N%"%I%l%9$^$G$*4j$$$$$?$7$^(B
;;;$B$9(B(1994/3$B8=:_(B)$B!#(B
;;;yuuji@ae.keio.ac.jp
;;;pcs39334@ASCII-NET
;;;Window manager for GNU Emacs
;;;
;;;[What is windows]
;;;
;;;  You can divide  the screen of GNU Emacs  as many as you  like.
;;;Since efficiency of implementation or so  depends  much  on  the
;;;style  of  window division,  you  may have  your  own  style  of
;;;partitioning.   But  if you  switch the  mode to  e-mail mode or
;;;NetNews mode, they break your favorite style.
;;;  Windows.el enables  you   to  have multiple   favorite  window
;;;configurations at the same time, and switch them.
;;;
;;;[Installation]
;;;
;;;  Put windows.el into the directory load-path indicates, and put
;;;following expressions into your ~/.emacs.
;;;
;;;   (autoload 'win-switch-to-window "windows" "Switch window." t)
;;;   (autoload 'win-show-window-list "windows" "List window." t)
;;;   (autoload 'win-last-window "windows" "Switch to lastwindow." t)
;;;   (define-key global-map "\C-c\C-w1" 'win-switch-to-window)
;;;
;;;[Key Bindings]
;;;
;;;  The default prefix key stroke is `C-c C-w'.   If it causes you
;;;some troubles, see the  section `Customizations'.  These are the
;;;default key bindings.
;;;
;;;C-c C-w 1Switch to window 1
;;;C-c C-w 2Switch to window 2
;;;   :
;;;C-c C-w 9Switch to window 9
;;;C-c C-w 0Swap windows with the buffer 0
;;;C-c C-w SPCSwitch to window 1..9 previously shown
;;;C-c C-w C-nSwitch to next window
;;;C-c C-w C-pSwitch to previous window
;;;C-c C-w !Delete current window
;;;C-c C-w =Show window list
;;;
;;;  The   key  strokes to   select windows  from   1 to 9  may  be
;;;frequently used, so the alternative key strokes `C-c [Num.]' are
;;;available  by   default.   To  disable these   strokes, set  the
;;;variable win:quick-select to `nil' in your ~/.emacs.
;;;
;;;[Description]
;;;
;;;  Windows.el has 10 buffers from 0 to 9.  You can use the buffer
;;;from 1 to 9 but the buffer 0 is  reserved for most recently used
;;;window.
;;;
;;;  For example,  you are  editing your  programs with  the screen
;;;split into  some sub-windows.  Type `C-c C-w  1'  to   save this
;;;window    configuration  into  the  buffer    1.  Initially,  no
;;;information is stored to the buffer 1, current  configuration is
;;;saved into the buffer 1.
;;;
;;;  After a while, a mail has arrived.  You may wish assign a mail
;;;mode configuration to the buffer 2.  Type `C-c C-w  2' to create
;;;the buffer 2,  and you will  see the  prompt "Create, Duplicate,
;;;Preserve"  in the  minibuffer.  Since   you needn't the  current
;;;window configuration to read mails, type `c', stands for Create,
;;;to  create the new window  configuration.  Then after invoke the
;;;mail reader,  current  window configuration  will  turn  to mail
;;;oriented one.  When you finish to read your mail, you can return
;;;to programming configuration with `C-c C-w 1'.
;;;
;;;  Let's read the NetNews.  M-x gnus...   O.K.! You've done.  You
;;;may have typed `q' to quit  gnus until yesterday.  But you don't
;;;have  to   do  it from now.  You   can  go  back  to programming
;;;immediately by typing `C-c C-w  1'!  Oops, you have  not created
;;;the new  configuration  buffer yet.  So  the  window you see  is
;;;still the window 1.  If you switch the window to another, you'll
;;;lose the configuration in the buffer 1.  In  this case, type `p'
;;;(stands  for Preserve) at   the prompt of   `Create,  Duplicate,
;;;Preserve' after  typing `C-c C-w 3'.  Windows.el  doesn't update
;;;the buffer 1  and saves the  current window configuration of the
;;;NetNews into the buffer 3.
;;;
;;;  Then, type `C-c C-w 2' to read the mail, type `C-c C-w 3' when
;;;you are  tired   with   programming.   `C-c C-w  SPC'   is  very
;;;combinient when you want to switch two configurations.
;;;
;;;  If you forget what screens allocated to the buffers, type `C-c
;;;C-w =' to display the number of buffers and  their corresponding
;;;buffer names in  the minibuffer.   The entry  preceded by `*' is
;;;the   selected buffer  and the  entry   with  `+' is  the buffer
;;;previously selected(that  is   the buffer   `C-c   C-w SPC' will
;;;select).
;;;
;;;[Other functions]
;;;
;;;  Maybe these functions will be indispensable when you are
;;;accustomed to the operations.
;;;
;;;(1)C-u - C-c C-w [No.]Clear the buffer [No.]
;;;(2)C-c C-w !Clear the current buffer
;;;(3)C-u 0 C-c C-w [CurrentNo.]Re-load the current buffer
;;;(4)C-u C-c C-w [No.]Overwrite the buffer [No.]
;;;
;;;(1)  is for clearing  the configuration buffer  specified by the
;;;number  [No.].   (2) is for   clearing the current configuration
;;;buffer.  You can kill all visible editing  buffers  with C-u.(3)
;;;is for restoring the window configuration from  the buffer, when
;;;you  type `C-x 1' by mistake  or so.  (4)   is  for updating the
;;;configuration   buffer  [No.]     with  the   current     window
;;;configuration.
;;;
;;;  When you create the new window, you see the prompt of `Create,
;;;Duplicate,    Preserve'  which  ask you  how   to hadle  current
;;;configuration buffer and  what configuration the new window must
;;;be.  The entries of the prompt stand for the followings.
;;;
;;;CreateAfter saving the current window
;;;configuration into the current buffer,
;;;create a newly allocated window.
;;;DuplicateAfter saving the current window
;;;configuration into the current buffer,
;;;create the new window with the same
;;;configuration as the current one.
;;;PreserveWithout updating the current buffer,
;;;use the current window configuration
;;;as the new window.
;;;
;;;[Customizations]
;;;
;;;  To change  the prefix key stroke  to  `C-c w' for example,
;;;put the followings into your ~/.emacs.
;;;
;;;(setq win:switch-prefix "\C-cw")
;;;(define-key global-map win:switch-prefix nil)
;;;(define-key global-map "\C-cw1" 'win-switch-to-window)
;;;
;;;And you can also change the key stroke of window selection to
;;;`a' to `z' other than `1' to `9'.
;;;
;;;(setq win:switch-prefix "\C-cw")
;;;(define-key global-map win:switch-prefix nil)
;;;(define-key global-map "\C-cwb" 'win-switch-to-window)
;;;(setq win:base-key ?`);; '`' is before 'a'
;;;(setq win:max-configs 27);; '`' to 'z' are 26 chars.
;;;(setq win:quick-select nil);; Not assign `C-c LETTER'
;;;
;;;Notice that '`' is the previous character of 'a' in ASCII code,
;;;and that C-c w ` is bound to swap the configuration of the
;;;buffer '`' and the current buffer.
;;;
;;;[Bugs]
;;;
;;;  With   executing  Emacs under  the  window system and resizing
;;;Emacs's  frame,   windows.el    cannot    restore   the   window
;;;configuration whic was saved before  resize.  Original  idea and
;;;operations  are fundamentally based    on `screen',  the  window
;;;manager  for   VT100   emulation  terminal,   but there    is no
;;;compatibility.
;;;
;;;[Copying]
;;;
;;;  This program is distributed as a free  software. The author is
;;;not responsible  for  any  possible   defects   caused  by  this
;;;software.
;;;
;;;  Comments  and bug   reports  are welcome. Don't  hesitated  to
;;;report.  My possible e-mail address is following.
;;;
;;;yuuji@ae.keio.ac.jp
;;;pcs39334@ASCII-NET
X
(defvar win:max-configs 10)
(defvar win:base-key ?0)
(if (> win:max-configs 27) (error "win:max-configs too large!"))
(defvar win:configs (make-vector win:max-configs nil)
X  "Array of window configurations.  0th value always has previous
window configuration.")
(defvar win:names (make-vector win:max-configs ""))
(defvar win:sizes (make-vector win:max-configs nil))
X
(defvar win:current-config 0 "Current window number.")
(defvar win:last-config 0 "Last window number.")
X
(defvar win:switch-map nil
X  "Key map for window switcher.")
X
(defvar win:switch-prefix "\C-c\C-w"
X  "*Prefix key stroke to switch windows.")
(defvar win:menu-key-stroke "\C-w"
X  "*Key assignment of win:swtich-menu")
(defvar win:quick-select t
X  "*T for making selection key stroke shorter.  You can switch windows
not only by `C-c C-w 1' but also by `C-c 1'.")
(defvar win:mode-line-format "[%c]"
X  "*Format of mode line that show the selected window number.")
X
X
(if win:switch-map nil
X  (setq win:switch-map (make-sparse-keymap))
X  (define-key global-map win:switch-prefix nil)
X  (define-key global-map win:switch-prefix win:switch-map)
X  (let ((key win:base-key) (max (+ win:base-key win:max-configs)))
X    (while (< key max)
X      (define-key win:switch-map (char-to-string key) 'win-switch-to-window)
X      (setq key (1+ key)))
X    (if (and win:quick-select (> (length win:switch-prefix) 1))
X(while (>= key win:base-key)
X  (setq key (1- key))
X  (define-key global-map
X    (concat (substring win:switch-prefix 0 1) (char-to-string key))
X    'win-switch-to-window))))
X  (define-key win:switch-map "=" 'win-show-window-list)
X  (define-key win:switch-map win:menu-key-stroke 'win-menu)
X  (define-key win:switch-map " " 'win-toggle-window)
X  (define-key win:switch-map "n" 'win-next-window)
X  (define-key win:switch-map "p" 'win-prev-window)
X  (define-key win:switch-map "!" 'win-delete-current-window)
X  )
X
(defun win:delete-window (n)
X  "Delete Nth entry of window configuration buffer."
X  (if (= n 0) (error "Can't delete window %c" win:base-key))
X  (if (y-or-n-p (format "Erase configuration of %c{%s}?"
X(+ n win:base-key) (aref win:names n)))
X      (progn
X(aset win:configs n nil)
X(if (= n win:current-config)
X    (progn
X      (setq win:current-config win:last-config
X    win:last-config 0)
X      (win:set-wc win:current-config)))
X(win:update-mode-line win:current-config)))
X  (message "")
)
X
(defun win-delete-current-window (arg)
X  "Delete selected window configuration buffer.  With universal-argument,
kill all visible buffer."
X  (interactive "P")
X  (let ((cwin (selected-window)) win (cc win:current-config)
X(blist (list (current-buffer))))
X    (if arg
X(progn
X  (setq win cwin)
X  (while (not (eq cwin (setq win (next-window win))))
X    (setq blist (cons (window-buffer win) blist)))))
X    (win:delete-window win:current-config)
X    (if (and arg (/= cc win:current-config))
X(progn
X  (while blist
X    (if (get-buffer (car blist))
X(kill-buffer (car blist)))
X    (setq blist (cdr blist))))))
)
X
(defun win-switch-to-window (arg)
X  "Switch window configurations."
X  (interactive "p")
X  (setq window (- last-command-char win:base-key))
X  (let ((wc (aref win:configs window)))
X    (cond
X     ((= window 0) (win-last-window))
X     ((< arg 0)
X      (win:delete-window window))
X     ((> arg 1)
X      (setq ;;win:last-config win:current-config
X       win:current-config window)
X      (win:store-config window)
X      (win:update-mode-line window)
X      (message "Update window[%c]." (+ window win:base-key)))
X     ((= win:current-config window)
X      (if (= arg 0)
X  (win:set-wc window)
X(message "This is window[%c]." (+ window win:base-key))))
X     (t
X      (if (aref win:configs window)
X  (progn
X    (win:store-config win:current-config)
X    (win:set-wc window)
X    (win:update-mode-line window)
X    (setq win:last-config win:current-config
X  win:current-config window)
X    (message "Switch to window[%c]" (+ window win:base-key)))
X(let (ans)
X  (if (/= (+ win:current-config win:last-config) 0)
X      (message
X       "window[%c] is nil. Create, Duplicate, Preserve? [cdpn]:"
X       (+ window win:base-key))
X    (message "Create window[%c]?(y or n):" (+ window win:base-key)))
X  (setq ans (read-char))
X  (cond
X   ((string-match (char-to-string ans) "cdpy")
X    (if (/= ans ?p)
X(win:store-config win:current-config))
X    (setq win:last-config win:current-config
X  win:current-config window)
X    (if (and (equal ans ?c) (/= win:last-config 0))
X(progn
X  (delete-other-windows)
X  (switch-to-buffer (get-buffer-create "*scratch*"))))
X    (win:store-config window)
X    (win:update-mode-line window)
X    (message "Memorize current window configuration into %c."
X     (+ window win:base-key))
X    (win:update-mode-line window))))
X)))))
X
(defun win-menu (arg)
X  (interactive "p")
X  (message "N)ext P)rev L)ast D)elete L)ist")
X  (let ((c (downcase (read-char))))
X    (cond
X     ((= c ?n) (win-next-window arg))
X     ((= c ?p) (win-prev-window arg))
X     ((= c ?l) (win-last-window))
X     ((= c ?d) (win-delete-current-window arg))
X     (t nil)))
)
X
(defun win-toggle-window ()
X  "Toggle current window and most recently used one."
X  (interactive)
X  (if (or (= win:last-config win:current-config)
X  (equal (aref win:configs win:last-config) nil))
X      (message "No other window.")
X    (win:store-config win:current-config)
X    (win:set-wc win:last-config)
X    (win:update-mode-line win:last-config)
X    ;;then swap two values
X    (setq win:last-config (+ win:last-config win:current-config)
X  win:current-config (- win:last-config win:current-config)
X  win:last-config (- win:last-config win:current-config))
X    (message "Switch to window[%c]." (+ win:current-config win:base-key)))
)
X
(defun win-last-window ()
X  "Switch to previously displayed window saved in temporary buffer."
X  (interactive)
X  ;;(let ((last-wc (aref win:configs 0))(last-sz (aref win:sizes 0)))
X  ;;  (if last-wc (win:set-wc last-wc last-sz)))
X  (win:set-wc 0)
X  (win:update-mode-line win:current-config)
)
X
(defun win-next-window (arg)
X  "Switch to window saved in the next buffer."
X  (interactive "p")
X  (let ((count 0)(num win:current-config)
X(incr (if (> arg 0) 1 (1- win:max-configs))))
X    (setq arg (max arg (- arg)))
X    (while (< count arg)
X      (setq num (+ num incr))
X      (if (aref win:configs (% num win:max-configs)) (setq count (1+ count))))
X    (setq num (% num win:max-configs))
X    (if (= num win:current-config)
X(message "Next window by %d is this window." num)
X      (win:store-config win:current-config)
X      (win:set-wc num)
X      (win:update-mode-line num)
X      (setq win:last-config win:current-config
X    win:current-config num))
X    (message "Switch to window[%c]." (+ win:current-config win:base-key)))
)
X
(defun win-prev-window (arg)
X  (interactive "p")
X  (win-next-window (- arg))
)
X
(defun win-show-window-list (wait)
X  "Show the windows' list in the minibuffer.  If the list is too long
to be displayed in a line, it will be showed line by line waiting WAIT
seconds on each line.  Default wait is 2 seconds."
X  (interactive "P")
X  (let ((i 0) (list "")cl ll cw)
X    (while (< i win:max-configs)
X      (if (aref win:configs i)
X  (progn
X    (setq ll list
X  cw (cond
X      ((= i win:current-config) "*")
X      ((= i win:last-config) "+")
X      (t ""))
X  cl (format "%s%c{%s} "
X     cw (+ i win:base-key) (aref win:names i))
X  list (concat ll cl))
X    (if (< (length list) (- (screen-width) 3)) nil
X      (message (concat ll "..."))
X      (sit-for (if wait (prefix-numeric-value wait) 2))
X      (setq list cl))))
X      (setq i (1+ i)))
X    (if (string= list "")
X(message "No window configuration stored.")
X      (message list)))
)
X
(defun win:set-wc (num)
X  (let*((size (aref win:sizes num))
X(oldh (nth 0 size)) (oldw (nth 1 size))
X(newh (screen-height)) (neww (screen-width))
X(wc (aref win:configs num)))
X    (win:store-config 0)  ;;save current configuration into array[0]
X    (if (and (equal oldh newh) (equal oldw neww))
X(set-window-configuration wc)
X      ;;(set-screen-height oldh)
X      ;;(set-screen-width oldw)
X      ;;(set-window-configuration wc)
X      ;;(call-process shell-file-name nil nil 1 "-c"
X      ;;  (concat "kill -WINCH "
X      ;;  (substring (make-temp-name "") 1)))
X      (message "Window was resized!  Clear window buffer.")
X      (ding)
X      (sit-for 2)))
)
X
(defun win:store-config (index)
X  (aset win:configs index (current-window-configuration))
X  (aset win:names index (buffer-name))
X  (aset win:sizes index (list (screen-height) (screen-width)))
)
X
(defvar win:mode-line-format "[%c]")
(defun win:update-mode-line (number)
X  (setq win:mode-string (format "[%c]" (+ number win:base-key)))
X  (set-buffer-modified-p (buffer-modified-p))
X  (sit-for 0)
)
X
(or global-mode-string (setq global-mode-string '("")))
(or (memq 'win:mode-string global-mode-string)
X    (setq global-mode-string (append global-mode-string '(win:mode-string))))
X
(provide 'windows)
(run-hooks 'win-load-hook)
X
;; $Id: windows.el 0.2 93/10/12 02:43:15 yuuji Exp Locker: yuuji $
;; $Log:windows.el $
;; Revision 0.2  93/10/12  02:43:15  yuuji
;; Change prefix key to `C-c C-w'.
;; 
X
; Local variables:
; fill-prefix: ";;;"
; paragraph-start: "^$\\|\\|;;;$"
; paragraph-separate: "^$\\|\\|;;;$"
; End:
SHAR_EOF
chmod 0644 windows.el ||
echo 'restore of windows.el failed'
Wc_c="`wc -c < 'windows.el'`"
test 24731 -eq "$Wc_c" ||
echo 'windows.el: original size 24731, current size' "$Wc_c"
fi
exit 0
