[Top][All Lists]

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

Re: Fix previous-button to work with connected buttons

From: Stefan Monnier
Subject: Re: Fix previous-button to work with connected buttons
Date: Sun, 11 Mar 2007 01:00:21 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux)

>>> Neither `previous-button' nor `next-button' work well with neighboring
>>> buttons inserted with `insert-text-button' - this patch is *not* able
>>> to solve that problem.
>> I think the patch below should provide a general fix.

> Please don't do that -- one of the goals of buttons is to work
> reasonably well if there are _lots_ of them, and that was the main
> reason for supporting both "overlay" and "text" buttons.  If you have
> lots of buttons, creating a unique marker for each button has nasty
> results (I've tested it).

Fair enough.  Also if the button is copied to a string and to other buffers,
the resulting marker ends up pointing elsewhere which may surprise other
pieces of code (although I couldn't find any).

How 'bout the patch below, then?


--- button.el   26 jan 2007 23:51:22 -0500      1.22
+++ button.el   11 mar 2007 00:58:33 -0500      
@@ -89,9 +89,6 @@
 ;; Prevent insertions adjacent to the text-property buttons from
 ;; inheriting its properties.
 (put 'default-button 'rear-nonsticky t)
-;; Text property buttons don't have a `button' property of their own, so
-;; they inherit this.
-(put 'default-button 'button t)
 ;; A `category-symbol' property for the default button type
 (put 'button 'button-category-symbol 'default-button)
@@ -316,7 +313,11 @@
       (setcar (cdr type-entry)
              (button-category-symbol (car (cdr type-entry))))))
   ;; Now add all the text properties at once
-  (add-text-properties beg end properties)
+  (add-text-properties beg end
+                       ;; Each button should have a different `button'
+                       ;; property so that next-single-property-change can
+                       ;; detect boundaries reliably.
+                       (cons 'button (cons (list t) properties)))
   ;; Return something that can be used to get at the button.

reply via email to

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