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: PATCH: ewoc.el to permit node representation abutment Date: Fri, 05 May 2006 14:03:15 +0200 Message-ID: Reply-To: ttn@gnu.org NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1146830628 6212 80.91.229.2 (5 May 2006 12:03:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 5 May 2006 12:03:48 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 05 14:03:45 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 1Fbz27-0001Yc-Tc for ged-emacs-devel@m.gmane.org; Fri, 05 May 2006 14:03:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fbz27-00067P-7g for ged-emacs-devel@m.gmane.org; Fri, 05 May 2006 08:03:43 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fbz18-0005W4-J9 for emacs-devel@gnu.org; Fri, 05 May 2006 08:02:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fbz11-0005Mk-Us for emacs-devel@gnu.org; Fri, 05 May 2006 08:02:38 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fbz10-0005MW-Iy for emacs-devel@gnu.org; Fri, 05 May 2006 08:02:34 -0400 Original-Received: from [151.37.172.252] (helo=surf.glug.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fbz19-0006Hm-AG for emacs-devel@gnu.org; Fri, 05 May 2006 08:02:43 -0400 Original-Received: from ttn by surf.glug.org with local (Exim 3.35 #1 (Debian)) id 1Fbz1f-0002Xo-00 for ; Fri, 05 May 2006 14:03:15 +0200 Original-To: emacs-devel@gnu.org 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:53944 Archived-At: ewoc.el is pretty cool but as it stands it inserts a gratuitous newline between each node's "pretty-printed" representation. this makes it unsuitable for single-line usage, a design bug in my book. i've locally modified ewoc.el to allow abutment of a node's representation, and correspondingly its only in-emacs client, as shown by the appended patch. here is a suitable ChangeLog entry: * 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, temporarily set the marker's insertion type to nil around the pretty-printer call. (ewoc-create): Use marker insertion type t. Elide two lambdas. (ewoc-refresh): Don't insert newline. Also, temporarily set the marker's insertion type to nil around the pretty-printer call. * pcvs-info.el (cvs-fileinfo-pp): Insert trailing newline. please review (especially pcvs behavior -- i tested lightly with, but don't normally use, pcvs). if there are no objections i will commit it in a week or so (w/ NEWS blurb). if anyone has written or has started writing docs for ewoc.el (presumably for lispref/ inclusion), please speak up else i will be doing that in the meantime. thi ___________________________________________________________________________ -*- mode: compilation; default-directory: "~/build/GNU/emacs/lisp/" -*- Compilation started at Fri May 5 13:47:14 for f in pcvs-info.el emacs-lisp/ewoc.el ; do diff -c $f $f.NEW ; done *** pcvs-info.el Thu May 4 15:29:51 2006 --- pcvs-info.el.NEW Fri May 5 12:43:07 2006 *************** *** 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) *** emacs-lisp/ewoc.el Mon Feb 6 13:14:52 2006 --- emacs-lisp/ewoc.el.NEW Fri May 5 12:34:52 2006 *************** *** 253,265 **** (when (markerp pos) (setq pos (marker-position pos))) (goto-char pos) (let ((inhibit-read-only t)) - ;; 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) ! (ewoc--node-create (copy-marker pos) data)))) (defun ewoc--delete-node-internal (ewoc node) --- 253,260 ---- (when (markerp pos) (setq pos (marker-position pos))) (goto-char pos) (let ((inhibit-read-only t)) (funcall pretty-printer data) ! (ewoc--node-create (copy-marker pos t) data)))) (defun ewoc--delete-node-internal (ewoc node) *************** *** 287,297 **** (save-excursion ;; 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 --- 282,294 ---- (save-excursion ;; First, remove the string from the buffer: (delete-region (ewoc--node-start-marker node) ! (ewoc--node-start-marker (ewoc--node-right node))) ;; Calculate and insert the string. ! (let ((m (ewoc--node-start-marker node))) ! (goto-char m) ! (set-marker-insertion-type m nil) ! (funcall pp (ewoc--node-data node)) ! (set-marker-insertion-type m t))))) ;;; =========================================================================== ;;; Public members of the Ewoc package *************** *** 321,329 **** ;; Set default values (unless header (setq header "")) (unless footer (setq footer "")) ! (setf (ewoc--node-start-marker dll) (copy-marker pos)) ! (let ((foot (ewoc--create-node footer (lambda (x) (insert footer)) pos)) ! (head (ewoc--create-node header (lambda (x) (insert header)) pos))) (ewoc--node-enter-first dll head) (ewoc--node-enter-last dll foot) (setf (ewoc--header new-ewoc) head) --- 318,326 ---- ;; Set default values (unless header (setq header "")) (unless footer (setq footer "")) ! (setf (ewoc--node-start-marker dll) (copy-marker pos t)) ! (let ((foot (ewoc--create-node footer 'insert pos)) ! (head (ewoc--create-node header 'insert pos))) (ewoc--node-enter-first dll head) (ewoc--node-enter-last dll foot) (setf (ewoc--header new-ewoc) head) *************** *** 555,567 **** (delete-region (ewoc--node-start-marker (ewoc--node-nth dll 1)) (ewoc--node-start-marker footer)) (goto-char (ewoc--node-start-marker footer)) ! (let ((node (ewoc--node-nth dll 1))) (while (not (eq node footer)) ! (set-marker (ewoc--node-start-marker node) (point)) ! (funcall (ewoc--pretty-printer ewoc) ! (ewoc--node-data node)) ! (insert "\n") ! (setq node (ewoc--node-next dll node))))) (set-marker (ewoc--node-start-marker footer) (point)))) (defun ewoc-collect (ewoc predicate &rest args) --- 552,567 ---- (delete-region (ewoc--node-start-marker (ewoc--node-nth dll 1)) (ewoc--node-start-marker footer)) (goto-char (ewoc--node-start-marker footer)) ! (let* ((pp (ewoc--pretty-printer ewoc)) ! (node (ewoc--node-nth dll 1)) ! (m (ewoc--node-start-marker node))) (while (not (eq node footer)) ! (set-marker m (point)) ! (set-marker-insertion-type m nil) ! (funcall pp (ewoc--node-data node)) ! (set-marker-insertion-type m t) ! (setq node (ewoc--node-next dll node) ! m (ewoc--node-start-marker node))))) (set-marker (ewoc--node-start-marker footer) (point)))) (defun ewoc-collect (ewoc predicate &rest args) Compilation exited abnormally with code 1 at Fri May 5 13:47:14