emacs-devel
[Top][All Lists]
Advanced

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

Re: [BUG] widget-field-overlay becomes wrong


From: Lars Hansen
Subject: Re: [BUG] widget-field-overlay becomes wrong
Date: Sun, 04 Jul 2004 11:47:37 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021213 Debian/1.2.1-2.bunk

Richard Stallman wrote:

What will happen if the user deletes all the text in the editable field,
then inserts new text?  Will that newly inserted text be treated
as part of a neighboring widget?  It seems likely.
You are right, zero-sized overlays cannot be ignored as I did. Such overlays should only go in overlays-after. This is done in the patch attached.

I don't think it is worth spending a lot of time to fix this,
because I think it is fundamentally impossible, and there are
more important things to do.

I don't see why it should be fundamentally impossible to fix this bug. AFAICS a widget cannot have zero size, and if it has a zero-sized overlay at one end, it is at the start.

I want to fix this bug because it annoys me in some tests I am doing.
I suggest we install my patch. It can always be removed if it has undesirable consequences.

For instance, would you be interested
in working on making saving of text properties in files more
convenient?  That is more important.

I would be happy to work much more on Emacs. However, that requires someone to finance it :-). Right now I don't have the time :-(.

*** wid-edit.el.~1.128.~        Tue Jun  8 21:50:16 2004
--- wid-edit.el Sun Jul  4 10:34:13 2004
***************
*** 414,426 ****
      (widget-put widget :doc-overlay overlay)))
  
  (defmacro widget-specify-insert (&rest form)
!   "Execute FORM without inheriting any text properties."
    `(save-restriction
      (let ((inhibit-read-only t)
!         (inhibit-modification-hooks t))
        (narrow-to-region (point) (point))
        (prog1 (progn ,@form)
!       (goto-char (point-max))))))
  
  (defface widget-inactive-face '((((class grayscale color)
                                  (background dark))
--- 414,444 ----
      (widget-put widget :doc-overlay overlay)))
  
  (defmacro widget-specify-insert (&rest form)
!   "Execute FORM without inheriting any text properties.
! Furthermore, ensure overlays ending at point or starting at point
! does not include text inserted."
    `(save-restriction
      (let ((inhibit-read-only t)
!         (inhibit-modification-hooks t)
!           overlays-before
!           overlays-after)
!       (mapc (lambda (overlay)
!               (when (and (= (point) (overlay-end overlay))
!                          (not (= (point) (overlay-start overlay))))
!                 (setq overlays-before (cons overlay overlays-before)))
!               (when (= (point) (overlay-start overlay))
!                 (setq overlays-after (cons overlay overlays-after))))
!             (overlays-in (if (= (point) (point-min)) (point) (1- (point)))
!                          (if (= (point) (point-max)) (point) (1+ (point)))))
        (narrow-to-region (point) (point))
        (prog1 (progn ,@form)
!         (mapc (lambda (overlay)
!                 (move-overlay overlay (overlay-start overlay) (point-min)))
!               overlays-before)
!         (mapc (lambda (overlay)
!                 (move-overlay overlay (point-max) (overlay-end overlay)))
!               overlays-after)
!         (goto-char (point-max))))))
  
  (defface widget-inactive-face '((((class grayscale color)
                                  (background dark))
***************
*** 1530,1538 ****
                     (if (>= old-pos (1- to))
                         (- old-pos to 1)
                       (- old-pos from)))))
-     ;;??? Bug: this ought to insert the new value before deleting the old one,
-     ;; so that markers on either side of the value automatically
-     ;; stay on the same side.  -- rms.
      (save-excursion
        (goto-char (widget-get widget :from))
        (widget-apply widget :delete)
--- 1548,1553 ----

reply via email to

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