all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Displaying an overlay image across the margins and body
@ 2021-07-06  7:36 Thomas F. K. Jorna
  2021-07-06  9:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas F. K. Jorna @ 2021-07-06  7:36 UTC (permalink / raw)
  To: help-gnu-emacs

Hi!

I want to create an overlay (or, to avoid X-Y problems, a multicolored, 
multilayered, visually distinct line at an arbitrary position that 
cannot be removed, like a page-break) that spans the entire "page", by 
which I mean the margins and buffer width, of zero width, and insertable 
anywhere.

I've created a sample function which does that (be sure to |(require 
'svg)| if you want to test it)

|(defun insert-svg-overlay () (interactive) (let* ((margin-pixel-width 
(* (frame-char-width) (car (window-margins)))) (svg (svg-create 
margin-pixel-width 50)) (svg2 (svg-create (window-body-width nil t) 50)) 
(ov (make-overlay (point) (point)))) (svg-rectangle svg 0 0 
margin-pixel-width 50 :fill-color "red") (svg-rectangle svg2 0 0 
(window-body-width nil t) 50 :fill-color "yellow") (overlay-put ov 
'before-string (concat (propertize "x" 'display (svg-image svg2)) 
(propertize "x" 'display (list (list 'margin 'right-margin) (svg-image 
svg))) (propertize "x" 'display (list (list 'margin 'left-margin) 
(svg-image svg))))))) |

which, if you have margins set, will insert an (ugly-looking) overlay 
like so red-yellow line inserted in the middle of some code 
<https://i.stack.imgur.com/vKBSg.png>.

This does exactly what I want at the start of an "actual" line. However, 
I would like it to do the same thing at the start of a /visual / line. 
However, doing so yields (inserting before |(svg-image svg)|) same line, 
now with the yellow line offset from the rest 
<https://i.stack.imgur.com/azk6U.png>

How do I "prevent" some of the overlay from going places it shouldn't? I 
have tried so many different combinations of |before-string|, 
|after-string| and plain inserting images, to no avail. There are two 
things that do work, but are undesirable in their own right.

 1. Make the middle rectangle 1 pixel shorter, by changing |svg2| to
    |(svg2 (svg-create (1- (window-body-width nil t) 50))| same line,
    now correct but with a 1 pixel gap between the middle yellow chunk
    and the right red chunk <https://i.stack.imgur.com/VYuRn.png>
    Undesirable for obvious reasons.
 2. Make the overlay occupy non-zero space. This allows you to change
    the region occupied by the overlay to the image/whatever, which
    somehow /does/ work. Undesirable because this would remove the
    character(s) we want to have.

I feel like there is some combination of |before-string|s and 
|after-string|s and svg-order that will accomplish what I want, but I 
have had very little luck so far.

Somehow parts of the overlay get pushed to the next line, but why? I'm 
relatively sure it has something to do with visual-line-mode, is there 
some way to "prevent" it from word-wrapping specific strings?

I am using svg's/overlays because I want to be able to draw in 
them/display multiple lines.

This way of displaying in the margins comes from |put-image|.

Thank you very much for your help!

Thomas F. K. Jorna

PS. This is a copy of 
https://emacs.stackexchange.com/questions/66457/why-cant-i-create-a-full-width-overlay-and-display-in-the-margins-at-the-same-t 




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Displaying an overlay image across the margins and body
  2021-07-06  7:36 Displaying an overlay image across the margins and body Thomas F. K. Jorna
@ 2021-07-06  9:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 2+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-07-06  9:23 UTC (permalink / raw)
  To: help-gnu-emacs

Thomas F. K. Jorna wrote:

> svg

Oh, good that you got it to work!

I tried several years ago to make a drawing of an outdoor
project I did. IIRC I didn't get it to work, not even
indoors...

The only thing I can say is your lines are so wide they
overflow the sacred 80 sometimes, perhaps. This

> (list (list 'margin 'left-margin))

perhaps can be put as

  '((margin left-margin))

?

-- 
underground experts united
https://dataswamp.org/~incal




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-06  9:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-06  7:36 Displaying an overlay image across the margins and body Thomas F. K. Jorna
2021-07-06  9:23 ` Emanuel Berg via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.