[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PATCH: ewoc.el to permit node representation abutment
From: |
Stefan Monnier |
Subject: |
Re: PATCH: ewoc.el to permit node representation abutment |
Date: |
Mon, 08 May 2006 11:04:15 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
> 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