Skip to content

Commit

Permalink
fix: Use defface instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Feb 6, 2024
1 parent b9e1ea1 commit c98dc62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Or you can bind it globally to replace `goto-line`:
(global-set-key [remap goto-line] 'goto-line-preview)
```

## Change hightlight color or duration
### Change hightlight color or duration

```el
;; Highlight 1.5 seconds when change preview line
(setq goto-line-preview-hl-duration 1.5)
;; Change highlight background color to white
(setq goto-line-preview-hl-color "white")
(set-face-background 'goto-line-preview-hl "white")
```

If you want to close highlight, set `goto-line-preview-hl-duration` to 0 or `nil`.
Expand Down
10 changes: 5 additions & 5 deletions goto-line-preview.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@
:group 'goto-line-preview
:type 'integer)

(defcustom goto-line-preview-hl-color "DimGray"
"Background color of highlight when change preview line."
:group 'goto-line-preview
:type 'string)
(defface goto-line-preview-hl
'((t :inherit highlight))
"Face to use for highlighting when change preview line."
:group 'goto-line-preview)

(defvar goto-line-preview--prev-window nil
"Record down the previous window before we do preivew display.")
Expand All @@ -71,7 +71,7 @@
"Keep highlight for a fixed time."
(when goto-line-preview-hl-duration
(let ((overlay (make-overlay (line-beginning-position) (line-end-position))))
(overlay-put overlay 'face `(:background ,goto-line-preview-hl-color))
(overlay-put overlay 'face 'goto-line-preview-hl)
(sit-for goto-line-preview-hl-duration)
(delete-overlay overlay))))

Expand Down

0 comments on commit c98dc62

Please sign in to comment.