diff options
| author | Thien-Thi Nguyen | 2006-05-23 07:31:45 +0000 |
|---|---|---|
| committer | Thien-Thi Nguyen | 2006-05-23 07:31:45 +0000 |
| commit | f569c26e7918554700a02146bd92a1ee8384ee4a (patch) | |
| tree | a0d096f9cf6d894ec477850d9c5daccfa8e2bcc8 | |
| parent | 1f5df1f78300c861f579886268bc97293857d3fa (diff) | |
| download | emacs-f569c26e7918554700a02146bd92a1ee8384ee4a.tar.gz emacs-f569c26e7918554700a02146bd92a1ee8384ee4a.zip | |
(ewoc-delete): New function.
(ewoc-filter): Use `ewoc-delete'.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/ewoc.el | 45 |
2 files changed, 31 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8249b0d7773..6ad38600eae 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2006-05-23 Thien-Thi Nguyen <ttn@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/ewoc.el (ewoc-delete): New function. | ||
| 4 | (ewoc-filter): Use `ewoc-delete'. | ||
| 5 | |||
| 1 | 2006-05-22 Stefan Monnier <monnier@iro.umontreal.ca> | 6 | 2006-05-22 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 7 | ||
| 3 | * textmodes/bibtex.el (bibtex-format-entry, bibtex-clean-entry): | 8 | * textmodes/bibtex.el (bibtex-format-entry, bibtex-clean-entry): |
diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el index 66bb0842da6..2cb90738072 100644 --- a/lisp/emacs-lisp/ewoc.el +++ b/lisp/emacs-lisp/ewoc.el | |||
| @@ -107,6 +107,7 @@ | |||
| 107 | ;; (defun ewoc-nth (ewoc n) | 107 | ;; (defun ewoc-nth (ewoc n) |
| 108 | ;; (defun ewoc-map (map-function ewoc &rest args) | 108 | ;; (defun ewoc-map (map-function ewoc &rest args) |
| 109 | ;; (defun ewoc-filter (ewoc predicate &rest args) | 109 | ;; (defun ewoc-filter (ewoc predicate &rest args) |
| 110 | ;; (defun ewoc-delete (ewoc &rest nodes) | ||
| 110 | ;; (defun ewoc-locate (ewoc &optional pos guess) | 111 | ;; (defun ewoc-locate (ewoc &optional pos guess) |
| 111 | ;; (defun ewoc-invalidate (ewoc &rest nodes) | 112 | ;; (defun ewoc-invalidate (ewoc &rest nodes) |
| 112 | ;; (defun ewoc-goto-prev (ewoc arg) | 113 | ;; (defun ewoc-goto-prev (ewoc arg) |
| @@ -376,6 +377,27 @@ arguments will be passed to MAP-FUNCTION." | |||
| 376 | (ewoc--refresh-node pp node)) | 377 | (ewoc--refresh-node pp node)) |
| 377 | (setq node (ewoc--node-next dll node)))))) | 378 | (setq node (ewoc--node-next dll node)))))) |
| 378 | 379 | ||
| 380 | (defun ewoc-delete (ewoc &rest nodes) | ||
| 381 | "Delete NODES from EWOC." | ||
| 382 | (ewoc--set-buffer-bind-dll-let* ewoc | ||
| 383 | ((L nil) (R nil)) | ||
| 384 | (dolist (node nodes) | ||
| 385 | ;; If we are about to delete the node pointed at by last-node, | ||
| 386 | ;; set last-node to nil. | ||
| 387 | (if (eq (ewoc--last-node ewoc) node) | ||
| 388 | (setf (ewoc--last-node ewoc) nil)) | ||
| 389 | (delete-region (ewoc--node-start-marker node) | ||
| 390 | (ewoc--node-start-marker (ewoc--node-next dll node))) | ||
| 391 | (set-marker (ewoc--node-start-marker node) nil) | ||
| 392 | (setf L (ewoc--node-left node) | ||
| 393 | R (ewoc--node-right node) | ||
| 394 | ;; Link neighbors to each other. | ||
| 395 | (ewoc--node-right L) R | ||
| 396 | (ewoc--node-left R) L | ||
| 397 | ;; Forget neighbors. | ||
| 398 | (ewoc--node-left node) nil | ||
| 399 | (ewoc--node-right node) nil)))) | ||
| 400 | |||
| 379 | (defun ewoc-filter (ewoc predicate &rest args) | 401 | (defun ewoc-filter (ewoc predicate &rest args) |
| 380 | "Remove all elements in EWOC for which PREDICATE returns nil. | 402 | "Remove all elements in EWOC for which PREDICATE returns nil. |
| 381 | Note that the buffer for EWOC will be current-buffer when PREDICATE | 403 | Note that the buffer for EWOC will be current-buffer when PREDICATE |
| @@ -386,28 +408,13 @@ ARGS are given they will be passed to the PREDICATE." | |||
| 386 | (ewoc--set-buffer-bind-dll-let* ewoc | 408 | (ewoc--set-buffer-bind-dll-let* ewoc |
| 387 | ((node (ewoc--node-nth dll 1)) | 409 | ((node (ewoc--node-nth dll 1)) |
| 388 | (footer (ewoc--footer ewoc)) | 410 | (footer (ewoc--footer ewoc)) |
| 389 | (next nil) | 411 | (goodbye nil) |
| 390 | (L nil) (R nil) | ||
| 391 | (inhibit-read-only t)) | 412 | (inhibit-read-only t)) |
| 392 | (while (not (eq node footer)) | 413 | (while (not (eq node footer)) |
| 393 | (setq next (ewoc--node-next dll node)) | ||
| 394 | (unless (apply predicate (ewoc--node-data node) args) | 414 | (unless (apply predicate (ewoc--node-data node) args) |
| 395 | ;; If we are about to delete the node pointed at by last-node, | 415 | (push node goodbye)) |
| 396 | ;; set last-node to nil. | 416 | (setq node (ewoc--node-next dll node))) |
| 397 | (if (eq (ewoc--last-node ewoc) node) | 417 | (apply 'ewoc-delete ewoc goodbye))) |
| 398 | (setf (ewoc--last-node ewoc) nil)) | ||
| 399 | (delete-region (ewoc--node-start-marker node) | ||
| 400 | (ewoc--node-start-marker (ewoc--node-next dll node))) | ||
| 401 | (set-marker (ewoc--node-start-marker node) nil) | ||
| 402 | (setf L (ewoc--node-left node) | ||
| 403 | R (ewoc--node-right node) | ||
| 404 | ;; Link neighbors to each other. | ||
| 405 | (ewoc--node-right L) R | ||
| 406 | (ewoc--node-left R) L | ||
| 407 | ;; Forget neighbors. | ||
| 408 | (ewoc--node-left node) nil | ||
| 409 | (ewoc--node-right node) nil)) | ||
| 410 | (setq node next)))) | ||
| 411 | 418 | ||
| 412 | (defun ewoc-locate (ewoc &optional pos guess) | 419 | (defun ewoc-locate (ewoc &optional pos guess) |
| 413 | "Return the node that POS (a buffer position) is within. | 420 | "Return the node that POS (a buffer position) is within. |