My use case for this SE is to have a box around region
face, so the highlighted region in transient-mark-mode
is visible even when the region overlaps with some other overlays:
(set-face-attribute 'region nil
:box '(:line-width -1
:color "gtk_selection_bg_color"
:style nil))
For example, with iedit-mode
:
Every time the text is highlighted with "boxed region" I can see the described text width flickering.
The dirty hack I could find to eliminate this flickering is to add a box with background colour to the default
face. Unfortunately, such hack would introduce a number of issues in other places, such as an additional gap between lines or incorrect rendering of button widgets (e.g. in customization buffers).
The ultimate solution is given in the following bug report (see attached patch at the end of the thread):
Text flickering moving cursor with box around text enabled
This solution affects Emacs internals and requires Emacs custom build after applying the patch.
I am going to try the later solution soon. The problem however is that my init.el
would then become incompatible with stock Emacs builds and will have to use some additional logic to find if the above patch is applied.
Hopefully, after some testing this patch would get accepted into Emacs source...
2019-01-21 follow-up:
It seems that the above referenced patch is not compatible with the latest Emacs source code. I had to make some changes in order to make it work with the current Emacs git master branch. Instead of creating another patch, I made a fork at github and created a branch from upstream with face box patch:
face-box-patch
Building Emacs from this branch is the same as stock Emacs builds.
The following is the init.el
code which should be compatible with both patched and vanilla Emacs versions:
(unwind-protect
(condition-case ex
(set-face-attribute
'region nil
:box '(:line-width (-1 . -1)
:color "gtk_selection_bg_color"
:style nil))
('error
(set-face-attribute
'region nil
:box '(:line-width -1
:color "gtk_selection_bg_color"
:style nil)))))
It is only tested on Linux with GTK+