unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* PATCH: ewoc.el to permit node representation abutment
@ 2006-05-05 12:03 Thien-Thi Nguyen
  2006-05-05 13:20 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Thien-Thi Nguyen @ 2006-05-05 12:03 UTC (permalink / raw)


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)))))
  \f
  ;;; ===========================================================================
  ;;;                  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)))))
  \f
  ;;; ===========================================================================
  ;;;                  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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-13  5:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2006-05-13  5:08         ` Thien-Thi Nguyen

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).