Mercurial > emacs
annotate lisp/winner.el @ 38583:10fd583eef97
*** empty log message ***
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 27 Jul 2001 08:41:35 +0000 |
parents | 63281ffd14fd |
children | 9e4a1be87f8c |
rev | line source |
---|---|
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
1 ;;; winner.el --- Restore old window configurations |
17469 | 2 |
38334
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
3 ;; Copyright (C) 1997, 1998, 2001 Free Software Foundation. Inc. |
17469 | 4 |
28071 | 5 ;; Author: Ivar Rummelhoff <ivarru@math.uio.no> |
17469 | 6 ;; Created: 27 Feb 1997 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
7 ;; Time-stamp: <1998-08-21 19:51:02 ivarr> |
28023
3978c673322b
Fix keywords, autoload cookies. Split
Dave Love <fx@gnu.org>
parents:
25733
diff
changeset
|
8 ;; Keywords: convenience frames |
17469 | 9 |
17470
c4cd2317fe60
Clean up comments, etc.
Richard M. Stallman <rms@gnu.org>
parents:
17469
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
c4cd2317fe60
Clean up comments, etc.
Richard M. Stallman <rms@gnu.org>
parents:
17469
diff
changeset
|
11 |
c4cd2317fe60
Clean up comments, etc.
Richard M. Stallman <rms@gnu.org>
parents:
17469
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
17469 | 13 ;; it under the terms of the GNU General Public License as published by |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17470
c4cd2317fe60
Clean up comments, etc.
Richard M. Stallman <rms@gnu.org>
parents:
17469
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
17469 | 18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
28 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
29 ;; Winner mode is a global minor mode that records the changes in the |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
30 ;; window configuration (i.e. how the frames are partitioned into |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
31 ;; windows) so that the changes can be "undone" using the command |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
32 ;; `winner-undo'. By default this one is bound to the key sequence |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
33 ;; ctrl-x left. If you change your mind (while undoing), you can |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
34 ;; press ctrl-x right (calling `winner-redo'). Even though it uses |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
35 ;; some features of Emacs20.3, winner.el should also work with |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
36 ;; Emacs19.34 and XEmacs20, provided that the installed version of |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
37 ;; custom is not obsolete. |
17469 | 38 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
39 ;; Winner mode was improved august 1998. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
40 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
41 ;;; Code: |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
42 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
43 (eval-when-compile |
28023
3978c673322b
Fix keywords, autoload cookies. Split
Dave Love <fx@gnu.org>
parents:
25733
diff
changeset
|
44 (require 'cl)) |
17469 | 45 |
28023
3978c673322b
Fix keywords, autoload cookies. Split
Dave Love <fx@gnu.org>
parents:
25733
diff
changeset
|
46 (eval-when-compile |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
47 (cond |
25733
b2b3b42a23b3
Use aref instead of sref.
Richard M. Stallman <rms@gnu.org>
parents:
25639
diff
changeset
|
48 ((eq (aref (emacs-version) 0) ?X) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
49 (defmacro winner-active-region () |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
50 '(region-active-p)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
51 (defsetf winner-active-region () (store) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
52 `(if ,store (zmacs-activate-region) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
53 (zmacs-deactivate-region)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
54 (t (defmacro winner-active-region () |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
55 'mark-active) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
56 (defsetf winner-active-region () (store) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
57 `(setq mark-active ,store)))) ) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
58 |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
59 (require 'ring) |
17469 | 60 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
61 (when (fboundp 'defgroup) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
62 (defgroup winner nil |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
63 "Restoring window configurations." |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
64 :group 'windows)) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
65 |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
66 (unless (fboundp 'defcustom) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
67 (defmacro defcustom (symbol &optional initvalue docs &rest rest) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
68 (list 'defvar symbol initvalue docs))) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
69 |
28023
3978c673322b
Fix keywords, autoload cookies. Split
Dave Love <fx@gnu.org>
parents:
25733
diff
changeset
|
70 |
3978c673322b
Fix keywords, autoload cookies. Split
Dave Love <fx@gnu.org>
parents:
25733
diff
changeset
|
71 ;;;###autoload |
20968 | 72 (defcustom winner-mode nil |
73 "Toggle winner-mode. | |
24637 | 74 Setting this variable directly does not take effect; |
75 use either \\[customize] or the function `winner-mode'." | |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
76 :set #'(lambda (symbol value) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
77 (winner-mode (or value 0))) |
20968 | 78 :initialize 'custom-initialize-default |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
79 :type 'boolean |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
80 :group 'winner |
20968 | 81 :require 'winner) |
82 | |
83 (defcustom winner-dont-bind-my-keys nil | |
84 "If non-nil: Do not use `winner-mode-map' in Winner mode." | |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
85 :type 'boolean |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
86 :group 'winner) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
87 |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
88 (defcustom winner-ring-size 200 |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
89 "Maximum number of stored window configurations per frame." |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
90 :type 'integer |
20968 | 91 :group 'winner) |
17469 | 92 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
93 |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
94 |
17469 | 95 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
96 ;;;; Saving old configurations (internal variables and subroutines) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
97 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
98 ;; This variable is updated with the current window configuration |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
99 ;; after every command, so that when command make changes in the |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
100 ;; window configuration, the last configuration can be saved. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
101 (defvar winner-currents nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
102 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
103 ;; The current configuration (+ the buffers involved). |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
104 (defsubst winner-conf () |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
105 (list (current-window-configuration) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
106 (loop for w being the windows |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
107 unless (window-minibuffer-p w) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
108 collect (window-buffer w)) )) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
109 ;; (if winner-testvar (incf winner-testvar) ; For debugging purposes |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
110 ;; (setq winner-testvar 0)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
111 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
112 ;; Save current configuration. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
113 ;; (Called by `winner-save-old-configurations' below). |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
114 (defun winner-remember () |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
115 (let ((entry (assq (selected-frame) winner-currents))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
116 (if entry (setcdr entry (winner-conf)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
117 (push (cons (selected-frame) (winner-conf)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
118 winner-currents)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
119 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
120 ;; Consult `winner-currents'. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
121 (defun winner-configuration (&optional frame) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
122 (or (cdr (assq (or frame (selected-frame)) winner-currents)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
123 (letf (((selected-frame) frame)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
124 (winner-conf)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
125 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
126 |
17469 | 127 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
128 ;; This variable contains the window cofiguration rings. |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
129 ;; The key in this alist is the frame. |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
130 (defvar winner-ring-alist nil) |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
131 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
132 ;; Find the right ring. If it does not exist, create one. |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
133 (defsubst winner-ring (frame) |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
134 (or (cdr (assq frame winner-ring-alist)) |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
135 (progn |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
136 (let ((ring (make-ring winner-ring-size))) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
137 (ring-insert ring (winner-configuration frame)) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
138 (push (cons frame ring) winner-ring-alist) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
139 ring)))) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
140 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
141 ;; If the same command is called several times in a row, |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
142 ;; we only save one window configuration. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
143 (defvar winner-last-command nil) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
144 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
145 ;; Frames affected by the previous command. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
146 (defvar winner-last-frames nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
147 |
38334
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
148 |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
149 (defun winner-equal (a b) |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
150 "Check two Winner configurations A and B for equality. |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
151 Winner configurations are of the form (CONFIG BUFFERS), |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
152 where CONFIG is a window configuration and BUFFERS is a list of |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
153 buffers." |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
154 (and (compare-window-configurations (car a) (car b)) |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
155 (equal (cdr a) (cdr b)))) |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
156 |
63281ffd14fd
(winner-equal): Make it a defun. Don't compare Winner
Gerd Moellmann <gerd@gnu.org>
parents:
28071
diff
changeset
|
157 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
158 ;; Save the current window configuration, if it has changed. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
159 ;; Then return frame, else return nil. |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
160 (defun winner-insert-if-new (frame) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
161 (unless (or (memq frame winner-last-frames) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
162 (eq this-command 'winner-redo)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
163 (let ((conf (winner-configuration frame)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
164 (ring (winner-ring frame))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
165 (when (and (not (ring-empty-p ring)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
166 (winner-equal conf (ring-ref ring 0))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
167 (ring-remove ring 0)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
168 (ring-insert ring conf) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
169 (push frame winner-last-frames) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
170 frame))) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
171 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
172 ;; Frames affected by the current command. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
173 (defvar winner-modified-list nil) |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
174 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
175 ;; Called whenever the window configuration changes |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
176 ;; (a `window-configuration-change-hook'). |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
177 (defun winner-change-fun () |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
178 (unless (memq (selected-frame) winner-modified-list) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
179 (push (selected-frame) winner-modified-list))) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
180 |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
181 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
182 ;; For Emacs20 (a `post-command-hook'). |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
183 (defun winner-save-old-configurations () |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
184 (unless (eq this-command winner-last-command) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
185 (setq winner-last-frames nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
186 (setq winner-last-command this-command)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
187 (dolist (frame winner-modified-list) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
188 (winner-insert-if-new frame)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
189 (setq winner-modified-list nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
190 ;; (ir-trace ; For debugging purposes |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
191 ;; "%S" |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
192 ;; (loop with ring = (winner-ring (selected-frame)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
193 ;; for i from 0 to (1- (ring-length ring)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
194 ;; collect (caddr (ring-ref ring i)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
195 (winner-remember)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
196 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
197 ;; For compatibility with other emacsen |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
198 ;; and called by `winner-undo' before "undoing". |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
199 (defun winner-save-unconditionally () |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
200 (unless (eq this-command winner-last-command) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
201 (setq winner-last-frames nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
202 (setq winner-last-command this-command)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
203 (winner-insert-if-new (selected-frame)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
204 (winner-remember)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
205 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
206 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
207 |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
208 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
209 ;;;; Restoring configurations |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
210 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
211 ;; Works almost as `set-window-configuration', |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
212 ;; but doesn't change the contents or the size of the minibuffer. |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
213 (defun winner-set-conf (winconf) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
214 (let ((miniwin (minibuffer-window)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
215 (minisel (window-minibuffer-p (selected-window)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
216 (let ((minibuf (window-buffer miniwin)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
217 (minipoint (window-point miniwin)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
218 (minisize (window-height miniwin))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
219 (set-window-configuration winconf) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
220 (setf (window-buffer miniwin) minibuf |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
221 (window-point miniwin) minipoint) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
222 (when (/= minisize (window-height miniwin)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
223 (letf (((selected-window) miniwin) ) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
224 ;; Clumsy due to cl-macs-limitation |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
225 (setf (window-height) minisize))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
226 (cond |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
227 (minisel (select-window miniwin)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
228 ((window-minibuffer-p (selected-window)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
229 (other-window 1)))))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
230 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
231 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
232 (defvar winner-point-alist nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
233 ;; `set-window-configuration' restores old points and marks. This is |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
234 ;; not what we want, so we make a list of the "real" (i.e. new) points |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
235 ;; and marks before undoing window configurations. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
236 ;; |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
237 ;; Format of entries: (buffer (mark . mark-active) (window . point) ..) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
238 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
239 (defun winner-make-point-alist () |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
240 (letf (((current-buffer))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
241 (loop with alist |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
242 with entry |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
243 for win being the windows |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
244 do (cond |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
245 ((window-minibuffer-p win)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
246 ((setq entry (assq win alist)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
247 ;; Update existing entry |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
248 (push (cons win (window-point win)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
249 (cddr entry))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
250 (t;; Else create new entry |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
251 (push (list (set-buffer (window-buffer win)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
252 (cons (mark t) (winner-active-region)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
253 (cons win (window-point win))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
254 alist))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
255 finally return alist))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
256 |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
257 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
258 (defun winner-get-point (buf win) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
259 ;; Consult (and possibly extend) `winner-point-alist'. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
260 (when (buffer-name buf) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
261 (let ((entry (assq buf winner-point-alist))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
262 (cond |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
263 (entry |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
264 (or (cdr (assq win (cddr entry))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
265 (cdr (assq nil (cddr entry))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
266 (letf (((current-buffer) buf)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
267 (push (cons nil (point)) (cddr entry)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
268 (point)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
269 (t (letf (((current-buffer) buf)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
270 (push (list buf |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
271 (cons (mark t) (winner-active-region)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
272 (cons nil (point))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
273 winner-point-alist) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
274 (point))))))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
275 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
276 ;; Make sure point doesn't end up in the minibuffer and |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
277 ;; delete windows displaying dead buffers. Return nil |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
278 ;; if and only if all the windows should have been deleted. |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
279 ;; Do not move neither points nor marks. |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
280 (defun winner-set (conf) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
281 (let* ((buffers nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
282 (origpoints |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
283 (loop for buf in (cadr conf) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
284 for pos = (winner-get-point buf nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
285 if (and pos (not (memq buf buffers))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
286 do (push buf buffers) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
287 collect pos))) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
288 (winner-set-conf (car conf)) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
289 (let (xwins) ; These windows should be deleted |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
290 (loop for win being the windows |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
291 unless (window-minibuffer-p win) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
292 do (if (pop origpoints) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
293 (setf (window-point win) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
294 ;; Restore point |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
295 (winner-get-point |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
296 (window-buffer win) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
297 win)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
298 (push win xwins))) ; delete this window |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
299 ;; Restore mark |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
300 (letf (((current-buffer))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
301 (loop for buf in buffers |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
302 for entry = (cadr (assq buf winner-point-alist)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
303 do (progn (set-buffer buf) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
304 (set-mark (car entry)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
305 (setf (winner-active-region) (cdr entry))))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
306 ;; Delete windows, whose buffers are dead. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
307 ;; Return t if this is still a possible configuration. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
308 (or (null xwins) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
309 (progn (mapcar 'delete-window (cdr xwins)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
310 (if (one-window-p t) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
311 nil ; No windows left |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
312 (progn (delete-window (car xwins)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
313 t))))))) |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
314 |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
315 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
316 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
317 ;;;; Winner mode (a minor mode) |
17469 | 318 |
20968 | 319 (defcustom winner-mode-hook nil |
320 "Functions to run whenever Winner mode is turned on." | |
321 :type 'hook | |
20969
6007dc30ec3b
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20968
diff
changeset
|
322 :group 'winner) |
17469 | 323 |
20969
6007dc30ec3b
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20968
diff
changeset
|
324 (defcustom winner-mode-leave-hook nil |
20968 | 325 "Functions to run whenever Winner mode is turned off." |
326 :type 'hook | |
20969
6007dc30ec3b
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
20968
diff
changeset
|
327 :group 'winner) |
17469 | 328 |
329 (defvar winner-mode-map nil "Keymap for Winner mode.") | |
17470
c4cd2317fe60
Clean up comments, etc.
Richard M. Stallman <rms@gnu.org>
parents:
17469
diff
changeset
|
330 |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
331 ;; Is `window-configuration-change-hook' working? |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
332 (defun winner-hook-installed-p () |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
333 (save-window-excursion |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
334 (let ((winner-var nil) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
335 (window-configuration-change-hook |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
336 '((lambda () (setq winner-var t))))) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
337 (split-window) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
338 winner-var))) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
339 |
28023
3978c673322b
Fix keywords, autoload cookies. Split
Dave Love <fx@gnu.org>
parents:
25733
diff
changeset
|
340 |
3978c673322b
Fix keywords, autoload cookies. Split
Dave Love <fx@gnu.org>
parents:
25733
diff
changeset
|
341 ;;;###autoload |
17469 | 342 (defun winner-mode (&optional arg) |
343 "Toggle Winner mode. | |
344 With arg, turn Winner mode on if and only if arg is positive." | |
345 (interactive "P") | |
346 (let ((on-p (if arg (> (prefix-numeric-value arg) 0) | |
347 (not winner-mode)))) | |
348 (cond | |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
349 ;; Turn mode on |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
350 (on-p |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
351 (setq winner-mode t) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
352 (cond |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
353 ((winner-hook-installed-p) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
354 (add-hook 'window-configuration-change-hook 'winner-change-fun) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
355 (add-hook 'post-command-hook 'winner-save-old-configurations)) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
356 (t (add-hook 'post-command-hook 'winner-save-unconditionally))) |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
357 (setq winner-modified-list (frame-list)) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
358 (winner-save-old-configurations) |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
359 (run-hooks 'winner-mode-hook)) |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
360 ;; Turn mode off |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
361 (winner-mode |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
362 (setq winner-mode nil) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
363 (remove-hook 'window-configuration-change-hook 'winner-change-fun) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
364 (remove-hook 'post-command-hook 'winner-save-old-configurations) |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
365 (remove-hook 'post-command-hook 'winner-save-unconditionally) |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
366 (run-hooks 'winner-mode-leave-hook))) |
17469 | 367 (force-mode-line-update))) |
368 | |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
369 ;; Inspired by undo (simple.el) |
24590 | 370 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
371 (defvar winner-undo-frame nil) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
372 |
24590 | 373 (defvar winner-pending-undo-ring nil |
374 "The ring currently used by winner undo.") | |
375 (defvar winner-undo-counter nil) | |
376 (defvar winner-undone-data nil) ; There confs have been passed. | |
377 | |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
378 (defun winner-undo () |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
379 "Switch back to an earlier window configuration saved by Winner mode. |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
380 In other words, \"undo\" changes in window configuration." |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
381 (interactive) |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
382 (cond |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
383 ((not winner-mode) (error "Winner mode is turned off")) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
384 (t (unless (and (eq last-command 'winner-undo) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
385 (eq winner-undo-frame (selected-frame))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
386 (winner-save-unconditionally) ; current configuration->stack |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
387 (setq winner-undo-frame (selected-frame)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
388 (setq winner-point-alist (winner-make-point-alist)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
389 (setq winner-pending-undo-ring (winner-ring (selected-frame))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
390 (setq winner-undo-counter 0) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
391 (setq winner-undone-data (list (winner-win-data)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
392 (incf winner-undo-counter) ; starting at 1 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
393 (when (and (winner-undo-this) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
394 (not (window-minibuffer-p (selected-window)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
395 (message "Winner undo (%d / %d)" |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
396 winner-undo-counter |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
397 (1- (ring-length winner-pending-undo-ring))))))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
398 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
399 (defun winner-win-data () |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
400 ;; Essential properties of the windows in the selected frame. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
401 (loop for win being the windows |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
402 unless (window-minibuffer-p win) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
403 collect (list (window-buffer win) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
404 (window-width win) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
405 (window-height win)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
406 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
407 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
408 (defun winner-undo-this () ; The heart of winner undo. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
409 (loop |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
410 (cond |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
411 ((>= winner-undo-counter (ring-length winner-pending-undo-ring)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
412 (message "No further window configuration undo information") |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
413 (return nil)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
414 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
415 ((and ; If possible configuration |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
416 (winner-set (ring-ref winner-pending-undo-ring |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
417 winner-undo-counter)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
418 ;; .. and new configuration |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
419 (let ((data (winner-win-data))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
420 (and (not (member data winner-undone-data)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
421 (push data winner-undone-data)))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
422 (return t)) ; .. then everything is all right. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
423 (t ; Else; discharge it and try another one. |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
424 (ring-remove winner-pending-undo-ring winner-undo-counter))))) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
425 |
17469 | 426 |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
427 (defun winner-redo () ; If you change your mind. |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
428 "Restore a more recent window configuration saved by Winner mode." |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
429 (interactive) |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
430 (cond |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
431 ((eq last-command 'winner-undo) |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
432 (winner-set |
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
433 (ring-remove winner-pending-undo-ring 0)) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
434 (unless (eq (selected-window) (minibuffer-window)) |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
435 (message "Winner undid undo"))) |
19564
8d89cc0f2b42
Many changes by Ivar Rummelhoff.
Richard M. Stallman <rms@gnu.org>
parents:
19502
diff
changeset
|
436 (t (error "Previous command was not a winner-undo")))) |
25639
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
437 |
8d9a53e6b71c
Major changes. Avoid changing point and mark.
Richard M. Stallman <rms@gnu.org>
parents:
24637
diff
changeset
|
438 ;;; To be evaluated when the package is loaded: |
17469 | 439 |
440 (unless winner-mode-map | |
441 (setq winner-mode-map (make-sparse-keymap)) | |
21125
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
442 (define-key winner-mode-map [(control x) left] 'winner-undo) |
d66c9c7b4927
Use list syntax for key definitions.
Richard M. Stallman <rms@gnu.org>
parents:
21016
diff
changeset
|
443 (define-key winner-mode-map [(control x) right] 'winner-redo)) |
17469 | 444 |
445 (unless (or (assq 'winner-mode minor-mode-map-alist) | |
446 winner-dont-bind-my-keys) | |
447 (push (cons 'winner-mode winner-mode-map) | |
448 minor-mode-map-alist)) | |
449 | |
450 (unless (assq 'winner-mode minor-mode-alist) | |
451 (push '(winner-mode " Win") minor-mode-alist)) | |
452 | |
453 (provide 'winner) | |
454 | |
17470
c4cd2317fe60
Clean up comments, etc.
Richard M. Stallman <rms@gnu.org>
parents:
17469
diff
changeset
|
455 ;;; winner.el ends here |