From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Fix previous-button to work with connected buttons Date: Sat, 10 Mar 2007 21:08:51 -0500 Message-ID: References: <87wt1o8xl6.fsf@x3y2z1.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1173578953 16205 80.91.229.12 (11 Mar 2007 02:09:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Mar 2007 02:09:13 +0000 (UTC) Cc: emacs-devel@gnu.org To: Diane Murray Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 11 03:09:06 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HQDUf-0003az-Qx for ged-emacs-devel@m.gmane.org; Sun, 11 Mar 2007 03:09:06 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HQDVA-00075p-7k for ged-emacs-devel@m.gmane.org; Sat, 10 Mar 2007 21:09:36 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HQDUz-00075h-7T for emacs-devel@gnu.org; Sat, 10 Mar 2007 21:09:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HQDUy-00075H-F3 for emacs-devel@gnu.org; Sat, 10 Mar 2007 21:09:24 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HQDUy-00075C-92 for emacs-devel@gnu.org; Sat, 10 Mar 2007 21:09:24 -0500 Original-Received: from tomts10.bellnexxia.net ([209.226.175.54] helo=tomts10-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HQDUT-0000TP-1y for emacs-devel@gnu.org; Sat, 10 Mar 2007 21:08:53 -0500 Original-Received: from pastel.home ([74.12.206.221]) by tomts10-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070311020851.DKKN1723.tomts10-srv.bellnexxia.net@pastel.home> for ; Sat, 10 Mar 2007 21:08:51 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id BDF9F7F22; Sat, 10 Mar 2007 21:08:51 -0500 (EST) In-Reply-To: <87wt1o8xl6.fsf@x3y2z1.net> (Diane Murray's message of "Sun\, 11 Mar 2007 00\:53\:25 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux) X-detected-kernel: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:67697 Archived-At: > 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