help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Redisplaying text in both display margins?


From: Paul W. Rankin
Subject: Re: Redisplaying text in both display margins?
Date: Mon, 25 Jan 2021 18:28:11 +1000
User-agent: Purely Mail via Roundcube/1.4.7

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!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]