You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- TODO: add internal/point.lisp package documentation about points and their :kind types -->
103
103
104
-
You may use these functions:
104
+
`point` is an object that points to the position of some text in the buffer.
105
105
106
-
```
107
-
(current-point)
108
-
(copy-point)
109
-
(point=) ;; and other comparison functions
110
-
(point-max)
111
-
(move-point point new-point)
112
-
```
113
-
114
-
The macro `(save-excursion …)` will run its body and preserve the
115
-
point position from before the macro was called.
106
+
This is its definition:
116
107
117
108
```lisp
118
-
(save-excursion
119
-
(move-point (current-point) point)
120
-
(prompt-for-string
121
-
"Say hi: "))
109
+
(defclass point ()
110
+
((buffer
111
+
:reader point-buffer
112
+
:type buffer)
113
+
(linum
114
+
:accessor point-linum
115
+
:type fixnum)
116
+
(line
117
+
:accessor point-line
118
+
:type line)
119
+
(charpos
120
+
:accessor point-charpos
121
+
:type fixnum)
122
+
(kind
123
+
:reader point-kind
124
+
:type point-kind)))
122
125
```
123
126
127
+
It has a `buffer` slot, a `line` number, and `charpos` is an offset from the beginning of the line, starting at zero.
128
+
129
+
`point` has a `kind` type. This is important as it defines how the
130
+
text at point moves or not when you insert content before it.
131
+
132
+
If you insert content at the point position, with `:right-inserting` the original position is unchanged, and with `:left-inserting` the position is adjusted by the length of your edit.
133
+
134
+
When `kind` is `:left-inserting`, and if you insert content *before* the point, then the point position is adjusted by the length of your edit.
135
+
136
+
When `kind` is `:temporary`, the point is used for temporary reads. The
137
+
overhead on creation and deletion is low, and there is no need to
138
+
explicitly delete the point. If you edit the buffer before the
139
+
position, the `point` cannot be used correctly any more.
140
+
141
+
When using `:left-inserting` or `:right-inserting`, you must explicitly delete the point after use with `delete-point`. For this reason, you should use the macro `with-point`, which automatically deletes it.
142
+
143
+
Use `with-points` to define points to use in the macro body, to ensure they are deleted.
144
+
145
+
Use `save-excursion` to move around the given point in the macro body, and come back to it once done.
0 commit comments