aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/emacs-lisp/ewoc.el56
2 files changed, 27 insertions, 33 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5fc4d502468..9e2b44df3ee 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -6,6 +6,10 @@
6 6
7 * emacs-lisp/ewoc.el (ewoc-refresh): Compute PP once before looping. 7 * emacs-lisp/ewoc.el (ewoc-refresh): Compute PP once before looping.
8 8
9 (ewoc--node-enter-before, ewoc--create-node): Delete funcs.
10 (ewoc--insert-new-node): New func.
11 Update callers of deleted funcs to use it, instead.
12
92006-05-11 Glenn Morris <rgm@gnu.org> 132006-05-11 Glenn Morris <rgm@gnu.org>
10 14
11 * calendar/calendar.el (diary-show-all-entries): Do not refer to 15 * calendar/calendar.el (diary-show-all-entries): Do not refer to
diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el
index cd1f6d30b42..d64991e5415 100644
--- a/lisp/emacs-lisp/ewoc.el
+++ b/lisp/emacs-lisp/ewoc.el
@@ -144,14 +144,6 @@
144 144
145\(fn NODE CHILD)") 145\(fn NODE CHILD)")
146 146
147(defun ewoc--node-enter-before (node elemnode)
148 "Insert ELEMNODE before NODE in a DLL."
149 (assert (and (null (ewoc--node-left elemnode)) (null (ewoc--node-right elemnode))))
150 (setf (ewoc--node-left elemnode) (ewoc--node-left node))
151 (setf (ewoc--node-right elemnode) node)
152 (setf (ewoc--node-right (ewoc--node-left node)) elemnode)
153 (setf (ewoc--node-left node) elemnode))
154
155(defun ewoc--node-next (dll node) 147(defun ewoc--node-next (dll node)
156 "Return the node after NODE, or nil if NODE is the last node." 148 "Return the node after NODE, or nil if NODE is the last node."
157 (unless (eq (ewoc--node-right node) dll) (ewoc--node-right node))) 149 (unless (eq (ewoc--node-right node) dll) (ewoc--node-right node)))
@@ -213,24 +205,28 @@ BUT if it is the header or the footer in EWOC return nil instead."
213 (eq node (ewoc--footer ewoc))) 205 (eq node (ewoc--footer ewoc)))
214 node)) 206 node))
215 207
216 208(defun ewoc--insert-new-node (node data pretty-printer)
217(defun ewoc--create-node (data pretty-printer pos) 209 "Insert before NODE a new node for DATA, displayed by PRETTY-PRINTER.
218 "Call PRETTY-PRINTER with point set at POS in current buffer. 210Call PRETTY-PRINTER with point at NODE's start, thus pushing back
219Remember the start position. Create a wrapper containing that 211NODE and leaving the new node's start there. Return the new node."
220start position and the element DATA."
221 (save-excursion 212 (save-excursion
222 ;; Remember the position as a number so that it doesn't move 213 (let* ((inhibit-read-only t)
223 ;; when we insert the string. 214 (m (copy-marker (ewoc--node-start-marker node)))
224 (when (markerp pos) (setq pos (marker-position pos))) 215 (pos (marker-position m))
225 (goto-char pos) 216 (elemnode (ewoc--node-create m data)))
226 (let ((inhibit-read-only t)) 217 (goto-char pos)
227 ;; Insert the trailing newline using insert-before-markers 218 ;; Insert the trailing newline using insert-before-markers
228 ;; so that the start position for the next element is updated. 219 ;; so that the start position for the next element is updated.
229 (insert-before-markers ?\n) 220 (insert-before-markers ?\n)
230 ;; Move back, and call the pretty-printer. 221 ;; Move back, and call the pretty-printer.
231 (backward-char 1) 222 (backward-char 1)
232 (funcall pretty-printer data) 223 (funcall pretty-printer data)
233 (ewoc--node-create (copy-marker pos) data)))) 224 (setf (marker-position m) pos
225 (ewoc--node-left elemnode) (ewoc--node-left node)
226 (ewoc--node-right elemnode) node
227 (ewoc--node-right (ewoc--node-left node)) elemnode
228 (ewoc--node-left node) elemnode)
229 elemnode)))
234 230
235(defun ewoc--refresh-node (pp node) 231(defun ewoc--refresh-node (pp node)
236 "Redisplay the element represented by NODE using the pretty-printer PP." 232 "Redisplay the element represented by NODE using the pretty-printer PP."
@@ -270,18 +266,17 @@ be inserted at the bottom of the ewoc."
270 (new-ewoc 266 (new-ewoc
271 (ewoc--create (current-buffer) 267 (ewoc--create (current-buffer)
272 pretty-printer nil nil dll)) 268 pretty-printer nil nil dll))
273 (pos (point))) 269 (pos (point))
270 head foot)
274 (ewoc--set-buffer-bind-dll new-ewoc 271 (ewoc--set-buffer-bind-dll new-ewoc
275 ;; Set default values 272 ;; Set default values
276 (unless header (setq header "")) 273 (unless header (setq header ""))
277 (unless footer (setq footer "")) 274 (unless footer (setq footer ""))
278 (setf (ewoc--node-start-marker dll) (copy-marker pos)) 275 (setf (ewoc--node-start-marker dll) (copy-marker pos)
279 (let ((foot (ewoc--create-node footer 'insert pos)) 276 foot (ewoc--insert-new-node dll footer 'insert)
280 (head (ewoc--create-node header 'insert pos))) 277 head (ewoc--insert-new-node foot header 'insert)
281 (ewoc--node-enter-before (ewoc--node-right dll) head) 278 (ewoc--footer new-ewoc) foot
282 (ewoc--node-enter-before dll foot) 279 (ewoc--header new-ewoc) head))
283 (setf (ewoc--header new-ewoc) head)
284 (setf (ewoc--footer new-ewoc) foot)))
285 ;; Return the ewoc 280 ;; Return the ewoc
286 new-ewoc)) 281 new-ewoc))
287 282
@@ -310,12 +305,7 @@ Return the new node."
310 "Enter a new element DATA before NODE in EWOC. 305 "Enter a new element DATA before NODE in EWOC.
311Return the new node." 306Return the new node."
312 (ewoc--set-buffer-bind-dll ewoc 307 (ewoc--set-buffer-bind-dll ewoc
313 (ewoc--node-enter-before 308 (ewoc--insert-new-node node data (ewoc--pretty-printer ewoc))))
314 node
315 (ewoc--create-node
316 data
317 (ewoc--pretty-printer ewoc)
318 (ewoc--node-start-marker node)))))
319 309
320(defun ewoc-next (ewoc node) 310(defun ewoc-next (ewoc node)
321 "Return the node in EWOC that follows NODE. 311 "Return the node in EWOC that follows NODE.