From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61735: 29.0.50; String object in margin not associated correctly with buffer text Date: Thu, 23 Feb 2023 19:45:29 +0200 Message-ID: <83h6vcp96u.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18311"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61735@debbugs.gnu.org To: dalanicolai , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 23 18:46:18 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pVFfe-0004b0-DD for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 Feb 2023 18:46:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVFfa-0006sg-PL; Thu, 23 Feb 2023 12:46:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVFfX-0006rm-3B for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 12:46:11 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVFfO-00069i-N6 for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 12:46:10 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVFfO-0003yt-JI for bug-gnu-emacs@gnu.org; Thu, 23 Feb 2023 12:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Feb 2023 17:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61735 X-GNU-PR-Package: emacs Original-Received: via spool by 61735-submit@debbugs.gnu.org id=B61735.167717434515259 (code B ref 61735); Thu, 23 Feb 2023 17:46:02 +0000 Original-Received: (at 61735) by debbugs.gnu.org; 23 Feb 2023 17:45:45 +0000 Original-Received: from localhost ([127.0.0.1]:35224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVFf6-0003y2-M6 for submit@debbugs.gnu.org; Thu, 23 Feb 2023 12:45:44 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:46988) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVFf5-0003xq-Bz for 61735@debbugs.gnu.org; Thu, 23 Feb 2023 12:45:43 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVFew-00065b-Am; Thu, 23 Feb 2023 12:45:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=PzF+9ySyHe5H5mepf6uVDjw+4aQtABIK2HjHmRh1ZhI=; b=hBMv+jDDuoRM In9TDcRFPRfiGYbCgEOaGxgj+mozrWGm3w9Nf0L6+Uiz2R2XiVTTq42nbHxpxQuHu0MpK11N8Agig L1JIVjmJymhlHBLpYg3YVs6kv4eqD2sbbt6zLiiTXJhNRH0QLR+k/ROXXxDUY3fPyYi8bBjngvuJz DW+DjEWlrF7l86ULX07Rrj4KURjrTIpR87s60KfmOmxTYl5dFZL1hH1pDKGF4khWtfTxt5GK43Jci ZrYvrdGgED5OYkkz77TJY8x3oVSR2t5/w9qfxLK+9KaF6IgjYJGt4rNQXpNNC28G7C/SLeXwDCAyA pnSZSRbJU0MqDqq7CdXRJw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVFeu-0006kB-KP; Thu, 23 Feb 2023 12:45:33 -0500 In-Reply-To: (message from dalanicolai on Thu, 23 Feb 2023 17:32:50 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:256501 Archived-At: > From: dalanicolai > Date: Thu, 23 Feb 2023 17:32:50 +0100 > > (defun baleen-render (data) > (pop-to-buffer (get-buffer-create "*baleen*")) > (set-window-margins nil 5) > (dolist (page data) > (dolist (match (cdr page)) > (let ((o (make-overlay (point) > (progn (insert match) > (point))))) > (let ((s " ")) > (put-text-property 0 1 > 'display `((margin left-margin) ,(format " %d" (car page))) > s) > (overlay-put o 'before-string s))) > (insert "\n")))) > > (baleen-render '((1 "test1" "test2") (2 "test3"))) > ``` > > Here, for every 'match' in a 'page' I am creating a new string 's' > to which I add the margin display property to 'associate' it > with some buffer text by using it as the value for its before-string > property. > However, although each 's' should get a different display property value > via (format " %d" (car page)), all margin entries end up showing the > same value of 2 (while the first two lines should show page number 1). > > To reproduce the error, simply evaluate the code above. Using edebug on > 'baleen-render' it can be seen that the code seems correct, i.e. (car > page) correctly returns the correct page number. > > It seems that although I am creating a different string object on each > iteration, somehow the object put in the marging seems to be always the > same. Is it really true that you create a different string object every time? Add a copy-sequence call there, like this: (let ((s (copy-sequence " "))) and the code does what you expect. Stefan, am I missing something here?