emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH: ewoc.el to permit node representation abutment


From: Thien-Thi Nguyen
Subject: PATCH: ewoc.el to permit node representation abutment
Date: Fri, 05 May 2006 14:03:15 +0200

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]