unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Diane Murray <disumu@x3y2z1.net>
Cc: emacs-devel@gnu.org
Subject: Re: Fix previous-button to work with connected buttons
Date: Sat, 10 Mar 2007 21:08:51 -0500	[thread overview]
Message-ID: <jwvbqj0h708.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87wt1o8xl6.fsf@x3y2z1.net> (Diane Murray's message of "Sun\, 11 Mar 2007 00\:53\:25 +0100")

> 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	other threads:[~2007-03-11  2:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-10 23:53 Fix previous-button to work with connected buttons Diane Murray
2007-03-11  2:08 ` Stefan Monnier [this message]
2007-03-11  2:45   ` Miles Bader
2007-03-11  6:00     ` Stefan Monnier
2007-03-11  6:12       ` Miles Bader
2007-03-11 10:55         ` David Kastrup
2007-03-11 12:53           ` Miles Bader
2007-03-11 13:04             ` David Kastrup
2007-03-11 21:46         ` Stefan Monnier
2007-03-11 22:52           ` Miles Bader
2007-04-01  2:28 ` Diane Murray
2007-04-01 14:00   ` Richard Stallman
2007-04-01 17:15   ` Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvbqj0h708.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=disumu@x3y2z1.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).