annotate tests/automated/extent-tests.el @ 5940:c608d4b0b75e cygwin64 tip

rescue lost branch from 64bit.backup
author Henry Thompson <ht@markup.co.uk>
date Thu, 16 Dec 2021 18:48:58 +0000
parents b79e1e02bf01
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
1 ;; Copyright (C) 2001 Free Software Foundation, Inc.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
2
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
3 ;; Author: Hrvoje Niksic <hniksic@xemacs.org>
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
4 ;; Maintainer: Hrvoje Niksic <hniksic@xemacs.org>
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
5 ;; Created: 1999
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
6 ;; Keywords: tests
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
7
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
8 ;; This file is part of XEmacs.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
9
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
10 ;; XEmacs is free software: you can redistribute it and/or modify it
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
11 ;; under the terms of the GNU General Public License as published by the
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
12 ;; Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
13 ;; option) any later version.
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
14
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
16 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
17 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
18 ;; for more details.
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
19
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5136
diff changeset
21 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
22
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
23 ;;; Synched up with: Not in FSF.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
24
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
25 ;;; Commentary:
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
26
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
27 ;; Test extents operations.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
28 ;; See test-harness.el for instructions on how to run these tests.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
29
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
30 (eval-when-compile
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
31 (condition-case nil
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
32 (require 'test-harness)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
33 (file-error
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
34 (push "." load-path)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
35 (when (and (boundp 'load-file-name) (stringp load-file-name))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
36 (push (file-name-directory load-file-name) load-path))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
37 (require 'test-harness))))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
38
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
39
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
40 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
41 ;; Creating and attaching.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
42 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
43
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
44 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
45 (let ((extent (make-extent nil nil))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
46 (string "somecoolstring"))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
47
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
48 ;; Detached extent.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
49 (Assert (extent-detached-p extent))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
50
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
51 ;; Put it in a buffer.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
52 (set-extent-endpoints extent 1 1 (current-buffer))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
53 (Assert (eq (extent-object extent) (current-buffer)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
54
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
55 ;; And then into another buffer.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
56 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
57 (set-extent-endpoints extent 1 1 (current-buffer))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
58 (Assert (eq (extent-object extent) (current-buffer))))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
59
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
60 ;; Now that the buffer doesn't exist, extent should be detached
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
61 ;; again.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
62 (Assert (extent-detached-p extent))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
63
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
64 ;; This line crashes XEmacs 21.2.46 and prior.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
65 (set-extent-endpoints extent 1 (length string) string)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
66 (Assert (eq (extent-object extent) string))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
67 )
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
68
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
69 (let ((extent (make-extent 1 1)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
70 ;; By default, extent should be closed-open
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
71 (Assert (eq (get extent 'start-closed) t))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
72 (Assert (eq (get extent 'start-open) nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
73 (Assert (eq (get extent 'end-open) t))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
74 (Assert (eq (get extent 'end-closed) nil))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
75
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
76 ;; Make it closed-closed.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
77 (set-extent-property extent 'end-closed t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
78
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
79 (Assert (eq (get extent 'start-closed) t))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
80 (Assert (eq (get extent 'start-open) nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
81 (Assert (eq (get extent 'end-open) nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
82 (Assert (eq (get extent 'end-closed) t))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
83
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
84 ;; open-closed
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
85 (set-extent-property extent 'start-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
86
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
87 (Assert (eq (get extent 'start-closed) nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
88 (Assert (eq (get extent 'start-open) t))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
89 (Assert (eq (get extent 'end-open) nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
90 (Assert (eq (get extent 'end-closed) t))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
91
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
92 ;; open-open
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
93 (set-extent-property extent 'end-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
94
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
95 (Assert (eq (get extent 'start-closed) nil))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
96 (Assert (eq (get extent 'start-open) t))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
97 (Assert (eq (get extent 'end-open) t))
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
98 (Assert (eq (get extent 'end-closed) nil)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
99
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
100 )
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
101
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
102 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
103 ;; Insertion behavior.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
104 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
105
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
106 (defun et-range (extent)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
107 "List (START-POSITION END-POSITION) of EXTENT."
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
108 (list (extent-start-position extent)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
109 (extent-end-position extent)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
110
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
111 (defun et-insert-at (string position)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
112 "Insert STRING at POSITION in the current buffer."
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
113 (save-excursion
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
114 (goto-char position)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
115 (insert string)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
116
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
117 ;; Test insertion at the beginning, middle, and end of the extent.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
118
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
119 ;; closed-open
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
120
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
121 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
122 (insert "###eee###")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
123 (let ((e (make-extent 4 7)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
124 ;; current state: "###[eee)###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
125 ;; 123 456 789
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
126 (Assert (equal (et-range e) '(4 7)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
127
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
128 (et-insert-at "xxx" 4)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
129
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
130 ;; current state: "###[xxxeee)###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
131 ;; 123 456789 012
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
132 (Assert (equal (et-range e) '(4 10)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
133
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
134 (et-insert-at "yyy" 7)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
135
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
136 ;; current state: "###[xxxyyyeee)###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
137 ;; 123 456789012 345
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
138 (Assert (equal (et-range e) '(4 13)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
139
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
140 (et-insert-at "zzz" 13)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
141
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
142 ;; current state: "###[xxxyyyeee)zzz###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
143 ;; 123 456789012 345678
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
144 (Assert (equal (et-range e) '(4 13)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
145 ))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
146
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
147 ;; closed-closed
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
148
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
149 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
150 (insert "###eee###")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
151 (let ((e (make-extent 4 7)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
152 (put e 'end-closed t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
153
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
154 ;; current state: "###[eee]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
155 ;; 123 456 789
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
156 (Assert (equal (et-range e) '(4 7)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
157
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
158 (et-insert-at "xxx" 4)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
159
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
160 ;; current state: "###[xxxeee]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
161 ;; 123 456789 012
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
162 (Assert (equal (et-range e) '(4 10)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
163
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
164 (et-insert-at "yyy" 7)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
165
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
166 ;; current state: "###[xxxyyyeee]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
167 ;; 123 456789012 345
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
168 (Assert (equal (et-range e) '(4 13)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
169
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
170 (et-insert-at "zzz" 13)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
171
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
172 ;; current state: "###[xxxyyyeeezzz]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
173 ;; 123 456789012345 678
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
174 (Assert (equal (et-range e) '(4 16)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
175 ))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
176
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
177 ;; open-closed
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
178
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
179 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
180 (insert "###eee###")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
181 (let ((e (make-extent 4 7)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
182 (put e 'start-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
183 (put e 'end-closed t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
184
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
185 ;; current state: "###(eee]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
186 ;; 123 456 789
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
187 (Assert (equal (et-range e) '(4 7)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
188
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
189 (et-insert-at "xxx" 4)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
190
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
191 ;; current state: "###xxx(eee]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
192 ;; 123456 789 012
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
193 (Assert (equal (et-range e) '(7 10)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
194
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
195 (et-insert-at "yyy" 8)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
196
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
197 ;; current state: "###xxx(eyyyee]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
198 ;; 123456 789012 345
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
199 (Assert (equal (et-range e) '(7 13)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
200
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
201 (et-insert-at "zzz" 13)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
202
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
203 ;; current state: "###xxx(eyyyeezzz]###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
204 ;; 123456 789012345 678
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
205 (Assert (equal (et-range e) '(7 16)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
206 ))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
207
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
208 ;; open-open
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
209
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
210 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
211 (insert "###eee###")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
212 (let ((e (make-extent 4 7)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
213 (put e 'start-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
214
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
215 ;; current state: "###(eee)###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
216 ;; 123 456 789
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
217 (Assert (equal (et-range e) '(4 7)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
218
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
219 (et-insert-at "xxx" 4)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
220
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
221 ;; current state: "###xxx(eee)###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
222 ;; 123456 789 012
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
223 (Assert (equal (et-range e) '(7 10)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
224
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
225 (et-insert-at "yyy" 8)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
226
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
227 ;; current state: "###xxx(eyyyee)###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
228 ;; 123456 789012 345
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
229 (Assert (equal (et-range e) '(7 13)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
230
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
231 (et-insert-at "zzz" 13)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
232
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
233 ;; current state: "###xxx(eyyyee)zzz###"
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
234 ;; 123456 789012 345678
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
235 (Assert (equal (et-range e) '(7 13)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
236 ))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
237
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
238
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
239 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
240 ;; Deletion behavior.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
241 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
242
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
243 (dolist (props '((start-closed t end-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
244 (start-closed t end-open nil)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
245 (start-closed nil end-open nil)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
246 (start-closed nil end-open t)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
247 ;; Deletion needs to behave the same regardless of the open-ness of
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
248 ;; the boundaries.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
249
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
250 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
251 (insert "xxxxxxxxxx")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
252 (let ((e (make-extent 3 9)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
253 (set-extent-properties e props)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
254
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
255 ;; current state: xx[xxxxxx]xx
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
256 ;; 12 345678 90
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
257 (Assert (equal (et-range e) '(3 9)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
258
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
259 (delete-region 1 2)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
260
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
261 ;; current state: x[xxxxxx]xx
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
262 ;; 1 234567 89
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
263 (Assert (equal (et-range e) '(2 8)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
264
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
265 (delete-region 2 4)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
266
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
267 ;; current state: x[xxxx]xx
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
268 ;; 1 2345 67
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
269 (Assert (equal (et-range e) '(2 6)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
270
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
271 (delete-region 1 3)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
272
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
273 ;; current state: [xxx]xx
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
274 ;; 123 45
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
275 (Assert (equal (et-range e) '(1 4)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
276
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
277 (delete-region 3 5)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
278
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
279 ;; current state: [xx]x
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
280 ;; 12 3
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
281 (Assert (equal (et-range e) '(1 3)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
282
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
283 )))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
284
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
285 ;;; #### Should have a test for read-only-ness and insertion and
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
286 ;;; deletion!
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
287
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
288 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
289 ;; `detachable' property
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
290 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
291
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
292 (dolist (props '((start-closed t end-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
293 (start-closed t end-open nil)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
294 (start-closed nil end-open nil)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
295 (start-closed nil end-open t)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
296 ;; `detachable' shouldn't relate to region properties, hence the
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
297 ;; loop.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
298 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
299 (insert "###eee###")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
300 (let ((e (make-extent 4 7)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
301 (set-extent-properties e props)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
302 (Assert (get e 'detachable))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
303
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
304 (Assert (not (extent-detached-p e)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
305
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
306 (delete-region 4 5)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
307 ;; ###ee### (not detached yet)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
308 (Assert (not (extent-detached-p e)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
309
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
310 (delete-region 4 6)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
311 ;; ###### (should be detached now)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
312 (Assert (extent-detached-p e))))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
313
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
314 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
315 (insert "###eee###")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
316 (let ((e (make-extent 4 7)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
317 (set-extent-properties e props)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
318 (put e 'detachable nil)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
319 (Assert (not (get e 'detachable)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
320
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
321 (Assert (not (extent-detached-p e)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
322
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
323 (delete-region 4 5)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
324 ;; ###ee###
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
325 (Assert (not (extent-detached-p e)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
326
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
327 (delete-region 4 6)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
328 ;; ###[]###
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
329 (Assert (not (extent-detached-p e)))
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
330 (Assert (equal (et-range e) '(4 4)))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
331 ))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
332 )
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
333
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
334
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
335 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
336 ;; Zero-length extents.
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
337 ;;-----------------------------------------------------
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
338
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
339 ;; closed-open (should stay put)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
340 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
341 (insert "######")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
342 (let ((e (make-extent 4 4)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
343 (et-insert-at "foo" 4)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
344 (Assert (equal (et-range e) '(4 4)))))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
345
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
346 ;; open-closed (should move)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
347 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
348 (insert "######")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
349 (let ((e (make-extent 4 4)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
350 (put e 'start-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
351 (put e 'end-closed t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
352 (et-insert-at "foo" 4)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
353 (Assert (equal (et-range e) '(7 7)))))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
354
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
355 ;; closed-closed (should extend)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
356 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
357 (insert "######")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
358 (let ((e (make-extent 4 4)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
359 (put e 'end-closed t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
360 (et-insert-at "foo" 4)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
361 (Assert (equal (et-range e) '(4 7)))))
468
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
362
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
363 ;; open-open (illegal; forced to behave like closed-open)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
364 (with-temp-buffer
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
365 (insert "######")
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
366 (let ((e (make-extent 4 4)))
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
367 (put e 'start-open t)
20ae8821c23d [xemacs-hg @ 2001-04-13 09:11:17 by michaels]
michaels
parents:
diff changeset
368 (et-insert-at "foo" 4)
5136
0f66906b6e37 Undo Assert-equal, Assert=, etc.; make `Assert' handle this automatically
Ben Wing <ben@xemacs.org>
parents: 4855
diff changeset
369 (Assert (equal (et-range e) '(4 4)))))
5803
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
370
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
371 ;;-----------------------------------------------------
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
372 ;; Extents and the minibuffer.
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
373 ;;-----------------------------------------------------
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
374
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
375 (let* ((string (copy-sequence "Der Hoelle Rache kocht in meinem Herzen"))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
376 (e (make-extent (search "Rache" string) (search "kocht" string)
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
377 string))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
378 (ee (make-extent (search "meinem" string) (search "Herzen" string)
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
379 string))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
380 (property-name '#:secret-token)
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
381 event list)
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
382 (setf (extent-property e 'duplicable) t
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
383 (extent-property e property-name) t
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
384 (extent-property ee 'duplicable) nil) ;; Actually the default.
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
385 (block enough
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
386 (enqueue-eval-event #'(lambda (ignore) (return-from enough)) nil)
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
387 ;; Silence prompt on TTY. Maybe we shouldn't be doing this.
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
388 (flet ((send-string-to-terminal (&rest ignore)))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
389 (while (setq event (next-event event string))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
390 (dispatch-event event))))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
391 (setq list (extent-list (get-buffer " *Echo Area*")))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
392 (Assert list "checking extent info was preserved in #'next-event")
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
393 (Assert (eql 1 (length list)) "checking only one extent was preserved")
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
394 (Assert (eql t (get (car list) property-name))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
395 "checking it was our duplicable extent that was preserved"))
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
396
b79e1e02bf01 Preserve extent information in the command builder code.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
397