cpitclaudel / biblio.el

Browse and import bibliographic references from CrossRef, DBLP, HAL, arXiv, Dissemin, and doi.org from Emacs
GNU General Public License v3.0
180 stars 14 forks source link

FR : Make face used for line highlighting in biblio-selection-mode customizable #43

Closed aagon closed 3 years ago

aagon commented 3 years ago

For the moment, defining a specific face and trying to set it as buffer local for hl-line-face in the biblio-selection-mode-hook does not work : the face used by hl-line-mode is still hl-line when we arrive in the biblio-selection-mode buffer.

It only works if the buffer-local setting is made in buffer-selection-mode before hl-line-mode is activated.

I propose the following :

If you agree, I can prepare the trivial PR with the changes.

Thanks again for this wonderful package,

Aymeric Agon-Rambosson

cpitclaudel commented 3 years ago

:+1: Sounds good to me. Shouldn't we inherit from hl-line instead of highlight? (and won't we inherit :extend from it? Of if it doesn't have :extend then why do we need it?)

Also, I prefer setq-local over set + make-local-variable

(It would be great to add a test for this, but it's not super high priority)

aagon commented 3 years ago

Shouldn't we inherit from hl-line instead of highlight?

Stock emacs makes hl-line inherit from highlight, but some themes (doom-themes in particular) set the background of each face differently : hl-line with low contrast to the normal background, to be used in an environment where the cursor is still visible, and highlight with high contrast to the normal background, perfect for environments where the cursor is hidden and the line highlighting is the only clue as to where the point is, as in biblio-selection-mode. In fact, I started this issue because with my theme (doom-molokai), the selected biblio entry was nigh-indistinguishable from the others, and setting a new face required modifying the minor mode.

So IMO best to inherit from highlight than from hl-line : doesn't change a thing for stock, but behaves better with some themes. And because we inherit from highlight, explicit :extend makes sense (I wanted to make the inheritance from highlight as similar as the of hl-line from highlight, which explicitly uses :extend).

Also, I prefer setq-local over set + make-local-variable

Done.

(It would be great to add a test for this, but it's not super high priority)

The only test I can think of would be to check whether the face is the right one in biblio-selection-mode, like this :

(it "has the right major mode"
            (with-current-buffer results-buffer
              (expect major-mode :to-equal 'biblio-selection-mode)))
;; New test :
(it "has the right face"
            (with-current-buffer results-buffer
              (expect (face-at-point) :to-equal 'biblio-highlight-extend-face)))

Let me know if you agree with this.

cpitclaudel commented 3 years ago

All of this makes complete sense. Thanks a lot.

aagon commented 3 years ago

Closed by #44