unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#40821: Margin strings are displayed in reverse order of overlay priority (low-priority specs hide high-priority ones)
@ 2020-04-24 15:56 Clément Pit-Claudel
  2020-04-25  7:58 ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Clément Pit-Claudel @ 2020-04-24 15:56 UTC (permalink / raw)
  To: 40821

[-- Attachment #1: Type: text/plain, Size: 2289 bytes --]

Hi all,

The following sample shows the words "low", "mid" and "high" in the left margin using overlays.

(with-current-buffer (get-buffer-create "*margins*")
  (erase-buffer)
  (delete-all-overlays)
  (setq left-margin-width 16)
  (let ((beg (point))
        (end (progn (insert "test") (point))))
    (let ((ov-low (make-overlay beg end)))
      (overlay-put ov-low 'before-string (propertize "low" 'display '((margin left-margin) "low")))
      (overlay-put ov-low 'priority 10))
    (let ((ov-mid (make-overlay beg end)))
      (overlay-put ov-mid 'before-string (propertize "mid" 'display '((margin left-margin) "mid")))
      (overlay-put ov-mid 'priority 50))
    (let ((ov-high (make-overlay beg end)))
      (overlay-put ov-high 'before-string (propertize "high" 'display '((margin left-margin) "high")))
      (overlay-put ov-high 'priority 100))))

All three overlays begin at the same point.  Currently, it seems that margin specs are concatenated in order of increasing priority.  This is likely due to before-strings being concatenated in that order?
One unfortunate side effect of this is that, when margins are too narrow, low-priority margin specs are displayed before high-priority ones, and hence high-priority ones are not visible.

Additionally, unlike fringe bitmaps, for which the highest-priority bitmap replaces all others on the same line, there doesn't seem to be a way for higher-priority margin specs to replace lower-priority ones.

This issue came up when trying to develop a mode to indicate errors and warnings in the margins (instead of drawing symbols in the fringes).  Currently, if a line contains errors and warnings, Flycheck will place multiple overlays on the same line, and the fringe bitmap corresponding to the highest-priority one will be displayed.  But if we put a symbol in the margins instead of the fringes, the symbols won't override each others: instead, they will be concatenated, often in the wrong order (as shown in the attached screenshot).

It would be great if margin specs could be displayed in order of decreasing priority, or if some mechanism existed to indicate that two margin specs are intended to replace each other (the highest-priority one replacing the lowest-priority one), rather than being concatenated.

Clément.


[-- Attachment #2: margins-w.png --]
[-- Type: image/png, Size: 40646 bytes --]

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

end of thread, other threads:[~2020-05-13 16:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-24 15:56 bug#40821: Margin strings are displayed in reverse order of overlay priority (low-priority specs hide high-priority ones) Clément Pit-Claudel
2020-04-25  7:58 ` Eli Zaretskii
2020-04-25 13:01   ` Clément Pit-Claudel
2020-04-25 14:04     ` Eli Zaretskii
2020-04-25 16:51       ` Clément Pit-Claudel
2020-04-25 17:08         ` Eli Zaretskii
2020-04-25 17:21           ` Clément Pit-Claudel
2020-04-25 17:36             ` Eli Zaretskii
2020-04-25 19:29               ` Dmitry Gutov
2020-04-25 20:50               ` Clément Pit-Claudel
2020-05-13 15:58   ` Clément Pit-Claudel
2020-05-13 16:25     ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).