Skip to content

Commit

Permalink
[#99] Add more faces for customization
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Jan 30, 2022
1 parent 282eaa8 commit 38b5e94
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].

## Unreleased
### Features
* You can now customize more faces: `ctrlf-minibuffer-message-face`
and `ctrlf-in-buffer-message-face`, both of which inherit from
`ctrlf-message-face`, which defaults to inheriting from
`minibuffer-prompt` as per previous behavior ([#99]).

[#99]: https://github.com/raxod502/ctrlf/issues/99

## 1.4 (released 2021-12-27)
### Features
* Add a new matching style for matching words ([#61]).
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ You can customize the visual appearance of CTRLF:
typed `C-l` each time you moved to a new match. This feature is
disabled by default.
* The index of the currently selected match and the total number of
matches are displayed at the end of the minibuffer. If
`ctrlf-show-match-count-at-eol` is non-nil (the default), then this
information is also shown at the end of the current line in the
buffer being searched, which alleviates the problem of needing to
look back and forth between the minibuffer and the buffer being
searched.
matches are displayed at the end of the minibuffer (using face
`ctrlf-minibuffer-message-face`). If `ctrlf-show-match-count-at-eol`
is non-nil (the default), then this information is also shown at the
end of the current line in the buffer being searched (using face
`ctrlf-in-buffer-message-face`), which alleviates the problem of
needing to look back and forth between the minibuffer and the buffer
being searched. Both of the mentioned faces inherit from
`ctrlf-message-face`, as will future faces used by CTRLF to display
messages.
* Zero-length matches (for example, in a regexp search for `^$` which
would identify all blank lines the buffer) are displayed as thin
vertical rectangles with a solid color since there is no text to
Expand Down
20 changes: 19 additions & 1 deletion ctrlf.el
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,18 @@ surrounded by word boundary constructs \\< and \\>."
'((t :inherit hl-line))
"Face used to highlight current line.")

(defface ctrlf-message-face
'((t :inherit minibuffer-prompt))
"Base face used for message display. Other CTRLF faces inherit from this.")

(defface ctrlf-minibuffer-message-face
'((t :inherit ctrlf-message-face))
"Face used to display CTRLF messages in the minibuffer.")

(defface ctrlf-in-buffer-message-face
'((t :inherit ctrlf-message-face))
"Face used to display CTRLF messages in buffers other than the minibuffer.")

;;;;; Variables

(defvar ctrlf-search-history nil
Expand Down Expand Up @@ -557,7 +569,13 @@ mess."
(if (not ctrlf--minibuffer)
(minibuffer-message format args)
(let ((string (apply #'format (concat " [" format "]") args)))
(put-text-property 0 (length string) 'face 'minibuffer-prompt string)
(put-text-property
0 (length string)
'face
(if ctrlf--message-in-buffer-p
'ctrlf-in-buffer-message-face
'ctrlf-minibuffer-message-face)
string)
(with-current-buffer ctrlf--minibuffer
;; Setting REAR-ADVANCE:
;; <https://github.com/raxod502/ctrlf/issues/4>
Expand Down

0 comments on commit 38b5e94

Please sign in to comment.