* bug#34022: 26.1; Region highlight has lower priority than flymake overlays
@ 2019-01-09 20:33 Johann Klähn
2019-01-09 20:52 ` João Távora
0 siblings, 1 reply; 9+ messages in thread
From: Johann Klähn @ 2019-01-09 20:33 UTC (permalink / raw)
To: 34022; +Cc: João Távora
I just noticed a bug (?) that region becomes de-facto "invisible" due to its highlight overlay having a lower priority than the flymake overlays. This only happens when both region and flymake diagnostics are indicated using the same face property (background in my case). It becomes more apparent for larger flymake overlays.
Steps to reproduce, starting from emacs -Q:
• M-: (set-face-background flymake-note "yellow green")
• M-x find-library flymake (or any file where there will be flymake diagnostics)
• M-x flymake-mode
• Jump to a docstring/line/paragraph highlighted using e.g. the `flymake-note' face.
• With transient-mark-mode enabled select regions that overlap with the
flymake overlay. ⇒ The region is not highlighted since the background
face property given by the flymake overlay takes precedence.
Relevant extract from simple.el.gz, where the secondary priority for
the region highlight overlay is set to 100:
> (defvar redisplay-highlight-region-function
> (lambda (start end window rol)
> (if (not (overlayp rol))
> (let ((nrol (make-overlay start end)))
> (funcall redisplay-unhighlight-region-function rol)
> (overlay-put nrol 'window window)
> (overlay-put nrol 'face 'region)
> ;; Normal priority so that a large region doesn't hide all the
> ;; overlays within it, but high secondary priority so that if it
> ;; ends/starts in the middle of a small overlay, that small overlay
> ;; won't hide the region's boundaries.
> (overlay-put nrol 'priority '(nil . 100))
> nrol)
> (unless (and (eq (overlay-buffer rol) (current-buffer))
> (eq (overlay-start rol) start)
> (eq (overlay-end rol) end))
> (move-overlay rol start end (current-buffer)))
> rol)))
Flymake uses 100 as the offset to compute the default priority for its overlays:
> (defun flymake--highlight-line (diagnostic)
> "Highlight buffer with info in DIAGNOSTIC."
> (when-let* ((ov (make-overlay
> (flymake--diag-beg diagnostic)
> (flymake--diag-end diagnostic))))
> ;; First set `category' in the overlay, then copy over every other
> ;; property.
> ;;
> (let ((alist (assoc-default (flymake--diag-type diagnostic)
> flymake-diagnostic-types-alist)))
> (overlay-put ov 'category (assoc-default 'flymake-category alist))
> (cl-loop for (k . v) in alist
> unless (eq k 'category)
> do (overlay-put ov k v)))
> ;; Now ensure some essential defaults are set
> ;;
> (cl-flet ((default-maybe
> (prop value)
> (unless (or (plist-member (overlay-properties ov) prop)
> (let ((cat (overlay-get ov
> 'flymake-category)))
> (and cat
> (plist-member (symbol-plist cat) prop))))
> (overlay-put ov prop value))))
> (default-maybe 'bitmap 'flymake-error-bitmap)
> (default-maybe 'face 'flymake-error)
> (default-maybe 'before-string
> (flymake--fringe-overlay-spec
> (overlay-get ov 'bitmap)))
> (default-maybe 'help-echo
> (lambda (window _ov pos)
> (with-selected-window window
> (mapconcat
> #'flymake--diag-text
> (flymake-diagnostics pos)
> "\n"))))
> (default-maybe 'severity (warning-numeric-level :error))
> (default-maybe 'priority (+ 100 (overlay-get ov 'severity))))
> ;; Some properties can't be overridden.
> ;;
> (overlay-put ov 'evaporate t)
> (overlay-put ov 'flymake-diagnostic diagnostic)))
Is it intentional that 100 is used as the offset here? This has the effect that most priorities will be above that of the region overlay.
---
In GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
of 2018-07-05 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
Recent messages:
Configured using:
'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
--localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
-fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY
ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS
GTK3 X11 MODULES THREADS LIBSYSTEMD LCMS2
Important settings:
value of $LC_ALL: en_US.UTF-8
value of $LC_MESSAGES: C
value of $LANG: de_DE.utf8
locale-coding-system: utf-8-unix
Major mode: Emacs-Lisp
Minor modes in effect:
flymake-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny seq dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cl-extra
help-fns radix-tree cl-print byte-opt bytecomp byte-compile cconv debug
face-remap misearch multi-isearch noutline outline easy-mmode lisp-mnt
checkdoc cl-macs gv cl-seq flymake-proc flymake compile comint
ansi-color ring warnings help-mode easymenu cl-loaddefs cl-lib jka-compr
thingatpt find-func elec-pair time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)
Memory information:
((conses 16 123857 7080)
(symbols 48 22067 1)
(miscs 40 144 289)
(strings 32 35534 1170)
(string-bytes 1 922022)
(vectors 16 17358)
(vector-slots 8 524383 14202)
(floats 8 67 298)
(intervals 56 2057 393)
(buffers 992 18))
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#34022: 26.1; Region highlight has lower priority than flymake overlays
2019-01-09 20:33 bug#34022: 26.1; Region highlight has lower priority than flymake overlays Johann Klähn
@ 2019-01-09 20:52 ` João Távora
2019-01-10 21:06 ` Johann Klähn
[not found] ` <1547153959.1638293.1631244736.794AFB75@webmail.messagingengine.com>
0 siblings, 2 replies; 9+ messages in thread
From: João Távora @ 2019-01-09 20:52 UTC (permalink / raw)
To: Johann Klähn; +Cc: 34022
Johann Klähn <johann@jklaehn.de> writes:
> I just noticed a bug (?) that region becomes de-facto "invisible" due
> to its highlight overlay having a lower priority than the flymake
> overlays. This only happens when both region and flymake diagnostics
> are indicated using the same face property (background in my case). It
> becomes more apparent for larger flymake overlays.
>
> Steps to reproduce, starting from emacs -Q:
>
> • M-: (set-face-background flymake-note "yellow green")
You probably mean
(set-face-background 'flymake-note "yellow green")
> Flymake uses 100 as the offset to compute the default priority for its
> overlays:
> Is it intentional that 100 is used as the offset here? This has the
> effect that most priorities will be above that of the region overlay.
Yes, it was intentional. Doesn't mean that it's correct :-) Perhaps it
should be reduced to the 50's region and also use the (nil . <value>),
form which I didn't know about (so thanks for showing me this).
I don't know if there are any guide-lines for interoperation in this
front, so if someone more knowledgeable than me want to chime in...
Anyway, for now, you can probably work around this with
(push '(priority . (nil . 50)) (get :note 'flymake-overlay-control))
João
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#34022: 26.1; Region highlight has lower priority than flymake overlays
2019-01-09 20:52 ` João Távora
@ 2019-01-10 21:06 ` Johann Klähn
2019-01-10 22:03 ` João Távora
[not found] ` <1547153959.1638293.1631244736.794AFB75@webmail.messagingengine.com>
1 sibling, 1 reply; 9+ messages in thread
From: Johann Klähn @ 2019-01-10 21:06 UTC (permalink / raw)
To: João Távora; +Cc: 34022
(Sorry, I initially forgot to CC the bug tracker.)
Hi João,
thanks for your quick response! I did not see `flymake-overlay-control' because I was still using
the version of flymake shipped with Emacs 26.1. (I really like the options introduced with the new
version allows, so I will probably switch to using it.)
On Wed, Jan 9, 2019, at 21:52, João Távora wrote:
> Johann Klähn <johann@jklaehn.de> writes:
> > • M-: (set-face-background flymake-note "yellow green")
>
> You probably mean
>
> (set-face-background 'flymake-note "yellow green")
Exactly :)
> Yes, it was intentional. Doesn't mean that it's correct :-) Perhaps it
> should be reduced to the 50's region and also use the (nil . <value>),
> form which I didn't know about (so thanks for showing me this).
Wrt. to using non-numeric priority values maybe Eli Zaretskii could chime in, because there is the
following section ("Overlay Properties") in the Emacs Lisp manual, which he wrote (see Bug#20253):
‖ ‘priority’
‖ This property’s value determines the priority of the overlay. If
‖ you want to specify a priority value, use either ‘nil’ (or zero),
‖ or a positive integer. Any other value has undefined behavior.
‖ [...]
‖ Note that Emacs sometimes uses non-numeric priority values for some
‖ of its internal overlays, so do not try to do arithmetic on the
‖ priority of an overlay (unless it is one that you created). In
‖ particular, the overlay used for showing the region uses a priority
‖ value of the form ‘(PRIMARY . SECONDARY)’, where the PRIMARY value
‖ is used as described above, and SECONDARY is the fallback value
‖ used when PRIMARY and the nesting considerations fail to resolve
‖ the precedence between overlays. However, you are advised not to
‖ design Lisp programs based on this implementation detail; if you
‖ need to put overlays in priority order, use the SORTED argument of
‖ ‘overlays-at’. *Note Finding Overlays::.
Even though it's shipped with Emacs, flymake is probably not "internal" enough to use those?
...looking around further I just found Bug#16192, where a similar problem was fixed for hl-line-mode
by using a negative priority. And then there is also Bug#15899, which discusses the use of overlays
to highlight region in the first place.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#34022: 26.1; Region highlight has lower priority than flymake overlays
2019-01-10 21:06 ` Johann Klähn
@ 2019-01-10 22:03 ` João Távora
0 siblings, 0 replies; 9+ messages in thread
From: João Távora @ 2019-01-10 22:03 UTC (permalink / raw)
To: Johann Klähn; +Cc: 34022
Johann Klähn <johann@jklaehn.de> writes:
> thanks for your quick response! I did not see
> `flymake-overlay-control' because I was still using the version of
> flymake shipped with Emacs 26.1. (I really like the options introduced
> with the new version allows, so I will probably switch to using it.)
Flymake is now also distributed through ELPA, so you can use the most
recent version even on Emacs 26.1
> ‖ ‘priority’
> ‖ This property’s value determines the priority of the overlay. If
> ‖ you want to specify a priority value, use either ‘nil’ (or zero),
> ‖ or a positive integer. Any other value has undefined behavior.
> ‖ [...]
> ‖ Note that Emacs sometimes uses non-numeric priority values for some
> ‖ of its internal overlays, so do not try to do arithmetic on the
> ‖ priority of an overlay (unless it is one that you created). In
> ‖ particular, the overlay used for showing the region uses a priority
> ‖ value of the form ‘(PRIMARY . SECONDARY)’, where the PRIMARY value
> ‖ is used as described above, and SECONDARY is the fallback value
> ‖ used when PRIMARY and the nesting considerations fail to resolve
> ‖ the precedence between overlays. However, you are advised not to
> ‖ design Lisp programs based on this implementation detail; if you
> ‖ need to put overlays in priority order, use the SORTED argument of
> ‖ ‘overlays-at’. *Note Finding Overlays::.
>
> Even though it's shipped with Emacs, flymake is probably not
> "internal" enough to use those?
Good point. Don't know how to fix it then.
> ...looking around further I just found Bug#16192, where a similar
> problem was fixed for hl-line-mode by using a negative priority. And
> then there is also Bug#15899, which discusses the use of overlays to
> highlight region in the first place.
>
I remember reading somewhere negative priorites were a nono, maybe that
has changed.
João
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1547153959.1638293.1631244736.794AFB75@webmail.messagingengine.com>]
end of thread, other threads:[~2019-11-02 16:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-09 20:33 bug#34022: 26.1; Region highlight has lower priority than flymake overlays Johann Klähn
2019-01-09 20:52 ` João Távora
2019-01-10 21:06 ` Johann Klähn
2019-01-10 22:03 ` João Távora
[not found] ` <1547153959.1638293.1631244736.794AFB75@webmail.messagingengine.com>
[not found] ` <83o98nhcst.fsf@gnu.org>
2019-01-11 9:33 ` João Távora
2019-01-11 19:14 ` Eli Zaretskii
2019-01-11 20:04 ` João Távora
2019-01-11 21:00 ` Eli Zaretskii
2019-11-02 16:17 ` João Távora
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.