unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: Where is ewoc--node-delete
Date: 21 May 2006 04:38:03 -0400	[thread overview]
Message-ID: <jkmzdbai38.fsf@glug.org> (raw)
In-Reply-To: <87ves0fr0k.fsf@utanet.at>

Stefan Reichör <stefan@xsteve.at> writes:

> I think the ewoc-delete-node is missing.  One could
> use the ewoc-filter trick above, but it is not the
> obvious way to delete a node.
> 
> So please (re)add ewoc-delete-node.

i think it is better to avoid introducing "ewoc-delete-node"
for now, if we can.  can you use the `ewoc-filter' (below),
instead?  here is an "ewoc-delete-node" implementation
that uses it:

(defun ewoc-delete-node (ewoc node)
  (ewoc-filter ewoc t node))

thi


_____________________________________________________
(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
is called.  PREDICATE must restore the current buffer before it returns
if it changes it.
The PREDICATE is called with the element as its first argument.  If any
ARGS are given they will be passed to the PREDICATE.
As a special case, if PREDICATE is t, ARGS specifies nodes to be
deleted unconditionally."
  (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))
    (cond ((eq t predicate)
           (setq goodbye args))
          (t (while (not (eq node footer))
               (setq next (ewoc--node-next dll node))
               (unless (apply predicate (ewoc--node-data node) args)
                 (push node goodbye))
               (setq node next))))
    (dolist (node goodbye)
      ;; 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))))

  reply	other threads:[~2006-05-21  8:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-19  9:50 Where is ewoc--node-delete Stefan Reichör
2006-05-19 22:22 ` Thien-Thi Nguyen
2006-05-20 19:14   ` Stefan Reichör
2006-05-21  8:38     ` Thien-Thi Nguyen [this message]
2006-05-21 11:33       ` Stefan Monnier
2006-05-21 11:36         ` David Kastrup
2006-05-21 13:05           ` Stefan Monnier
2006-05-21 14:29             ` Thien-Thi Nguyen
2006-05-21 21:55               ` Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jkmzdbai38.fsf@glug.org \
    --to=ttn@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).