summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/ewoc.el
diff options
context:
space:
mode:
authorKaroly Lorentey <lorentey@elte.hu>2006-05-24 09:13:31 +0000
committerKaroly Lorentey <lorentey@elte.hu>2006-05-24 09:13:31 +0000
commit40a1b46245c1a8786324f5a06d6cb8d4bd9d5b74 (patch)
treef45020695e190f511f4faf4dd3ed144059f298c0 /lisp/emacs-lisp/ewoc.el
parentdbe9f5ba9648890dc34f4836a49fde766b21ce74 (diff)
parent4ea5193b9cc5c577127ca6c89ecfaad819398d3b (diff)
downloademacs-40a1b46245c1a8786324f5a06d6cb8d4bd9d5b74.tar.gz
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-289 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-290 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-291 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-292 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-293 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-567
Diffstat (limited to 'lisp/emacs-lisp/ewoc.el')
-rw-r--r--lisp/emacs-lisp/ewoc.el52
1 files changed, 32 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el
index 7742de944cb..2cb90738072 100644
--- a/lisp/emacs-lisp/ewoc.el
+++ b/lisp/emacs-lisp/ewoc.el
@@ -96,6 +96,7 @@
;;
;; (defun ewoc-create (pretty-printer &optional header footer)
;; (defalias 'ewoc-data 'ewoc--node-data)
+;; (defun ewoc-set-data (node data)
;; (defun ewoc-location (node)
;; (defun ewoc-enter-first (ewoc data)
;; (defun ewoc-enter-last (ewoc data)
@@ -106,6 +107,7 @@
;; (defun ewoc-nth (ewoc n)
;; (defun ewoc-map (map-function ewoc &rest args)
;; (defun ewoc-filter (ewoc predicate &rest args)
+;; (defun ewoc-delete (ewoc &rest nodes)
;; (defun ewoc-locate (ewoc &optional pos guess)
;; (defun ewoc-invalidate (ewoc &rest nodes)
;; (defun ewoc-goto-prev (ewoc arg)
@@ -255,7 +257,7 @@ NODE and leaving the new node's start there. Return the new node."
;;; ===========================================================================
;;; Public members of the Ewoc package
-
+;;;###autoload
(defun ewoc-create (pretty-printer &optional header footer)
"Create an empty ewoc.
@@ -296,6 +298,10 @@ respectively, of the ewoc."
\(fn NODE)")
+(defun ewoc-set-data (node data)
+ "Set NODE to encapsulate DATA."
+ (setf (ewoc--node-data node) data))
+
(defun ewoc-enter-first (ewoc data)
"Enter DATA first in EWOC.
Return the new node."
@@ -371,6 +377,27 @@ arguments will be passed to MAP-FUNCTION."
(ewoc--refresh-node pp node))
(setq node (ewoc--node-next dll node))))))
+(defun ewoc-delete (ewoc &rest nodes)
+ "Delete NODES from EWOC."
+ (ewoc--set-buffer-bind-dll-let* ewoc
+ ((L nil) (R nil))
+ (dolist (node nodes)
+ ;; If we are about to delete the node pointed at by last-node,
+ ;; set last-node to nil.
+ (if (eq (ewoc--last-node ewoc) node)
+ (setf (ewoc--last-node ewoc) nil))
+ (delete-region (ewoc--node-start-marker node)
+ (ewoc--node-start-marker (ewoc--node-next dll node)))
+ (set-marker (ewoc--node-start-marker node) nil)
+ (setf L (ewoc--node-left node)
+ R (ewoc--node-right node)
+ ;; Link neighbors to each other.
+ (ewoc--node-right L) R
+ (ewoc--node-left R) L
+ ;; Forget neighbors.
+ (ewoc--node-left node) nil
+ (ewoc--node-right node) nil))))
+
(defun ewoc-filter (ewoc predicate &rest args)
"Remove all elements in EWOC for which PREDICATE returns nil.
Note that the buffer for EWOC will be current-buffer when PREDICATE
@@ -381,28 +408,13 @@ ARGS are given they will be passed to the PREDICATE."
(ewoc--set-buffer-bind-dll-let* ewoc
((node (ewoc--node-nth dll 1))
(footer (ewoc--footer ewoc))
- (next nil)
- (L nil) (R nil)
+ (goodbye nil)
(inhibit-read-only t))
(while (not (eq node footer))
- (setq next (ewoc--node-next dll node))
(unless (apply predicate (ewoc--node-data node) args)
- ;; If we are about to delete the node pointed at by last-node,
- ;; set last-node to nil.
- (if (eq (ewoc--last-node ewoc) node)
- (setf (ewoc--last-node ewoc) nil))
- (delete-region (ewoc--node-start-marker node)
- (ewoc--node-start-marker (ewoc--node-next dll node)))
- (set-marker (ewoc--node-start-marker node) nil)
- (setf L (ewoc--node-left node)
- R (ewoc--node-right node)
- ;; Link neighbors to each other.
- (ewoc--node-right L) R
- (ewoc--node-left R) L
- ;; Forget neighbors.
- (ewoc--node-left node) nil
- (ewoc--node-right node) nil))
- (setq node next))))
+ (push node goodbye))
+ (setq node (ewoc--node-next dll node)))
+ (apply 'ewoc-delete ewoc goodbye)))
(defun ewoc-locate (ewoc &optional pos guess)
"Return the node that POS (a buffer position) is within.