From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: pwr--- via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: Redisplaying text in both display margins? Date: Mon, 25 Jan 2021 18:28:11 +1000 Organization: By Dasein Message-ID: <01e529e1bfecb8e32c9d737ebfd26140@bydasein.com> References: <87a6t546pl.fsf@bydasein.com> <8335yx7y8s.fsf@gnu.org> Reply-To: "Paul W. Rankin" Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3419"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Purely Mail via Roundcube/1.4.7 Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 25 09:36:05 2021 Return-path: Envelope-to: geh-help-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 1l3xLw-0000lu-ED for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Jan 2021 09:36:04 +0100 Original-Received: from localhost ([::1]:35620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l3xLv-0001zZ-EX for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 25 Jan 2021 03:36:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3xEb-00085A-7k for help-gnu-emacs@gnu.org; Mon, 25 Jan 2021 03:28:29 -0500 Original-Received: from sendmail.purelymail.com ([34.202.193.197]:46064) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l3xEZ-0000rW-Oo for help-gnu-emacs@gnu.org; Mon, 25 Jan 2021 03:28:28 -0500 DKIM-Signature: a=rsa-sha256; b=ixIBAmq+IhZUAWDTv0FPc6vCY9DgfO9hqAH4TlyEKtYv4CU/sBfs8GKt4RoqmUc1VU1/TSfJJ9eEwz38NRZK7tYjiQEd0FQj5EBo6VRbvSJvhBkiPqYkfSiuYErHK49DUQk6+F35Rq+2XJAWwMjoRx9lWS21qGZnV5+FWwfcsfclJpZlzlipHxcBRBtBrtpRQCwLXQ1jw2rrOEFLVCDw9h/IksT2JXy4eKqYJgHQHd2rGJtcGfl9ywBZZsT7dFk7aLZV7ELrDmhwrksu+hxxwNiYXfp1/IkisT2NFQLbzgxNa2WZJQK4TxTAO8oHU5ac6lPs+8i44dFK33SrliP0Mg==; s=purelymail2; d=bydasein.com; v=1; bh=zWzQmfNUQLv7uYUNjgE/WYK+pFmvQuwf8+ARZn8/oPk=; h=Received:From:To; DKIM-Signature: a=rsa-sha256; b=iePpprvhSX5+DEsGd8mmAi3Y18EWUCHPduiBiE4nOGD6V2RcGa0Npo9aNfxXX/2+QMla8gIDNnAWzA530b2prSZOKJ7rH48GKRTNCtnOS6mvAfO1ihpehvq3ezm2PXgwI5gkSAesqti/XTm+dc1h5LlG1Usg+8zXE3GS/BeNTqtTtuQmq35WHlb6ZIBupbmdAOYuVOcoMbwTs4bFg2J79hrCr4YQtivseyX6VsiO7aLIgug0v+bzAk6up/zoTaQQuXf1T1xsRrTjdf0rtCGgH8vK0u4VEeTvxEbsPP/BJ5o3adzYsm0o5hWhQY2uDM2B6YcxH8OlBvR7YwfHdtYwFg==; s=purelymail2; d=purelymail.com; v=1; bh=zWzQmfNUQLv7uYUNjgE/WYK+pFmvQuwf8+ARZn8/oPk=; h=Feedback-ID:Received:From:To; Feedback-ID: 791:353:null:purelymail X-Pm-Original-To: help-gnu-emacs@gnu.org Original-Received: by ip-172-30-0-247.ec2.internal (JAMES SMTP Server ) with ESMTPA ID 547372886; Mon, 25 Jan 2021 08:28:11 +0000 (UTC) In-Reply-To: <8335yx7y8s.fsf@gnu.org> X-Sender: pwr@bydasein.com Received-SPF: pass client-ip=34.202.193.197; envelope-from=pwr@bydasein.com; helo=sendmail.purelymail.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127350 Archived-At: On 2021-01-20 01:16, Eli Zaretskii wrote: >> Feedback-ID: 791:353:null:purelymail >> 2. When redisplaying a string in the left margin, how to right-align >> it, >> ideally padded with a couple of spaces away from the body text. >> >> I have read over (info "(elisp) Display Property") a few times, but >> haven't been able to quite grok it for this specific problem. > > I think the node "Pixel Specification" there should tell you how to > accomplish that, but if you already read that, please ask more > specific questions, and/or show the code you tried that didn't work. Thanks for the help. I had another read through and after some trial and error got something working how I like. However I've run into some behaviour that confuses me. I'll describe this first but this will be clearer with the example below. To achieve the desired result of a string in the left display margin aligned with the body text I've put display text properties onto two regions of text, one a space to fill most of the margin, and then the string to display. However, when inserting enough body text to cause these regions to wrap, the space in the margin begins to shrink. To reproduce: emacs -Q (erase-buffer) (set-window-margins nil 20) (insert "foobarbaz") (put-text-property 4 7 'display '((margin left-margin) (space :width (- left-margin 2)))) (put-text-property 7 10 'display '((margin left-margin) "1")) This should result in a window with something like: 1 foo Then assuming a frame of 80 columns and `truncate-lines' is nil (or visual-line-mode is enabled): (goto-char (point-min)) (insert (make-string 45 ?x)) The "1" will appear to get pushed towards the left as more text is added until the line wraps the window: So my question becomes, how should I apply these display text properties such that they will not be affected by line wrapping? Thanks!