emacs-devel
[Top][All Lists]
Advanced

[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: Sat, 10 Mar 2007 21:08:51 -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.
Can you test it?


        Stefan


--- orig/lisp/button.el
+++ mod/lisp/button.el
@@ -89,10 +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 +312,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 (copy-marker beg t) properties)))
   ;; Return something that can be used to get at the button.
   beg)
 
@@ -345,11 +345,7 @@
 
 (defun button-at (pos)
   "Return the button at position POS in the current buffer, or nil."
-  (let ((button (get-char-property pos 'button)))
-    (if (or (overlayp button) (null button))
-       button
-      ;; Must be a text-property button; return a marker pointing to it.
-      (copy-marker pos t))))
+  (get-char-property pos 'button))
 
 (defun next-button (pos &optional count-current)
   "Return the next button after position POS in the current buffer.
@@ -453,5 +449,5 @@
 
 (provide 'button)
 
-;;; arch-tag: 5f2c7627-413b-4097-b282-630f89d9c5e9
+;; arch-tag: 5f2c7627-413b-4097-b282-630f89d9c5e9
 ;;; button.el ends here




reply via email to

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