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