From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: PATCH: ewoc.el to permit node representation abutment Date: 13 May 2006 01:08:03 -0400 Message-ID: References: <8764kkty67.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1147496915 17737 80.91.229.2 (13 May 2006 05:08:35 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 13 May 2006 05:08:35 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 13 07:08:32 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FemMf-0004nC-Au for ged-emacs-devel@m.gmane.org; Sat, 13 May 2006 07:08:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FemMe-0004HD-Lw for ged-emacs-devel@m.gmane.org; Sat, 13 May 2006 01:08:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FemMH-0004Cz-Ni for emacs-devel@gnu.org; Sat, 13 May 2006 01:08:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FemMG-0004A7-GA for emacs-devel@gnu.org; Sat, 13 May 2006 01:08:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FemMG-00049Y-9I for emacs-devel@gnu.org; Sat, 13 May 2006 01:08:04 -0400 Original-Received: from [67.59.132.6] (helo=mail.agora-net.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FemO9-0004MH-BP for emacs-devel@gnu.org; Sat, 13 May 2006 01:10:01 -0400 Original-Received: from ttn by mail.agora-net.com with local (Exim 4.50) id 1FemMF-0000wU-8F for emacs-devel@gnu.org; Sat, 13 May 2006 01:08:03 -0400 Original-To: emacs-devel@gnu.org In-Reply-To: Original-Lines: 244 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:54372 Archived-At: Stefan Monnier writes: > Hmm... now it looks too complex to be installed before Emacs-22. yeah, looks like toggling marker insertion type did not prove to be so clean in practice. i've installed a few (hopefully uncontroversial) implementation touch-ups to ewoc.el (now at cvs revision 1.23) and have prepared the following patch against it for review. this one differs from the previous two in that pcvs.el is also involved. (it's omission before shows a testing methodology bug, argh...) as before, changes to pcvs*.el are to preserve "look and feel" from the user's perspective. here is a suitable ChangeLog entry: * emacs-lisp/ewoc.el (ewoc--adjust): New func. (ewoc--insert-new-node): Don't insert trailing newline. Instead, adjust succesor nodes' start markers. (ewoc--refresh-node): Delete all text from current node's start marker to the next one's; adjust successor nodes' start markers. (ewoc--create): Doc fix. (ewoc--refresh): Don't insert newline. (ewoc--set-hf): Use `ewoc--set-buffer-bind-dll-let*'. * pcvs.el (cvs-make-cvs-buffer): Specify extra newline for ewoc's header and footer. (cvs-update-header): Update initial header recognition. Append newline to final header and footer values. * pcvs-info.el (cvs-fileinfo-pp): Insert trailing newline. i will be off net for a few days but will be back to address comments and hopefully wrap things up early next week. thi __________________________________________________________________ *** emacs-lisp/ewoc.el Fri May 12 13:36:31 2006 --- emacs-lisp/ewoc.el.NEW Sat May 13 06:11:24 2006 *************** (defsubst ewoc--filter-hf-nodes (ewoc no *** 205,210 **** --- 205,226 ---- (eq node (ewoc--footer ewoc))) node)) + (defun ewoc--adjust (beg end node) + ;; "Manually reseat" markers for NODE and its successors (including footer + ;; and dll), in the case where they originally shared start position with + ;; BEG, to END. BEG and END are buffer positions describing NODE's left + ;; neighbor. This operation is functionally equivalent to temporarily + ;; setting these nodes' markers' insertion type to t around the pretty-print + ;; call that precedes the call to `ewoc-adjust', and then changing them back + ;; to nil. + (when (< beg end) + (let (m) + (while (and (= beg (setq m (ewoc--node-start-marker node))) + (progn + (set-marker m end) + (not (eq dll node)))) + (setq node (ewoc--node-right node)))))) + (defun ewoc--insert-new-node (node data pretty-printer) "Insert before NODE a new node for DATA, displayed by PRETTY-PRINTER. Call PRETTY-PRINTER with point at NODE's start, thus pushing back *************** (defun ewoc--insert-new-node (node data *** 215,243 **** (pos (marker-position m)) (elemnode (ewoc--node-create m data))) (goto-char pos) - ;; Insert the trailing newline using insert-before-markers - ;; so that the start position for the next element is updated. - (insert-before-markers ?\n) - ;; Move back, and call the pretty-printer. - (backward-char 1) (funcall pretty-printer data) (setf (marker-position m) pos (ewoc--node-left elemnode) (ewoc--node-left node) (ewoc--node-right elemnode) node (ewoc--node-right (ewoc--node-left node)) elemnode (ewoc--node-left node) elemnode) elemnode))) (defun ewoc--refresh-node (pp node) "Redisplay the element represented by NODE using the pretty-printer PP." ! (let ((inhibit-read-only t)) ;; First, remove the string from the buffer: ! (delete-region (ewoc--node-start-marker node) ! (1- (marker-position ! (ewoc--node-start-marker (ewoc--node-right node))))) ;; Calculate and insert the string. ! (goto-char (ewoc--node-start-marker node)) ! (funcall pp (ewoc--node-data node)))) ;;; =========================================================================== ;;; Public members of the Ewoc package --- 231,256 ---- (pos (marker-position m)) (elemnode (ewoc--node-create m data))) (goto-char pos) (funcall pretty-printer data) (setf (marker-position m) pos (ewoc--node-left elemnode) (ewoc--node-left node) (ewoc--node-right elemnode) node (ewoc--node-right (ewoc--node-left node)) elemnode (ewoc--node-left node) elemnode) + (ewoc--adjust pos (point) node) elemnode))) (defun ewoc--refresh-node (pp node) "Redisplay the element represented by NODE using the pretty-printer PP." ! (let ((inhibit-read-only t) ! (m (ewoc--node-start-marker node)) ! (R (ewoc--node-right node))) ;; First, remove the string from the buffer: ! (delete-region m (ewoc--node-start-marker R)) ;; Calculate and insert the string. ! (goto-char m) ! (funcall pp (ewoc--node-data node)) ! (ewoc--adjust m (point) R))) ;;; =========================================================================== ;;; Public members of the Ewoc package *************** (defun ewoc-create (pretty-printer &opti *** 251,258 **** PRETTY-PRINTER should be a function that takes one argument, an element, and inserts a string representing it in the buffer (at point). The string PRETTY-PRINTER inserts may be empty or span ! several lines. A trailing newline will always be inserted ! automatically. The PRETTY-PRINTER should use `insert', and not `insert-before-markers'. Optional second argument HEADER is a string that will always be --- 264,270 ---- PRETTY-PRINTER should be a function that takes one argument, an element, and inserts a string representing it in the buffer (at point). The string PRETTY-PRINTER inserts may be empty or span ! several lines. The PRETTY-PRINTER should use `insert', and not `insert-before-markers'. Optional second argument HEADER is a string that will always be *************** (defun ewoc-refresh (ewoc) *** 522,528 **** (while (not (eq node footer)) (set-marker (ewoc--node-start-marker node) (point)) (funcall pp (ewoc--node-data node)) - (insert "\n") (setq node (ewoc--node-next dll node))))) (set-marker (ewoc--node-start-marker footer) (point)))) --- 534,539 ---- *************** (defun ewoc-get-hf (ewoc) *** 561,571 **** (defun ewoc-set-hf (ewoc header footer) "Set the HEADER and FOOTER of EWOC." ! (setf (ewoc--node-data (ewoc--header ewoc)) header) ! (setf (ewoc--node-data (ewoc--footer ewoc)) footer) ! (save-excursion ! (ewoc--refresh-node 'insert (ewoc--header ewoc)) ! (ewoc--refresh-node 'insert (ewoc--footer ewoc)))) (provide 'ewoc) --- 572,585 ---- (defun ewoc-set-hf (ewoc header footer) "Set the HEADER and FOOTER of EWOC." ! (ewoc--set-buffer-bind-dll-let* ewoc ! ((head (ewoc--header ewoc)) ! (foot (ewoc--footer ewoc))) ! (setf (ewoc--node-data head) header ! (ewoc--node-data foot) footer) ! (save-excursion ! (ewoc--refresh-node 'insert head) ! (ewoc--refresh-node 'insert foot)))) (provide 'ewoc) *** pcvs.el Sat May 13 06:16:33 2006 --- pcvs.el.NEW Sat May 13 06:35:42 2006 *************** (defun cvs-make-cvs-buffer (dir &optiona *** 467,473 **** (cvs-mode) (set (make-local-variable 'list-buffers-directory) buffer-name) ;;(set (make-local-variable 'cvs-temp-buffer) (cvs-temp-buffer)) ! (let ((cookies (ewoc-create 'cvs-fileinfo-pp "\n" ""))) (set (make-local-variable 'cvs-cookies) cookies) (add-hook 'kill-buffer-hook (lambda () --- 467,473 ---- (cvs-mode) (set (make-local-variable 'list-buffers-directory) buffer-name) ;;(set (make-local-variable 'cvs-temp-buffer) (cvs-temp-buffer)) ! (let ((cookies (ewoc-create 'cvs-fileinfo-pp "\n\n" "\n"))) (set (make-local-variable 'cvs-cookies) cookies) (add-hook 'kill-buffer-hook (lambda () *************** (defun cvs-update-header (cmd add) *** 618,624 **** (str (car hf)) (done "") (tin (ewoc-nth cvs-cookies 0))) ! (if (eq (length str) 1) (setq str "")) ;; look for the first *real* fileinfo (to determine emptyness) (while (and tin --- 618,624 ---- (str (car hf)) (done "") (tin (ewoc-nth cvs-cookies 0))) ! (if (eq (length str) 2) (setq str "")) ;; look for the first *real* fileinfo (to determine emptyness) (while (and tin *************** (defun cvs-update-header (cmd add) *** 633,638 **** --- 633,639 ---- (setq str (replace-match "" t t str)) (if (zerop (length str)) (setq str "\n")) (setq done (concat "-- last cmd: " cmd " --")))) + (setq str (concat str "\n") done (concat done "\n")) ;; set the new header and footer (ewoc-set-hf cvs-cookies str (concat "\n--------------------- " *** pcvs-info.el Thu May 4 15:29:51 2006 --- pcvs-info.el.NEW Fri May 5 12:43:07 2006 *************** (defun cvs-fileinfo-pp (fileinfo) *** 379,385 **** ;; or nothing ""))) (format "%-11s %s %-11s %-11s %s" ! side status type base file))))))) (defun cvs-fileinfo-update (fi fi-new) --- 379,386 ---- ;; or nothing ""))) (format "%-11s %s %-11s %-11s %s" ! side status type base file)))) ! "\n"))) (defun cvs-fileinfo-update (fi fi-new)