counsel-outline background with face-style 'org

Hi Prot,

First of all, I'd like to say I've been using modus-operandi for some time and I'm really enjoying it. Though it is comfortable and the purpose of the theme is accessibility, and you clearly state that you will sacrifice aesthetics for accessibility whenever they conflict, I must say I like the looks as well. It is also heartwarming to see the commitment and generosity with which you have been developing this project. So I'd like to join the chorus from #108 (closed). Thank you!

That said, I do have a corner case for which modus-themes could have a better coverage, and I've been meaning to contribute a report for some time, and finally found the time to do it. The case is counsel-outline.

It is a tricky one, in my experience, because of the usual way to define the faces used by counsel-outline by inheritance from outline faces (that's what modus-themes does), and the way Ivy overlays some faces to highlight candidates or matches. On top of that counsel-outline has some idiosyncrasies of it's own regarding face setting (that is, counsel-outline-face-style). As a matter of fact, most of the themes I've used in the past did require some manual intervention for better results.

The issue arises when counsel-outline-face-style is set to value 'org. In this case, counsel-outline uses the faces counsel-outline-1 through counsel-outline-8. Those faces are explicitly set by modus-themes to inherit from the corresponding outline-N faces, and this is the only case of counsel-outline-face-style value for which counsel-outline uses the counsel-outline-N faces. However, when this is done, the background of Ivy's fontification, particularly that of ivy-current-match, is overridden by the counsel-outline-N faces so that the current candidate ranges from "hard to spot" to "completely invisible".

To reproduce the issue, start with emacs -Q, then evaluate:

(add-to-list 'load-path "~/.emacs.d/elpa/ivy-20201214.2049")
(add-to-list 'load-path "~/.emacs.d/elpa/swiper-20201208.1419")
(add-to-list 'load-path "~/.emacs.d/elpa/counsel-20201214.2037")
(add-to-list 'load-path "~/.emacs.d/elpa/modus-themes-20201215.1002")

(setq counsel-outline-display-style 'path) ; default
;; (setq counsel-outline-display-style 'headline)
;; (setq counsel-outline-display-style 'title)

;; (setq counsel-outline-face-style nil) ; default
(setq counsel-outline-face-style 'org)
;; (setq counsel-outline-face-style 'verbatim)
;; (setq counsel-outline-face-style 'custom); depends on counsel-outline-custom-faces

;; Makes the issue a little more visible, but otherwise has no implication,
;; the problem affects `modus-themes` regardless of the value of
;; `modus-themes-headings`.
(setq modus-themes-headings '((t . rainbow)))

(require 'counsel)
(require 'modus-themes)

(load-theme 'modus-operandi t)
(ivy-mode)

The packages are all in their respective latest versions a MELPA, and I'm using GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2020-08-11.

Now, let's consider a test file ~/test.org with contents:

* Heading 1
** Subheading 1.1
* Heading 2
* Heading 3
** Subheading 3.1 Foo
*** Sub-subheading 3.1.1
** Subheading 3.2

In this setting, call M-x counsel-outline. The result when typing "Foo" on the prompt and selecting "Subheading 3.1.1" (hit once C-n for that) is:

Screenshot_1

Note that the background of ivy-current-match is barely visible, and is only applied to the path separators (the slash, by default). If we choose counsel-outline-display-style as either 'headline or 'title, it becomes completely invisible, as the path separator is not used. For example, the results for 'headline:

Screenshot_2

In this case, it is literally impossible to tell which is the currently selected candidate.

Results are fine for counsel-outline-face-style 'verbatim and nil (for 'custom it depends on whatever the user places in counsel-outline-custom-faces so not really in scope here).

In my experience, this effect stems from inheriting the outline faces so there is a conflict with Ivy's faces. To the point that I've adopted as practice to set only the foreground of counsel-outline-1 through counsel-outline-8 to match those of outline-N faces. This is what I get by so doing (in my own config, thus not within the bounds of the above ECM):

Screenshot_3

I've been so doing since some time, as this also solves some minibuffer sizing instability for Ivy when proportional fonts are used, and even more so when scaled headings are used. (Note that I've been doing this for some time, and using only monospaced fonts, so this might not correspond to current state of things in Ivy).

This may also be a reason why this is not a good solution in general for modus-themes to adopt. I'm not sure users would like to see their proportional/scaled headings "stripped down" in counsel-outline. My personal assessment is that the benefits of it are worth it, but in this report I just mention this as an alternative. And also because I think this approach highlights well where the problem lies, whatever you think the way to go is.

Anyway, this is just a small glitch in an overall great theme, for which I thank you once again.

Cheers!