This package allow you to create a peek view below/above cursor point to show things.
Note: this package is still in frequent updating, with function name changing possibly.
- Peek view follows your cursor.
- Buffer and window local peek views. Also capable for content sharing between different buffer and windows.
- Store text of marked region, and then display it on the peek view.
- Peek the destination of
xref-find-definitions
. eldoc-message-function
andeldoc-display-functions
integration.- Scroll up or down inside peek view.
- Live update
- Image Preview
- Support
- image presentation using a string which has no
\n
inside and usesdisplay
text property to show image, likeinsert-image
with defaultSTRING
parameter orinsert-image-file
function. - image mode
- image presentation using a string which has no
- Doesn't Support:
- image presentation using a overlay which uses
display
text property on itsbefore-string
orafter-string
, likeput-image
- image presentation using a overlay which uses
- Support
-
Store marked region and peek it later:
- Mark a region
- Use
peek-overlay-dwim
to store the region - Use
peek-overlay-dwim
again to show a peek view of the marked content. You can use this command in other buffer/window to show the marked content. - Use
peek-overlay-dwim
to hidden the peek view.
Tip: You can make the peek view of the marked region automatically updated by customizing
peek-live-update
tot
. Or you want to manually update content, you can usepeek-view-refresh
command. It should be noted that live updating/refreshing peek view can only be done when the source buffer(owns marked region) is alive. -
Find definition of a symbol.
- Use
peek-xref-definition
to show the definition at the cursor point in peek view. - Use
peek-overlay-dwim
to hide the peek view.
- Use
-
Display eldoc for the symbol under cursor.
note: you need Emacs version >= 28.1- Customize `peek-enable-eldoc-display-integration' to t.
- You may also want to remove other eldoc display functions
(remove-hook 'eldoc-display-functions 'eldoc-display-in-buffer)
- Use
eldoc
to diplay eldoc for the symbol under cursor. - Use
peek-overlay-dwim
to hide the peek view.
-
Display eldoc message
Customizepeek-enable-eldoc-message-integration
tot
to enable the eldoc message integration. You may also want to customizepeek-eldoc-message-overlay-position
too.
Note:peek-overlay-eldoc-message-toggle-stauts
function can be used to toggle whether the peek view for eldoc message will be shown. -
Scroll up/down in the peek view
M-n
: peek-next-lineM-p
: peek-prev-line
(use-package peek
:straight (:type git :host sourcehut :repo "meow_king/peek")
:custom
;; only list some settings that are wanted to be chaned by most people
(peek-overlay-window-size 11) ; lines
;; you can also set `peek-overlay-border-character' to nil to achieve a similar
;; looking as `make-separator-line', which is useful when you find there is a wrong
;; number of border characters when using default settings. However, in this case,
;; please consider report a bug.
(peek-overlay-border-character ?\N{BOX DRAWINGS LIGHT HORIZONTAL})
(peek-overlay-position 'above) ; or below
(peek-overlay-distance 4) ; the distance between peek view and the cursor point
;; one line before the place found by `peek-definition' will also appear
;; in peek window. Note `peek-definition' is the underlying function of
;; `peek-xref-definition'
(peek-definition-surrounding-above-lines 1)
(peek-live-update t) ; live update peek view of a marked region
(peek-enable-eldoc-message-integration t) ; enable `eldoc-message-function' integration
;; eldoc message overlay at two lines below the point
;; It's recommended to set the eldoc message overlay below the point since the pop up of
;; the peek overlay may cause visual shaking
(peek-eldoc-message-overlay-position 2)
;; enable `eldoc-display-functons' integration
;; note: you need Emacs version >= 28.1
(peek-enable-eldoc-display-integration t)
:config
(global-peek-mode 1)
;; Keybindings
;; default keybindings in peek-mode-keymap
(define-key peek-mode-keymap (kbd "M-n") 'peek-next-line)
(define-key peek-mode-keymap (kbd "M-p") 'peek-prev-line)
;; or you can use `keymap-global-set', which is introduced in emacs 29
(global-set-key (kbd "C-x P p") #'peek-overlay-dwim)
(global-set-key (kbd "C-x P d") #'peek-xref-definition)
(global-set-key (kbd "C-x P m") #'peek-overlay-eldoc-message-toggle-stauts)
(global-set-key (kbd "C-c c d") #'eldoc)
;; Eldoc display setting
;; Besides making `peek-enable-eldoc-display-integration' to t, you may want to remove
;; other eldoc display functions.
(remove-hook 'eldoc-display-functions 'eldoc-display-in-buffer)
;; you may also want to set scroll margin (see its docs)
(setq-default scroll-margin 5))
Go to customize
-> peek
These API may be useful for advanced customization:
eldoc-message-function
related API:peek-overlay-eldoc-message-toggle-stauts
,peek-overlay-eldoc-message-disable
,peek-overlay-eldoc-message-enable
. Possible customization direction: for model editing mode likeevil
, you can use these function to only enable displaying eldoc message overlay(peek view) when in insert mode. Personally I use meow, and this is my settings:
(add-hook 'meow-insert-enter-hook 'peek-overlay-eldoc-message-enable)
(add-hook 'meow-insert-exit-hook 'peek-overlay-eldoc-message-disable)
-
peek-overlay-set-custom-content
,peek-overlay-toggle
,peek-overlay-hide
,peek-overlay-show
-
peek-definition
. This function can be used to create custom peek definition command likepeek-xref-definition
.
;; goto-definition function: any number of parameters, no requirement for returned
;; value. The only requirement is that it should act to go the the point of definition.
(defun peek-goto-xref-defintion-func (identifier)
"Go to the definition of IDENTIFIER."
(xref-find-definitions identifier)
;; clear xref history
(pop (car (xref--get-history))))
;; integration
(defun peek-xref-definition ()
"Peek xref definition."
(interactive)
(peek-definition
'peek-goto-xref-defintion-func
(list (thing-at-point 'symbol))))
- peek-collection: A collection of convenient integration for Emacs package Peek.
- Support
Child frame
. (CurrentlyPeek
only supportoverlay
.) - Pseudo
overlay
that behaves like floating on the upper layer of the text (like child frame, so we have better terminal support). Maybe I should take a look at the source code ofcorfu
orcompany
.