From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: PATCH: ewoc.el to permit node representation abutment
Date: Mon, 08 May 2006 11:04:15 -0400 [thread overview]
Message-ID: <jwv4q00zidd.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jkvesg9a2i.fsf@glug.org> (Thien-Thi Nguyen's message of "08 May 2006 04:48:05 -0400")
> i've revised the patch (please see below) to handle empty representations.
> this was tested by modifying `cvs-fileinfo-pp' to output empty string for a
> certain hardcoded filename in my local repo, making the empty string
> conditional on a variable and toggling the variable followed by either
> `ewoc-refresh' or `ewoc-invalidate' calls. (this description omits several
> steps for preparing the testing framework, but you get the idea.)
> * emacs-lisp/ewoc.el (ewoc--create-node): Don't insert
> trailing newline. Also, create marker with insertion type t.
> (ewoc--refresh-node): Delete all text from current node's
> start marker to the next one's. Also, make the marker
> "stay put" before calling the pretty-printer, and return it.
> (ewoc--init-stay-put-list, ewoc--reset-marker-types): New funcs.
> (ewoc-create): Use marker insertion type t.
> (ewoc-map): Collect "stay put" markers; reset them when done.
> (ewoc-invalidate): Rewrite.
> (ewoc-refresh): Don't insert newline.
> Collect "stay put" markers; reset them when done.
> (ewoc-set-hf): Reset header and footer markers when done.
> * pcvs-info.el (cvs-fileinfo-pp): Insert trailing newline.
> note that ewoc.el is 1.19 from cvs.
Hmm... now it looks too complex to be installed before Emacs-22.
Can't it be done more simply. Basically just do something like:
[ quality-control: this is guaranteed 100% untested ]
(defun ewoc--refresh-node (pp node)
"Redisplay the element represented by NODE using the pretty-printer PP.
Set NODE's start marker's insertion type to nil and return it."
(save-excursion
(let* ((inhibit-read-only t)
(m (ewoc--node-start-marker node))
(n (ewoc--node-right node)))
;; First, remove the string from the buffer:
(delete-region m (ewoc--node-start-marker n))
;; Calculate and insert the string.
(goto-char m)
;; Temporarily change insertion type of the end marker so it is indeed
;; moved to the end.
(set-marker-insertion-type (ewoc--node-start-marker n) t)
(funcall pp (ewoc--node-data node))
(set-marker-insertion-type (ewoc--node-start-marker n) nil)
;; Since our markers have insertion type nil (i.e. not "insert-before"),
;; all markers that were at position `m' are still at position `m',
;; including the ones for subsequent empty nodes, which we thus have
;; to reseat.
(setq m (ewoc--node-start-marker n))
(while (and (setq n (ewoc--node-right n))
(< (ewoc--node-start-marker n) m))
(set-marker (ewoc--node-start-marker n) m))))))
-- Stefan
next prev parent reply other threads:[~2006-05-08 15:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-05 12:03 PATCH: ewoc.el to permit node representation abutment Thien-Thi Nguyen
2006-05-05 13:20 ` Stefan Monnier
2006-05-05 21:43 ` ttn
2006-05-08 8:48 ` Thien-Thi Nguyen
2006-05-08 15:04 ` Stefan Monnier [this message]
2006-05-13 5:08 ` 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=jwv4q00zidd.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--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).