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: Sun, 11 Mar 2007 01:00:21 -0500 Message-ID: References: <87wt1o8xl6.fsf@x3y2z1.net> <873b4c7b2f.fsf@catnip.gol.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1173592858 9230 80.91.229.12 (11 Mar 2007 06:00:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 11 Mar 2007 06:00:58 +0000 (UTC) Cc: Diane Murray , emacs-devel@gnu.org To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 11 07:00:52 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 1HQH6w-0007iL-4M for ged-emacs-devel@m.gmane.org; Sun, 11 Mar 2007 07:00:50 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HQH7Q-0007bx-T8 for ged-emacs-devel@m.gmane.org; Sun, 11 Mar 2007 01:01:20 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HQH7F-0007br-Rr for emacs-devel@gnu.org; Sun, 11 Mar 2007 01:01:09 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HQH7E-0007be-GE for emacs-devel@gnu.org; Sun, 11 Mar 2007 01:01:09 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HQH7E-0007bb-99 for emacs-devel@gnu.org; Sun, 11 Mar 2007 01:01:08 -0500 Original-Received: from tomts40.bellnexxia.net ([209.226.175.97] helo=tomts40-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HQH6a-0005Xj-GS; Sun, 11 Mar 2007 01:00:29 -0500 Original-Received: from alfajor.home ([74.12.204.225]) by tomts40-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070311060022.EMNB1624.tomts40-srv.bellnexxia.net@alfajor.home>; Sun, 11 Mar 2007 01:00:22 -0500 Original-Received: by alfajor.home (Postfix, from userid 20848) id F02911C149; Sun, 11 Mar 2007 01:00:21 -0500 (EST) In-Reply-To: <873b4c7b2f.fsf@catnip.gol.com> (Miles Bader's message of "Sun\, 11 Mar 2007 11\:45\:12 +0900") 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:67710 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. > 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? Stefan --- 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. beg)