comparison lisp/emacs-lisp/ewoc.el @ 32487:d5d7a3fbf10c

(ewoc-location): New function. (ewoc-enter-after, ewoc-enter-before): Document return value.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 15 Oct 2000 05:16:36 +0000
parents 3a1ff1caafe2
children c12aa82daf99
comparison
equal deleted inserted replaced
32486:8177ece14fdd 32487:d5d7a3fbf10c
29 29
30 ;; Ewoc Was Once Cookie 30 ;; Ewoc Was Once Cookie
31 ;; But now it's Emacs' Widget for Object Collections 31 ;; But now it's Emacs' Widget for Object Collections
32 32
33 ;; As the name implies this derives from the `cookie' package (part 33 ;; As the name implies this derives from the `cookie' package (part
34 ;; of Elib). The changes are mostly superficial: 34 ;; of Elib). The changes are pervasive though mostly superficial:
35 35
36 ;; - uses CL (and its `defstruct' 36 ;; - uses CL (and its `defstruct')
37 ;; - separate from Elib. 37 ;; - separate from Elib.
38 ;; - uses its own version of a doubly-linked list which allows us 38 ;; - uses its own version of a doubly-linked list which allows us
39 ;; to merge the elib-wrapper and the elib-node structures into ewoc-node 39 ;; to merge the elib-wrapper and the elib-node structures into ewoc-node
40 ;; - dropping functions not used by PCL-CVS (the only client of ewoc at the 40 ;; - dropping functions not used by PCL-CVS (the only client of ewoc at the
41 ;; time of writing) 41 ;; time of writing)
72 ;; Ewoc does not affect the mode of the buffer in any way. It 72 ;; Ewoc does not affect the mode of the buffer in any way. It
73 ;; merely makes it easy to connect an underlying data representation 73 ;; merely makes it easy to connect an underlying data representation
74 ;; to the buffer contents. 74 ;; to the buffer contents.
75 ;; 75 ;;
76 ;; A `ewoc--node' is an object that contains one element. There are 76 ;; A `ewoc--node' is an object that contains one element. There are
77 ;; functions in this package that given an ewoc--node extracts the data, or 77 ;; functions in this package that given an ewoc--node extract the data, or
78 ;; gives the next or previous ewoc--node. (All ewoc--nodes are linked together 78 ;; give the next or previous ewoc--node. (All ewoc--nodes are linked together
79 ;; in a doubly linked list. The 'previous' ewoc--node is the one that appears 79 ;; in a doubly linked list. The `previous' ewoc--node is the one that appears
80 ;; before the other in the buffer.) You should not do anything with 80 ;; before the other in the buffer.) You should not do anything with
81 ;; an ewoc--node except pass it to the functions in this package. 81 ;; an ewoc--node except pass it to the functions in this package.
82 ;; 82 ;;
83 ;; An ewoc is a very dynamic thing. You can easily add or delete elements. 83 ;; An ewoc is a very dynamic thing. You can easily add or delete elements.
84 ;; You can apply a function to all elements in an ewoc, etc, etc. 84 ;; You can apply a function to all elements in an ewoc, etc, etc.
93 ;; In the mean time `grep '^(.*ewoc-[^-]' emacs-lisp/ewoc.el' can help 93 ;; In the mean time `grep '^(.*ewoc-[^-]' emacs-lisp/ewoc.el' can help
94 ;; you find all the exported functions: 94 ;; you find all the exported functions:
95 ;; 95 ;;
96 ;; (defun ewoc-create (pretty-printer &optional header footer) 96 ;; (defun ewoc-create (pretty-printer &optional header footer)
97 ;; (defalias 'ewoc-data 'ewoc--node-data) 97 ;; (defalias 'ewoc-data 'ewoc--node-data)
98 ;; (defun ewoc-location (node)
98 ;; (defun ewoc-enter-first (ewoc data) 99 ;; (defun ewoc-enter-first (ewoc data)
99 ;; (defun ewoc-enter-last (ewoc data) 100 ;; (defun ewoc-enter-last (ewoc data)
100 ;; (defun ewoc-enter-after (ewoc node data) 101 ;; (defun ewoc-enter-after (ewoc node data)
101 ;; (defun ewoc-enter-before (ewoc node data) 102 ;; (defun ewoc-enter-before (ewoc node data)
102 ;; (defun ewoc-next (ewoc node) 103 ;; (defun ewoc-next (ewoc node)
193 (if (< n 0) (setq n (- -1 n))) 194 (if (< n 0) (setq n (- -1 n)))
194 (while (and (not (eq dll node)) (> n 0)) 195 (while (and (not (eq dll node)) (> n 0))
195 (setq node (ewoc--node-branch node branch)) 196 (setq node (ewoc--node-branch node branch))
196 (setq n (1- n))) 197 (setq n (1- n)))
197 (unless (eq dll node) node))) 198 (unless (eq dll node) node)))
199
200 (defun ewoc-location (node)
201 "Return the start location of NODE."
202 (ewoc--node-start-marker node))
198 203
199 204
200 ;;; The ewoc data type 205 ;;; The ewoc data type
201 206
202 (defstruct (ewoc 207 (defstruct (ewoc
334 (ewoc--set-buffer-bind-dll ewoc 339 (ewoc--set-buffer-bind-dll ewoc
335 (ewoc-enter-before ewoc (ewoc--node-nth dll -1) data))) 340 (ewoc-enter-before ewoc (ewoc--node-nth dll -1) data)))
336 341
337 342
338 (defun ewoc-enter-after (ewoc node data) 343 (defun ewoc-enter-after (ewoc node data)
339 "Enter a new element DATA after NODE in EWOC." 344 "Enter a new element DATA after NODE in EWOC.
345 Returns the new NODE."
340 (ewoc--set-buffer-bind-dll ewoc 346 (ewoc--set-buffer-bind-dll ewoc
341 (ewoc-enter-before ewoc (ewoc--node-next dll node) data))) 347 (ewoc-enter-before ewoc (ewoc--node-next dll node) data)))
342 348
343 (defun ewoc-enter-before (ewoc node data) 349 (defun ewoc-enter-before (ewoc node data)
344 "Enter a new element DATA before NODE in EWOC." 350 "Enter a new element DATA before NODE in EWOC.
351 Returns the new NODE."
345 (ewoc--set-buffer-bind-dll ewoc 352 (ewoc--set-buffer-bind-dll ewoc
346 (ewoc--node-enter-before 353 (ewoc--node-enter-before
347 node 354 node
348 (ewoc--create-node 355 (ewoc--create-node
349 data 356 data